您好,登錄后才能下訂單哦!
環(huán)境:
CentOS-6.8-x8664-minimal
cacti-0.8.8h.tar.gz
cacti系統(tǒng)安全性存在一定的問題,強烈建議部署在內(nèi)網(wǎng)環(huán)境中!
先更新系統(tǒng)
yum -y install wget vim-enhanced
mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/{.repo,backup}
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.163.com/.help/CentOS6-Base-163.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum clean all
yum makecache
yum -y update
1.安裝LAMP
安裝MySQLyum install -y mysql-server mysql-client mysql-devel
安裝httpd服務(wù)yum -y install httpd
安裝php服務(wù)yum -y install php php-mysql
檢查以上軟件是否安裝成功(應(yīng)該是10個)
rpm -qa |egrep 'php|httpd|mysql'
mysql-5.1.73-7.el6.x8664
php-common-5.3.3-48.el68.x8664
php-pdo-5.3.3-48.el68.x8664
php-5.3.3-48.el68.x8664
mysql-libs-5.1.73-7.el6.x8664
mysql-server-5.1.73-7.el6.x8664
httpd-tools-2.2.15-54.el6.centos.x8664
httpd-2.2.15-54.el6.centos.x8664
php-cli-5.3.3-48.el68.x8664
php-mysql-5.3.3-48.el68.x8664
安裝需要的庫文件yum -y install zlib freetype libjpeg fontconfig gd libxml2 zlib freetype libjpeg fontconfig gd libxml2 php-gd gcc net-snmp-devel mysql-devel dos2unix autoconf
2.安裝rrd工具yum -y install rrdtool rrdtool-devel
3.安裝并配置監(jiān)控需要的snmp工具yum -y install net-snmp net-snmp-devel net-snmp-utils
配置snmp(監(jiān)控本機,可作為安裝后的出圖驗證)
vim /etc/snmp/snmpd.conf
將com2sec notConfigUser default public
改為:com2sec notConfigUser 127.0.0.1 public
將access notConfigGroup "" any noauth exact systemview none none
改為:access notConfigGroup "" any noauth exact all none none
將view all included .1 80 去掉注釋符
4.啟動服務(wù)并加如開機啟動
service httpd start
service mysqld start
service snmpd start
chkconfig httpd on
chkconfig mysqld on
chkconfig snmpd on
5.安裝cacti
wget https://www.cacti.net/downloads/cacti-0.8.8h.tar.gz
tar zxf cacti-0.8.8h.tar.gz -C /var/www/html/
cd /var/www/html/
mv cacti-0.8.8h/ /var/www/html/cacti
6.初始化數(shù)據(jù)庫
mysql -u root
create database cacti;
grant all on cacti. to cacti@localhost identified by 'admin@123';
grant all on cacti. to cacti@'127.0.0.1' identified by 'admin@123';
flush privileges;
use cacti;
source /var/www/html/cacti/cacti.sql;
quit
7.設(shè)置php.ini的時區(qū)(否則不出圖)
vim /etc/php.ini
date.timezone = Asia/Shanghai
8.配置cacti
vim /var/www/html/cacti/include/config.php
$databasetype = "mysql";
$databasedefault = "cacti";
$databasehostname = "localhost";
$databaseusername = "cacti";
$databasepassword = "admin@123";
$databaseport = "3306";
9.設(shè)置相關(guān)權(quán)限和計劃任務(wù).
useradd cacti -d /var/www/html/cacti -s /sbin/nologin
chown -R cacti /var/www/html/cacti/rra /var/www/html/cacti/log
echo '/5 root /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1' >> /etc/crontab
10.安裝spine輪詢插件
下載-->解壓-->進入目錄-->安裝
wget https://www.cacti.net/downloads/spine/cacti-spine-0.8.8h.tar.gz
tar zxcf cacti-spine-0.8.8h.tar.gz
cd cacti-spine-0.8.8h.tar.gz
./configure
make&&make install
cp /usr/local/spine/etc/spine.conf.dist /etc/spine.conf
spine -v
vim /etc/spine.conf
DBHost localhost
DBDatabase cacti
DBUser cacti
DBPass admin@123
DBPort 3306
測試/usr/local/spine/bin/spine
接下來配置cacti圖形工具(默認安裝在/usr/local/spine/sbin/spine,已鏈接到/sbin/spine中):
Console -> Configureation -> Settings -> Alternate Poller Path -> Spine Poller File Path
Console -> Cacti Settings -> Poller -> Poller Type
然后修改計劃任務(wù),由原來的5分鐘執(zhí)行一次,修改為每分鐘執(zhí)行一次/5 php /opt/cacti/cacti/poller.php > /dev/null 2>&1
改為/1 php /opt/cacti/cacti/poller.php > /dev/null 2>&1
11.重啟全部服務(wù)
service httpd restart
service mysqld restart
service snmpd restart
13.完成安裝
http://localhost/cacti
用戶名為admin,密碼默認為admin,密碼首次登錄要求修改。
排障
1、不出圖:/var/www/html/cacti
目錄賦權(quán)777,等5分鐘輪詢。
2、還不出圖:
mysql
use cacti;
select count(*) from polleroutput;
truncate table polleroutput;
select count(*) from polleroutput;
最后重建緩存。
3、改中文支持
--將rrdtool版本號改為1.2.x;
--將字體文件MSYH.ttf復制進/usr/share/fonts/下,并授權(quán)777;
--cacti頁面中,將default font path改為/usr/share/fonts/MSYH.ttf;
--修改vim /var/www/html/cacti/lib/functions.php,倒數(shù)第2行添加:
setlocale(LCCTYPE,"zhCN.UTF-8");
--重啟httpd服務(wù)。
附:
比如說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 443 -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
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。