apache2.2.8+mysql5.0.51+php5.2.5+snmp5.14(詳細說明)+rrdtool+cacti 配置
apache2.2.8+mysql5.0.51+php5.2.5+snmp5.14(詳細說明)+rrdtool+cacti 配置
OS fedora7 安裝選包定製
全選開發包
伺服器 一個沒選
本機IP 192.168.1.254
安裝 mysql
所有安裝程序 在 /usr/local下
# groupadd mysql
# useradd -g mysql mysql
# cd /usr/local
# tar -zxvf mysql-5.0.51.tar.gz
# cd mysql-5.0.51
[root@localhost mysql-5.0.51# ./configure --prefix=/usr/local/mysql
# make
# make install
# cd ../mysql
# scripts/mysql_install_db --user=mysql
# chown -R root .
# chown -R mysql var
# chgrp -R mysql .
# ./bin/mysqld_safe --user=mysql &
# ./bin/mysqladmin -uroot password mysql
# cp ../mysql-5.0.51/support-files/my-large.cnf /etc/my.cnf
# cp ../mysql-5.0.51/support-files/mysql.server /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --level mysqld 345 on
# chkconfig --list mysqld
#
Mysql 安裝結束
安裝apache
# tar -zxvf httpd-2.2.8.tar.gz
# cd httpd-2.2.8
# ./configure --prefix=/usr/local/apache --enable-mods-shared=all --enable-so
# make;make install
# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
# cd /etc/rc3.d
# ln -s /etc/init.d/httpd S85httpd
# ln -s /etc/init.d/httpd K85httpd
# /usr/local/apache/bin/apachectl star
Apache 安裝完畢
安裝PHP
安裝支持圖形處理,自己可以找最新的安裝。
##### zlib#####
cd zlib-1.2.3
./configure --prefix=/usr/local/zlib
make
make install
cd ..
##### FreeType ##### freetype-2.3.5.tar.gz
cd freetype-2.3.5
./configure --prefix=/usr/local/freetype
make
make install
cd ..
##### LibPNG #####
cd libpng-1.2.20
cp scripts/makefile.linux makefile
make test
make install
cd ..
##### Jpeg ##### jpegsrc.v6b.tar.gz
cd jpeg-6b
mkdir /usr/local/jpeg
mkdir /usr/local/jpeg/bin
mkdir /usr/local/jpeg/lib
mkdir /usr/local/jpeg/include
mkdir /usr/local/jpeg/man
mkdir /usr/local/jpeg/man/man1
./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
make
make install
cd ..
##### gd ##### gd-2.0.33.tar.gz
cd gd-2.0.33
./configure --prefix=/usr/local/gd \
--with-jpeg=/usr/local/jpeg \
--with-freetype=/usr/local/freetype \
--with-png \
--with-zlib
[root@localhost local# tar -zxvf php-5.2.5.tar.gz
[root@localhost local# cd php-5.2.5
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-
mysql=/usr/local/mysql --with-config-file-path=/usr/local/php/etc --with-openssl=/usr/local/ssl --with-gd=/usr/local/gd --
with-gdbm=/usr/lib --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/jpeg --with-png-dir --with-
zlib=/usr/local/zlib --enable-mbstring --enable-sockets
# make;make install
# cp php.ini-dist /usr/local/php/etc/php.ini
# vi /usr/local/apache/conf/httpd.conf
按 I 鍵 添加 AddType application/x-tar .tgz
AddType application/x-httpd-php .php
AddType image/x-icon .ico
DirectoryIndex index.php index.html index.html.var
保存退出 :wq
# /usr/local/apache/bin/apachectl restart
Php安裝完畢
設置mysql
# /usr/local/mysql/bin/mysql -u root -pmysql
mysql> create database cactidb;
mysql> grant all on cactidb.* to root;
mysql> grant all on cactidb.* to root@localhost;
mysql> grant all on cactidb.* to cactiuser;
mysql> grant all on cactidb.* to cactiuser@localhost;
mysql> set password for cactiuser@localhost=password('cactipw');
註:以上語句輸出 Query OK, 0 rows affected (0.01 sec) 表示成功
mysql> exit
Mysql設置完畢
檢測apache + php + mysql
# cd /www/htdocs
# touch info.php
# vi info.php
<?
phpinfo( );
?>
保存退出 :wq
# touch mydqltest.html
# vi mysqltest.html
<html>
<body>
<?
$link=mysql_connect('localhost','root');
mysql_select_db('mysql');
$str="select * from user;";
$result=mysql_query($str,$link);
$show=mysql_num_rows($result);
mysql_close($link);
for ($i=0;$i < $show;$i++)
{
$arr[$i]=mysql_fetch_array($result);
};
?>
<table align=center border=1>
<tr align=center>
<td>Host</td>
<td>User</td>
<td>Password</td>
</tr>
<?for ($i=0;$i<$show;$i++){?>
<tr>
<td><?echo $arr[$i]?></td>
<td><?echo $arr[$i]?></td>
<td><?echo $arr[$i]?></td>
</tr>
<?};?>
</body>
</html>
保存退出 :wq
重啟mysql + apache 服務
# service mydql restart
# service httpd restart
進入瀏覽器檢查
http://192.168.1.254/info.php 和 http://192.168.1.254/mysqltest.html
安裝rrdtool
# tar zxvf rrdtool-1.0.50.tar.gz
# cd rrdtool-1.0.50
# ./configure
# make && make install
我的是fedora 7,用下面的方法。
yum install rrdtool
Rrdtool安裝完畢
安裝net-snmp、snmpwalk和snmpget命令
# rpm -qa | grep net-snmp
net-snmp-5.0.9-2.30E.15
net-snmp-devel-5.0.9-2.30E.15
net-snmp-libs-5.0.9-2.30E.15
net-snmp-utils-5.0.9-2.30E.15
# vi /etc/snmp/snmpd.conf
更改 1、com2sec notConfigUser default public
改為:com2sec notConfigUser 127.0.0.1 public
2、access notConfigGroup "" any noauth exact systemview none none
改為:access notConfigGroup "" any noauth exact all none none
3、#view all included .1 80
將前面的 # 註釋 去掉。
保存退出 :wq
# service snmpd restart
使用yum安裝更方便:
# yum install net-snmp
# yum update net-snmp
配置還是使用上面的方法修改。
或者使用:net-snmp-5.1.4.tar.gz安裝
# tar -zxvf net-snmp-5.1.4.tar.gz
# cd net-snmp-5.1.4
# ./configure
# make
# make install
運行snmpconf -g basic_setup,會在當前目錄下生成一個snmpd.conf配置文件:
# snmpconf -g basic_setup
運行後會出現一個詢問菜單,按如下步驟進行回答:CODE:Do you want to configure the information returned in
the system MIB group (contact info, etc)? (default = y): y
The location of the system: Shenzhen, China
The contact information: master@emerson.com
Do you want to properly set the value of the sysServices.0 OID (if you don't know, just say no)? (default = y): y
does this host offer physical services (eg, like a repeater) : 1
does this host offer datalink/subnetwork services (eg, like a bridge): 0
does this host offer internet services (eg, supports IP): 1
does this host offer end-to-end services (eg, supports TCP): 1
does this host offer application services (eg, supports SMTP): 1
Do you want to configure the agent's access control? (default = y): y
Do you want to allow SNMPv3 read-write user based access (default = y): n
Do you want to allow SNMPv3 read-only user based access (default = y): n
Do you want to allow SNMPv1/v2c read-write community access (default = y): n
Do you want to allow SNMPv1/v2c read-only community access (default = y): y
The community name to add read-only access for: public
The hostname or network address to accept this community name from : (RETURN)
The OID that this community should be restricted to : (RETURN)
Do you want to configure where and if the agent will send traps? (default = y): n
Do you want to configure the agent's ability to monitor various aspects of your system? (default = y): y
Do you want to configure the agents ability to monitor processes? (default = y): y
Name of the process you want to check on: sshd(需要監控的進程)
Maximum number of processes named ' sshd' that should be running : 1
Minimum number of processes named ' sshd' that should be running : 0
Do another proc line? (default = y): n
Do you want to configure the agents ability to monitor disk space? (default = y): y
Enter the mount point for the disk partion to be checked on: /
Enter the minimum amount of space that should be available on /var: %100
Do another disk line? (default = y): y
Enter the mount point for the disk partion to be checked on: /var
Enter the minimum amount of space that should be available on /var: %100
Do another disk line? (default = y): y
Enter the mount point for the disk partion to be checked on: /usr
Enter the minimum amount of space that should be available on /usr: %100
Do another disk line? (default = y): y
Enter the mount point for the disk partion to be checked on: /home
Enter the minimum amount of space that should be available on /home: %100
Do another disk line? (default = y): n
Do you want to configure the agents ability to monitor load average? (default = y): y
Enter the maximum allowable value for the 1 minute load average: 12
Enter the maximum allowable value for the 5 minute load average: 12
Enter the maximum allowable value for the 15 minute load average: 12
Do another load line? (default = y): n
Do you want to configure the agents ability to monitor file sizes? (default = y): n(如果想監控文件的大小,可以選y)
4.運行net-snmp:
# snmpd -c /path/snmpd.conf (要上面生成的絕對路徑)
測試一下看看net-snmp是否配置成功:
#snmpwalk -v 1 -c public localhost .1 (是否可以從.1開始採集伺服器數據)
#snmpwalk -v 1 -c public localhost dskPercent.1 (看看剛配置過的硬碟監測是否成功)
如果有數據了,恭喜你snmp安裝成功了。
註:如果你機器內沒有snmpwalk和snmpge命令,請到安裝盤裡查找 net-snmp-utils 包,rpm -ivh net-snmp-utils-*.rpm 只后這兩個命令就
在系統里了。其他包也都在安裝盤裡 確保安裝這四個包就OK
安裝/ 配置cacti
# useradd cactiuser -g users
# passwd cactiuser (pwd:cactipw)
# cp cacti-0.8.7.tar.gz /var/www/html
# cd /var/www/html
# tar -zxvf cacti-0.8.7.tar.gz
# mv cacti-0.8.6g cacti
# cd cacti
# /usr/local/mysql/bin/mysql -u root -p cactidb < cacti.sql
passwork:
# chown -R cactiuser rra/ log/
# cd scripts
# chown cactiuser:users *
# vi /www/htdocs/cacti/include/config.php
$database_type = 「mysql」;
$database_default = 「cactidb」;
$database_hostname = 「localhost」;
$database_username = 「cactiuser」;
$database_password = 「cactipw」;
更改用戶、密碼 等項 與上面給出的對應 保存退出
# crontab -u cactiuser -e
加入
*/5 * * * * /usr/local/php/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1
保存退出:wq
全部設置完畢。
打開瀏覽器 http://192.168.1.254/cacti 進入cacti的初始設置頁面
第一次默認登陸賬號:admin 密碼 admin
登陸后在新改個密碼就OK
需要說明的還有路徑
snmpwalk Binary Path : /usr/bin/snmpwalk
snmpget Binary Path: /usr/bin/snmpget
RRDTool Binary Path: /usr/bin/rrdtool
PHP Binary Path: /usr/local/php/bin/php
Cacti Log File Path: /var/www/html/cacti/log/cacti.log
Cactid Poller File Path:/var/www/html/cacti/poller.php
如果你是按我的步驟做的 那上面的路徑一定不會錯。
註:此時graphs還不能顯示圖形,需要將服務重新啟動一下
# service snmpd restart
# service mysql restart
# service httpd restart
源於: http://cndefu.blog.163.com/blog/static/59393188200803124532865/
[ 本帖最後由 lFANS 於 2008-6-4 09:09 編輯 ]
《解決方案》
好文章,先留著備用了。
《解決方案》
頂一下,目前最新了
《解決方案》
好東西呢,比我寫計劃書還詳細
《解決方案》
回復 #2 miladuo 的帖子
應寫個腳本, 一步到位
《解決方案》
謝謝樓主了。
《解決方案》
:wink: :wink: 很詳細..
《解決方案》
原帖由 toplimeng 於 2008-2-22 09:25 發表 http://bbs.chinaunix.net/images/common/back.gif
好東西呢,比我寫計劃書還詳細
過獎
《解決方案》
原帖由 lFANS 於 2008-1-31 16:51 發表 http://bbs.chinaunix.net/images/common/back.gif
apache2.2.8+mysql5.0.51+php5.2.5+snmp5.14(詳細說明)+rrdtool+cacti 配置
OS fedora7 安裝選包定製
全選開發包
伺服器 一個沒選
本機IP 192.168.1.254
安裝 mysql
所有安裝程序 在 /usr/lo ...
好文
《解決方案》
回復 #1 lFANS 的帖子
:P 好好好好好好好好好好好好好好