我的安装过程
系統(tǒng)環(huán)境:
系統(tǒng)版本:centos 6.2
安裝情況:最小化安裝
一,安裝LAMP環(huán)境
1.[root@mls]#?yum -y install ?gcc make vim unzip wget install httpd mysql mysql-devel mysql-server php php-devel php-mysql php-comman php-pdo php-gd lm_sensor net-snmp php-snmp net-snmp-utils
2.[root@mls]#?chkconfig mysqld on
[root@mls]#?chkconfig httpd on
[root@mls]#?chkconfig snmpd on
[root@mls]#?service mysqld start
[root@mls]#service httpd start
[root@mls]#service snmpd start
3.[root@mls]# mysqladmin -u root password '123456'
[root@mls]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.69 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database cacti;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on cacti.* to cactiuser@localhost identified by '654321';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
?
4.安裝rrdtool
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.6.tar.gz
[root@mls ~]# tar xf rrdtool-1.4.4.tar.gz
[root@mls ~]# cd rrdtool-1.4.4
[root@mls rrdtool-1.4.4]# ./configure --prefix=/usr/local/rrdtool && make && make install
報(bào)錯(cuò):
configure: WARNING:
----------------------------------------------------------------------------
* I found a copy of pkgconfig, but there is no cairo-png.pc file around.
You may want to set the PKG_CONFIG_PATH variable to point to its
location.
----------------------------------------------------------------------------
configure: WARNING:
----------------------------------------------------------------------------
* I could not find a working copy of cairo-png. Check config.log for hints on why
this is the case. Maybe you need to set LDFLAGS and CPPFLAGS appropriately
so that compiler and the linker can find libcairo and its header files. If
you have not installed cairo-png, you can get it either from its original home on
http://cairographics.org/releases/
You can find also find an archive copy on
http://oss.oetiker.ch/rrdtool/pub/libs
The last tested version of cairo-png is 1.4.6.
LIBS=-lm
LDFLAGS=
CPPFLAGS=
----------------------------------------------------------------------------
checking for cairo_svg_surface_create in -lcairo... no
checking for pkg-config... (cached) pkg-config
configure: WARNING:
----------------------------------------------------------------------------
* I found a copy of pkgconfig, but there is no cairo-svg.pc file around.
You may want to set the PKG_CONFIG_PATH variable to point to its
location.
----------------------------------------------------------------------------
configure: WARNING:
----------------------------------------------------------------------------
* I could not find a working copy of cairo-svg. Check config.log for hints on why
this is the case. Maybe you need to set LDFLAGS and CPPFLAGS appropriately
so that compiler and the linker can find libcairo and its header files. If
you have not installed cairo-svg, you can get it either from its original home on
http://cairographics.org/releases/
You can find also find an archive copy on
http://oss.oetiker.ch/rrdtool/pub/libs
The last tested version of cairo-svg is 1.4.6.
LIBS=-lm
LDFLAGS=
CPPFLAGS=
----------------------------------------------------------------------------
checking for cairo_pdf_surface_create in -lcairo... no
checking for pkg-config... (cached) pkg-config
configure: WARNING:
----------------------------------------------------------------------------
* I found a copy of pkgconfig, but there is no cairo-pdf.pc file around.
You may want to set the PKG_CONFIG_PATH variable to point to its
location.
----------------------------------------------------------------------------
configure: WARNING:
----------------------------------------------------------------------------
* I could not find a working copy of cairo-pdf. Check config.log for hints on why
this is the case. Maybe you need to set LDFLAGS and CPPFLAGS appropriately
so that compiler and the linker can find libcairo and its header files. If
you have not installed cairo-pdf, you can get it either from its original home on
http://cairographics.org/releases/
You can find also find an archive copy on
http://oss.oetiker.ch/rrdtool/pub/libs
The last tested version of cairo-pdf is 1.4.6.
LIBS=-lm
LDFLAGS=
CPPFLAGS=
----------------------------------------------------------------------------
checking for cairo_ps_surface_create in -lcairo... no
checking for pkg-config... (cached) pkg-config
configure: WARNING:
----------------------------------------------------------------------------
* I found a copy of pkgconfig, but there is no cairo-ps.pc file around.
You may want to set the PKG_CONFIG_PATH variable to point to its
location.
----------------------------------------------------------------------------
configure: WARNING:
----------------------------------------------------------------------------
* I could not find a working copy of cairo-ps. Check config.log for hints on why
this is the case. Maybe you need to set LDFLAGS and CPPFLAGS appropriately
so that compiler and the linker can find libcairo and its header files. If
you have not installed cairo-ps, you can get it either from its original home on
http://cairographics.org/releases/
You can find also find an archive copy on
http://oss.oetiker.ch/rrdtool/pub/libs
The last tested version of cairo-ps is 1.4.6.
LIBS=-lm
LDFLAGS=
CPPFLAGS=
----------------------------------------------------------------------------
checking for glib_check_version in -lglib-2.0... no
checking for pkg-config... (cached) pkg-config
configure: WARNING:
----------------------------------------------------------------------------
* I found a copy of pkgconfig, but there is no glib-2.0.pc file around.
You may want to set the PKG_CONFIG_PATH variable to point to its
location.
----------------------------------------------------------------------------
configure: WARNING:
----------------------------------------------------------------------------
* I could not find a working copy of glib-2.0. Check config.log for hints on why
this is the case. Maybe you need to set LDFLAGS and CPPFLAGS appropriately
so that compiler and the linker can find libglib-2.0 and its header files. If
you have not installed glib-2.0, you can get it either from its original home on
ftp://ftp.gtk.org/pub/glib/2.12/
You can find also find an archive copy on
http://oss.oetiker.ch/rrdtool/pub/libs
The last tested version of glib-2.0 is 2.12.12.
LIBS=-lm
LDFLAGS=
CPPFLAGS=
----------------------------------------------------------------------------
checking for pango_cairo_context_set_font_options in -lpangocairo-1.0... no
checking for pkg-config... (cached) pkg-config
configure: WARNING:
----------------------------------------------------------------------------
* I found a copy of pkgconfig, but there is no pangocairo.pc file around.
You may want to set the PKG_CONFIG_PATH variable to point to its
location.
----------------------------------------------------------------------------
configure: WARNING:
----------------------------------------------------------------------------
* I could not find a working copy of pangocairo. Check config.log for hints on why
this is the case. Maybe you need to set LDFLAGS and CPPFLAGS appropriately
so that compiler and the linker can find libpangocairo-1.0 and its header files. If
you have not installed pangocairo, you can get it either from its original home on
http://ftp.gnome.org/pub/GNOME/sources/pango/1.17
You can find also find an archive copy on
http://oss.oetiker.ch/rrdtool/pub/libs
The last tested version of pangocairo is 1.17.
LIBS=-lm
LDFLAGS=
CPPFLAGS=
----------------------------------------------------------------------------
checking for xmlParseFile in -lxml2... no
checking for pkg-config... (cached) pkg-config
configure: WARNING:
----------------------------------------------------------------------------
* I found a copy of pkgconfig, but there is no libxml-2.0.pc file around.
You may want to set the PKG_CONFIG_PATH variable to point to its
location.
----------------------------------------------------------------------------
configure: WARNING:
----------------------------------------------------------------------------
* I could not find a working copy of libxml-2.0. Check config.log for hints on why
this is the case. Maybe you need to set LDFLAGS and CPPFLAGS appropriately
so that compiler and the linker can find libxml2 and its header files. If
you have not installed libxml-2.0, you can get it either from its original home on
http://xmlsoft.org/downloads.html
You can find also find an archive copy on
http://oss.oetiker.ch/rrdtool/pub/libs
The last tested version of libxml-2.0 is 2.6.31.
LIBS=-lm
LDFLAGS=
CPPFLAGS= -I/usr/include/libxml2
----------------------------------------------------------------------------
configure: error: Please fix the library issues listed above and try again.
[root@bogon rrdtool-1.4.4]#
yum -y install libxml2-devel
yum -y install pango*
?
?
?
make[2]: Entering directory `/root/rrdtool-1.4.4/bindings'
make[3]: Entering directory `/root/rrdtool-1.4.4/bindings'
cd perl-piped && /usr/bin/perl Makefile.PL PREFIX=/usr/local/rrdtool LIB=/usr/local/rrdtool/lib/perl/5.10.1
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at Makefile.PL line 1.
BEGIN failed--compilation aborted at Makefile.PL line 1.
make[3]: *** [perl-piped/Makefile] Error 2
make[3]: Leaving directory `/root/rrdtool-1.4.4/bindings'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/root/rrdtool-1.4.4/bindings'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/rrdtool-1.4.4'
make: *** [all] Error 2
解決辦法:yum -y install perl-devel
再次執(zhí)行[root@mls rrdtool-1.4.4]# ./configure --prefix=/usr/local/rrdtool && make && make install
ln -s /usr/local/rrdtool/bin/* /usr/local/bin/
5.?安裝cacti-0.8.7.e
wget? http://www.cacti.net/downloads/cacti-0.8.7e.tar.gz
# tar xf cacti-0.8.7e.tar.gz -C /var/www/html/
# cd /var/www/html/
# mv cacti-0.8.7e/ cacti
# chown -R root.root /var/www/html/cacti/
6.導(dǎo)入數(shù)據(jù)庫
mysql -u root -p cacti?<cacti/cacti.sql
Enter password
?
7.修改cacti配置文件,連接數(shù)據(jù)庫
vim /var/www/html/cacti/include/config.php
$database_username?=?"cactiuser";
$database_password?=?"654321";
########################################
?vim /var/www/html/cacti/include/global.php
$database_username?=?"cactiauser";
$database_password?=?"654321"
8.安裝cacti-plugin
# wget http://mirror.cactiusers.org/downloads/plugins/cacti-plugin-0.8.7e-PA-v2.6.zip
unzip cacti-plugin-0.8.7e-PA-v2.6.zip
cd cacti-plugin-arch/
?cp /root/cacti-plugin-arch/{cacti-plugin-0.8.7e-PA-v2.6.diff,pa.sql} /var/www/html/cacti/
?cd /var/www/html/cacti/
9、打補(bǔ)丁導(dǎo)入數(shù)據(jù)庫
yum -y install patch
# patch -p1 -N?<cacti-plugin-0.8.7e-PA-v2.6.diff
# mysql -uroot -p cacti<pa.sql
10.修改配置文件
修改配置文件,如下:
vim include/global.php
$config['url_path'] = '/cacti/';
11、添加計(jì)劃任務(wù)
# crontab -e
*/5 * * * * /usr/bin/php /var/www/html/cacti/poller.php
service crond restart
12.關(guān)閉iptables和selinux,無法打開http://ip/cacti/install/界面
13.一切默認(rèn)安裝 rrd 1.2?
14、被監(jiān)控端配置(不要了)
# vim /etc/snmp/snmpd.conf
com2sec notConfigUser default public
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
access notConfigGroup "" any noauth exact mib2 none none
view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root?<root@localhost>?(configure /etc/snmp/snmp.local.conf)
pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat
15、重啟服務(wù)(不要了)
# service snmpd restart
到此就差不多了,我們可以做些檢測在服務(wù)器上,有信息返回說明正常:
# snmpwalk -v 2c -c public?ServerIP?if
16、安裝nagios
1、建立用戶
2、編譯安裝nagios
?
3、安裝插件
?
4、修改apache的配置文件
5、配置nagios添加主機(jī),服務(wù)信息
在/usr/local/nagios/etc/objects/下建立2個(gè)文件:
?
6、建立登陸的用戶名密碼
# htpasswd -c /usr/local/nagios/etc/htpasswd nagiosadmin(################)
7、修改nagios.cfg文件,添加文件路徑信息:
# You can specify individual object config files as shown below:
#cfg_file=/usr/local/nagios//etc/objects/commands.cfg
#cfg_file=/usr/local/nagios//etc/objects/contacts.cfg
#cfg_file=/usr/local/nagios//etc/objects/timeperiods.cfg
#cfg_file=/usr/local/nagios//etc/objects/templates.cfg
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
8、啟動nagios以后訪問輸入用戶名密碼就可以看到Nagios了
檢查配置文件是否正確
[root@mls etc]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Nagios Core 3.3.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 07-25-2011
License: GPL
Website: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Processing object config file '/usr/local/nagios/etc/objects/hosts.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/services.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...
Processing object config file '/usr/local/nagios//etc/objects/localhost.cfg'...
Read object config files okay...
Running pre-flight check on configuration data...
Checking services...
Checked 9 services.
Checking hosts...
Checked 2 hosts.
Checking host groups...
Checked 1 host groups.
Checking service groups...
Checked 0 service groups.
Checking contacts...
Checked 1 contacts.
Checking contact groups...
Checked 1 contact groups.
Checking service escalations...
Checked 0 service escalations.
Checking service dependencies...
Checked 0 service dependencies.
Checking host escalations...
Checked 0 host escalations.
Checking host dependencies...
Checked 0 host dependencies.
Checking commands...
Checked 24 commands.
Checking time periods...
Checked 5 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check
?
四、整合cacti+nagios
整合cacti和nagios是利用了cacti的一個(gè)插件nagios for cacti,它的原理是將nagios的數(shù)據(jù)通過ndo2db導(dǎo)入到mysql數(shù)據(jù)庫(cacti的庫中),然后cacti讀取數(shù)據(jù)庫信息將nagios
的結(jié)果展示出來。
1、安裝php-json擴(kuò)展,因?yàn)镹PC使用了ExtJS,如過沒有json的擴(kuò)展NPC界面無法出來。
# tar xf php-json-ext-1.2.1.tar.gz
# cd php-json-ext-1.2.1
# phpize
如果沒有命令的話安裝下面的軟件包
# rpm -ihv /media/CentOS/php-devel-5.1.6-27.el5.i386.rpm
# sh configure && make && make install
2、新建文件,添加信息如下:
# vim /etc/php.d/json.ini
extension=json.so
3、安裝ndoutils,需要安裝mysql-devel前面已經(jīng)裝過這里就不用再裝了
# tar xf ndoutils-1.4b9.tar.gz
# cd ndoutils-1.4b9
# ./configure?--with-mysql-inc=/usr/include/mysql?--with-mysql-lib=/usr/lib/mysql --enable-mysql?--with-ndo2db-user=nagios--with-ndo2db-group=nagios
# make(不用make install)
4、復(fù)制文件
# cp src/{ndomod-3x.o,ndo2db-3x,log2ndo,file2sock} /usr/bin/
# cp config/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg
# cp config/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg
# chmod 644 /usr/local/nagios/etc/ndo*
5、修復(fù)配置文件信息,連接數(shù)據(jù)庫
# vim /usr/local/nagios/etc/ndo2db.cfg
socket_type=tcp
db_host=127.0.0.1
db_port=3306
db_name=cacti
db_prefix=npc_
db_user=cactiuser
db_pass=654321
debug_level=1
# vim /usr/local/nagios/etc/ndomod.cfg
output_type=tcpsocket
output=127.0.0.1
6、添加啟動腳本,并修改Ndo2dbBin
# cp /download/ndoutils-1.4b9/daemon-init /etc/init.d/ndo2db
# vim ?/etc/init.d/ndo2db
/etc/init.d/ndo2dbNdo2dbBin=/usr/bin/ndo2db-3x
# service ndo2db start
[root@mls ndoutils-1.4b9]# service ndo2db start
Starting ndo2db:Failed to obtain lock on file /usr/local/nagios/var/ndo2db.lock: Permission denied
: Permission denied
done.
[root@mls ndoutils-1.4b9]# chmod 700 /etc/init.d/ndo2db
Failed to obtain lock on file /usr/local/nagios/var/ndo2db.lock: Permission denied??: Permission denied
修改ndo2db.lock的所屬組和用戶對它有寫的權(quán)限
7、安裝npc
# tar xf npc-2.0.4.tar.gz
# mv npc /var/www/html/cacti/plugins/
修改配置文件,添加如下信息
# vim /var/www/html/cacti/include/global.php
$plugins?=?array();
$plugins[]='npc';
?
?8、修改nagios添加信息:
# vim /usr/local/nagios/etc/nagios.cfg
broker_module=/usr/bin/ndomod-3x.o?config_file=/usr/local/nagios/etc/ndomod.cfg
event_broker_options=-1
service nagios restart
啟動之后在cacti中添加npc,如下:
添加npc
9.但是看npc里發(fā)現(xiàn)空白的,沒有數(shù)據(jù),是因?yàn)閜hp沒有PDO_MYSQL支持,所以安裝PDO_MYSQL(暫時(shí)沒有安裝了)
10、之后再訪問還不行,還要修改數(shù)據(jù)庫結(jié)構(gòu):
11.之后再訪問還是沒有數(shù)據(jù)了,另外cacti無法顯示圖片,但是點(diǎn)進(jìn)去有圖:
解決方法:
settings里面的RRDTOOLS版本設(shè)置不對,默認(rèn)為1.0.x,改為1.2.x就行了。
?
?
?
?
?
?
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/seasonsstory/p/3171975.html
總結(jié)
- 上一篇: C# 架构模式
- 下一篇: iphone开发笔记