天天看點

Cacti在Solaris10下的安裝

=====================================================================================================================

Solaris下MySQL的安裝:

1.Solaris下的MySQL目錄:

/usr/sfw/sbin:守護程序mysqld,mysqld_safe

/usr/sfw/bin:管理工具mysqladmin,mysqlcheck等

/usr/sfw/share/mysql/:配置檔案 my-medium.cnf等

/var/mysql:MySQL資料目錄

/usr/sfw/include/mysql:MySql的頭檔案

2.配置MySQL配置檔案

-bash-3.00#cp /usr/sfw/share/mysql/my-medium.cnf /etc/my.cnf

-bash-3.00#vi /etc/my.cnf

# The following options will be passed to all MySQL clients

[client]

#password       = your_password

port            = 3306

##Modified content [email protected]

#socket         = /var/lib/mysql/mysql.sock

socket          = /home/mysql/5.0/mysql/mysql.sock

# Here follows entries for some specific programs

# The MySQL server

[mysqld]

port            = 3306

#socket         = /var/lib/mysql/mysql.sock

##Modified content [email protected]

socket          = /home/mysql/5.0/mysql/mysql.sock

skip-locking

key_buffer = 16M

max_allowed_packet = 1M

table_cache = 64

sort_buffer_size = 512K

net_buffer_length = 8K

read_buffer_size = 256K

read_rnd_buffer_size = 512K

myisam_sort_buffer_size = 8M

3.建立mysql使用者

-bash-3.00#useradd -u 1002 mysql

-bash-3.00#groupadd -g 1002 mysql mysql

-bash-3.00#mkdir /export/home/mysql

4.啟動mysql

-bash-3.00#./mysqld &

發生如下錯誤:

080424 15:45:53 InnoDB: Started

080424 15:45:53 Fatal error: Can't open privilege tables: Table 'mysql.host' doesn't exist

080424 15:45:53 Aborting

解決方法:

rm -rf /pathtodatadir

then

cd /usr/local/mysql1/bin

./mysql_install_db --user=mysql --ldata=/var/mysql

./mysqld_safe --datadir=/var/mysql --user=mysql &

5.安裝成功

備份:[[email protected] src]#mysqldump -u root -p --opt mysql > mysql_back

恢複:[[email protected] src]#mysql -u root -p mysql < mysql_back

=====================================================================================================================

Solaris下apache的安裝

1.Solaris下的Apache目錄:

/usr/apache2:主目錄,如/usr/apache2/bin下有apachectl,httpd

/etc/apache2/:配置檔案,如httpd.conf-example

/var/apache2/logs:日志檔案

/var/run/apache2/httpd.pid:運作目錄

2.配置檔案

-bash-3.00#cp /etc/apache2/httpd.conf-example  /etc/apache2/httpd.conf

-bash-3.00#vi /etc/apache2/httpd.conf

    Set ServerName if necessary (default is 127.0.0.1)

    Set ServerAdmin to a valid email address

如沒有目錄/var/run/apache2/則需要建立此目錄

3.運作./usr/apache2/bin/apachectl start &

或者,啟用apache服務:

-bash-3.00# svcadm enable apache2

=====================================================================================================================

Solaris下PHP的安裝

1.編譯安裝

./configure --prefix=/usr/local/php --with-apxs2=/usr/apache2/bin/apxs --with-mysql=/usr/sfw/include/mysql

--with-config-file-path=/usr/local/php/etc

錯誤一:

checking for int8... (cached) no

checking base type of last arg to accept... (cached) socklen_t

checking return type of qsort... (cached) void

configure: error: Cannot find MySQL header files under /usr/

将--with-mysql=/usr/sfw/include/mysql改為--with-mysql=/usr/sfw/便可解決

錯誤二:

Configuring extensions

checking whether to enable LIBXML support... yes

checking libxml2 install dir... no

checking for xml2-config path... /usr/bin/xml2-config

configure: error: libxml2 version 2.6.11 or greater required.

解決方法有二:

一是采用低版本的php-4.4.8.tar.gz

二是更新libxml2和重新安裝一個libxml2(不推薦,容導緻系統版本不一直而崩潰)或重新安裝一個新的libxml2(推薦)

tar zxvf libxml2-2.6.26.tar.gz

./configure –prefix=/usr/local/libxml

make;make install

重新開機機子,更新子產品

2.配置PHP

檢查htppd.conf檔案中是否插入“LoadModule php5_module modules/libphp5.so“

手動插入行“AddType application/x-httpd-php .php .phtml”

注意不要象一些文檔說的加入兩句:

#AddHandler php4-script .php

AddType application/x-httpd-php .php

這是錯誤

測試頁面:<?phpinfo()?>

=====================================================================================================================

Solaris下net-snmp和rrdtool的安裝

1.net-snmp的安裝

./configure

make;make install

如CACTI出現如下錯誤:

.Encryption support not enabled.

snmpbulkwalk: USM encryption error

Encryption support not enabled.

解決方法:

You probably need to install the openssl-dev package and rebuild net-snmp.

2.修改snmp的配置檔案:

#vi /usr/local/share/snmp/snmpd.conf

修改下面幾部分内容:

1)com2sec notConfigUser default public

改為:com2sec notConfigUser localhost public

2)access notConfigGroup "" any noauth exact systemview none none

改為:access notConfigGroup "" any noauth exact all none none

3)#view all included .1 80

4)createUser frederic MD5 mypassphrase DES

group groupv3   usm        frederic

access groupv3   ""      any       auth      exact  all    all    all

修改計劃任務,使CACTI每5分鐘獲得一次資料:

#crontab -e 使用者名

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/php/bin/php /var/apache2/htdocs/cacti/poller.php > /dev/null 2>&1

3.測試SNMP

snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.100.6.0

snmpget -v 3 -l AuthNoPriv -u frederic -A mypassphrase 192.168.0.6 sysName.0

2)Test configuration

snmpwalk -v 1 -c public localhost .1.3.6.1.2.1.1.1.0

--query which Net-SNMP version is running on a host

snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.100.2.0

snmpwalk -v 1 -c foo localhost .1.3.6.1.2.1.1.1.0

--An incorrect passphrase will result in this error message

snmpget -v 3 -l AuthNoPriv -u frederic -A badpassphrase 192.168.0.6 sysName.0

--This query will show you what filesystems are mounted

snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.9.1.2

--display your network interfaces

snmpwalk -v 1 -c public localhost .1.3.6.1.2.1.2.2.1.2

snmpwalk -v 2c -c public 192.168.0.6 if

/usr/local/php/bin/php /var/apache2/htdocs/cacti/cli/poller_reindex_hosts.php -id=All

Timeout: No Response from 192.168.0.6:161.

04/28/2008 12:14:55 PM - SYSTEM STATS: Time:4.4020 Method:cmd.php Processes:1 Threads:N/A Hosts:2

HostsPerProcess:2 DataSources:14 RRDsProcessed:0

=====================================================================================================================

1.rrdtool的安裝

perl /scripts/unix_users.pl cacti

/usr/local/cactid/bin/cactid --conf=/usr/local/cactid/etc/cactid.conf

1)rrdtool dump two_gw_call_monitor_connectednew_2954.rrd > /tmp/2954.xml

2)sed -i -e 's/NaN/2.4300000000e+02/' 2954.xml

3)rrdtool restore -f 2954.xml two_gw_call_monitor_connectednew_2954.rrd

/usr/local/php/bin/php /var/apache2/htdocs/cacti/poller.php

/var/spool/cron/crontabs/cacti

/usr/local/rrdtool-1.2.19/bin/rrdtool  fetch localhost_mem_buffers_14.rrd  AVERAGE

/usr/local/rrdtool-1.2.19/bin/rrdtool  info localhost_mem_buffers_14.rrd

php rebuild_poller_cache.php -d

=====================================================================================================================

Solaris下CACTI的安裝

1.修改配置

grant all privileges on *.* to 'cacti'@'localhost' identified by 'cacti'

/usr/sfw/bin/mysql -ucacti -pcacti cacti < cacti.sql 

#vi include/config.php

修改如下段落:

$database_type = "mysql";

$database_default = "cacti";

$database_hostname = "localhost";

$database_username = "cactiuser";

$database_password = "cactiuser";

$database_port = "3306";

改為:

$database_type = "mysql";

$database_default = "cacti";

$database_hostname = "localhost";

$database_username = "使用者名";

$database_password = "你的密碼";

$database_port = "3306";

2.修改CACTI的配置檔案

#chown -R rra/ log/

這樣cacti就基本配置完成了

在浏覽器裡輸入IP/cacti,錯誤提示:

Please make sure you have specified a valid MySQL database name in 'include/config.php'

解決方法為修改/etc/my.cnf檔案:

socket = /tmp/mysql.sock

##[email protected] 20080425

#socket = /var/lib/mysql/mysql.sock

##http://192.168.0.6/cacti

使用者名和密碼是admin和admin

3.crontab自啟動

注意Solaris下,指令行可以有結果,而crontab沒有,則是因為使用的環境變量不同所緻,

應該加上/export/home/cacti/.bash_profile,如下:

0,5,10,15,20,25,30,35,40,45,50,55 * * * *

. /export/home/cacti/.bash_profile; /opt/php/bin/php /opt/cacti/cacti-0.8.6b/poller.php

=====================================================================================================================

CACTI使用技巧:

1、cacti的流程是從Data Input Methods開始,建立一個資訊采集的方法先,裡面定義了采集的方法和采集需要的腳本(注意:

如果使用CACTID最好使用可執行檔案的全路徑),可以定義一個輸入和輸出。輸入可以為你執行這個腳本帶入參數,比如連接配接

資料庫的參數,這樣隻要設定這個參數就可以連上不同的資料庫了。輸出是資訊采集的輸入結果,以列名+冒号+采集結果的

形式傳回。

2、然後是資料模版,裡面需要選擇Data Input Methods,如果資料輸入方法中有參數的,這裡可以設定參數,也可以選擇忽略

這個設定,然後到最後配置圖形的時候再輸入特定的參數。

3、建立圖形模版,裡面需要定義圖形的ITEM,可以使用AREA方式先畫一個框,然後把其他值以STACK的方式往前面的AREA上面

累加。也可以使用GPRINT方式在最下面的備注那裡輸出些資訊(一般是輸入最後采集時候的值)。這裡可以定義CDEF function,

這個函數可以把你顯示的ITEM進行轉換,比如把8k轉換成8192位元組等,這個函數可以自定義的(可以參考Graph Management中的

CDEFs中的定義來進行自定義)。

4、建立DATASOURCE,然後建立GRAPH。

最後可以把他們放到一個TREE上