CentOS7安裝Cacti1.2.11運維監控系統
2020/04/16 Kunshan
说明:安裝測試正常

  1. CentOS7 環境,CentOS-7-x86_64-DVD-1908.iso
  2. Cacti ,The latest stable version is 1.2.11, released 04/05/20
    Spine ,The latest stable version is 1.2.11, released 04/05/20
    一、 安裝與設定centos 7
    安裝,指定ip,設定telnet,安裝NTP,關閉防火墻,更新yum源及安裝依賴包
    1.1. 安裝CentOS-7-x86_64-DVD-1908.iso

    CentOS7安裝Cacti1.2.11運維監控系統_第1张图片
    1.2. 在網卡ifcfg-ens192中指定IP地址
    vi /etc/sysconfig/network-scripts/ifcfg-ens192
    ONBOOT=yes
    BOOTPROTO=none
    IPADDR=10.72.0.11
    GATEWAY=10.72.0.1
    DNS1=192.168.78.192
    DNS2=192.168.78.193
    PREFIX=24
    CentOS7安裝Cacti1.2.11運維監控系統_第2张图片
    1.3. 重啟網絡
    sudo service network restart
    CentOS7安裝Cacti1.2.11運維監控系統_第3张图片
    1.4. 安裝telnet
    yum -y install telnet-server.x86_64
    yum -y install telnet.x86_64
    yum -y install xinetd.x86_64
    CentOS7安裝Cacti1.2.11運維監控系統_第4张图片
    1.5. 設置開機啟動與配置防火墻
    systemctl enable xinetd.service
    systemctl enable telnet.socket
    systemctl start telnet.socket
    systemctl start xinetd
    firewall-cmd --permanent --add-port=23/tcp
    firewall-cmd --reload
    CentOS7安裝Cacti1.2.11運維監控系統_第5张图片
    1.6. 關閉防火墻、關閉SELINUX
    systemctl disable firewalld.service #禁止firewall开机启动
    vi /etc/selinux/config
    SELINUX=disabled

1.7. 安裝NTP,修改時間
sudo yum install ntp
systemctl enable ntpd
systemctl start ntpd
timedatectl set-timezone Asia/Shanghai
timedatectl set-ntp yes
ntpq -p
CentOS7安裝Cacti1.2.11運維監控系統_第6张图片
1.8. YUM源更新與重啟系統
1.8.1. yum -y install wget (nano, net-tools)
1.8.2. mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak
1.8.3. wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
1.8.4. yum makecache
二、下载PHP7.2,安装 Apache
2.1. 下載,安裝
yum -y install epel-release
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
CentOS7安裝Cacti1.2.11運維監控系統_第7张图片
yum install yum-utils -y
yum-config-manager --enable remi-php72
yum -y install httpd httpd-devel

2.2. 開啟自動啟動服務與檢查狀態
systemctl enable httpd
systemctl start httpd
systemctl status httpd

2.3. 配置修改,建立cacti.conf
cd /etc/httpd/conf.d/
nano cacti.conf
參考:
https://github.com/Cacti/documentation/blob/develop/Install-Under-CentOS_LAMP.md

![]

CentOS7安裝Cacti1.2.11運維監控系統_第8张图片
3.2.4. 重啟httpd服務
systemctl restart httpd
systemctl status httpd
三、安裝net-snmp工具
3.1. 安裝及服務啟動與檢查
yum -y install net-snmp net-snmp-utils net-snmp-libs net-snmp-devel 2 systemctl
CentOS7安裝Cacti1.2.11運維監控系統_第9张图片
systemctl enable snmpd
systemctl start snmpd
systemctl status snmpd
CentOS7安裝Cacti1.2.11運維監控系統_第10张图片
3.2. 配置修改snmpd.conf
vi /etc/snmp/snmpd.conf
CentOS7安裝Cacti1.2.11運維監控系統_第11张图片
view systemview included .1
access notConfigGroup "" any noauth exact all none none
CentOS7安裝Cacti1.2.11運維監控系統_第12张图片
3.3. 重啟服務與測試,有數據即可
systemctl restart snmpd
systemctl status snmpd
snmpwalk -v 2c -c public localhost
四、安裝MariaDB10.4
4.1. 進入安裝
cd /etc/yum.repos.d/
touch MariaSB.10x.repo
CentOS7安裝Cacti1.2.11運維監控系統_第13张图片

nano MariaSB.10x.repo
[mariadb]
name = MariaDB
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.4/centos7-amd64/
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
CentOS7安裝Cacti1.2.11運維監控系統_第14张图片
4.2. 清除yum緩存後重建
yum clean all
yum makecache
cd /
4.3. 安裝數據庫及服務啟動與檢查
yum -y install mariadb mariadb-server mariadb-devel MariaDB-client
systemctl enable mariadb
systemctl start mariadb
systemctl status mariadb
CentOS7安裝Cacti1.2.11運維監控系統_第15张图片
4.4. 初始化配置
mysql_secure_installation
4.5. 登入數據庫,允許所有用戶訪問
mysql -uroot -p
GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY 'cacti' WITH GRANT OPTION;
flush privileges;
CentOS7安裝Cacti1.2.11運維監控系統_第16张图片
4.6. 修改默認編碼server.cnf
4.6.1. 查看默認編碼
status;
4.6.2. 修改配置文件
nano /etc/my.cnf.d/server.cnf
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4

[mysqld]
character-set-client-handshake = true
character_set_client = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
max_heap_table_size = 128M
max_allowed_packet = 16777216
join_buffer_size = 128M
innodb_file_format = Barracuda
tmp_table_size = 64M
join_buffer_size = 128M
innodb_file_per_table = ON
innodb_buffer_pool_size = 1024M
innodb_doublewrite = off
innodb_lock_wait_timeout = 50
innodb_flush_log_at_trx_commit = 2
innodb_large_prefix = 1
log-error = /var/log/mysql/mysql-error.log
log-queries-not-using-indexes = 1
slow-query-log = 1
slow-query-log-file = /var/log/mysql/mysql-slow.log
innodb_doublewrite = ON
innodb_flush_method = O_DIRECT
innodb_flush_log_at_timeout = 3
innodb_read_io_threads = 32
innodb_write_io_threads = 16
innodb_buffer_pool_instances = 9
innodb_io_capacity = 5000
innodb_io_capacity_max = 10000

4.7. 重啟數據庫及查看
systemctl restart mariadb
systemctl status mariadb
mysql -uroot -p
status;
CentOS7安裝Cacti1.2.11運維監控系統_第17张图片
4.8. 修改數據庫時間
mysql -uroot -p mysqlmysql -uroot -p
grant select on mysql.time_zone_name to root@localhost;
flush privileges;
exit;
CentOS7安裝Cacti1.2.11運維監控系統_第18张图片
五、安裝cacti-1.2.11
5.1. 下載cacti-1.2.11,放入html目錄
下載放入home/power解壓到 html
tar -xvf cacti-1.2.11.tar.gz -C /var/www/html/
修改為cacti,及權限更改
chown apache:apache -R /var/www/html/cacti/
CentOS7安裝Cacti1.2.11運維監控系統
5.2. 創建cacti數據庫
mysql -uroot -p
create database if not exists cacti;
use cacti;
source /var/www/html/cacti/cacti.sql
flush privileges;
CentOS7安裝Cacti1.2.11運維監控系統_第19张图片
六、安裝rrdtool
6.1. 安裝依賴包
yum -y install gcc mysql-devel autautomake libtool dos2unix help2man open ssl-devel perl perl-devel rpm-develoconf libxml2-devel libxml2 pcre pcre-de vel pango pango-devel
yum -y install rrdtool
yum -y install perl-rrdtool
yum -y install perl-DB

CentOS7安裝Cacti1.2.11運維監控系統_第20张图片
6.2 版本檢查
rrdtool -v
七、安裝php模塊
7.1. 安裝
yum -y install php-gmp php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli php-intl php-snmp php-ldap
CentOS7安裝Cacti1.2.11運維監控系統_第21张图片
7.2. 配置php時區
nano /etc/php.ini
date.timezone = Asia/Shanghai
memory_limit = 2048M
max_execution_time = 60
CentOS7安裝Cacti1.2.11運維監控系統
八、Cacti文件與數據的設置
cd /var/www/html/cacti/include/
nano config.php
database    名稱和密碼設置
九、Spine 定時任務
1 分鐘
crontab -e
/1 * /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1
十、安裝spine1.2.11
10.1. 下載放入home/power後安裝
cd cacti-spine-1.2.11/
./bootstrap
CentOS7安裝Cacti1.2.11運維監控系統_第22张图片
./configure
make
make inst
權限配置
chown root:root /usr/local/spine/bin/spine

10.2. 初始化驗證及重啟
/usr/local/spine/bin/spine
CentOS7安裝Cacti1.2.11運維監控系統_第23张图片
十一、Web開啟 http://10.72.0.11/cacti/install
11.1. 開啟10.72.1.11,錯誤如下:
CentOS7安裝Cacti1.2.11運維監控系統_第24张图片
11.2. 安裝php模塊
yum install -y php php-common php-bcmath php-cli \
php-mysqlnd php-gd php-gmp php-intl \
php-json php-ldap php-mbstring \
php-pdo php-pear php-snmp php-process \
php-xml php-zip
11.3. 重啟服務
CentOS7安裝Cacti1.2.11運維監控系統_第25张图片
Cacti.log錯誤,創建日誌及權限分配(寫入權限)

touch /var/www/html/cacti/log/cacti.log
chmod -R 777 /var/www/html/cacti/log
chmod -R 777 /var/www/html/cacti/log/cacti.log

十二、正式安裝cacti1.2.11
12.1. 重新開啟 http://10.72.0.11/cacti/install

12.2. 更改密碼

12.3. 選擇主題與語言

12.4. 安裝向導檢查,須全部通過
CentOS7安裝Cacti1.2.11運維監控系統_第26张图片
12.5. 選擇 新的主要服務器
CentOS7安裝Cacti1.2.11運維監控系統_第27张图片
12.6. 目前權限檢查,須全部可寫
CentOS7安裝Cacti1.2.11運維監控系統_第28张图片
12.7. 可執行程序位置和版本
12.8. 修改週期與初步默認網絡設置
CentOS7安裝Cacti1.2.11運維監控系統_第29张图片
12.9. 默認模板設置,繼續下一頁
12.10. 下一頁,確認安裝
CentOS7安裝Cacti1.2.11運維監控系統_第30张图片
12.11. 完成安裝

12.12. 開始使用後進入界面
CentOS7安裝Cacti1.2.11運維監控系統_第31张图片
12.13. 更新模式更換為 spine

12.14. 新增管理設備,測試運行
CentOS7安裝Cacti1.2.11運維監控系統_第32张图片
12.15. 創建成功

CentOS7安裝Cacti1.2.11運維監控系統_第33张图片

可繼續新增管理設備,進行設備監測及網絡流量監控......
繼續學習
參考https://www.cacti.net

待更新
---Cacti1.2.11 系統之監控運維具體設置