• Linux Enterprise 5 安装nagios+nagiosql详细步骤



    一、配置安装环境 yum install httpd* yum install php* yum install net-snmp yum install mysql* yum install glibc* 二、安装nagios 2.1 增加用户及创建目录 groupadd nagios useradd -g nagios nagios usermod -G nagios apache //将apache、nagios用户加入到nagios组里; usermod -G nagios nagios mkdir /usr/local/nagios chown -R nagios:nagios /usr/local/nagios 2.2 安装nagios主程序 在 /usr/local/目录下建立一个软件存放目录soft mkdir soft 将主程序拷备到soft目录中 [./为当前目录] cd soft cp /root/shared/nagios-3.5.0.tar.gz ./ 解压缩 tar -zxvf nagios-3.5.0.tar.gz cd nagios 编译,指定安装目录为/usr/local/nagios ./configure --prefix=/usr/local/nagios #注意横线前后都是没有空格的,不然会有问题 make all make install make install-init make install-config make install-commandmode make install-webconf 进入到/usr/local/nagios下查看是否有etc、bin、 sbin、 share、 var这五个目录 2.3 安装插件 cd /usr/local/soft/ cp /root/shared/nagios-plugins-1.4.16.tar.gz ./ tar -zxvf nagios-plugins-1.4.16.tar.gz cd nagios-plugins-1.4.16 ./configure --prefix=/usr/local/nagios/ make make install 2.4 修改apache配置文件进行登录验证 增加登录认证用户及密码配置 /usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users admin(nagiosadmin为账号) 在配置文件中加入以下选项(也可以不加) vim /etc/httpd/conf/httpd.conf ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin" <Directory "/usr/local/nagios/sbin"> # SSLRequireSSL Options ExecCGI AllowOverride None Order allow,deny Allow from all # Order deny,allow # Deny from all # Allow from 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </Directory> Alias /nagios "/usr/local/nagios/share" <Directory "/usr/local/nagios/share"> # SSLRequireSSL Options None AllowOverride None Order allow,deny Allow from all # Order deny,allow # Deny from all # Allow from 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </Directory> 2.5 配置各服务开机启动 #配置机器启动时自动启动Nagios chkconfig --add nagios chkconfig nagios on chkconfig --add httpd chkconfig httpd on chkconfig --list httpd chkconfig --add mysqld chkconfig mysqld on chkconfig --list mysqld 2.6 关闭SELinux vi /etc/selinux/config SELINUX=disabled 2.7 检查Nagios配置文件 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 2.8 安装nrpe插件 cd /usr/local/soft/ cp /root/shared/nrpe-2.13.tar.gz ./ tar -zxvf nrpe-2.13.tar.gz cd nrpe-2.13 ./configure make all make install-plugin make install-daemon make install-daemon-config /usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc /usr/bin/install -c -m 644 -o nagios -g nagios sample-config/nrpe.cfg /usr/local/nagios/etc /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d 通过如下命令验证nrpe是否正常,可以看到端口5666已经打开 /usr/local/nagios/libexec/check_nrpe -H localhost netstat -atulnp | grep 'nrpe' 三、安装nagiosql 3.1 安装前准备 NagiosQL的本身其实就是一个web程序,安装过程很简单,就是在Webserver下部署 - Webserver e.g. Apache 1.x or above 使用apache2.x - PHP 4.3 or above PHP4.3或以上版本 - MySQL 4.1 or above MySQL4.1或以上版本 - Nagios 2 or above Nagios2或以上版本,使用3.x - PEAR Module: HTML_Template_IT 1.1 or above(输入rpm -qa php-pear查看是否安装) 以下环境配置查看用:php -m 命令查看 - PHP Extension: gettext - PHP Extension: mysql (没有安装则输入 yum install php-mysql 进行安装) - PHP Extension: ftp 3.1.1 安装PEAR Module: HTML_Template_IT 1.1 安装以下项目前,请确保安装 php-pear 安装命令yum install php-pear 通过pear install HTML_Template_IT 命令进行安装 如果出现无法找到HTML_Template_IT包的现象 到PEAR 官网下载最新的HTML_Template_IT包 http://pear.php.net/package/PEAR 放到如下目录:/usr/share/pear/PEAR/PackageFile/ cp /root/shared/HTML_Template_IT-1.3.0.gz /usr/share/pear/PEAR/PackageFile/ 再次运行以下命令 安装成功 pear install HTML_Template_IT-1.3.0.gz 3.1.2 安装php 的 SSH2扩展 1.用rpm -qa openssl 、rpm -qa openssl-devel命令 查看是否安装openssl openssl-devel 两个 2.编译安装libssh2 cd /usr/local/soft/ wget http://www.libssh2.org/download/libssh2-1.2.9.tar.gz tar zxvf libssh2-1.2.9.tar.gz cd libssh2-1.2.9 ./configure make make install 3.编译安装ssh2(官网http://www.php.net/ssh2) 安装前请确保安装php-devel cd /usr/local/soft/ wget http://pecl.php.net/get/ssh2-0.11.2.tgz tar zxvf ssh2-0.11.2.tgz cd ssh2-0.11.2 phpize(如果没有找到该命令,请确定是否安装的是php-devel) ./configure --with-ssh2 make cp modules/ssh2.so /usr/lib/php/modules/ echo "extension=ssh2.so" >> /etc/php.ini 4.重启php service httpd restart 3.1.3 修改php时差及标准时间 php5默认date.timezone为utc,改为date.timezone = PRC vim /etc/php.ini 找到date.timezone 将值修改为PRC 并去掉;号 重启php service httpd restart 3.2 安装nagiosql 主程序 3.2.1 相关环境 Nagios根位置:/usr/local/nagios Nagios配置文件位置:/usr/local/nagios/etc Nagios的用户和用户组:nagios|nagios apache的启动用户和用户组:apache|apache 设置mysql root账号的密码 命令如下: mysqladmin -u root password 'systemg' 3.2.2 安装主程序 解压nagiosql_320.tar.gz到/usr/local/nagios/nagiosql下 cd /usr/local/nagios/ cp /root/shared/nagiosql_320.tar.gz ./ tar -zxvf nagiosql_320.tar.gz mv nagiosql32 nagiosql 修改用户权限 chown -R nagios:nagios /usr/local/nagios/nagiosql chmod 777 /usr/local/nagios/nagiosql 修改config目录的访问权限,以使apache对其具有写权限,、 chmod -R 777 /usr/local/nagios/nagiosql/config 创建配置文件目录,并修改权限 cd /usr/local/nagios/nagiosql/ mkdir etc cd etc mkdir backup hosts import services cd backup mkdir hosts services 对nagiosql下的etc进行权限设置 chown -R apache:apache etc 在install下创建ENABLE_INSTALLER文件 cd /usr/local/nagios/nagiosql/install touch ./ENABLE_INSTALLER 修改apache的httpd.conf文件,部署web服务,添加如下内容。 apache配置文件位置vim /etc/httpd/conf/httpd.conf Alias /nagiosQL "/usr/local/nagios/nagiosql" <Directory "/usr/local/nagios/nagiosql"> # SSLRequireSSL Options None AllowOverride None Order allow,deny Allow from all </Directory> 重启php service httpd restart 通过IE浏览器进入如下地址http://<IP>/ nagiosQL,其中IP是apache服务主机的IP地址 3.2.3 修改基本系统配置: 【管理】-【Config targets】-【修改】 如下: 【基目录】/usr/local/nagios/nagiosql/ 【主机目录】/usr/local/nagios/nagiosql/etc/hosts/ 【服务目录】/usr/local/nagios/nagiosql/etc/services/ 【备份目录】/usr/local/nagios/nagiosql/etc/backup/ 【主机备份目录】/usr/local/nagios/nagiosql/etc/backup/hosts/ 【服务备份目录】/usr/local/nagios/nagiosql/etc/backup/services/ 【Nagios基目录】/usr/local/nagios/etc/ 【导入路径】/usr/local/nagios/etc/objects/ 【Nagios命令文件】/usr/local/nagios/var/rw/nagios.cmd 【Nagios执行文件】/usr/local/nagios/bin/nagios 【Nagios进程文件】/usr/local/nagios/var/nagios.lock 【Nagios配置文件 】/usr/local/nagios/etc/nagios.cfg 3.2.4 导入nagios配置到Nagiosql里 点击工具→导入数据→按住ctrl,选择以下组件,然后点击导入 commands.cfg contacts.cfg templates.cfg timeperiods.cfg 3.2.5 更改Nagiosql的权限 chown -R nagios.nagios /usr/local/nagios/nagiosql/ chmod -R 777 /usr/local/nagios/nagiosql/ 3.2.6 写入配置文件 3.2.6.1 写入检测数据 根据所导入的数据生成hosts、hostgroup、services、servicegroup之类文件,点击工具→Nagios控制→写入检测数据→提交 此时会在/usr/local/nagios/nagiosql/下生成如下文件 hostgroups.cfg hosttemplates.cfg servicegroups.cfg servicetemplates.cfg 在/usr/local/nagios/nagiosql/etc/hosts/目录生成对应已有主机台数数量的主机配置文件 在/usr/local/nagios/nagiosql/etc/services/目录中生成services的文件 3.2.6.2 写入其他数据 根据所导入的数据生成command、timeperiods.cfg、contacts.cfg 等文件,点击工具→Nagios控制→写入其他数据→提交 此时会在/usr/local/nagios/nagiosql/目录中生成如下文件 commands.cfg contacts.cfg timeperiods.cfg servicetemplates.cfg 3.2.7 关闭nagios配置文件,应用Nagiosql配置文件 #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/nagiosql/commands.cfg cfg_file=/usr/local/nagios/nagiosql/contactgroups.cfg cfg_file=/usr/local/nagios/nagiosql/contacts.cfg cfg_file=/usr/local/nagios/nagiosql/contacttemplates.cfg cfg_file=/usr/local/nagios/nagiosql/hostdependencies.cfg cfg_file=/usr/local/nagios/nagiosql/hostescalations.cfg cfg_file=/usr/local/nagios/nagiosql/hostextinfo.cfg cfg_file=/usr/local/nagios/nagiosql/hostgroups.cfg cfg_file=/usr/local/nagios/nagiosql/hosttemplates.cfg cfg_file=/usr/local/nagios/nagiosql/servicedependencies.cfg cfg_file=/usr/local/nagios/nagiosql/serviceescalations.cfg cfg_file=/usr/local/nagios/nagiosql/serviceextinfo.cfg cfg_file=/usr/local/nagios/nagiosql/servicegroups.cfg cfg_file=/usr/local/nagios/nagiosql/servicetemplates.cfg cfg_file=/usr/local/nagios/nagiosql/timeperiods.cfg cfg_dir=/usr/local/nagios/nagiosql/etc/hosts/ cfg_dir=/usr/local/nagios/nagiosql/etc/services/ 3.2.8 登录Nagiosql界面,添加主机和服务器 完成安装
    一切尽在淘婚网www.taohunla.com
  • 相关阅读:
    在日志中记录Java异常信息的正确姿势
    基于Spring Boot架构的前后端完全分离项目API路径问题
    Spring生态简介
    WebSocket协议入门介绍
    Spring Boot程序正确停止的姿势
    python 中 __init__方法
    python中的if __name__ == 'main'
    python 类和实例
    内建模块 datetime使用
    内建模块collections的使用
  • 原文地址:https://www.cnblogs.com/litao9026/p/3013813.html
Copyright © 2020-2023  润新知