cacti install

cacti 是网络监控用的一个工具

1.依赖包

yum mariadb nginx snmpd

yum -y install net-snmp

yum -y install net-snmp-utils

yum -y install rrdtool

service snmpd start

#测试本机snmp启动是否成功

snmpwalk -v 2c -c public localhost

2.mysql安装

cat <<EOF > /etc/yum.repo.d/MariaDB.repo

[mariadb]

name = MariaDB

baseurl = http://yum.mariadb.org/10.1/centos7-amd64

gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

gpgcheck=1

EOF

yum install MariaDB-server MariaDB-client

systemctl start mariadb

mysql_secure_installation ##passwd cacti

#修改/etc/my.cnf /etc/my.cnf.d/server|client. 修改数据库编码

[client]

default-character-set=utf8

[mysql]

default-character-set=utf8

[mysqld]

collation-server = utf8_unicode_ci

init-connect=’SET NAMES utf8′

character-set-server = utf8

#修改时区

mysql_tzinfo_to_sql /usr/share/zoneinfo/ | mysql -u root -p mysql

#curl -O http://mirror.cogentco.com/pub/apache//httpd/httpd-2.4.29.tar.gz

#tar xzf httpd-2.4.29.tar.gz

#cd httpd-2.4.29

#./configure –prefix=/usr/local/httpd-2.4.29

3.nginx安装

yum install epel-release

yum install nginx

server中配置

location / {

index index.php index.html index.htm;

}

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;

}

service nginx start

4.cacti安装

curl -O https://www.cacti.net/downloads/cacti-1.1.28.tar.gz

tar xzf cacti-1.1.28.tar.gz

mv cacti-1.1.28 /usr/share/nginx/html/

yum install php-mysql php-snmp php-xml

yum install gcc

yum install libxml2-devel

#download php

./configure –prefix=/usr/local/php-5.6.32

make

make install

#导入数据到数据库

mysqladmin –user=root -p create cacti

mysql -uroot -pcacti -D cacti < /usr/share/nginx/html/cacti-1.1.28/cacti.sql

##add priviledge on mysql.timezone to cacti

mysql -uroot -pcacti <<EOF

GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY ‘12345678’;

GRANT select ON mysql.* TO cacti@localhost IDENTIFIED BY ‘12345678’;

flush privileges;

EOF

#修改cacti的数据库连接配置

vi /usr/share/nginx/html/cacti-1.1.28/include/config.php

#database_username = “cacti”;

#database_password = “12345678”;

useradd cacti

chown -R cacti rra/log/

#增加cacti所需要的mariadb配置

/etc/my.cnf

[client-server]

max_allowed_packet = 16777216

[mysqld]

join_buffer_size = 64M

innodb_buffer_pool_size = 3072M

innodb_doublewrite = OFF

innodb_additional_mem_pool_size = 80M

innodb_flush_log_at_timeout = 3

innodb_read_io_threads = 32

innodb_write_io_threads = 16

max_heap_table_size = 1024M

tmp_table_size = 64M

default-time_zone = Asia/Shanghai

yum install openldap openldap-devel

#其他依赖库在./configure那一步时会有报错提示,根据错误安装相应的包,yum装

cp -frp /usr/lib64/libldap* /usr/lib/

cp -frp /usr/lib64/liblber* /usr/lib/

5.php安装

php去官网下载,解压后进入目录

./configure –prefix=/usr/local/php-5.6.32 –with-snmp –enable-fpm –with-mysql –with-pdo-mysql –enable-sockets –enable-mbstring –with-zlib –with-gmp –with-gd –with-openssl –with-ldap

成功后make && make install

#php,fpm配置

cp /usr/local/php-5.6.32/etc/php-fpm.conf.default /usr/local/php-5.6.32/etc/php-fpm.conf

cp source/php.ini-production /usr/local/php-5.6.32/lib/php.ini

修改配置文件php.ini

date.timezone = “Asia/Shanghai”

#查看ini文件信息

/usr/local/php-5.6.32/bin/php –ini

/usr/local/php-5.6.32/sbin/php-fpm -p /usr/local/php-5.6.32

cacti 用户的crontab 任务

*/5 * * * * /usr/local/php-5.6.32/bin/php /usr/share/nginx/html/cacti/poller.php > /dev/null 2>&1

#*/5 * * * * cacti /usr/local/php-5.6.32/bin/php /usr/share/nginx/html/cacti/poller.php > /dev/null 2>&1

6.登陆

访问

http://ip/cacti/

用户密码为admin/admin

#参考

官方安装文档

https://docs.cacti.net/manual:100:1_installation.1_install_unix.1_configure_php#configure_php

https://www.cacti.net/downloads/docs/html/unix_configure_cacti.html

某博客安装文档

https://qiita.com/Kenji_TAJIMA/items/91965a94c624fa0c89ca

PHP configure not finding LDAP header libraries

https://serverfault.com/questions/633394/php-configure-not-finding-ldap-header-libraries

#备用

How-to-install-Cacti-Monitoring-Server-With-Nginx

https://github.com/blackyboy/Ubuntu-Linux-Stuffs/blob/master/How-to-install-Cacti-Monitoring-Server-With-Nginx.md

php动态静态编译

http://evoupsight.com/blog/2013/12/10/php-use-snmp-module-to-monitor/

php编译时查看ldap模块

./configure –help|grep ldap