zoukankan      html  css  js  c++  java
  • 我的安装过程

    系统环境:

    系统版本:centos 6.2

    安装情况:最小化安装

    一,安装LAMP环境

    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

    报错:

    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

    再次执行[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.导入数据库

    mysql -u root -p cacti <cacti/cacti.sql

    Enter password

    7.修改cacti配置文件,连接数据库

    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、打补丁导入数据库

    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、添加计划任务

    # crontab -e

    */5 * * * * /usr/bin/php /var/www/html/cacti/poller.php

    service crond restart

    12.关闭iptables和selinux,无法打开http://ip/cacti/install/界面

    13.一切默认安装 rrd 1.2 

    14、被监控端配置(不要了)

    # 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、重启服务(不要了)
    # service snmpd restart

    到此就差不多了,我们可以做些检测在服务器上,有信息返回说明正常:
    # snmpwalk -v 2c -c public ServerIP if

    16、安装nagios

    1、建立用户

    1. # useradd -s /bin/bash nagios
    2. # mkdir -p /usr/local/nagios
    3. # chown -R nagios.nagios /usr/local/nagios/

    2、编译安装nagios

    1. # tar xf nagios-3.4.1.tar.gz
    2. # cd nagios
    3. # ./configure --prefix=/usr/local/nagios/
    4. # make all
    5. # make install
    6. # make install-init
    7. # make install-commandmode
    8. # make install-config
    9. # make install-webconf
    10. # chkconfig --add nagios(buyaole)
    11. # chkconfig nagios on
    12. # service nagios start

    3、安装插件

    1. # tar xf nagios-plugins-1.4.16.tar.gz
    2. # cd nagios-plugins-1.4.16
    3. # ./configure --prefix=/usr/local/nagios/ && make && make install

    4、修改apache的配置文件

    1. # vim /etc/httpd/conf/httpd.conf
    2. 最后添加如下内容,设置成需要输入密码才能登陆
    3. ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
    4. <Directory "/usr/local/nagios/sbin">
    5. AuthType Basic
    6. Options ExecCGI
    7. AllowOverride None
    8. Order allow,deny
    9. Allow from all
    10. AuthName "Nagions Access"
    11. AuthUserFile /usr/local/nagios/etc/htpasswd
    12. Require valid-user
    13. </Directory>
    14. Alias /nagios "/usr/local/nagios/share"
    15. <Directory "/usr/local/nagios/share">
    16. AuthType Basic
    17. Options None
    18. AllowOverride None
    19. Order allow,deny
    20. Allow from all
    21. AuthName "Nagios Access"
    22. AuthUserFile /usr/local/nagios/etc/htpasswd
    23. Require valid-user
    24. </Directory>

    5、配置nagios添加主机,服务信息
    在/usr/local/nagios/etc/objects/下建立2个文件:

      1. (1)hosts.cfg定义主机的文件
      2. define host{
      3. use linux-server
      4. host_name 172.16.21.46
      5. address 172.16.21.46
      6. }
      7. (2)services.cfg 定义主机服务的文件
      8. define service{
      9. use local-service 
      10. host_name 172.16.21.46
      11. service_description ssh 
      12. check_command check_ssh 
      13. }
      14. define service{
      15. use local-service
      16. host_name 172.16.21.46
      17. service_description Ping
      18. check_command check_ping
      19. }
      20. # chown nagios.nagios /usr/local/nagios/etc/objects/{hosts.cfg,services.cfg}

    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的一个插件nagios for cacti,它的原理是将nagios的数据通过ndo2db导入到mysql数据库(cacti的库中),然后cacti读取数据库信息将nagios

    的结果展示出来。

    1、安装php-json扩展,因为NPC使用了ExtJS,如过没有json的扩展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前面已经装过这里就不用再装了

    # 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、复制文件

    # 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、修复配置文件信息,连接数据库

    # 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的所属组和用户对它有写的权限

    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里发现空白的,没有数据,是因为php没有PDO_MYSQL支持,所以安装PDO_MYSQL(暂时没有安装了)

    1. # wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
    2. # tar zxvf PDO_MYSQL-1.0.2.tgz
    3. # cd PDO_MYSQL-1.0.2
    4. # /usr/bin/phpize
    5. #./configure --with-php-config=/usr/bin/php-config
    6. #make
    7. #make install
    8. 修改php.ini,添加如下信息,之后重启httpd即可
    9. extension = "pdo_mysql.so"

    10、之后再访问还不行,还要修改数据库结构:

    1. # mysql -u root -p
    2. use cacti
    3. mysql> alter table npc_eventhandlers add long_output TEXT NOT NULL default '' after output;
    4. mysql> alter table npc_hostchecks add long_output TEXT NOT NULL default '' after output;
    5. mysql> alter table npc_hoststatus add long_output TEXT NOT NULL default '' after output;
    6. mysql> alter table npc_notifications add long_output TEXT NOT NULL default '' after output;
    7. mysql> alter table npc_servicechecks add long_output TEXT NOT NULL default '' after output;
    8. mysql> alter table npc_servicestatus add long_output TEXT NOT NULL default '' after output;
    9. mysql> alter table npc_statehistory add long_output TEXT NOT NULL default '' after output;
    10. mysql> alter table npc_systemcommands add long_output TEXT NOT NULL default '' after output;

    11.之后再访问还是没有数据了,另外cacti无法显示图片,但是点进去有图:

    解决方法:
    settings里面的RRDTOOLS版本设置不对,默认为1.0.x,改为1.2.x就行了。



  • 相关阅读:
    复利计算-做汉堡,结对2.0-复利计算再升级
    java集合
    java 封装,继承,多态基础
    购物车
    ajax
    演示
    实验四
    实验三
    构建之法6-7章读后感
    作业调度模拟程序
  • 原文地址:https://www.cnblogs.com/seasonsstory/p/3171975.html
Copyright © 2011-2022 走看看