安装epel rpm–ivh http://mirrors.neusoft.edu.cn/epel/6Server/x86_64/epel-release-6-8.noarch.rpm yum install mhash libmcrypt mcrypt make apr* autoconf automake curl curl-devel gccgcc-c++ zlib-devel openssl openssl-devel pcre-devel gd kernel keyutils patchperl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel pplcloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-develkrb5-devel zlib-devel libXpm* freetype freetype-devel libjpeg* libpng*php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch wget http://nginx.org/download/nginx-1.5.4.tar.gz wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.gz http://mirrors.scie.in/mariadb/mariadb-5.5.31/kvm-tarbake-jaunty-x86/mariadb-5.5.31.tar.gz http://www.php.net/get/php-5.4.16.tar.gz/from/a/mirror wget http://jaist.dl.sourceforge.net/ ... .6.12-source.tar.gz
groupadd mysql useradd -g mysql mysql -s /sbin/nologin mkdir -p /data/mysql chown -R mysql:mysql /data/mysql mkdir -p /usr/local/mysql
cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql-DSYSCONFDIR=/etc make && make install ./scripts/mysql_install_db--user=mysql --basedir=/data/mysql cp ./support-files/mysql.server/etc/rc.d/init.d/mysqld chmod 755 /etc/init.d/mysqld vi /etc/rc.d/init.d/mysqld basedir = /usr/local/mysql datadir = /data/mysql
chkconfig mysqld on
./scripts/mysql_install_db–basedir=/usr/local/mysql–datadir=/data/mysql--user=mysql
echo “PATH=$PATH:/usr/local/mysql/bin”>>/etc/profile source /etc/profile chown -R root.mysql /usr/local/mysql/
ln -s /usr/local/mysql/lib/mysql/usr/lib/mysql vi /etc/ld.so.conf.d/mysql.conf /usr/local/mysql/lib
/bin/mysqld_safe –user=mysql& mysqladmin -u root password vmware
http://wiki.nginx.org/InstallOptions ./configure --user=www --group=www --with-http_stub_status_module--with-http_flv_module --with-http_ssl_module --with-pcre --with-file-aio--with-http_gzip_static_module make&& make install vi/etc/init.d/nginx #!/bin/bash # #Startup script for Nginx - this script starts and stops the nginx daemon # #chkconfig: - 85 15 #description: Nginx is an HTTP(S) server,HTTP(S) reverse proxy and IMAP/POP3 proxy server #processname: nginx #config: /usr/local/nginx/conf/nginx.conf #pidfile: /usr/local/nginx/logs/nginx.pid
#Source function library. ./etc/rc.d/init.d/functions
#Source networking configuration. ./etc/sysconfig/network
#Check that networking is up. ["$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx" prog=$(basename$nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
[-f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
start(){ [ -x $nginx ] || exit 5 [ -f $NGINX_CONF_FILE ] || exit 6 echo -n $"Starting $prog: " daemon $nginx -c $NGINX_CONF_FILE retval=$? echo [ $retval -eq 0 ] && touch$lockfile return $retval }
stop(){ echo -n $"Stopping $prog: " killproc $prog -QUIT retval=$? echo [ $retval -eq 0 ] && rm -f$lockfile return $retval }
restart(){ configtest || return $? stop sleep 1 start }
reload(){ configtest || return $? echo -n $"Reloading $prog: " killproc $nginx -HUP RETVAL=$? echo }
force_reload(){ restart }
configtest(){ $nginx -t -c $NGINX_CONF_FILE }
rh_status(){ status $prog }
rh_status_q(){ rh_status >/dev/null 2>&1 }
case"$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart|configtest) $1 ;; reload) rh_status_q || exit 7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q || exit 0 ;; *) echo $"Usage: $0{start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" exit 2 esac
wgethttp://nchc.dl.sourceforge.net/p ... mcrypt-2.6.8.tar.gz 安装mcrypt tar -zxvf mcrypt-2.6.8.tar.gz cd mcrypt-2.6.8 exportLD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH LD_LIBRARY_PATH=/usr/local ./configure
tar zxvf php-5 ./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc--with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config--with-mysql-sock=/tmp/mysql.sock --with-gd --with-iconv --with-zlib--enable-xml --enable-bcmath --enable-shmop --enable-sysvsem--enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fpm--enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl--enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap--without-pear --with-gettext --enable-session --with-mcrypt=/usr/local/include--with-curl make && make install
cp php.ini-production /usr/local/php5/etc/php.ini#复制php配置文件到安装目录 rm -rf /etc/php.ini #删除系统自带配置文件 ln -s /usr/local/php5/etc/php.ini /etc/php.ini#添加软链接 cp /usr/local/php5/etc/php-fpm.conf.default/usr/local/php5/etc/php-fpm.conf #拷贝模板文件为php-fpm配置文件 vi /usr/local/php5/etc/php-fpm.conf#编辑 user= www #设置php-fpm运行账号为www group= www #设置php-fpm运行组为www pid= run/php-fpm.pid #取消前面的分号 设置 php-fpm开机启动 cp /usr/local/src/php-5.4.5/sapi/fpm/init.d.php-fpm/etc/rc.d/init.d/php-fpm#拷贝php-fpm到启动目录 chmod +x /etc/rc.d/init.d/php-fpm#添加执行权限 chkconfig php-fpm on #设置开机启动 vi /usr/local/php5/etc/php.ini ;date.timezone= 修改为:date.timezone = Shanghai #时区 expose_php =On
vi /usr/local/nginx/conf/nginx.conf user www www; index index.php index.html index.htm; #pass the PHP scripts to FastCGI server listeningon 127.0.0.1:9000 # location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name; include fastcgi_params; } #取消FastCGI server部分location的注释,并要注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径 include vhost/*.conf; #虚拟主机配置文件 eg server{ listen 80; server_name www.domain.com; root /usr/local/nginx/html/blog; index index.php index.html index.htm; # if (!-e $request_filename) { # rewrite ^.+/?(/blog/wp-.*) $1 last; # rewrite ^.+/?(/blog/.*\.php)$ $1 last; # rewrite ^(.+)$ /blog/index.php?q=$1 last; # }
# pass the PHP scripts to FastCGIserver listening on 127.0.0.1:9000 # 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 ~.*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 1h; }
#log_format access '$remote_addr - $remote_user [$time_local] "$request" ' #'$status $body_bytes_sent"$http_referer" ' #'"$http_user_agent"$http_x_forwarded_for'; #access_log /var/logs/nginx/access.log access; } /etc/init.d/nginxrestart
<?php phpinfo(); ?>
chown www.www /usr/local/nginx/html/ -R chmod 700 /usr/local/nginx/html/ -R
xcache #/usr/local/php/bin/phpize #./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config make&& make install Installing shared extensions: /usr/local/php5/lib/php/extensions/no-debug-non-zts-20100525/
rrdtool http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.8.tar.gz cacti http://www.cacti.net/downloads/cacti-0.8.8a.tar.gz yum install cairo-devel libxml2-devel pango-devel pango libpng-devel freetypefreetype-devel libart_lgpl-devel tar zxvf rrdtool-1.4.8.tar.gz
cd rrd rrdtool-1.4.8
./configure –prefix=/usr/local/rrdtool && make && make install
yum install net-snmp-utils php-snmp net-snmp-libs
vim /etc/snmp/snmpd.conf
注释掉下面2行
#view systemview included .1.3.6.1.2.1.1
#view systemview included .1.3.6.1.2.1.25.1.1
增加如下一行
view systemview included .1
完整配置文件如下 com2secnotConfigUser default public
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
view systemview included .1
access notConfigGroup “” any noauth exact systemview none none
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat
chkconfig snmpd on
chkconfig snmptrapd on tar zxvf cacti-0.8.8a.tar.gz
mv cacti-0.8.8a/* /usr/local/nginx/html/cacti/*
useradd cacti -g users -s /sbin/nologin
mysql -p
mysql>create database cacti;
mysql>use cacti;
mysql>source /usr/local/nginx/html/cacti/cacti.sql
mysql>GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY ‘vmware’;
mysql> flush privileges;
mysql> \q
打开ip/cacti按操作提示安装,CACTI安装完使用,在RRD目录一直未能生成监控文件,导致Graph中不能生成监控图像。
执行/usr/local/php-5.4.16/bin/php/usr/local/nginx/html/cacti/poller.php提示找不到*.so文件,最后才发现是安装操作系统时php的rpm安装包没有卸载掉,导致执行的时候调用了/usr/bin/php,正确PHP Binary Path 应该是/usr/local/php-5.3.24/bin/php
在监控端执行命令检查是否可以抓取数据
| snmpwalk -c public -v 2c 192.168.*.* |
如果出现SNMP ERROR说明snmp配置错误或者防火墙端口没有开放
|