cacti
关闭防火墙和selinux
[root@test1 ~]# sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
[root@test1 ~]# setenforce 0
[root@test1 ~]# systemctl stop firewalld && systemctl disable firewalld
添加epel源
[root@test1 ~]# yum -y install epel-release
添加wlnmp一键包源
[root@test1 ~]# rpm -ivh http://mirrors.wlnmp.com/centos/whsir-release-centos.noarch.rpm
安装nginx、php、mysql
[root@test1 ~]# yum -y install wnginx wphp71 wmysql57
安装php扩展及其他所需依赖
[root@test1 ~]# yum -y install wphp71-ldap wphp71-snmp wrrdtool wnet-snmp wspine-1.2.2 sendmail
设置两个软链接
[root@test1 ~]# ln -sv /usr/local/mysql/lib/libmysqlclient.so.20 /usr/lib64/libmysqlclient.so.20
[root@test1 ~]# ln -sv /usr/local/mysql/lib/libmysqlclient.so /usr/lib64/libmysqlclient.so
取消被禁用的php函数
[root@test1 ~]# vim /usr/local/php/etc/php.ini
找到disable_functions行,删除exec,shell_exec,popen,再将时区改为Asia/Shanghai,保存退出,重启php服务
#/etc/init.d/php-fpm71 restart
启动相关服务
[root@test1 ~]# for i in nginx mysql snmpd;do /etc/init.d/$i restart;done
修改默认MySQL密码,创建cacti数据库,并添加相应权限(MySQL密码默认为空)
[root@test1 ~]# mysql -uroot -p
mysql> set password = password('aa4455**');
mysql> CREATE DATABASE cacti DEFAULT CHARACTER SET utf8;
mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'P@ssw0rd';
mysql> GRANT SELECT ON mysql.time_zone_name TO cacti@localhost IDENTIFIED BY 'P@ssw0rd';
mysql> ALTER DATABASE cacti CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
mysql> flush privileges;
mysql> quit
在my.cnf中添加以下参数(注意最后两个参数如果不添加,后续可能会产生warning),然后重启MySQL
#vim /etc/my.cnf #在[mysqld]段中添加如下内容
要修改的
innodb_flush_log_at_timeout = 3
innodb_read_io_threads = 32
innodb_write_io_threads = 16
tmp_table_size = 120M
innodb_buffer_pool_size = 1024M
新增加的
max_heap_table_size = 120M
join_buffer_size = 150M
innodb_buffer_pool_instances = 10
innodb_io_capacity = 5000
innodb_io_capacity_max = 10000
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
[root@test1 ~]# /etc/init.d/mysql restart
[root@test1 ~]# /etc/init.d/nginx restart
加载时区到mysql数据库
[root@test1 ~]# /usr/local/mysql/bin/mysql_tzinfo_to_sql /usr/share/zoneinfo/|mysql -uroot -paa4455** mysql
下载cacti
[root@test1 ~]# mkdir -p /var/www && cd /var/www/
[root@test1 www]# wget https://www.cacti.net/downloads/cacti-1.2.14.tar.gz
[root@test1 www]# tar -zxvf cacti-1.2.14.tar.gz
[root@test1 www]# mv cacti-1.2.14 cacti
修改cacti数据库配置文件
[root@test1 www]# cd cacti/include/
[root@test1 include]# vim config.php
$database_type = 'mysql';
$database_default = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cacti';
$database_password = 'P@ssw0rd';
导入cacti.sql
[root@test1 include]# mysql -uroot -p aa4455** cacti < /var/www/cacti/cacti.sql
创建日志文件
[root@test1 include]# touch /var/www/cacti/log/{cacti.log,cacti_stderr.log}
创建软链接
[root@test1 include]# ln -sv /usr/local/rrdtool/bin/rrdtool /usr/local/bin/
[root@test1 include]# ln -sv /usr/local/snmp/bin/snmpwalk /usr/local/bin/
[root@test1 include]# ln -sv /usr/local/snmp/bin/snmpget /usr/local/bin/
[root@test1 include]# ln -sv /usr/local/snmp/bin/snmpbulkwalk /usr/local/bin/
[root@test1 include]# ln -sv /usr/local/snmp/bin/snmpgetnext /usr/local/bin/
[root@test1 include]# ln -sv /usr/local/snmp/bin/snmptrap /usr/local/bin/
[root@test1 ~]# cd
修改cacti目录权限
[root@test1 ~]# [root@test1 include]# chown -R www.www /var/www/cacti
修改nginx配置
[root@test1 ~]# cp /usr/local/nginx/conf/vhost/demo.conf /usr/local/nginx/conf/vhost/cacti.conf
[root@test1 ~]# vim /usr/local/nginx/conf/vhost/cacti.conf
server
{
server_name 172.16.186.139; #server_name为本机IP
index index.html index.htm index.php;
root /var/www;
....
....
include enable-php71.conf;
....
....
[root@test1 ~]# nginx -t
[root@test1 ~]# /etc/init.d/nginx reload
spine配置
spine是一个基于C语言的,非常快速的轮询引擎,它是默认的cmd.php的可选替代,如果要使用spine需要单独的设置
[root@test1 ~]# cd /usr/local/spine/etc/
[root@test1 etc]# cp spine.conf.dist spine.conf
[root@test1 etc]# vim spine.conf
注意:该文件中有2处一样的要修改
DB_Host localhost
DB_Database cacti
DB_User cacti
DB_Pass P@ssw0rd
DB_Port 3306
验证
[root@test1 etc]# /usr/local/spine/bin/spine -C /usr/local/spine/etc/spine.conf
进入web安装
http://192.168.44.139/cacti
默认账号/密码都为admin,第一次登陆后会提示更改密码
Flz***c1
选择语言为中文并接受GPL许可协议,而后点击开始
检查是否有欠缺/未安装的,补充完整后点击下一步(有2个感叹号的项可忽略)
下面2张图为一张整图
下图中在左下角打上对号,点击下一页
修改扫描的网段,如下图
下图中直接点下一页即可
下图中在“确认安装”前打上对号,点击安装
开始安装,如下图
安装完成后点击左下角的“开始使用”
手动设置spine
后续添加相应的设置、监控设备等,先下班
docker部署:https://gitee.com/Coding-01/docker-cacti
欢迎加入QQ群一起讨论Linux、开源等技术