安裝Cacti1.1.38(親測可用)

1.軟件安裝?
1.1?更新系統(tǒng)?
yum -y install wget vim-enhancedmkdir /etc/yum.repos.d/backupmv /etc/yum.repos.d/{*.repo,backup}wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.163.com/.help/CentOS7-Base-163.repowget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.reporm -rf /var/cache/yumrm -rf /var/cache/manyum makecacheyum update1.2?安裝?Cacti?部署環(huán)境所需軟件包?
1.2.1?添加?MariaDB YUM?倉庫,執(zhí)行以下腳本?
echo '# MariaDB 10.2 CentOS repository list - created 2017-07-03 06:59 UTC # [mariadb]name = MariaDBbaseurl = https://ipv4.mirrors.ustc.edu.cn/mariadb/yum/10.2/centos7-amd64gpgkey=https://ipv4.mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDBgpgcheck=1'>/etc/yum.repos.d/Mariadb.repo1.2.2?安裝軟件環(huán)境?
yum install -y httpd mariadb mariadb-server mariadb-devel net-snmp net-snmp-utils net-snmp-libs net-snmp-agent-libs net-snmp-devel php php-snmp php-ldap php-pdo php-mysql php-devel php-pear php-common php-gd php-mbstring php-xml php-process rrdtool rrdtool-php rrdtool-perl rrdtool-devel gcc openssl-devel dos2unix autoconf automake binutils libtool cpp postfix glibc-headers kernel-headers glibc-devel gd gd-devel help2man ntpdate wget patch2.環(huán)境配置?
2.1?配置?PHP?
修改?PHP?主配置文件?/etc/php.ini?
關(guān)閉安全模式,以支持?rrdtool,允許?exec()?訪問?
[PHP]safe_mode = Off設(shè)置時區(qū)?
[Date]date.timezone = Asia/Shanghai2.2?配置?Web?服務(wù)器?Apache httpd?
編輯?/etc/httpd/conf.d/php.conf?配置文件,確保文件含有?
# PHP is an HTML-embedded scripting language which attempts to make it# easy for developers to write dynamically generated webpages.LoadModule php5_module modules/libphp5.so## Cause the PHP interpreter to handle files with a .php extension.AddHandler php5-script .php2.3?配置數(shù)據(jù)庫?MariaDB?
為安全起見,設(shè)置數(shù)據(jù)庫?root?用戶密碼?
systemctl start mariadbmysqladmin -uroot password xxx123導(dǎo)入時區(qū)數(shù)據(jù)到?mysql?數(shù)據(jù)庫?
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -uroot mysql -p修改?/etc/my.cnf.d/server.cnf?文件,確保文件含有?
[mysqld]character_set_server = utf8mb4collation_server = utf8mb4_unicode_cicharacter_set_client = utf8mb4max_connections = 100max_heap_table_size = 4096Mmax_allowed_packet = 16777216join_buffer_size = 64Mtmp_table_size = 64Minnodb_file_per_table = ONinnodb_buffer_pool_size = 25600Minnodb_doublewrite = OFFinnodb_lock_wait_timeout = 50innodb_flush_log_at_timeout = 3innodb_read_io_threads = 32innodb_write_io_threads = 162.4?配置?SNMP?
配置?net-snmp-agent,?修改配置文件?/etc/snmp/snmpd.conf?
將41行?
com2sec notConfigUser ?default ??????public?
改為?
com2sec notConfigUser ?127.0.0.1 ????public?
將62行?
access ?notConfigGroup "" ?????any ??????noauth ???exact ?systemview none none?
改為?
access ?notConfigGroup "" ?????any ??????noauth ???exact ?all ???none ??none?
將85行?
#view all ???included ?.1 ??????????????????????????????80?
改為?
view all ???included ?.1 ??????????????????????????????80?
3.安裝配置?Cacti?
3.1?下載解壓?Cacti?安裝包?
useradd -r -M cacticd /var/www/html/wget https://github.com/Cacti/cacti/archive/release/1.1.38.tar.gztar -zxvf 1.1.38.tar.gzcp -R cacti-release-1.1.38/ /var/www/html/cacticd /var/www/html/cacti3.2?創(chuàng)建?cacti?數(shù)據(jù)庫,創(chuàng)建?cactiuser?用戶,設(shè)置相關(guān)授權(quán)?
mysql -u root -pCREATE database cacti default character set utf8;create user 'cacti'@'localhost' identified by 'xxx3';grant all privileges on cacti.* to cacti@localhost;grant select on mysql.time_zone_name to 'cacti'@'localhost' identified by 'xxx3';flush privileges;3.3?導(dǎo)入?Cacti?默認數(shù)據(jù)庫?
use cacti;source /var/www/html/cacti/cacti.sql;flush privileges;quit3.4?編輯?/var/www/html/cacti/include/config.php?
$database_type = "mysql";$database_default = "cacti";$database_hostname = "localhost";$database_username = "cacti";$database_password = "xxx3"/* load up old style plugins here */$plugins = array();//$plugins[] = 'thold';3.5?創(chuàng)建?cacti?系統(tǒng)用戶,設(shè)置?graph/log?目錄權(quán)限?
chown -R apache.apache /var/www/html/chown -R cacti ?/var/www/html/chown -R apache.apache /var/www/html/cacti/chown -R cacti /var/www/html/cacti/{rra,log}/chmod -R 777 /var/www/html/cacti/{rra,log}/3.6?添加定時任務(wù)?
crontab -e*/1 * * * * /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&14.配置防火墻?
4.1?配置?firewalld?防火墻?
firewall-cmd --permanent --add-port=3306/tcpfirewall-cmd --permanent --add-service=httpfirewall-cmd --permanent --add-port=161/udpfirewall-cmd ?--permanent --add-port=162/udpfirewall-cmd --reload4.2?關(guān)閉selinux?
setenforce 0sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config5.安裝?spine?
5.1?下載解壓與?Cacti?相同版本號?Spine?源碼安裝包?
cd /usr/local/srcwget http://www.cacti.net/downloads/spine/cacti-spine-1.1.38.tar.gztar xf cacti-spine-1.1.38.tar.gz5.2?源碼編譯安裝?spine?
ln -s /usr/lib64/libmysqlclient.so.18.0.0 /usr/lib64/libmysqlclient.sontpdate ntp.sjtu.edu.cncd cacti-spine-1.1.38./configure && make && make install5.3?復(fù)制修改配置文件?
cp /usr/local/spine/etc/spine.conf.dist /etc/spine.confvim /etc/spine.confDB_Host ????????????????localhostDB_Database ????????????cactiDB_User ????????????????cactiDB_Pass ????????????????xxx3DB_Port ????????????????3306RDB_Host ???????????????localhostRDB_Database ???????????cactiRDB_User ???????????????cactiRDB_Pass ???????????????xxx3RDB_Port ???????????????33065.4?測試?
/usr/local/spine/bin/spine?將會出現(xiàn)以下結(jié)果?
SPINE: Using spine config file [/etc/spine.conf]?
SPINE: Version 1.1.38 starting?
SPINE: Time: 0.0429 s, Threads: 5, Devices: 0?
6.設(shè)置重啟、開機啟動相關(guān)服務(wù)?
systemctl restart httpdsystemctl restart mariadbsystemctl restart crondsystemctl restart snmpdsystemctl enable httpdsystemctl enable mariadbsystemctl enable crondsystemctl enable snmpd7.登錄?Cacti WEB?頁面修改?Cacti?配置?
Console ->?設(shè)置(Cacti Settings)?-> Paths ->?在?Spine Binary File Location?文本框內(nèi)填入配置文件路徑?/usr/local/spine/bin/spine?,在?Spine Config File Path?框內(nèi)填入配置文件路徑?/usr/local/spine/etc/spine.conf,點擊保存 (Save)。?
Console ->?設(shè)置(Cacti Settings)?-> Poller ->?在?Poller Type?下拉框中選擇?spine?,點擊保存 (Save)。?
8.特別提示?
在添加完設(shè)備和圖形后,需要重建采集器緩存。?
Console –>?系統(tǒng)工具?–> Rebuild Poller Cache?
附:?
比如說cacti平臺要求更改默認端口號(例改為10010),且做白名單限制(例只允許IP地址123.123.123.123登錄),相關(guān)設(shè)置如下?
1、改端口號?
vim /etc/httpd/conf/httpd.conf?
在第137行下修改Listen:80為Listen:10010,保存退出。?
2、防火墻放行10010端口號?
vim /etc/sysconfig/iptables?
添加防火墻規(guī)則?
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10010 -j ACCEPT?
重啟防火墻服務(wù)?
service iptables restart?
3、做白名單訪問限制?
vim /etc/httpd/conf/httpd.conf?
在第318行下,?<Directory "/var/www/html">內(nèi)添加如下內(nèi)容并保存退出?
Order allow,deny?
Allow from 123.123.123.123?
重啟httpd服務(wù)?
service httpd restart?
了解更多網(wǎng)絡(luò)知識關(guān)注:http://www.vecloud.com/