CentOS 7 安装Cacti-1.2.2 (一)

必要条件

您需要一台CentOS 7 服务器:

本文在Centos7.x系统上运行,php使用7.1版本,mysql使用5.7版本,注意内存要大于2G!!!


1、添加epel源

[root@localhost ~]# yum install epel-release -y


2、添加wlnmp一键包源

[root@localhost ~]# rpm -ivh http://mirrors.whsir.com/centos/whsir-release-centos.noarch.rpm

3、安装nginx、php、mysql

[root@localhost ~]# yum install wnginx wphp71 wmysql57 -y 

4、安装php扩展及其他所需依赖

[root@localhost ~]# yum install wphp71-ldap wphp71-snmp wrrdtool wnet-snmp wspine-1.2.2 sendmail -y

5、设置两个软链接

[root@localhost ~]# ln -sv /usr/local/mysql/lib/libmysqlclient.so.20 /usr/lib64/libmysqlclient.so.20

[root@localhost ~]# ln -sv /usr/local/mysql/lib/libmysqlclient.so /usr/lib64/libmysqlclient.so


6、取消被禁用的php函数

# vim  /usr/local/php/etc/php.ini


找到disable_functions行,删除shell_exec,exec,popen,保存退出,重启php服务

#/etc/init.d/php-fpm71 restart

7、启动相关服务

/etc/init.d/nginx start

/etc/init.d/mysql start

/etc/init.d/snmpd start


8、修改MySQL密码(默认为空)


修改默认MySQL密码,创建cacti数据库,并添加相应权限

[root@localhost ~]# mysql -u root -p

mysql> set password = password('P@ssw0rd');

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


9、加载时区到mysql数据库

[root@localhost ~]# /usr/local/mysql/bin/mysql_tzinfo_to_sql /usr/share/zoneinfo/ | mysql -uroot -pP@ssw0rd mysql


10、下载cacti

[root@localhost ~]# mkdir /var/www -p 

[root@localhost ~]# cd /var/www/

[root@localhost www]# wget https://www.cacti.net/downloads/cacti-1.2.2.tar.gz

[root@localhost www]# tar xf cacti-1.2.2.tar.gz 

[root@localhost www]# mv  cacti-1.2.2   cacti


11、修改cacti数据库配置文件

#cd /var/www/cacti/include

# vim config.php 


$database_type     = 'mysql';

$database_default  = 'cacti';

$database_hostname = 'localhost';

$database_username = 'cacti';

$database_password = 'P@ssw0rd';

$database_port     = '3306';


12、导入cacti.sql

# mysql -uroot -pP@ssw0rd cacti < /var/www/cacti/cacti.sql
touch日志文件;


[root@localhost ~]# touch /var/www/cacti/log/cacti.log

[root@localhost ~]# touch /var/www/cacti/log/cacti_stderr.log

13、创建软链接

ln -sv /usr/local/rrdtool/bin/rrdtool /usr/local/bin/rrdtool

ln -sv /usr/local/php/bin/php /usr/bin/php

ln -sv /usr/local/snmp/bin/snmpwalk /usr/local/bin/snmpwalk

ln -sv /usr/local/snmp/bin/snmpget /usr/local/bin/snmpget

ln -sv /usr/local/snmp/bin/snmpbulkwalk /usr/local/bin/snmpbulkwalk

ln -sv /usr/local/snmp/bin/snmpgetnext /usr/local/bin/snmpgetnext

ln -sv /usr/local/snmp/bin/snmptrap /usr/local/bin/snmptrap


14、修改cacti目录权限

# chown -R www:www /var/www/cacti/ 

15、修改nginx配置

修改root路径为root /var/www;,取消php注释include enable-php71.conf;,修改下server_name为本机IP,或者自己填个域名,自行hosts,不做过多说明!

16、重启nginx服务

#nginx -t 

# /etc/init.d/nginx reload

17、spine配置

spine是一个基于C语言的,非常快速的轮询引擎,它是默认的cmd.php的可选替代,如果要使用spine需要单独的设置


[root@localhost ~]# cd /usr/local/spine/etc/

[root@localhost etc]# cp spine.conf.dist  spine.conf  

# vim spine.conf

DB_Host       localhost

DB_Database   cacti

DB_User       cacti

DB_Pass       P@ssw0rd

DB_Port       3306

验证一下

/usr/local/spine/bin/spine -C /usr/local/spine/etc/spine.conf



返回以下内容表示成功:


SPINE: Using spine config file [spine.conf]

SPINE: Version 1.2.2 starting

Created directory: /var/net-snmp

Created directory: /var/net-snmp/mib_indexes

SPINE: Time: 0.0465 s, Threads: 1, Devices: 0


18、进入web安装

http://192.168.44.139/cacti

默认账号密码admin,第一次登陆后会提示更改密码

image.png

image.png

image.png

image.png

安装向导检查,根据检查结果,自行更改php.ini和my.cnf文件,更改后记得重启,如相关参数在配置中不存在,手动添加即可

这里需要在my.cnf添加以下参数(注意最后两个参数如果不添加,后续可能会产生warning),然后重启MySQL

#vim /etc/my.cnf

innodb_flush_log_at_timeout = 3

innodb_read_io_threads = 32

innodb_write_io_threads = 16

 

character-set-server=utf8mb4

collation-server=utf8mb4_unicode_ci

# /etc/init.d/nginx restart 

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

安装完成后,看到以下页面

image.png

21、手动配置spine

image.png


标签: Cacti

作者头像
萧萧一风创始人

做一个积极主动热情的人,为了想要完成的事情和实现的目标,拼命投入力量。

上一篇:Windows Server 2008 下创建批处理备份mysql数据库并压缩删除bat
下一篇:Cacti-1.2.2 配置监控本机 (二)

发表评论