Cacti的安裝配置
Cacti的安裝配置
1.使用如下命令來(lái)安裝cacti,這個(gè)會(huì)自動(dòng)安裝需要的組件。
- [root@tigertall php.d]# yum install cacti
2.創(chuàng)建mysql數(shù)據(jù)庫(kù)
- [root@tigertall php.d]# mysqladmin -uroot -phandomse create cacti
3.導(dǎo)入默認(rèn)的cacti數(shù)據(jù)庫(kù)
如果使用yum默認(rèn)安裝,創(chuàng)建數(shù)據(jù)庫(kù)的腳本
默認(rèn)在/usr/share/doc/cacti-0.8.7f/cacti.sql
- [root@tigertall php.d]# cd /usr/share/doc/cacti-0.8.7f/
執(zhí)行創(chuàng)建數(shù)據(jù)庫(kù)的命令
- [root@tigertall 0.8.7.f]# mysql -uroot -phandomse cacti < cacti.sql
4.創(chuàng)建cacti數(shù)據(jù)庫(kù)的用戶和密碼,
登錄到數(shù)據(jù)庫(kù)
- [root@tigertall 0.8.7.f]# mysql -u root -p 'pass'
用戶授權(quán),請(qǐng)把用戶名,數(shù)據(jù)庫(kù)和密碼換成自己需要的設(shè)置。
- mysql> GRANT ALL ON cacti.* TO cactiuser@localhost
- --> IDENTIFIED BY 'password';
刷新權(quán)限
- mysql> flush privileges;
5.編輯cacti配置,做數(shù)據(jù)連接設(shè)置
- [root@tigertall include]# vi /usr/share/cacti/include/config.php
這里有cacti連接使用的數(shù)據(jù)庫(kù)類型,用戶名,密碼信息
- /* make sure these values refect \*/
- /* your actual database/host/user/password */
- $database_type = "mysql";
- $database_default = "cacti";
- $database_hostname = "localhost";
- $database_username = "cactiuser";
- $database_password = "cactiuser";
- $database_port = "3306";
- /* Default session name - Session name must */
- /* contain alpha characters */
- #$cacti_session_name = "Cacti";
把上述配置按照自己的需要設(shè)置
6.目錄權(quán)限設(shè)置
- [root@tigertall include]# cd /usr/share/cacti/
- [root@tigertall cacti]# ll rra
- lrwxrwxrwx 1 root root 18 Jul 17 15:07 rra -> /var/lib/cacti/rra
- [root@tigertall cacti]# ll log
- lrwxrwxrwx 1 root root 15 Jul 17 15:07 log -> /var/log/cacti/
從上述可以看到,rra實(shí)際上是var/lib/cacti/rra的一個(gè)軟鏈接,
log則是/var/log/cacti的一個(gè)軟鏈接。
更改上述目錄的權(quán)限,按需要更改屬主,下面生成數(shù)據(jù)會(huì)用到這個(gè)用戶。
- [root@tigertall cacti]# chown -R gaohu rra/ log/
7.配置自動(dòng)作業(yè)時(shí)間
編輯crontab。
- [root@tigertall log]# crontab -e
增加如下內(nèi)容,
- */5 * * * * php /usr/share/cacti/poller.php > /dev/null 2>&1
注意:
這個(gè)地方不能按照官方文檔來(lái),不能加上執(zhí)行的用戶名,
crontab根本沒(méi)有執(zhí)行用戶這個(gè)參數(shù)的,官方文檔是這樣的:
- */5 * * * * gaohu php /usr/share/cacti/poller.php > /dev/null 2>&1
按照這個(gè)設(shè)置,會(huì)報(bào)錯(cuò)的:
- 07/17/2010 10:59:57 PM - POLLER: Poller[0] WARNING:
- Cron is out of sync with the Poller Interval!
- The Poller Interval is '300' seconds,
- with a maximum of a '300' second Cron,
- but 419 seconds have
- passed since the last poll!
會(huì)告警說(shuō)設(shè)置的是300秒,結(jié)果400多秒了還沒(méi)有執(zhí)行過(guò)。Cacti下如果磁盤(pán)監(jiān)控不到、如果圖出不來(lái)、網(wǎng)卡流量達(dá)到100M以上圖像有問(wèn)題如果碰到這一系列的問(wèn)題該怎么辦?本文講述的是Cacti下的問(wèn)題的解決技巧。
以上內(nèi)容意思是,每隔五分鐘,執(zhí)行下php腳本,統(tǒng)計(jì)下數(shù)據(jù)。
一個(gè)由此引發(fā)的問(wèn)題見(jiàn)***。
8.登錄服務(wù)器
初始登錄時(shí),用戶名和密碼為admin,登錄后,會(huì)要求立即切換密碼。
【編輯推薦】