===
2017 03月 cacti竟然從0.8.8h 一躍為 1.0.0
於是花了些時間嘗試安裝,在卡了一堆bug與套件設定架設完成後,
上網看完討論決定放棄深究,果不其然,如今相差近三個星期已經推行到了1.1.0
才重拾心情再次安裝一次,果然順多了XDD
就把安裝畫面與過程做個筆記。
安裝環境為CentOS 7
在安裝Cacti之前先來處理個前置作業:DB安裝與設定
1.0之前的版本對於DB並無特定的要求
而至1.0之後則是有Mysql >5.6 MariaDB>10.0+
故直接先去Mysql抓取目前最新版本回來安裝
當然,相對指令也有所不同
#Mysql 安裝步驟
setenforce 0
yum info mariadb-libs.x86_64
#預設安裝之mariadb套件
yum remove mariadb-libs.x86_64
yum remove mariadb*
將mysql-5.7.17-1.el7.x86_64.rpm-bundle.tar解壓縮後安裝丟置/tmp目錄安裝以下套件
須注意順序,不然會安裝失敗
yum localinstall mysql-community-common-5.7.17-1.el7.x86_64.rpm
yum localinstall mysql-community-libs-5.7.17-1.el7.x86_64.rpm
yum localinstall mysql-community-libs-compat-5.7.17-1.el7.x86_64.rpm
yum localinstall mysql-community-devel-5.7.17-1.el7.x86_64.rpm
yum localinstall mysql-community-client-5.7.17-1.el7.x86_64.rpm
yum localinstall mysql-community-server-5.7.17-1.el7.x86_64.rpm
systemctl start mysqld
#擷取資料庫初始化之預設root密碼
cat /var/log/mysqld.log |grep password
會出現類似下列訊息
#2017-03-22T02:20:07.946593Z 1 [Note] A temporary password is generated for root@localhost: VC<ugKe.p7OL
將預設root密碼敲入並更改root密碼
mysql -u root -p
#更換root 密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root_P@ssw0rd';
FLUSH PRIVILEGES;
===============
至此Mysql安裝設定暫時完成
===============
Cacti 前置作業:
預設安裝套件如下:
yum -y install httpd*
yum -y install php php-gd php-mbstring php-mysql php-ldap php-posix php-snmp
yum -y install net-snmp*
yum -y install rrdtool*
yum -y install freetype-devel libpng-devel libart_lgpl-devel
yum -y install openssl*
yum -y install gcc
========
設定PHP Timezone
vi /etc/php.ini
timezone=Asia/Taipei
========
安裝 Cacit 1.1.0
#Install Cacit 1.1.0
cd /tmp/
wget http://www.cacti.net/downloads/cacti-1.1.0.tar.gz
tar -xzvf cacti-1.1.0.tar.gz
mv cacti-1.1.0 cacti
cp -R cacti /var/www/html
chmod 777 /var/www/html/cacti/log
chmod 777 /var/www/html/cacti/rra
chmod -R 777 /var/www/html/cacti/cache/
chmod 755 /var/www/html/cacti/poller.php
#安裝設定網頁後需改回755
chmod -R 777 /var/www/html/cacti/resource/
chmod -R 777 /var/www/html/cacti/scripts
chmod -R 755 /var/www/html/cacti/resource/
chmod -R 755 /var/www/html/cacti/scripts
=========
重啟 apache(怕沒重啟帶入設定)
systemctl restart httpd
=========
設定cacti 與DB
#建立資料庫
mysql -u root -p
create database cacti ;
create database syslog ;
//GRANT cacti 資料庫權限給Cacti 資料庫使用者,密碼為cacti
//GRANT ALL ON '資料庫'.* TO '帳號'@'IP/hostname' IDENTIFIED BY '密碼';
//@後之IP或是HOSTNAME為限定其主機與IP可連結,留空白則為都開放。
SET GLOBAL validate_password_policy='LOW';
grant all on cacti.* to 'cactiuser'@'localhost' identified by "cactiP@ssw0rd";
grant all on syslog.* to 'cactiuser'@'localhost' identified by "cactiP@ssw0rd";
grant SELECT on mysql.* to 'cactiuser'@'localhost' identified by "cactiP@ssw0rd";
flush privileges;
#將欄位設定匯入mysql
如果都安裝在同一台則
cd /var/www/html/cacti/
mysql -u root -p -A cacti < cacti.sql
cd /var/www/cacti/pluging/syslog/
mysql -u root -p -A syslog < syslog.sql
#設定Mysql timezone
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
#設定/etc/my.cnf
vim /etc/my.cnf
===========
#Mysql 5.7.17 for Cacti 1.1.0
[mysqld]
innodb_buffer_pool_size = 512M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
init-connect='SET NAMES utf8'
lower_case_table_names=0
max_heap_table_size=90M
max_allowed_packet=167M
tmp_table_size = 64M
join_buffer_size =128M
sort_buffer_size = 4M
read_rnd_buffer_size = 4M
innodb_doublewrite = OFF
innodb_flush_log_at_timeout = 3
innodb_read_io_threads = 32
innodb_write_io_threads = 16
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
===========
重啟Mysqld
systemctl restart mysqld
===========
設定Cacti DB設定
vim /var/www/html/cacti/include/config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost"; //也可填寫ip如"192.168.1.99"
$database_username = "cactiuser";
$database_password = "cactiP@ssw0rd";
$database_port = "3306";
$database_ssl = false;
===========
6. crontab 排成設定
crontab –e
*/5 * * * * /usr/bin/php /var/www/html/cacti/poller.php >/dev/null 2>&1
===========
防火牆開啟
sudo firewall-cmd --permanent --zone=public --add-port=80/tcp
sudo firewall-cmd --permanent --zone=public --add-port=161/udp
sudo firewall-cmd --permanent --zone=public --add-port=162/udp
sudo firewall-cmd --reload
sudo firewall-cmd --list-all
至此Cacti http端設定完畢
應該會顯示以下畫面
如果沒有就對照所缺之套件來安裝
理論上到這邊就沒甚麼問題了
另外安裝 spine增進cacti 效能的套件(可裝可不裝)
cacti spine
==============
https://www.urban-software.com/cacti-howtos/cacti/install-cacti-spine-poller/
cacti spine install
===================
yum install dos2unix
yum install autoconf
yum install automake
yum install libtool
yum -y install help2man
cd /tmp
wget http://www.cacti.net/downloads/spine/cacti-spine-1.0.0.tar.gz
tar -xzvf cacti-spine-1.0.0.tar.gz
cd cacti-spine-1.0.0
./bootstrap
./configure --prefix=/usr/local/spine
make
make install
chown root:root /usr/local/spine/bin/spine
chmod +s /usr/local/spine/bin/spine
#設定spine
cp /usr/local/spine/etc/spine.conf.dist /usr/local/spine/etc/spine.conf
vi /usr/local/spine/etc/spine.conf
====
DB_Host localhost
DB_Database cacti
DB_User cactiuser
DB_Pass cactiP@ssw0rd
DB_Port 3306
DB_PreG 0
====
Client SNMP設定
vim /etc/snmp/snmpd.conf
==========
#com2sec notConfigUser default public
#group notConfigGroup v1 notConfigUser
#group notConfigGroup v2c notConfigUser
新增下列設定
com2sec local localhost public
com2sec mynetwork 192.168.1.0/24 public
group notConfigGroup v1 local
group notConfigGroup v2c local
group notConfigGroup v1 mynetwork
group notConfigGroup v2c mynetwork
view all included .1 80
view systemview included .1.3.6.1.2.1.2
access notConfigGroup "" any noauth prefix all none none
access notConfigGroup "" any noauth prefix all all all
===========
systemctl restart snmpd.service
===========
Try it!
您好,不好意思,想跟您請教一下,#安裝設定網頁後需改回755,意思是指啥,看的不是很懂,謝謝。
回覆刪除因為777會使any user具有rwx(讀取、寫入、執行)的權限,
回覆刪除而小弟淺見該資料夾若非需要一般使用者對於該資料夾只需讀取與執行的權限故建議改成755。