环境:系统为CentOS 6.0
1. 安装所依赖的软件包
- yum groupinstall "SNMP Support"
- yum install net-snmp-devel
- yum install rrdtool*
安装snmp和rrdtool(cacti绘图需要rrdtool)
安装php-snmp扩展
- cd /usr/local/src/php-5.2.17/ext/snmp/
- /usr/local/php/bin/phpize
- ./configure
- make
- make install
- # 添加扩展
- vi /usr/local/php/etc/php.ini
- extension = "snmp.so"
- # 重载php
- php-fpm reload
2. 添加cacti用户
- useradd -r cacti -d /data/www/cacti
3. 下载软件包,解压
- wget http://www.cacti.net/downloads/cacti-0.8.7g.tar.gz -P /usr/local/src
- tar zxvf /usr/local/src/cacti-0.8.7g.tar.gz -C /data/www
- chown -R root:root /data/www/cacti
- chown -R cacti:cacti /data/www/cacti/logs
- chown -R cacti:cacti /data/www/cacti/rra
- chmod -R 0777 /data/www/cacti/logs
- chmod -R 0777 /data/www/cacti/rra
4. 创建数据库并导入数据
- mysql -uroot -p
- > create database cacti;
- > grant all on cacti.* to cacit@'192.168.1.10' identified by 'xxxxxx';
- > flush privileges;
因为cacti.sql文件中使用TYPE=MyISAM,我的mysql版本是5.5.x,将TYPE=修改为ENGINE=
- sed -i 's#TYPE=#ENGINE=#g' /data/www/cacti/cacti.sql
导入数据库
- mysql -uroot -p cacti < /data/www/cacti/cacti.sql
5. 修改cacti配置文件
- vi /data/www/cacti/include/config.php
- $database_type = "mysql";
- $database_default = "cacti";
- $database_hostname = "192.168.1.10";
- $database_username = "cacti";
- $database_password = "xxxxxx";
- $database_port = "3306";
6. 添加定时任务
- su – cacti
- crontab -e
- */5 * * * * /usr/local/php/bin/php /data/www/cacti/poller.php > /dev/null 2>&1
可以手动执行/usr/local/php/bin/php /data/www/cacti/poller.php看看是否有报错,如果有报错需要解决。
7. 配置nginx
nginx,php和mysql的安装参考张宴的文章
- vi /usr/local/nginx/conf/vhosts/cacti.conf
- server
- {
- listen 192.168.1.11:8013;
- server_name 192.168.1.11;
- index index.html index.htm index.php;
- root /data/www/cacti;
- location ~ .*\.(php|php5)?$
- {
- # fastcgi_pass unix:/tmp/php-cgi.sock;
- fastcgi_pass 192.168.1.10:9000;
- fastcgi_index index.php;
- include fcgi.conf;
- }
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
- {
- expires 30d;
- access_log off;
- }
- location ~ .*\.(js|css)?$
- {
- expires 1h;
- access_log off;
- }
- log_format cacti '$remote_addr – $remote_user [$time_local] [$request_time] "$request" '
- '$status $body_bytes_sent "$http_referer" '
- '"$http_user_agent" $http_x_forwarded_for';
- access_log off;
- }
重载nginx
- nginx -t
- nginx -s reload
8. 安装rrdtool
在第一步中已经用yum安装完成
9. 进入登陆界面
在Web浏览器中输入:http://192.168.1.11:8013/,确认各个执行文件的路径,最后进入登陆页面,用户名和密码都为admin,之后需要输入admin的新密码两次,安装完成。
转载于:https://blog.51cto.com/linuxjcq/717933