提前安裝的包
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裙顽,內(nèi)容如下付燥。
# 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,添加如下內(nèi)容
[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問(wèn)題
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql -p
php
使用nginx做web服務(wù)器(建議編譯安裝)
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
修改數(shù)據(jù)庫(kù)相關(guān)的用戶名和密碼
安裝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
修改數(shù)據(jù)相關(guān)的用戶名和密碼
導(dǎo)入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
數(shù)據(jù)庫(kù)名稱:cacti
用戶名:cactiuser
數(shù)據(jù)庫(kù)密碼:cactipass
確認(rèn)web和db服務(wù)都已啟動(dòng)愈犹,使用下面命令啟動(dòng)
systemctl start mariadb.service
systemctl start nginx.service
systemctl start php-fpm.service
這3個(gè)進(jìn)程都要啟動(dòng)
配置cacti
添加crontab任務(wù)
vim /etc/cron.d/cacti
*/1 * * * * nginx /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1
注意是使用nginx用戶運(yùn)行crontab
訪問(wèn) http://your-ip/cacti 键科,根據(jù)向?qū)нM(jìn)行配置。
默認(rèn)用戶admin 密碼admin,第一次登陸需要修改勋颖,新密碼規(guī)則最低要求包括字母大小寫(xiě)嗦嗡、數(shù)字。
Configuration的settings修改
paths
spine二進(jìn)制文件和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內(nèi)核數(shù)的整數(shù)倍)
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填寫(xiě)網(wǎng)站完整的url
Templates
Data Source里的Interface - Traffic修改Data Source Profile為High Collection Rate(支持每分鐘視圖)
cacti版本升級(jí)
備份mysql數(shù)據(jù)
mysqldump -l --add-drop-table cacti > mysql.cacti -u root -p
升級(jí)spine
刪除老版本spine
rm -rf /usr/local/spine/
安裝配置新版本spine
升級(jí)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
從老版本文件夾復(fù)制相關(guān)文件到新版本
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
確認(rèn)rra,log這2個(gè)文件夾的權(quán)限(user/group)卑硫。
管理界面升級(jí)
訪問(wèn)cacti所在url,根據(jù)向?qū)?jí)cacti