close

[Centos]Install Cacti 1.2.23 o

Cacti 是一款免費的開源前端網路監控工具,用於監控和繪製 LAN 中各種 IT 資源的時間序列指標。它使用 RRDtool 以指定的時間間隔輪詢服務,然後在直觀的圖形上表示它們。

Cacti 監控各種指標,例如 CPU、記憶體和頻寬利用率、磁碟空間、文件系統和正在運行的進程等等。您可以監控伺服器、路由器、交換機甚至防火牆等設備。此外,您可以配置警報,以便在系統停機時,您可以通過電子郵件接收通知。本文,我們使用 CentOS 8 / RHEL 8 上安裝cacti監控工具的過程。
安裝測試時 Cacti 版本是 1.2.23 版本。

[Centos]Install Cacti 1.2.23 o

Linux 其他版本測試過目前僅有Centos系統為正常
測試使用Ubuntu 20以上版本可以安裝但是安裝所要使用的Weathermap插件會不定時的出現錯誤且圖片會破圖
最後還是跳回Centos後續裝完後才發現 Centos 有其他Linux可以替代例如AlmaLinux ,Rocky Linux  系統有興趣的人再測試看看吧!!
寫完後也有測試Centos 可以順利移轉至AlmaLinux ,Rocky Linux 系統也是相當簡單!!
以下為安裝過程可能會不盡相同,目前測試是可以正常運行且LOG部分還沒有出現錯誤!!

1.Install the LAMP Stack

環境準備安裝最新EPEL

sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

[CentOS 8] 無法使用: No URLs in mirrorlist error


2.安裝 Apache

sudo yum install -y httpd httpd-devel

 

[Centos]Install Cacti 1.2.23 o

 

Configuring Firewall for Cacti

sudo firewall-cmd --permanent --add-service=http

sudo firewall-cmd --permanent --add-service=https

sudo firewall-cmd --reload

sudo systemctl restart httpd

[Centos]Install Cacti 1.2.23 o

[Centos]Install Cacti 1.2.23 o

3.安裝 PHP 7.4

sudo dnf module list php

[Centos]Install Cacti 1.2.23 o

sudo dnf module reset php

sudo dnf module enable php:remi-7.4

[Centos]Install Cacti 1.2.23 o

sudo dnf install php php-opcache php-gd php-curl php-mysqlnd

[Centos]Install Cacti 1.2.23 o

php -v

[Centos]Install Cacti 1.2.23 o

sudo systemctl enable php-fpm

[Centos]Install Cacti 1.2.23 o

sudo systemctl start php-fpm

sudo systemctl status php-fpm

[Centos]Install Cacti 1.2.23 o

 

3.1安裝php擴展

sudo yum install -y php php-xml php-session php-sockets php-ldap php-gd php-json php-mysqlnd php-gmp php-mbstring php-posix php-snmp php-intl

[Centos]Install Cacti 1.2.23 o

 

3.2測試 PHP

sudo vim /var/www/html/info.php

新增以下資訊

<?php phpinfo( ); ?>

打開瀏覽器輸入 http://localhost/info.php 確認運作正常

[Centos]Install Cacti 1.2.23 o

3.3 設置php,設定時區

sudo vim /etc/php.ini

調整每個批次檔最大執行時間

max_execution_time = 60

[Centos]Install Cacti 1.2.23 o

更新暫存記憶體大小

memory_limit = 512M

[Centos]Install Cacti 1.2.23 o

設定時區

date.timezone = Asia/Taipei

[Centos]Install Cacti 1.2.23 o

 

4.安裝Snmp RRDToolRRDToolCacti數據輪詢工具

sudo yum install -y net-snmp net-snmp-utils net-snmp-libs net-snmp-devel net-snmp-perl rrdtool git

[Centos]Install Cacti 1.2.23 o

Config Snmp.conf

sudo vim /etc/snmp/snmpd.conf

[Centos]Install Cacti 1.2.23 o

//修改default爲本機(cacti服務器)的ip,修改public爲自己的團體名(一般不改),42 com2sec notConfigUser 192.168.2.186 public

[Centos]Install Cacti 1.2.23 o

//systemview改成all ,供所有snmp 訪問權限  64

[Centos]Install Cacti 1.2.23 o

 

[Centos]Install Cacti 1.2.23 o

access notConfigGroup "" any noauth exact all none none

[Centos]Install Cacti 1.2.23 o

view all included .1 80 // 去掉# 85

[Centos]Install Cacti 1.2.23 o

5.安裝MariaDB資料庫

sudo yum install -y mariadb-server mariadb mariadb-devel

[Centos]Install Cacti 1.2.23 o

5.1_初始化資料庫

設定MariaDB,初始化資料庫,設定密碼,

除了開始直接Enter,其他的選擇都輸入Y

sudo systemctl restart mariadb

sudo mysql_secure_installation

[Centos]Install Cacti 1.2.23 o

Enter current password for root (enter for none): Enter

Set root password? [Y/n]: Y //輸入root管理員密碼

New password: (password)

Re-enter new password: (password)

Password updated successfully!

Remove anonymous users? [Y/n]: Y //刪除匿名賬號

Disallow root login remotely? [Y/n]: Y /禁止root管理員從遠程登錄

Remove test database and access to it? [Y/n]: Y //刪除test資料庫及讀取權限

Reload privilege tables now? [Y/n]: Y //更新設定立即生效

 

5.2_資料庫參數設定Configure MariaDB

sudo vim /etc/my.cnf.d/mariadb-server.cnf

[mysqld]部分增加以下設定:

collation-server=utf8mb4_unicode_ci

character-set-server=utf8mb4

innodb_file_format=Barracuda

innodb_large_prefix=1

innodb_doublewrite=OFF

max_heap_table_size=256M

tmp_table_size=256M

join_buffer_size=20M

sort_buffer_size=2M

innodb_buffer_pool_size=4096M

innodb_flush_log_at_timeout=3

innodb_read_io_threads=32

innodb_write_io_threads=16

innodb_io_capacity=5000

innodb_io_capacity_max=10000

innodb_buffer_pool_instances=9

[Centos]Install Cacti 1.2.23 o

5.3_ MariaDB  時區設定檔

cacti 資料庫用戶設置 MariaDB 時區表。

sudo mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

[Centos]Install Cacti 1.2.23 o

sudo systemctl restart mariadb

sudo mysql -u root -p

select timediff(now(),convert_tz(now(),@@session.time_zone,'+00:00'));

SELECT @@GLOBAL.time_zone, @@SESSION.time_zone;

SHOW GLOBAL VARIABLES LIKE '%time_zone';

show databases;

select @@tmp_table_size;

show variables like 'join_buffer_size';

[Centos]Install Cacti 1.2.23 o

 

6.開啟相關服務

sudo systemctl start httpd snmpd mariadb php-fpm

sudo systemctl restart httpd snmpd mariadb php-fpm

sudo systemctl enable httpd snmpd mariadb php-fpm

[Centos]Install Cacti 1.2.23 o

sudo systemctl status httpd

[Centos]Install Cacti 1.2.23 o

sudo systemctl status mariadb

[Centos]Install Cacti 1.2.23 o

 

sudo systemctl status snmpd

[Centos]Install Cacti 1.2.23 o

sudo systemctl status php-fpm

[Centos]Install Cacti 1.2.23 o

驗證snmp是否有數據

netstat -alun | grep 161

[Centos]Install Cacti 1.2.23 o

snmpwalk -v 2c -c public localhost

[Centos]Install Cacti 1.2.23 o

7. Download and cacti configure

ll /var/www/html/

sudo rm -r /var/www/html/*.*

git clone -b 1.2.x https://github.com/Cacti/cacti.git

cd cacti

sudo mv * /var/www/html/

ll /var/www/html/

[Centos]Install Cacti 1.2.23 o

7.1創建cacti數據庫,創建數據庫用戶cactiuser,設定相關授權

sudo mysql -u root -p

[Centos]Install Cacti 1.2.23 o

CREATE DATABASE cacti DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;

GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost' IDENTIFIED BY 'cactiuser';

GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost;

ALTER DATABASE cacti CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

FLUSH PRIVILEGES;

[Centos]Install Cacti 1.2.23 o

 

7.2導入Cacti 預設資料庫

use cacti

source /var/www/html/cacti.sql;

flush privileges;

exit

[Centos]Install Cacti 1.2.23 o

[Centos]Install Cacti 1.2.23 o

 

7.3 設定cacti config

sudo cp /var/www/html/include/config.php.dist /var/www/html/include/config.php

[Centos]Install Cacti 1.2.23 o

 

sudo vim /var/www/html/include/config.php

[Centos]Install Cacti 1.2.23 o

7.4 設定cacti 資料夾權限

sudo touch /var/www/html/log/cacti.log

sudo touch /var/www/html/log/cacti_stderr.log

sudo chown apache:apache /var/www/html/ -R

sudo chown cacti:cacti /var/www/html/{rra,log}/ -R

sudo chmod 777 /var/www/html/{rra,log}/ -R

[Centos]Install Cacti 1.2.23 o

7.5 重啟相關服務sudo systemctl restart httpd snmpd mariadb php-fpm

 

 

 

 

8.Add alias path to apache

sudo vim /etc/httpd/conf.d/cacti.conf

 

Alias /cacti    /var/www/html

 

<Directory /var/www/html/>

        <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 192.168.0.12/24

        </IfModule>

</Directory>

9.Setup crontab poller

方法有三種目前我使用9.1-9.2建立只需要使用一組設定就可以

onfigure a cron job to run poller.php script in every 5 minutes. This script will collect and update the system metrics in /rra directory.

echo "*/5 * * * *    apache   /usr/bin/php /var/www/html/poller.php > /dev/null 2>&1" | sudo tee /etc/crontab[Centos]Install Cacti 1.2.23 o

 

sudo tail -f /var/log/cron

[Centos]Install Cacti 1.2.23 o

sudo cat /var/log/cron

[Centos]Install Cacti 1.2.23 o

sudo systemctl enable crond

sudo systemctl status crond

[Centos]Install Cacti 1.2.23 o

9.2 使用crontab命令添加任務

# crontab -e

我這裏配置成每1分鐘運行一次

*/1 * * * * /usr/bin/php /var/www/html/poller.php > /dev/null 2>&1

sudo /usr/bin/php /var/www/html/poller.php

crontab -l

ll /etc/cron.d/

9.3

Set up the poller to collect data every 5 minutes. Create file cactipoller in

echo "*/1 * * * *apache /usr/bin/php /var/www/html/poller.php > /dev/null 2>&1" | sudo tee /etc/cron.d/cactipoller

添加好crontab計劃任務後,驗證下crond服務是否已經啓動,並設置開機自動啓動

 

10. install Cacti

[Centos]Install Cacti 1.2.23 o

[Centos]Install Cacti 1.2.23 o

[Centos]Install Cacti 1.2.23 o

[Centos]Install Cacti 1.2.23 o

[Centos]Install Cacti 1.2.23 o

[Centos]Install Cacti 1.2.23 o

[Centos]Install Cacti 1.2.23 o

[Centos]Install Cacti 1.2.23 o

[Centos]Install Cacti 1.2.23 o

[Centos]Install Cacti 1.2.23 o

[Centos]Install Cacti 1.2.23 o

[Centos]Install Cacti 1.2.23 o

[Centos]Install Cacti 1.2.23 o

[Centos]Install Cacti 1.2.23 o

[Centos]Install Cacti 1.2.23 o

[Centos]Install Cacti 1.2.23 o

[Centos]Install Cacti 1.2.23 o

 

Cacti_SSL 設定

Cacti – Cacti-SSL-Configuration (campus-rv.net)
Cacti: docs/Cacti-SSL-Configuration.html | Fossies
好記憶不如爛筆頭: [Nginx] NGINX 設定 HTTPS 網頁加密連線,建立自行簽署的 SSL 憑證 (javawu.idv.tw)
Install Let’s Encrypt SSL Certificate for Nginx on RHEL 9/8 (tecmint.com)
使用 2048 個位元的 RSA 金鑰來建立 SSL 憑證簽署要求 - IBM 說明文件
Apache 2.x 生成CSR – 憑證安裝支援 – GlobalSign (cloudmax.com.tw)
Create an SSL Certificate (Apache) (asperasoft.com)

LAMP完整版請參考CACTI官網設定

Cacti® - The Complete RRDTool-based Graphing Solution

參考文章 Cacti install

CentOS 7安裝Cacti 1.2.3 - 台部落 (twblogs.net)
如何在CentOS 8/RHEL 8上安装Cacti | 一览网事 (eflytop.com)
How to install Cacti Server on CentOS 8 | CentLinux
How To Install Cacti On CentOS 8 / RHEL 8 | ITzGeek
How To Install Cacti Network Monitoring on CentOS 8 - idroot
How To Install Cacti on RHEL 8 / CentOS 8 | ComputingForGeeks
How to Install Cacti Monitoring Tool on CentOS 8 / RHEL 8 (linuxtechi.com)
cacti-1.1.38 on centos 7 x86_86 with nginx - Cacti
Install Cacti 1.1.8 in NanoPi - M1 | Jackden's Blog (jackden-diary.blogspot.com)
Install Cacti (Network Monitoring) on RHEL/CentOS 8/7 and Fedora 30 (tecmint.com)
如何在CentOS 8上安裝Cacti Monitoring Server - 0x資訊 (0xzx.com)
DAY23-cacti安裝 - iT 邦幫忙::一起幫忙解決難題,拯救 IT 人的一天 (ithome.com.tw)
StartDoIT: How to Install Cacti on CentOS 8 (startdoits.blogspot.com)
CentOS 7 安裝 Cacti Server – Ken Wu (wordpress.com)
Cacti Server – 新增監控設備 – Ken Wu (wordpress.com)
Cacti Server – Client 端設定 – Ken Wu (wordpress.com)
20090516-Mars-RRDTool+Cacti Setup and Configuration (tp.edu.tw)
How to Install a LAMP Stack on CentOS 8 | Linode
How To Install Linux, Apache, MySQL, PHP (LAMP) stack On CentOS 6 | DigitalOcean
Centos 6/7 LAMP server setup · GitHub
documentation/Install-Under-CentOS_LAMP.md at develop · Cacti/documentation · GitHub
How to Install Cacti 1.1 on CentOS 7 - Vultr.com
How to Install Cacti latest version on CentOS 8/7 - YouTube
投影片 1 (tp1rc.edu.tw)
輕鬆做好流量管理—Cacti(上) | 網管人 (netadmin.com.tw)

Apache Config
鳥哥的 Linux 私房菜 -- WWW 伺服器 Apache (vbird.org)
Day 15: Apache簡單設定 - iT 邦幫忙::一起幫忙解決難題,拯救 IT 人的一天 (ithome.com.tw)
邁向 RHCE 之路 (Day26) - Apache 網頁伺服器 - iT 邦幫忙::一起幫忙解決難題,拯救 IT 人的一天 (ithome.com.tw)
Apache HTTP Server 安裝與配置 - IBM 說明文件
How to configure Apache 2 (ntu.edu.sg)
apache 2.2 - You don't have permission to access /cacti/index.php on this server - Server Fault
Apache Redirect - Cacti
Apache HTTP Server - ArchWiki (archlinux.org)
Access authorization in Apache 2.4 < System | The Art of Web (the-art-of-web.com)
What does Apache's "Require all granted" really do? - Server Fault
存取限制 (cyut.edu.tw)
locking down Apache to localhost - Stack Overflow
Access Control - Apache HTTP Server Version 2.4
core - Apache HTTP Server Version 2.4
[Apache] Apache 從 2.2 換至 2.4 httpd.conf 的調整筆記 (windows 環境) | 楓葉筆記本 - 點部落 (dotblogs.com.tw)
Configuring the Apache Error and Access Logs | Linuxize
APACHE的記錄檔格式 LogFormat 語法 @新精讚 (sfs.tw)
Apache Logging Basics - The Ultimate Guide To Logging (loggly.com)
Log Files - Apache HTTP Server Version 2.4
mod_log_config - Apache HTTP Server Version 2.4
"Forbidden - You don't have permission to access / on this server" Error (tecmint.com)
Getting started with Apache HTTP Server :: Fedora Docs (fedoraproject.org)
Apache HTTP Server - ArchWiki (archlinux.org)

Crontab log 設定查看
如何查看crontab的日誌記錄 - 台部落 (twblogs.net)
把 crontab 執行指令輸出寫入記錄檔 - Linux 技術手札 (ltsplus.com)
crontab 開機自動執行指令 - Linux 技術手札 (ltsplus.com)
Linux 設定 crontab 工作排程 log 記錄檔教學與範例 - Office 指南 (officeguide.cc)

Cacti Setup Error 資料
Cacti install problem on Directory Permission Checks - Cacti
[HOWTO] - Configure, and Tune SELinux and Contexts - Cacti
[Solved] "The cacti poller has not run yet" - Cacti
New user of cacti and error 404 - Cacti


cacti selinux config
HOWTO Centos 7 Install - Cacti
深綠色的私人世界: cacti with SELinux (otaku119.blogspot.com)
Enabling SELinux on the RTM Web Server (for RHEL/Ubuntu installations) - IBM Documentation
[HOWTO] - Configure, and Tune SELinux and Contexts - Cacti
SELinux and problems with Cacti... - Cacti
installation: /usr/share/log Not writable - Cacti
cacti 1.1.3, nginx with php-fpm on centos 7 - Cacti
Cacti - Boost selinux settings | Routerjanitor
Cacti® - The Complete RRDTool-based Graphing Solution
StartDoIT: How to Install Cacti on CentOS 8 (startdoits.blogspot.com)





 

 


arrow
arrow

    sungshu 發表在 痞客邦 留言(0) 人氣()