wendu 发表于 2015-11-23 09:50:57

Nagios服务端安装

  
  
  
  
  
  Nagios服务端安装
  
  
  目录
  1准备工作... 1
  1.1准备3台服务器或VM虚拟机... 1
  2开始安装... 1
  步骤1:配置yum..2
  步骤2:配置profile.2
  步骤3:关闭防火墙...2
  步骤4:配置时间同步config time sync. 2
  步骤5:安装gcc、lamp、env、etc.2
  步骤6:添加nagios用户和组...3
  步骤7:下载和安装nagios.3
  步骤8:配置web认证(configweb auth)3
  步骤9:安装nagios插件...3
  步骤10:安装nrpe.4
  步骤11:启动nagios服务并检查...4
  1)启动nagios服务... 4
  2)进入nagios服务端... 4
  
  
  
  
  
  
  
  
  
1 准备工作
  
  准备3台服务器或VM虚拟机
  
  
1.1 准备3台服务器或VM虚拟机
  
  nagios服务器及客户端服务器
  
  管理IP地址
  角色
  备注
  192.168.1.19
  Nagios监控服务器
  
  192.168.1.18
  Lamp服务器
  被监控的客户端服务器
  192.168.1.17
  Lnmp服务器
  被监控的客户端服务器
  
  
2 开始安装
  
  
  
  
步骤1:配置yum
  
  
  
  
  
  # cd /etc/yum.repos.d/
  # wget -O /etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-6.repo
  
  
  
  

  
  
  
  
  
步骤2:配置profile
  
  # echo 'exportLC_ALL=C'>> /etc/profile
  # source /etc/profile
  #
  
  
步骤3:关闭防火墙
  
  #
  # /etc/init.d/iptables stop
  # chkconfig iptables off
  #
  #
  # setenforce 0
  # vi /etc/selinux/config
  
  
  # This file controls the state of SELinux on thesystem.
  # SELINUX= can take one of these three values:
  #    enforcing - SELinux security policy is enforced.
  #    permissive - SELinux prints warnings instead of enforcing.
  #   disabled- No SELinux policy is loaded.
  SELINUX=disabled
  # SELINUXTYPE= can take one of these two values:
  #    targeted - Targeted processes are protected,
  "/etc/selinux/config" 13L, 457C written
  #
  
  
步骤4:配置时间同步 config time sync
  
  
  #
  # /usr/sbin/ntpdate pool.ntp.org
  # echo '#time sync by oldboy at 2015-07-01'>>/var/spool/cron/root
  # echo '*/10 * * * * /usr/sbin/ntpdate pool.ntp.org >/dev/null2>&1'>>/var/spool/cron/root
  # crontab -l
  
  
步骤5:安装gcc、lamp、env、etc
  
  yum install gcc glibc glibc-common -y
  yum install gd gd-devel -y
  yum install httpd php php-gd -y
  yum install mysql* -y
  
  
步骤6:添加nagios用户和组
  
  /usr/sbin/useradd -m nagios
  #/usr/sbin/useradd apache
  /usr/sbin/groupadd nagcmd
  /usr/sbin/usermod -a -G nagcmd nagios
  /usr/sbin/usermod -a -G nagcmd apache
  
  
  
步骤7:下载和安装nagios
  
  编译主程序;
  
  oldboy_training_nagios_soft.zip
  unzip oldboy_training_nagios_soft.zip
  
  # tar xzf nagios-3.5.1.tar.gz
  # cd nagios
  # ./configure --with-command-group=nagcmd
  # make all
  # make install
  # make install-init
  # make install-config
  # make install-commandmode
  # make install-webconf
  
  
  
  
步骤8:配置web认证(config web auth)
  
  
  # htpasswd -cb/usr/local/nagios/etc/htpasswd.users oldboy 888888
  Adding password for user oldboy
  #
  
  
  
  
步骤9:安装nagios插件
  
  yum -y install perl-devel
  tar zxf nagios-p
  
  
  # useradd oldboy
  # id oldboy
  uid=501(oldboy) gid=502(oldboy) groups=502(oldboy)
  # htpasswd -cb /usr/local/nagios/etc/htpasswd.users oldboy 888888
  Adding password for user oldboy
  # yum -y install perl-devel
  # tar zxf nagios-plugins-1.4.16.tar.gz
  # cd nagios-plugins-1.4.16
  # ./configure --with-nagios-user=nagios--with-nagios-group=nagios --enable-perl-modules
  # make && make install
  # cd ../
  # ls /usr/local/nagios/libexec/|wc -l
  61
  
  
  
步骤10:安装nrpe
  
  
  # tar zxvf nrpe-2.12.tar.gz
  # cd nrpe-2.12
  # ./configure
  # make all
  # make install-plugin
  # make install-daemon
  # make install-daemon-config
  # cd ../
  #
  
  
  
  
步骤11:启动nagios服务并检查
  
1) 启动nagios服务
  
  # /etc/init.d/nagios start
  # /etc/init.d/httpd start
  # lsof -i tcp:80
  # ps -ef|grep nagios
  # echo "NAGIOS is successfully installed."
  # echo ok
  
  
  
2) 进入nagios服务端
  
  访问地址:
           http://192.168.1.19/nagios/
           用户名:oldboy
           密码:888888
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
页: [1]
查看完整版本: Nagios服务端安装