CentOS 7.3 安裝Cacti

新版本安裝時有些小技巧,在此紀錄一下

1.安裝套件
2.啟動服務
3.資料庫初始化設定
4.httpd cacti設定
5.crond 設定
6.Web初始化設定
7.安裝Cacti Plugin

1.安裝套件
for cacti

#yum install epel-release

cacti 1.0.4 建議Mariadb 版本在10.0以上

#vi /etc/yum.repos.d/MariaDB10.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
#yum install httpd httpd-devel mariadb-server mariadb-client php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli php-snmp php-ldap net-snmp-utils net-snmp-libs rrdtool cacti git mod_ssl  net-snmp-perl

2.啟動服務

修改PHP timezone

#vi /etc/php.ini
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "Asia/Taipei"
#systemctl start snmpd.service
#systemctl start mariadb.service
#systemctl enable httpd.service
#systemctl enable mariadb.service
#systemctl enable snmpd.service

3.資料庫初始化設定

#mysql_secure_installation
#mysql -u root -p
MariaDB [(none)]> create database cacti;
Query OK, 1 row affected (0.01 sec)

MariaDB [(none)]> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'yourpassword';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> FLUSH privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit;
Bye
#rpm -ql cacti | grep cacti.sql
/usr/share/doc/cacti-1.0.4/cacti.sql
#mysql -u cacti -p cacti < /usr/share/doc/cacti-1.0.4/cacti.sql
#vi /etc/cacti/db.php
/* make sure these values reflect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "yourpassword";
$database_port = "3306";
$database_ssl = false;

4.httpd cacti設定

#vi /etc/httpd/conf.d/cacti.conf
Alias /cacti /usr/share/cacti
<Directory /usr/share/cacti/>
<IfModule mod_authz_core.c>
# httpd 2.4
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
# httpd 2.2
Order deny,allow
Deny from all
Allow from all
</IfModule>
</Directory>
#vi /etc/httpd/conf/httpd.conf
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/usr/share/cacti"
#systemctl restart httpd.service

5.crond 設定

#vi /etc/cron.d/cacti
*/5 * * * * cacti /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

6.Web初始化設定
登入Web,接受License,點選下一步

出現TimeZone問題

#mysql_tzinfo_to_sql  /usr/share/zoneinfo | mysql -p mysql
#mysql -u root -p
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 14
Server version: 5.5.52-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 
MariaDB [(none)]> 
MariaDB [(none)]> GRANT SELECT ON mysql.time_zone_name TO cacti@localhost IDENTIFIED BY 'yourpassword';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> FLUSH privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit
Bye

除了TimeZone問題外,有些參數還必須再做調整

#vi /etc/my.cnf
[mysqld]
collation-server = utf8mb4_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8mb4
max_heap_table_size = 256M
max_allowed_packet = 16777216
tmp_table_size = 64M
join_buffer_size = 64M
innodb_file_per_table = on
innodb_doublewrite = off
innodb_additional_mem_pool_size = 80M
innodb_flush_log_at_trx_commit = 2
innodb_buffer_pool_size = 512M
innodb_flush_log_at_timeout = 3
innodb_read_io_threads = 32
innodb_write_io_threads = 16
#systemctl restart mariadb.service

重新整理Web,確認參數已經正確,點選下一步

點選下一步

點選下一步

點選下一步

全選,點選完成

預設登入帳號密碼 admin / admin ,第一次登入會要求修改密碼,完成

若忘記Web密碼,可透過以下方式恢復

#mysql -u root -p
MariaDB [(none)]> use cacti
MariaDB [cacti]> update user_auth set password=md5('admin') where username='admin';

7.安裝Cacti Plugin
Plugin 來源為GitHub,使用git下載檔案
安裝thold

#git clone https://github.com/Cacti/plugin_thold.git

把檔案放到/usr/share/cacti/plugins 底下,檔名記得更換

#mv plugin_thold thold ; mv thold /usr/share/cacti/plugins

透過Cacti Plugin Management進行安裝,並且開啟此外掛

8.安裝spine

#yum  install dos2unix autoconf automake libtool help2man wget gcc gcc-c++ make automake autoconf patch net-snmp-devel mysql-devel openssl-devel libtool dos2unix help2man

下載spine安裝

#wget http://www.cacti.net/downloads/spine/cacti-spine-1.1.16.tar.gz
#tar -xzf cacti-spine-1.1.16.tar.gz
#cd cacti-spine-1.1.16
#./bootstrap
#./configure --prefix=/usr/local/spine
#make;make install
#chown root:root /usr/local/spine/bin/spine
#chmod +s /usr/local/spine/bin/spine
#cp /usr/local/spine/etc/spine.conf.dist /usr/local/spine/etc/spine.conf
#vi /usr/local/spine/etc/spine.conf

Refer:https://mariadb.com/kb/en/the-mariadb-library/yum/

Facebook Comments

“CentOS 7.3 安裝Cacti” 有 9 則留言.

  1. 目前版本已經是1.1.2了 流程略有差異,可是裡面的模版一個都沒有 是要從舊版移過來嗎?

  2. 您好,按照您的文章做到後面”#vi /etc/my.cnf” 設定一些DB Settings的時候,我把您提供的預設值貼上去後存檔,接著重啟服務,出現以下錯誤:Job for mariadb.service failed because the control process exited with error code. See “systemctl status mariadb.service” and “journalctl -xe” for details.

    請問是我步驟有錯誤嗎?

    謝謝

留言已被關閉。