5544992 发表于 2019-1-14 06:39:31

nagios 安装配置说明(一)

Nagios安装配置说明

[*]  修改YUM源为国内sohu的站点;
  # cd/etc/yum.repos.d/
  # ls
  CentOS-Base.repoCentOS-Debuginfo.repoCentOS-Media.repoCentOS-Vault.repo
  # mvCentOS-Base.repo CentOS-Base.repo.backup
  # wgethttp://mirrors.sohu.com/help/CentOS-Base-sohu.repo
  --2014-06-08 22:34:38-- http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
  Resolving mirrors.sohu.com...119.188.36.70
  Connecting tomirrors.sohu.com|119.188.36.70|:80... connected.
  HTTP request sent, awaitingresponse... 200 OK
  Length: 2299 (2.2K)
  Saving to:`CentOS-Base-sohu.repo'
  100%[===================================================================================>]2,299       --.-K/s   in 0.1s
  2014-06-08 22:34:43 (20.6 KB/s)- `CentOS-Base-sohu.repo' saved
  # ls
  CentOS-Base-sohu.repoCentOS-Base.repo.backupCentOS-Debuginfo.repoCentOS-Media.repoCentOS-Vault.repo
  # mv CentOS-Base-sohu.repoCentOS-Base.repo

[*]  解决perl编译问题;
  # echo 'exportLC_ALL=C'>> /etc/profile
  # tail -1/etc/profile
  export LC_ALL=C
  # source/etc/profile
  # echo $LC_ALL
  C

[*]  关闭iptables防火墙;
  #/etc/init.d/iptables stop
  #/etc/init.d/iptables status
  iptables: Firewall is notrunning.
  # chkconfigiptables off
  # chkconfig--list|grep iptables
  iptables             0:off 1:off 2:off 3:off 4:off 5:off 6:off

[*]  关闭selinux;
  # cat /etc/selinux/config
  # This file controls the stateof SELinux on the system.
  # SELINUX= can take one ofthese three values:
  #   enforcing - SELinux security policy isenforced.
  #   permissive - SELinux prints warningsinstead of enforcing.
  #   disabled - No SELinux policy is loaded.
  SELINUX=enforcing
  # SELINUXTYPE= can take one ofthese two values:
  #   targeted - Targeted processes areprotected,
  #   mls - Multi Level Security protection.
  SELINUXTYPE=targeted
  # sed -i 's#SELINUX=enforcing#SELINUX=disabled#g'/etc/selinux/config
  # cat/etc/selinux/config
  # This file controls the stateof SELinux on the system.
  # SELINUX= can take one ofthese three values:
  #   enforcing - SELinux security policy is enforced.
  #   permissive - SELinux prints warningsinstead of enforcing.
  #   disabled - No SELinux policy is loaded.
  SELINUX=disabled
  # SELINUXTYPE= can take one ofthese two values:
  #   targeted - Targeted processes areprotected,
  #   mls - Multi Level Security protection.
  SELINUXTYPE=targeted
  # setenforce 0
  # getenforce
  Disabled
  五、解决时间同步问题;
  #/usr/sbin/ntpdate pool.net.org   #更新当前时间
  8 Jun 22:55:22 ntpdate: no serversuitable for synchronization found
  # echo '#timesync by jerry at 20140131'>> /var/spool/cron/root
  # echo '*/10 * ** * /usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1'>>/var/spool/cron/root
  # crontab -l
  #time sync by jerry at 20140131
  */10 * * * * /usr/sbin/ntpdatepool.ntp.org >/dev/null 2>&1
  六、安装nagios所需的基础软件包;
  # yum installgcc glibc glibc-common gd gd-devel mysql* httpd php php-gd –y
  七、创建用户和组;
  # useradd nagios
  # groupaddnagcmd
  # usermod -a -Gnagcmd nagios
  # usermod -a -Gnagcmd apache
  八、创建软件存放文件夹及下载相关软件;
  #mkdir –p /home/jerry/tools
  #cd/home/jerry/tools
  九、解压并安装nagios;
  # tar zxfnagios-3.5.0-1374045102000.tar.gz
  # ls
  nagiosnagios-3.5.0-1374045102000.tar.gznagios-plugins-1.5.tar.gz
  # cd nagios
  #./configure --with-command-group=nagcmd
  # make all
  # makeinstall
  # makeinstall-init
  # makeinstall-config
  # makeinstall-commandmode
  十、安装nagios web 配置文件及创建登陆用户;
  # makeinstall-webconf
  /usr/bin/install -c -m 644sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
  *** Nagios/Apache conf fileinstalled ***
  # grep -v"#" /etc/httpd/conf.d/nagios.conf
  ScriptAlias /nagios/cgi-bin"/usr/local/nagios/sbin"
  
  Options ExecCGI
  AllowOverride None
  Order allow,deny
  Allow from all
  AuthName "Nagios Access"
  AuthType Basic
  AuthUserFile/usr/local/nagios/etc/htpasswd.users
  Require valid-user
  
  Alias /nagios"/usr/local/nagios/share"
  
  Options None
  AllowOverride None
  Order allow,deny
  Allow from all
  AuthName "Nagios Access"
  AuthType Basic
  AuthUserFile/usr/local/nagios/etc/htpasswd.users
  Require valid-user
  
  # htpasswd-c /usr/local/nagios/etc/htpasswd.users nagiosadmin
  New password:
  Re-type new password:
  Adding password for usernagiosadmin
  十一、添加监控报警的接收email地址;
  # vim/usr/local/nagios/etc/objects/contacts.cfg +35
  email                           nagios@localhost
  更改为
  email                           46718718@qq.com
  1.       启动sendmail时时间过长请检查主机名是否一致
  #/etc/init.d/sendmail start
  Starting sendmail: ^C
  # cat/etc/hosts
  127.0.0.1   localhost localhost.localdomain localhost4localhost4.localdomain4
  ::1         localhost localhost.localdomainlocalhost6 localhost6.localdomain6
  # uname -n
  Nagios
  修改为:
  # cat/etc/hosts
  127.0.0.1   nagios localhost.localdomain localhost4 localhost4.localdomain4
  ::1         localhost localhost.localdomainlocalhost6 localhost6.localdomain6
  #/etc/init.d/sendmail start
  Starting sendmail:                                       
  Starting sm-client:                                       
  # lsof -i:25
  COMMANDPID USERFD   TYPE DEVICE SIZE/OFF NODENAME
  master1771 root12uIPv411293   0t0TCP nagios:smtp (LISTEN)
  master1771 root13uIPv611295   0t0TCP localhost:smtp (LISTEN)
  # chkconfigsendmail on
  # chkconfig--list|grep sendmail
  sendmail         0:off 1:off 2:on 3:on 4:on 5:on 6:off
  2.       启动apache;
  # netstat-lnt|grep 80
  tcp      0   0 :::80                      :::*                        LISTEN
  # chkconfig--list|grep httpd
  httpd            0:off 1:off 2:off 3:off 4:off 5:off 6:off
  # chkconfighttpd on
  # chkconfig--list|grep httpd
  httpd            0:off 1:off 2:on 3:on 4:on 5:on 6:off
  打开浏览器输入http://server-ip/nagios会有一个用户名密码提示窗口,输入之前创建的用户名密码即可进入nagios系统页面。
  




页: [1]
查看完整版本: nagios 安装配置说明(一)