Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15964
  • 博文数量: 3
  • 博客积分: 162
  • 博客等级: 入伍新兵
  • 技术积分: 30
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-01 10:27
文章分类

全部博文(3)

文章存档

2012年(3)

我的朋友
最近访客

分类: LINUX

2012-04-20 14:40:35

Centos 6.2(Dell R610)安装Varnish、Nginx、MySQL、php、Nagios监控 教你打造强大MAGENTO服务器

插入光盘,安装系统,语言选择英文,分区按照我下面的分区方式,安装选择Base Server,去喝杯咖啡吧。

[root@front yum.repos.d]# df -h Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 4128448 374268 3544468 10% / tmpfs 4021724 0 4021724 0% /dev/shm /dev/sda6 119852252 1104388 112659724 1% /home /dev/sda2 8256952 2156376 5681148 28% /usr /dev/sda5 4128448 257020 3661716 7% /var
下面开始配置服务器

远程链接工具Puttp,下载地址

第一步,修改SSH配置

vi /etc/ssh/sshd_config

将PermitRootLogin yes修改为PermitRootLogin no禁止root用户远程登录,提高系统安全性。
重新启动sshd

/sbin/service sshd restart 或者 /etc/init.d/sshd restart

第二步:安装基础软件
这些软件是系统所需要的基础软件,执行前请确保已经联网。
切换到ROOT账户

su root LANG=C yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers cmake bison

顺手更新下系统

yum update

喝杯水,看着屏幕,一路yes。需要配置成国内的dns,使用163的centos源,安装速度比较快。

第三步:安装附加软件,下载地址请自己Google。

ln -s /home /app cd /app wget unzip software.zip

1、安装iconv库,干嘛用的请google

tar zxvf libiconv-1.13.tar.gz cd libiconv-1.13/ ./configure --prefix=/usr/local make make install cd ../

2、安装mcrypt库

tar zxvf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8/ ./configure make make install /sbin/ldconfig cd libltdl/ ./configure --enable-ltdl-install make make install cd ../../

3、安装mhash

tar zxvf mhash-0.9.9.9.tar.gz cd mhash-0.9.9.9/ ./configure make make install cd ../

4、建立软链接

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4 ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8 ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2 ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1 ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

5、安装mcrypt

tar zxvf mcrypt-2.6.8.tar.gz cd mcrypt-2.6.8/ /sbin/ldconfig ./configure make make install cd ../

6、安装ImageMagick

tar zxf ImageMagick.tar.gz cd ImageMagick-6.5.1-2/ ./configure make make install cd ../

7、安装libevent

tar xf libevent-1.4.14b-stable.tar.gz cd libevent-1.4.14b-stable ./configure --prefix=/usr make make install cd ..

8、安装memcached

tar xf memcached-1.4.5.tar.gz cd memcached-1.4.5 ./configure --with-libevent=/usr make make install cd ..

以11211端口启动Memcached

/usr/local/bin/memcached -d -p 11211 -u nobody -m 2048 -c 10240 -P /var/run/memcached/memcached.pid

第四步:安装MySQL
1、添加MYSQL用户

/usr/sbin/groupadd mysql /usr/sbin/useradd -g mysql mysql

2、安装MySQL

tar xf mysql-5.5.21.tar.gz cd mysql-5.5.21 cmake -DCMAKE_INSTALL_PREFIX=/app/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/app/mysql/data make make install

3、更改文件权限

chmod +w /app/mysql chown -R mysql:root /app/mysql

4、创建配置文件和启动服务

cp support-files/my-huge.cnf /etc/my.cnf cp support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld vi /etc/init.d/mysqld (编辑此文件,查找并修改以下变量内容:) basedir=/app/mysql datadir=/app/mysql/data

将 mysql 加入开机启动

chkconfig --add mysqld chkconfig --level 345 mysqld on

5、初始化数据库

/app/mysql/scripts/mysql_install_db \ --defaults-file=/etc/my.cnf \ --basedir=/app/mysql \ --datadir=/app/mysql/data \ --user=mysql

6、启动数据库

cd ../ /sbin/service mysqld start

第五步:安装PHP 5.3.10
1、安装php主程序

  ln -s /app/mysql/lib/libmysqlclient.so.18 /usr/lib/ ln -s /app/mysql/lib/libmysqlclient.so.18 /usr/lib64/   tar xf php-5.3.10.tar.gz cd php-5.3.10 ./configure --prefix=/app/php --with-config-file-path=/app/php/etc --with-mysql=/app/mysql --with-pdo-mysql=/app/mysql/ --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-ftp make ZEND_EXTRA_LIBS='-liconv' make install cp php.ini-production /app/php/etc/php.ini cd ../

2、安装memcache扩展

tar zxvf memcache-2.2.6.tgz cd memcache-2.2.6/ /app/php/bin/phpize ./configure --with-php-config=/app/php/bin/php-config make make install cd ../

3、安装imagick扩展

tar zxvf imagick-3.0.1.tgz cd imagick-3.0.1/ /app/php/bin/phpize ./configure --with-php-config=/app/php/bin/php-config make make install cd ../

4、安装xcache扩展

tar xf xcache-1.3.1.tar.gz cd xcache-1.3.1 /app/php/bin/phpize ./configure --enable-xcache --with-php-config=/app/php/bin/php-config make make install cd ../

5、修改php.ini文件 /app/etc/php.ini

extension_dir = "/app/php/lib/php/extensions/no-debug-non-zts-20090626/" extension = "memcache.so" extension = "imagick.so" short_open_tag = On memory_limit = 512M expose_php = Off

6、启动PHP FPM

ulimit -SHn 65535 /app/php/sbin/php-fpm

可以用 ps aux|grep php来验证下是否已经启动php-fpm

第六步:安装Nginx
1、安装PCRE

tar zxvf pcre-8.01.tar.gz cd pcre-8.01/ ./configure make make install cd ../

2、安装Nginx

tar zxvf nginx-0.8.50.tar.gz cd nginx-0.8.50/ ./configure --user=nobody --group=nobody --prefix=/app/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module make make install cd ../

4、启动Nginx

ulimit -SHn 65535 /app/nginx/sbin/nginx

5、创建日志切割脚本

vi /app/nginx/sbin/cut_nginx_log.sh

添加内容如下

#!/bin/bash # This script run at 00:00   # The Nginx logs path logs_path="/app/nginx/logs/"   mkdir -p ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/ mv ${logs_path}access.log ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/access_$(date -d "yesterday" +"%Y%m%d").log kill -USR1 `cat /app/nginx/logs/nginx.pid`

用Crontab使其每日凌晨自动运行

crontab -e

添加内容

00 00 * * * /bin/bash /app/nginx/sbin/cut_nginx_log.sh

第七步:优化系统
1、修改/etc/sysctl.conf文件,添加下列内容到文件末尾

# Add net.ipv4.tcp_max_syn_backlog = 65536 net.core.netdev_max_backlog = 32768 net.core.somaxconn = 32768   net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216   net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_synack_retries = 2 net.ipv4.tcp_syn_retries = 2   net.ipv4.tcp_tw_recycle = 1 #net.ipv4.tcp_tw_len = 1 net.ipv4.tcp_tw_reuse = 1   net.ipv4.tcp_mem = 94500000 915000000 927000000 net.ipv4.tcp_max_orphans = 3276800   #net.ipv4.tcp_fin_timeout = 30 #net.ipv4.tcp_keepalive_time = 120 net.ipv4.ip_local_port_range = 1024 65535

使之立即生效

/sbin/sysctl -p

第七步:安装Varnish
相当牛的缓存软件,不多介绍了。

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig   tar xf varnish-3.0.2.tar.gz ./configure --prefix=/app/varnish make make install

第八步:安装ntp进行时间同步

yum install ntp /usr/sbin/ntpdate 0.pool.ntp.org

下面进行ntp内网服务器的配置,注意非服务器不用执行下面的步骤
1、修改ntp配置文件
vi /etc/ntp.conf

# Hosts on local network are less restricted. restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap #去掉前面的注释,允许内网其他机器访问服务器。

2、vi /etc/ntp/step-tickers

#添加国际标准时间服务器 0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org

3、启动NTPD时间服务器

/sbin/service ntpd start /sbin/chkconfig ntpd on

第九步,安装Nagios监控

被监控机(即被监测服务器,非监测服务器,一般web服务器都是被监测的对象。)
1、添加用户

/usr/sbin/groupadd nagios /usr/sbin/useradd -g nagios -d /app/nagios -s /sbin/nologin nagios

2、安装plugin

tar zxf nagios-plugins-1.4.15.tar.gz cd nagios-plugins-1.4.15 ./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/app/nagios --with-ping-command="/bin/ping" --with-mysql=/app/mysql --enable-perl-modules make make install cd ..

3、安装Nrpe

tar zxvf nrpe-2.12.tar.gz cd nrpe-2.12 ./configure --prefix=/app/nagios make all make install-plugin make install-daemon make install-daemon-config chown -R nagios:nagios /app/nagios

4、配置Nagios,即允许哪个服务器访问

vi /app/nagios/etc/nrpe.cfg allowed_hosts=127.0.0.1,192.168.11.110

修改/etc/hosts.allow增加监控机ip

echo 'nrpe:192.168.1.110' >> /etc/hosts.allow

5、启动 NRPE 守护进程:

/app/nagios/bin/nrpe -c /app/nagios/etc/nrpe.cfg -d

可以将此命令加入 /etc/rc.local ,以便开机自动启动。

echo "/app/nagios/bin/nrpe -c /app/nagios/etc/nrpe.cfg -d" >> /etc/rc.local

检查 NRPE 是否正常:
在被监控机上

/app/nagios/libexec/check_nrpe -H 127.0.0.1

查看相应的端口:netstat -an |grep 5666
防火墙开启5666 允许局域网IP或固定IP连接
在监控主机上

/app/nagios/libexec/check_nrpe -H $目标主机地址

都应该可以输出 NRPE 的版本: NRPE v2.12
检查可监控的服务
在被监控端的 nrpe.cfg 文件中,可以看到这样的配置:
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
这是用来检查 CPU 负载的。
如果需要自定参数则使用下面命令
command[check_load]=/usr/local/nagios/libexec/check_load -w $ARG1$ -c $ARG2$
并开启dont_blame_nrpe =1
开启参数将会带来一定的安全风险

接下来安装监控机器:

安装 Nagios 主要是两部分,Nagios Core 和 Nagios Plugins。Nagios Core 只是个 Daemon,负责调度,真正的检测操作还是通过 Nagios Plugins 来实现的。
安装 Nagios Core
* 下载解压

wget tar zxf nagios-3.2.3.tar.gz cd nagios-3.2.3

* 添加 nagios 用户和组

/usr/sbin/useradd -m -s /bin/bash nagios /usr/sbin/groupadd nagios /usr/sbin/usermod -G nagios nagios

因为要用到 CGI 的 Web 监控面板,所以这里我们还要添加一个 nagcmd 组,用于 CGI 执行相关指令。

/usr/sbin/groupadd nagcmd /usr/sbin/usermod -a -G nagcmd nagios /usr/sbin/usermod -a -G nagcmd nobody

* 配置编译安装

./configure --prefix=/app/nagios --with-group=nagios --with-user=nagios --with-command-group=nagcmd --with-cgiurl=/cgi-bin make all make install make install-init make install-commandmode make install-config

* 添加启动服务

/sbin/chkconfig nagios on

* 启动 Nagios

/sbin/service nagios start

安装 Nagios Plugins

wget tar zxf nagios-plugins-1.4.14.tar.gz cd nagios-plugins-1.4.14 ./configure --prefix=/app/nagios --with-cgiurl=/cgi-bin make && make install

配置 Web 监控面板

安装 perl-FCGI 、perl-FCGI-ProcManager 和 perl-IO-ALL:

wget tar -zxf FCGI-0.67.tar.gz cd FCGI-0.67 perl Makefile.PL make && make install cd ..
wget tar -zxf FCGI-ProcManager-0.18.tar.gz cd FCGI-ProcManager-0.18 perl Makefile.PL make && make install cd ..
wget tar zxf IO-All-0.39.tar.gz cd IO-All-0.39 perl Makefile.PL make && make install

创建启动脚本
vi start_perl_cgi.sh

#!/bin/bash #set -x dir=/app/nginx   stop () { #pkill -f $dir/perl-fcgi.pl kill $(cat $dir/logs/perl-fcgi.pid) rm $dir/logs/perl-fcgi.pid 2>/dev/null rm $dir/logs/perl-fcgi.sock 2>/dev/null echo "stop perl-fcgi done" }   start () { rm $dir/sbin/now_start_perl_fcgi.sh 2>/dev/null   chown nobody.root $dir/logs echo "$dir/sbin/perl-fcgi.pl -l $dir/logs/perl-fcgi.log -pid $dir/logs/perl-fcgi.pid -S $dir/logs/perl-fcgi.sock" >>$dir/sbin/now_start_perl_fcgi.sh   chown nobody.nobody $dir/sbin/now_start_perl_fcgi.sh chmod u+x $dir/sbin/now_start_perl_fcgi.sh   sudo -u nobody $dir/sbin/now_start_perl_fcgi.sh echo "start perl-fcgi done" }   case $1 in stop) stop ;; start) start ;; restart) stop start ;; esac

安装 nginx-fcgi 脚本:
vi perl-fcgi.pl

#!/usr/bin/perl # # author Daniel Dominik Rudnicki # thanks to: Piotr Romanczuk # email daniel@sardzent.org # version 0.4.3 # webpage # # BASED @ # # # use strict; use FCGI; use Getopt::Long; use IO::All; use Socket;   sub init { GetOptions( "h" => \$help, "verbose!"=>\$verbose, "pid=s" => \$filepid, "l=s" => \$logfile, "S:s" => \$unixsocket, "P:i" => \$unixport) or usage(); usage() if $help;   print " Starting Nginx-fcgi\n" if $verbose; print " Running with $> UID" if $verbose; print " Perl $]" if $verbose;   if ( $> == "0" ) { print "\n\tERROR\tRunning as a root!\n"; print "\tSuggested not to do so !!!\n\n"; exit 1; }   if ( ! $logfile ) { print "\n\tERROR\t log file must declared\n" . "\tuse $0 with option -l filename\n\n"; exit 1; } print " Using log file $logfile\n" if $verbose; "\n\n" >> io($logfile); addlog($logfile, "Starting Nginx-cfgi"); addlog($logfile, "Running with $> UID"); addlog($logfile, "Perl $]"); addlog($logfile, "Testing socket options"); if ( ($unixsocket && $unixport) || (!($unixsocket) && !($unixport)) ) { print "\n\tERROR\tOnly one option can be used!\n"; print "\tSuggested (beacuse of speed) is usage UNIX socket -S \n\n"; exit 1; }   if ($unixsocket) { print " Daemon listening at UNIX socket $unixsocket\n" if $versbose; addlog($logfile, "Deamon listening at UNIX socket $unixsocket"); } else { print " Daemon listening at TCP/IP socket *:$unixport\n" if $verbose; # addlog($logfile, "Daemon listening at TCP/IP socket *:$unixport"); }   if ( -e $filepid ) { print "\n\tERROR\t PID file $filepid already exists\n\n"; addlog($logfile, "Can not use PID file $filepid, already exists."); exit 1; }   if ( $unixsocket ) { print " Creating UNIX socket\n" if $verbose; $socket = FCGI::OpenSocket( $unixsocket, 10 ); if ( !$socket) { print " Couldn't create socket\n"; addlog($logfile, "Couldn't create socket"); exit 1; } print " Using UNIX socket $unixsocket\n" if $verbose; } else { print " Creating TCP/IP socket\n" if $verbose; $portnumber = ":".$unixport; $socket = FCGI::OpenSocket( $unixport, 10 ); if ( !$socket ) { print " Couldn't create socket\n"; addlog($logfile, "Couldn't create socket"); exit 1; } print " Using port $unixport\n" if $verbose; } addlog($logfile, "Socket created");   if ( ! $filepid ) { print "\n\tERROR\t PID file must declared\n" . "\tuse $0 with option -pid filename\n\n"; exit 1; } print " Using PID file $filepid\n" if $verbose; addlog($logfile, "Using PID file $filepid");   my $pidnumber = $$; $pidnumber > io($filepid); print " PID number $$\n" if $verbose; addlog($logfile, "PID number $pidnumber");   }   sub addzero { my ($date) = shift; if ($date < 10) { return "0$date"; } return $date; }   sub logformat { my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$iddst) = localtime(time); my $datestring; $year += 1900; $mon++; $mon = addzero($mon); $mday = addzero($mday); $min = addzero($min); $datestring = "$year-$mon-$mday $hour:$min"; return($datestring); }   sub addlog { my ($log_file, $log_message) = @_; my $curr_time = logformat(); my $write_message = "[$curr_time] $log_message"; $write_message >> io($log_file); "\n" >> io($log_file); }   sub printerror { my $message = @_; print "\n Nginx FastCGI\tERROR\n" . "\t $message\n\n"; exit 1; }   sub usage { print "\n Nginx FastCGI \n" . "\n\tusage: $0 [-h] -S string -P int\n" . "\n\t-h\t\t: this (help) message" . "\n\t-S path\t\t: path for UNIX socket" . "\n\t-P port\t\t: port number" . "\n\t-p file\t\t: path for pid file" . "\n\t-l file\t\t: path for logfile" . "\n\n\texample: $0 -S /var/run/nginx-perl_cgi.sock -l /var/log/nginx/nginx-cfgi.log -pid /var/run/nginx-fcgi.pid\n\n"; exit 1; }     init; # END() { } BEGIN() { } *CORE::GLOBAL::exit = sub { die "fakeexit\nrc=".shift()."\n"; }; eval q{exit}; if ($@) { exit unless $@ =~ /^fakeexit/; } ;   # fork part my $pid = fork();   if( $pid == 0 ) { &main; exit 0; }   print " Forking worker process with PID $pid\n" if $verbose; addlog($logfile, "Forking worker process with PID $pid"); print " Update PID file $filepid\n" if $verbose; addlog($logfile, "Update PID file $filepid"); $pid > io($filepid); print " Worker process running.\n" if $verbose; addlog ($logfile, "Parent process $$ is exiting"); exit 0;   sub main { $request = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%req_params, $socket ); if ($request) { request_loop()}; FCGI::CloseSocket( $socket ); }   sub request_loop { while( $request->Accept() >= 0 ) { # processing any STDIN input from WebServer (for CGI-POST actions) $stdin_passthrough = ''; $req_len = 0 + $req_params{'CONTENT_LENGTH'}; if (($req_params{'REQUEST_METHOD'} eq 'POST') && ($req_len != 0) ){ while ($req_len) { $stdin_passthrough .= getc(STDIN); $req_len--; } }   # running the cgi app if ( (-x $req_params{SCRIPT_FILENAME}) && (-s $req_params{SCRIPT_FILENAME}) && (-r $req_params{SCRIPT_FILENAME}) ){ foreach $key ( keys %req_params){ $ENV{$key} = $req_params{$key}; } if ( $verbose ) { addlog($logfile, "running $req_params{SCRIPT_FILENAME}"); } # # open $cgi_app, '-|', $req_params{SCRIPT_FILENAME}, $stdin_passthrough or print("Content-type: text/plain\r\n\r\n"); print "Error: CGI app returned no output - Executing $req_params{SCRIPT_FILENAME} failed !\n"; # addlog($logfile, "Error: CGI app returned no output - Executing $req_params{SCRIPT_FILENAME} failed !");   if ($cgi_app) { print <$cgi_app>; close $cgi_app; } } else { print("Content-type: text/plain\r\n\r\n"); print "Error: No such CGI app - $req_params{SCRIPT_FILENAME} may not exist or is not executable by this process.\n"; addlog($logfile, "Error: No such CGI app - $req_params{SCRIPT_FILENAME} may not exist or is not executable by this process."); } } }

如果不用 sudo 方式运行 nginx-fcgi,请注释掉 nginx-fcgi 脚本中的:

if ( $> == “0″ ) {
print “\n\tERROR\tRunning as a root!\n”;
print “\tSuggested not to do so !!!\n\n”;
exit 1;
}

启动 nginx-fcgi:

vi now_start_perl_fcgi.sh

/app/nginx/sbin/perl-fcgi.pl -l /app/nginx/logs/perl-fcgi.log -pid /app/nginx/logs/perl-fcgi.pid -S /app/nginx/logs/perl-fcgi.sock

注意一定要为 socket 添加 nginx 帐户的权限,否则 cgi 会执行失败。

新建 nginx-fcgi 脚本指令配置,直接从 fastcgi_params 复制模板:

cp /etc/nginx/fastcgi_params /etc/nginx/nginx_fcgi_params

去除尾部的:

# PHP only, required if PHP was built with –enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;

新建站点配置文件:

server { listen 80; server_name localhost xxx.xxx.xxx.xxx; root /app/nagios/share; access_log off; location /status/ { stub_status on; access_log off; } location / { root /app/nagios/share; index index.html index.htm index.php; }   location ~ .*\.php?$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }   location /nagios { alias /app/nagios/share; }   location /cgi-bin/images { alias /app/nagios/share/images; }   location /cgi-bin/stylesheets { alias /app/nagios/share/stylesheets; }   location /cgi-bin { alias /app/nagios/sbin; }   location ~ .*\.(cgi|pl)?$ { gzip off; root /app/nagios/sbin; rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break; fastcgi_pass unix:/app/nginx/logs/perl-fcgi.sock; fastcgi_index index.cgi; fastcgi_param SCRIPT_FILENAME /app/nagios/sbin$fastcgi_script_name; fastcgi_param QUERY_STRING $query_string;   fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param REQUEST_URI $request_uri;   #fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_NAME $server_name; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param SERVER_SOFTWARE nginx;   fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param HTTP_ACCEPT_ENCODING gzip,deflate; fastcgi_param HTTP_ACCEPT_LANGUAGE zh-cn; fastcgi_read_timeout 60; } include include/auth; }

* 修改配置文件
打开 /usr/local/nagios/etc/cgi.cfg,修改 use_authentication 为:
use_authentication=0
即去除用户验证,然后重启 nagios。
打开 /usr/local/nagios/share/config.inc.php,把:
$cfg['cgi_base_url']=’/nagios/cgi-bin’;
改为(根据自己的实际情况修改):
$cfg['cgi_base_url']=’/cgi-bin’;
* 访问监控面板

搭建完成!

附:
创建用户

/usr/sbin/useradd somebody passwd somebody

修改DNS

vi /etc/resolv.conf

去除所有内容
添加

nameserver 202.96.209.5

关闭防火墙命令

/sbin/service iptables stop 或者 /etc/init.d/iptables stop

重启网络

/sbin/service network restart

重新安装Dell R610网卡驱动,系统自带的驱动和网卡硬件不兼容,在高负载下网卡会停止运行

tar xf Bcom_LAN_14.1.5_Linux_Source_A00.tar.gz cd Bcom_LAN_14.1.5_Linux_Source_A00/NetXtremeII/ rpm -ivh netxtreme2-5.0a.10-1.src.rpm cd /usr/src/redhat/ rpmbuild -bb SPECS/netxtreme2.spec rpm -ivh RPMS/x86_64/netxtreme2-5.0a.10-1.x86_64.rpm cd /app/software/Bcom_LAN_14.1.5_Linux_Source_A00 echo "/sbin/rmmod bnx2;/sbin/modprobe bnx2;" > lan_dr_up.sh chmod +x lan_dr_up.sh ./lan_dr_up.sh &

安装并启动Rsync
为磁盘同步做准备

/usr/bin/rsync --daemon echo "/usr/bin/rsync --daemon" >> /etc/rc.local
阅读(3027) | 评论(0) | 转发(1) |
0

上一篇:Vim的分屏功能

下一篇:没有了

给主人留下些什么吧!~~