提前安装的包
yum install help2man
yum install rrdtool rrdtool-devel rrdtool-php rrdtool-perl
yum install gd gd-devel php-gd
yum install net-snmp*
yum安装 MariaDB-10.3
添加文件/etc/yum.repos.d/MariaDB.repo,内容如下。
# MariaDB 10.3 CentOS repository list - created 2017-02-17 06:03 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
安装MariaDB
yum install MariaDB-server MariaDB-client
配置文件/etc/my.cnf,添加如下内容
[client]
default-character-set=utf8mb4
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-external-locking
key_buffer_size = 16K
max_allowed_packet = 16M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 240K
max_heap_table_size = 50M
tmp_table_size = 64M
join_buffer_size = 64M
innodb_doublewrite = OFF
innodb_flush_log_at_timeout = 3
innodb_read_io_threads = 32
innodb_write_io_threads = 16
max_connections = 128
default_time_zone = 'Asia/Shanghai'
character_set_server = utf8mb4
collation-server = utf8mb4_unicode_ci
innodb_buffer_pool_size = 242M
解决MySQL TimeZone database is not populated问题
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql -p
php
使用nginx做web服务器(建议编译安装)
yum install php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli php-snmp php-ldap php-fpm
安装cacti-1.1.2
安装cacti-spine
tar zxvf cacti-spine-1.1.2.tar.gz
cd cacti-spine-1.1.2
./bootstrap
./configure
make
make install
chown root:root /usr/local/spine/bin/spine
chmod +s /usr/local/spine/bin/spine
cd /usr/local/spine/etc
cp spine.conf.dist spine.conf
编辑spine.conf
修改数据库相关的用户名和密码
安装cacti
安装源码
tar zxvf cacti-1.1.2.tar.gz
mv cacti-1.1.2 /var/www/html/cacti
chown -R nginx:nginx /var/www/html/cacti
编辑config.php
cd /var/www/html/cacti/include/
cp config.php.dist config.php
修改数据相关的用户名和密码
导入sql
mysql -uroot -p
MariaDB [(none)]> create database cacti;
MariaDB [(none)]> grant all on *.* to cactiuser@localhost identified by "cactipass";
MariaDB [(none)]> flush privileges;
mysql -u cactiuser -p cacti < /var/www/html/cacti/cacti.sql
数据库名称:cacti
用户名:cactiuser
数据库密码:cactipass
确认web和db服务都已启动,使用下面命令启动
systemctl start mariadb.service
systemctl start nginx.service
systemctl start php-fpm.service
这3个进程都要启动
配置cacti
添加crontab任务
vim /etc/cron.d/cacti
*/1 * * * * nginx /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1
注意是使用nginx用户运行crontab
访问 http://your-ip/cacti ,根据向导进行配置。
默认用户admin 密码admin,第一次登陆需要修改,新密码规则最低要求包括字母大小写、数字。
Configuration的settings修改
paths
spine二进制文件和spine.conf所在路径。
RRDfile Auto Clean打勾,方式选择Delete。
Device Defaults
Downed Device Detection选择none。
Poller
Poller Type选择spine
Poller Interval选择Every Minute
Cron Interval选择Every Minute
Maximum Threads per Process选择2(CPU内核数的整数倍)
Number of PHP Script Servers选择1
Script and Script Server Timeout Value选择45
The Maximum SNMP OIDs Per SNMP Get Request选择8(2的次方)
Data Storage
Structured RRD Path (/host_id/local_data_id.rrd)打勾
Visual
Enable Real-time Graphing打勾
Mail/Reporting/DNS
Server Base URL填写网站完整的url
Templates
Data Source里的Interface - Traffic修改Data Source Profile为High Collection Rate(支持每分钟视图)
cacti版本升级
备份mysql数据
mysqldump -l --add-drop-table cacti > mysql.cacti -u root -p
升级spine
删除老版本spine
rm -rf /usr/local/spine/
安装配置新版本spine
升级cacti
备份老cacti文件夹
cd /var/www/html
mv cacti cacti_old
解压新版本
tar zxvf cacti-1.1.5.tar.gz
mv cacti-1.1.5 /var/www/html/cacti
chown -R nginx:nginx /var/www/html/cacti
编辑config.php
从老版本文件夹复制相关文件到新版本
cp -r cacti_old/rra/* cacti/rra/
cp -u cacti_old/scripts/* cacti/scripts/
cp -u -R cacti_old/resource/* cacti/resource/
chown -R nginx:nginx /var/www/html/cacti
确认rra,log这2个文件夹的权限(user/group)。
管理界面升级
访问cacti所在url,根据向导升级cacti