標籤:
一、安裝配置LAMP環境
yum -y install httpd php php-mysql php-snmp php-xml php-gd mysql mysql-server
啟動http和mysql
service httpd startservice mysqld start
執行mysql安全設定,根據提示設定root密碼
mysql_secure_installation
二、安裝RRDTool和net-snmp
1、RRDTool主要用於繪圖
yum -y install rrdtool
2、net-snmp主要用於收集並傳送伺服器的統計資訊
yum -y install net-snmp net-snmp-libs net-snmp-utils
3、配置net-snmp
vim /etc/snmp/snmpd.conf
將55行的view systemview included .1.3.6.1.2.1.1改為view systemview included .1.3.6.1.2.1
4、啟動net-snmp
service snmpd start
5、測試net-snmp
snmpwalk -v 1 -c public localhost .1.3.6.1.2.1.1.1.0
如果顯示類似:SNMPv2-MIB::sysDescr.0 = STRING: Linux guest.guest 2.6.32-573.8.1.el6.x86_64 #1 SMP Tue Nov 10 18:01:38 UTC 2015 x86_64,說明net-snmp工作正常。
三、下載安裝cacti
1、下載cacti,並放到html目錄下
wget http://www.cacti.net/downloads/cacti-0.8.8f.tar.gztar zxf cacti-0.8.8f.tar.gzmv cacti-0.8.8f /var/www/html/cacti
2、在mysql中添加cacti資料庫,並匯入模板資料庫
cd /var/www/html/cacti/mysqladmin --user=root -p create cactimysql -uroot -p cacti < cacti.sql
3、在mysql中建立cacti使用者,使用者名稱為cactiuser,密碼暫訂為123
mysql -u root -p GRANT ALL ON cacti.* TO [email protected] IDENTIFIED BY ‘123‘;flush privileges;
quit
4、在Linux系統中添加cacti使用者
useradd cactiuserchown -R cactiuser rra/ log/
5、配置include/config.php
$database_type = "mysql";$database_default = "cacti";$database_hostname = "localhost";$database_username = "cactiuser";$database_password = "123";$database_port = "3306";$database_ssl = false;
6、添加計劃任務
echo "*/5 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1">>/etc/crontabservice crond restart
四、初始化安裝cacti
瀏覽器中輸入:http://www.yourdomain.com/cacti
一路下一步,預設初始使用者名稱和密碼都是:admin
五、配置開機啟動
chkconfig --level 35 snmpd onchkconfig --level 35 httpd onchkconfig --level 35 mysqld onchkconfig --level 35 crond on
六、加入一個新的Linux被監控主機(CentOS)
目標機器上安裝net-snmp即可
yum install -y net-snmp net-snmp-perl net-snmp-devel net-snmp-utils net-snmp-libs
啟動net-snmp(預設199號連接埠)
service snmpd start
在網路頁面左側,選擇Devices——add,填寫hostname(ip或網域名稱),並將SNMP Version改為2
CentOS 6.7安裝配置Cacti監控系統