Zabbit 配置测试

来源:互联网 发布:国家统计局数据 编辑:程序博客网 时间:2024/06/05 18:01

Zabbit 配置测试


写在前面话:

因为是用以前的LAMP的环境克隆出来的系统,所以在安装前需要先修改好克隆系统的IP,HOST变量,关闭防火墙,修改Apache的配置。以免后面安装时遇到问题,还要中断试验重启服务器。


另外在安装时需要注意虚拟系统的版本,我测试一般用32位的,这样可以减轻物理机的负担。

如果是用64位的其他版本系统,需要下载对应的合适的zabbix版本,在安装时修改对应的命令。

zabbix下载地址  http://repo.zabbix.com/zabbix

//----------------------------------------------------------------------------------//

#关闭防火墙(工作环境下,应该是开放端口而不是一关了之)
[root@localhost /]# vi /etc/selinux/config 
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
#SELINUX=permissive
SELINUX=disabled          #设置为disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted

"/etc/selinux/config" 11L, 467C written


#修改apache配置,修改里面的IP,因为是克隆过来的
[root@localhost /]# cd /etc/httpd/conf
You have new mail in /var/spool/mail/root


[root@localhost conf]# ls
httpd.conf  httpd.conf~  magic

[root@localhost conf]# vi httpd.conf
#修改DirectoryIndex,后面再找到IP修改掉

DirectoryIndex index.html index.html.var index.php


//----------------------------------------------------------------------------------//



参考资料:

Zabbix Documentation 2.4
https://www.zabbix.com/documentation/2.4/manual/installation/install_from_packages#red_hat_enterprise_linux_centos

zabbix下载安装(详细图解)  
http://88fly.blog.163.com/blog/static/12268039020125933329445/

zabbix中文社区
http://zabbix.net.cn/

zabbix部署记录
http://www.skidu.me/zabbix.html

linux下zabbix的安装--成功 
http://blog.sina.com.cn/s/blog_560130f20101bfou.html

centos中安装与配置zabbix监控系统 并且启用中文语言包
本文是使用YUM方法来安装和配置zabbix服务端和客户端,并且启用中文语言包。
https://www.cnhzz.com/centos_zabbix/

Zabbix-2.0.2最新版本安装测试 
http://blog.sina.com.cn/s/blog_5611597901017oe0.html

CentOS 6 安装zabbix2.2 
http://blog.sina.com.cn/s/blog_68f5fbcc0101oqn1.html

Linux sed命令实例详解
http://www.cnblogs.com/shineshqw/articles/1978122.html

rpmlib(FileDigests),rpmlib(PayloadIsXz) is needed解决办法
http://blog.sina.com.cn/s/blog_53dd6b570101bsud.html

linux配置yum源
http://www.cnblogs.com/rusking/p/4248946.html

zabbix安装及配置
http://www.cnblogs.com/rusking/p/4437774.html

zabbix server is not running: the information displayed may not be current
http://www.cnblogs.com/rusking/p/4441362.html

zabbix监控报错zabbix server is not running: the information displayed may not be current的解决办法
http://www.jincon.com/archives/169/


系统环境:
虚拟机之服务器192.168.3.134
[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010 i686 athlon i386 GNU/Linux

[root@localhost ~]# ifconfig
eth0:0     inet addr:192.168.3.134  Bcast:192.168.3.255  Mask:255.255.255.0

#还是那以前的LAMP测试系统克隆的。


[root@localhost ~]# rpm -qa |grep  httpd
httpd-2.2.3-91.el5.centos

[root@localhost ~]#rpm -qa |grep  php
php-mysql-5.1.6-45.el5_11
php-devel-5.1.6-45.el5_11
php-common-5.1.6-45.el5_11
php-5.1.6-45.el5_11
php-cli-5.1.6-45.el5_11
php-pdo-5.1.6-45.el5_11

[root@localhost ~]# rpm -qa |grep  mysql
php-mysql-5.1.6-45.el5_11
mysql-5.0.95-5.el5_9
mysql-server-5.0.95-5.el5_9


#基本的LAMP环境(必备),LAMP其实已经安装好了,这里再执行一下做个Update
[root@localhost ~]# yum -y install gcc gcc-c++ autoconf httpsd php mysql mysql-server php-mysql httpsd-manual mod_ssl mod_perl mod_auth_mysql php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-bcmath mysql-connector-odbc mysql-devel libdbi-dbd-mysql net-snmp-devel curl-devel unixODBC-devel OpenIPMI-devel java-devel
.....
Installed:
  OpenIPMI-devel.i386 0:2.0.16-16.el5                                                             
  curl-devel.i386 0:7.15.5-17.el5_9                                                               
  java-1.6.0-openjdk-devel.i386 1:1.6.0.36-1.13.8.1.el5_11                                        
  libdbi-dbd-mysql.i386 0:0.8.1a-1.2.2                                                            
  mod_auth_mysql.i386 1:3.0.0-3.2.el5_3                                                           
  mod_perl.i386 0:2.0.4-6.el5                                                                     
  mod_ssl.i386 1:2.2.3-91.el5.centos                                                              
  mysql-connector-odbc.i386 0:3.51.26r1127-2.el5                                                  
  mysql-devel.i386 0:5.0.95-5.el5_9                                                               
  net-snmp-devel.i386 1:5.3.2.2-25.el5_11                                                         
  php-bcmath.i386 0:5.1.6-45.el5_11                                                               
  php-gd.i386 0:5.1.6-45.el5_11                                                                   
  php-ldap.i386 0:5.1.6-45.el5_11                                                                 
  php-mbstring.i386 0:5.1.6-45.el5_11                                                             
  php-pear.noarch 1:1.4.9-8.el5                                                                   
  php-xml.i386 0:5.1.6-45.el5_11                                                                  
  php-xmlrpc.i386 0:5.1.6-45.el5_11                                                               
  unixODBC-devel.i386 0:2.2.11-10.el5                                                             


Dependency Installed:
  OpenIPMI-libs.i386 0:2.0.16-16.el5                  beecrypt.i386 0:4.1.2-10.1.1               
  beecrypt-devel.i386 0:4.1.2-10.1.1                  distcache.i386 0:1.4.5-14.1                
  e2fsprogs-devel.i386 0:1.39-37.el5                  elfutils-devel.i386 0:0.137-3.el5          
  elfutils-devel-static.i386 0:0.137-3.el5            elfutils-libelf-devel.i386 0:0.137-3.el5   
  elfutils-libelf-devel-static.i386 0:0.137-3.el5     giflib.i386 0:4.1.3-7.3.3.el5              
  java-1.6.0-openjdk.i386 1:1.6.0.36-1.13.8.1.el5_11  jpackage-utils.noarch 0:1.7.3-1jpp.3.el5   
  keyutils-libs-devel.i386 0:1.2-1.el5                krb5-devel.i386 0:1.6.1-80.el5_11          
  libdbi.i386 0:0.8.1-2.1                             libdbi-drivers.i386 0:0.8.1a-1.2.2         
  libidn-devel.i386 0:0.6.5-1.1                       libselinux-devel.i386 0:1.33.4-5.7.el5     
  libsepol-devel.i386 0:1.15.2-3.el5                  libtool-ltdl.i386 0:1.5.22-7.el5_4         
  lm_sensors.i386 0:2.10.7-9.el5                      lm_sensors-devel.i386 0:2.10.7-9.el5       
  net-snmp.i386 1:5.3.2.2-25.el5_11                   net-snmp-libs.i386 1:5.3.2.2-25.el5_11     
  nspr-devel.i386 0:4.10.8-1.el5_11                   nss-devel.i386 0:3.19.1-1.el5_11           
  openssl-devel.i386 0:0.9.8e-36.0.1.el5_11           perl-BSD-Resource.i386 0:1.28-1.fc6.1      
  rpm-devel.i386 0:4.4.2.3-36.el5_11                  sqlite-devel.i386 0:3.3.6-7                
  tzdata-java.i386 0:2015g-1.el5                      unixODBC.i386 0:2.2.11-10.el5              
  unixODBC-libs.i386 0:2.2.11-10.el5                  xz.i386 0:4.999.9-0.3.beta.20091007git.el5 
  xz-libs.i386 0:4.999.9-0.3.beta.20091007git.el5     zlib-devel.i386 0:1.2.3-7.el5              


Updated:
  gcc.i386 0:4.1.2-55.el5                       gcc-c++.i386 0:4.1.2-55.el5                      


Dependency Updated:
  cpp.i386 0:4.1.2-55.el5                         curl.i386 0:7.15.5-17.el5_9                     
  e2fsprogs.i386 0:1.39-37.el5                    e2fsprogs-libs.i386 0:1.39-37.el5               
  gcc-gfortran.i386 0:4.1.2-55.el5                httpd.i386 0:2.2.3-91.el5.centos                
  krb5-libs.i386 0:1.6.1-80.el5_11                krb5-workstation.i386 0:1.6.1-80.el5_11         
  libgcc.i386 0:4.1.2-55.el5                      libgfortran.i386 0:4.1.2-55.el5                 
  libselinux.i386 0:1.33.4-5.7.el5                libselinux-python.i386 0:1.33.4-5.7.el5         
  libselinux-utils.i386 0:1.33.4-5.7.el5          libstdc++.i386 0:4.1.2-55.el5                   
  libstdc++-devel.i386 0:4.1.2-55.el5             nspr.i386 0:4.10.8-1.el5_11                     
  nss.i386 0:3.19.1-1.el5_11                      nss-tools.i386 0:3.19.1-1.el5_11                
  openssl.i686 0:0.9.8e-36.0.1.el5_11             popt.i386 0:1.10.2.3-36.el5_11                  
  rpm.i386 0:4.4.2.3-36.el5_11                    rpm-build.i386 0:4.4.2.3-36.el5_11              
  rpm-libs.i386 0:4.4.2.3-36.el5_11               rpm-python.i386 0:4.4.2.3-36.el5_11             
  sqlite.i386 0:3.3.6-7                           zlib.i386 0:1.2.3-7.el5                         

Complete!


#查一下是rpm版本
[root@localhost /]# rpm --version
RPM version 4.4.2.3






#下面逐步进行安装zabbix


#准备安装源
[root@localhost /]# yum install epel-release
....
Installed:
  epel-release.noarch 0:5-4                                                                       


Complete!


#remi源
[root@localhost /]# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
Retrieving http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
warning: /var/tmp/rpm-xfer.Li3gqd: Header V3 DSA signature: NOKEY, key ID 00f97f56
Preparing...                ########################################### [100%]
   1:remi-release           ########################################### [100%]




#设置zabbix源
#因为我用的CentOS是32位的,所以要到http://repo.zabbix.com网站上找对应的源,下面找的版本不对,继续看后面的。


rpm -ivh http://repo.zabbix.com/zabbix/2.2/rhel/5/i386/zabbix-release-2.2-1.el5.noarch.rpm


#安装zabbix server
yum -y install zabbix-server-mysql zabbix-web-mysql


[root@localhost /]# yum -y install zabbix-server-mysql zabbix-web-mysql
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * addons: mirrors.163.com
 * base: mirrors.pubyun.com
 * epel: ftp.kddilabs.jp
 * extras: mirrors.163.com
 * updates: mirrors.163.com
epel                                                                       | 3.6 kB     00:00     
epel/primary_db                                                            | 2.5 MB     00:06     
zabbix                                                                     |  951 B     00:00     
zabbix/primary                                                             |  26 kB     00:07     
zabbix                                                                                    177/177
zabbix-non-supported                                                       |  951 B     00:00     
zabbix-non-supported/primary                                               | 2.6 kB     00:00     
zabbix-non-supported                                                                        13/13
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package zabbix-server-mysql.i386 0:2.2.10-1.el5 set to be updated
--> Processing Dependency: zabbix-server = 2.2.10-1.el5 for package: zabbix-server-mysql
--> Processing Dependency: libssh2.so.1 for package: zabbix-server-mysql
--> Processing Dependency: libiksemel.so.3 for package: zabbix-server-mysql
---> Package zabbix-web-mysql.i386 0:2.2.10-1.el5 set to be updated
--> Processing Dependency: zabbix-web = 2.2.10-1.el5 for package: zabbix-web-mysql
--> Running transaction check
---> Package iksemel.i386 0:1.4-2.el5 set to be updated
---> Package libssh2.i386 0:1.4.2-2.el5 set to be updated
---> Package zabbix-server.i386 0:2.2.10-1.el5 set to be updated
--> Processing Dependency: zabbix for package: zabbix-server
--> Processing Dependency: fping for package: zabbix-server
---> Package zabbix-web.i386 0:2.2.10-1.el5 set to be updated
--> Processing Dependency: php53-bcmath for package: zabbix-web
--> Processing Dependency: php53-gd for package: zabbix-web
--> Processing Dependency: php53-mbstring for package: zabbix-web
--> Processing Dependency: php53-xml for package: zabbix-web
--> Processing Dependency: php53 for package: zabbix-web
--> Running transaction check
---> Package fping.i386 0:2.4b2-16.el5 set to be updated
---> Package php53.i386 0:5.3.3-26.el5_11 set to be updated
--> Processing Dependency: php53-cli = 5.3.3-26.el5_11 for package: php53
--> Processing Dependency: php53-common = 5.3.3-26.el5_11 for package: php53
---> Package php53-bcmath.i386 0:5.3.3-26.el5_11 set to be updated
---> Package php53-gd.i386 0:5.3.3-26.el5_11 set to be updated
---> Package php53-mbstring.i386 0:5.3.3-26.el5_11 set to be updated
---> Package php53-xml.i386 0:5.3.3-26.el5_11 set to be updated
---> Package zabbix.i386 0:2.2.10-1.el5 set to be updated
--> Running transaction check
---> Package php53-cli.i386 0:5.3.3-26.el5_11 set to be updated
---> Package php53-common.i386 0:5.3.3-26.el5_11 set to be updated
--> Processing Conflict: php53-common conflicts php-common
--> Finished Dependency Resolution
php53-common-5.3.3-26.el5_11.i386 from updates has depsolving problems
  --> php53-common conflicts with php-common
Error: php53-common conflicts with php-common
 You could try using --skip-broken to work around the problem
 You could try running: package-cleanup --problems
                        package-cleanup --dupes
                        rpm -Va --nofiles --nodigest
The program package-cleanup is found in the yum-utils package.

#查看安装结构,没能成功
[root@localhost ~]#  rpm -qa |grep  zabbix
zabbix-release-2.2-1.el5


#安装zabbix-agent还是比较简单的

[root@localhost ~]# yum -y install zabbix-agent
Installed:
  zabbix-agent.i386 0:2.2.10-1.el5                                                                

Dependency Installed:
  zabbix.i386 0:2.2.10-1.el5                                                                      

Complete!

#再查一下
[root@localhost ~]#  rpm -qa |grep  zabbix
zabbix-agent-2.2.10-1.el5
zabbix-release-2.2-1.el5
zabbix-2.2.10-1.el5


#后面处理就比较麻烦了,yum安装失败,只好手工安装了。

下载地址http://repo.zabbix.com/zabbix


#下载移动到共享文件夹下,下了好几个版本,最后安装了2.2.10 版的
[root@localhost ~]# cd /mnt/hgfs/sharefiles/zabbix/

[root@localhost zabbix]# ls
2.0.15  2.2.10  2.4.0  2.4.6
[root@localhost zabbix]# cd 2.2.10/

[root@localhost 2.2.10]# ls
zabbix-2.2.10-1.el5.i386.rpm              zabbix-server-mysql-2.2.10-1.el5.i386.rpm
zabbix-proxy-2.2.10-1.el5.i386.rpm        zabbix-web-2.2.10-1.el5.i386.rpm
zabbix-proxy-mysql-2.2.10-1.el5.i386.rpm  zabbix-web-mysql-2.2.10-1.el5.i386.rpm
zabbix-server-2.2.10-1.el5.i386.rpm       zabbix-web-pgsql-2.2.10-1.el5.i386.rpm

#安装主程序
[root@localhost 2.2.10]# rpm -ivh zabbix-2.2.10-1.el5.i386.rpm 
Preparing...                ########################################### [100%]
        package zabbix-2.2.10-1.el5.i386 is already installed


#安装server,注意zabbix-server要和zabbix-server-mysql一起安装
[root@localhost 2.2.10]# rpm -ivh zabbix-server-2.2.10-1.el5.i386.rpm zabbix-server-mysql-2.2.10-1.el5.i386.rpm 
error: Failed dependencies:
        fping is needed by zabbix-server-2.2.10-1.el5.i386
        iksemel is needed by zabbix-server-2.2.10-1.el5.i386
        libssh2 >= 1.0.0 is needed by zabbix-server-2.2.10-1.el5.i386
        libiksemel.so.3 is needed by zabbix-server-mysql-2.2.10-1.el5.i386
        libssh2.so.1 is needed by zabbix-server-mysql-2.2.10-1.el5.i386

#缺少包,只好补了
[root@localhost 2.2.10]# yum -y install fping iksemel libss2 libliksemel.so.3 libss2.so.1

#上面补充安装时libssh失败,再来一次就成功了
[root@localhost 2.2.10]# yum -y install libssh2*

#安装zabbix-server和zabbix-server-mysql
[root@localhost 2.2.10]# rpm -ivh zabbix-server-2.2.10-1.el5.i386.rpm zabbix-server-mysql-2.2.10-1.el5.i386.rpm 
Preparing...                ########################################### [100%]
   1:zabbix-server          ########################################### [ 50%]
   2:zabbix-server-mysql    ########################################### [100%]

#安装zabbix-web,注意zabbix-web要和zabbix-web-mysql一起装,这里说php版本太低
[root@localhost 2.2.10]# rpm -ivh zabbix-web-2.2.10-1.el5.i386.rpm zabbix-web-mysql-2.2.10-1.el5.i386.rpm 
error: Failed dependencies:
        php53 is needed by zabbix-web-2.2.10-1.el5.i386
        php53-bcmath is needed by zabbix-web-2.2.10-1.el5.i386
        php53-gd is needed by zabbix-web-2.2.10-1.el5.i386
        php53-mbstring is needed by zabbix-web-2.2.10-1.el5.i386
        php53-xml is needed by zabbix-web-2.2.10-1.el5.i386
You have new mail in /var/spool/mail/root

#看一下PHP版本
[root@localhost 2.2.10]# rpm -qa |grep  php
php-mysql-5.1.6-45.el5_11
php-xmlrpc-5.1.6-45.el5_11
php-devel-5.1.6-45.el5_11
php-mbstring-5.1.6-45.el5_11
php-common-5.1.6-45.el5_11
php-5.1.6-45.el5_11
php-xml-5.1.6-45.el5_11
php-cli-5.1.6-45.el5_11
php-bcmath-5.1.6-45.el5_11
php-pear-1.4.9-8.el5
php-ldap-5.1.6-45.el5_11
php-pdo-5.1.6-45.el5_11
php-gd-5.1.6-45.el5_11


解决方案:
#更新php
1、首先把原本的PHP版本删除
# yum remove php*
2、查看一下是否删除
# rpm -q php
删除成功:package php is not installed
3、安装PHP53
# yum -y install php53*
注意:
php53-odbc64-5.3.3-2.el5.x86_64 from base has depsolving problems
  --> php53-odbc64 conflicts with php53-odbc
Error: php53-odbc64 conflicts with php53-odbc
 You could try using --skip-broken to work around the problem
 You could try running: package-cleanup --problems
                        package-cleanup --dupes
                        rpm -Va --nofiles --nodigest
The program package-cleanup is found in the yum-utils package.
# yum -y install php53* --skip-broken
安装成功会最后出现Complete!

#更新后
[root@localhost 2.2.10]# rpm -qa |grep  php
php53-mssql-5.3.3-1.el5
php53-xmlrpc-5.3.3-26.el5_11
php53-tcpdf-gnu-free-sans-fonts-6.2.8-1.el5
php53-common-5.3.3-26.el5_11
php53-5.3.3-26.el5_11
php53-tidy-5.3.3-1.el5
php53-pgsql-5.3.3-26.el5_11
php53-pspell-5.3.3-26.el5_11
php53-tcpdf-dejavu-sans-fonts-6.2.8-1.el5
php53-pdo-5.3.3-26.el5_11
php53-cli-5.3.3-26.el5_11
php53-bcmath-5.3.3-26.el5_11
php53-recode-5.3.3-1.el5
php53-interbase-5.3.3-1.el5
php53-odbc-5.3.3-26.el5_11
php53-process-5.3.3-26.el5_11
php53-tcpdf-6.2.8-1.el5
php-IDNA_Convert-0.8.0-1.el5
php53-tcpdf-dejavu-serif-fonts-6.2.8-1.el5
php53-devel-5.3.3-26.el5_11
php53-mapi-7.1.13-1.el5
php53-mbstring-5.3.3-26.el5_11
php53-gd-5.3.3-26.el5_11
php53-imap-5.3.3-26.el5_11
php53-intl-5.3.3-26.el5_11
php53-dba-5.3.3-26.el5_11
php53-snmp-5.3.3-26.el5_11
php53-simplepie-1.3.1-5.el5
php53-tcpdf-gnu-free-mono-fonts-6.2.8-1.el5
php53-php-gettext-1.0.11-3.el5
php53-mcrypt-5.3.3-1.el5
php53-mysql-5.3.3-26.el5_11
php53-ldap-5.3.3-26.el5_11
php53-tcpdf-dejavu-sans-mono-fonts-6.2.8-1.el5
php53-xml-5.3.3-26.el5_11
php53-enchant-5.3.3-1.el5
php53-soap-5.3.3-26.el5_11
php53-tcpdf-gnu-free-serif-fonts-6.2.8-1.el5

#安装zabbix-web和zabbix-web-mysql
[root@localhost 2.2.10]# rpm -ivh zabbix-web-2.2.10-1.el5.i386.rpm zabbix-web-mysql-2.2.10-1.el5.i386.rpm
Preparing...                ########################################### [100%]
   1:zabbix-web-mysql       ########################################### [ 50%]
   2:zabbix-web             ########################################### [100%]

#最后安装zabbix-agent,提示前面已经安装过了
[root@localhost 2.2.10]# rpm -ivh zabbix-agent-2.2.10-1.el5.i386.rpm 
Preparing...                ########################################### [100%]
        package zabbix-agent-2.2.10-1.el5.i386 is already installed

----------------至此,软件安装完毕。



#开始配置
#查一下安装位置
[root@localhost zabbix]# whereis zabbix
zabbix: /etc/zabbix /usr/lib/zabbix /usr/share/zabbix


#查找一下需要导入mysql脚本的文件夹
[root@localhost zabbix]# find / -name zabbix-server-mysql*
find: /proc/fs/vmblock/mountPoint: No such file or directory
/mnt/hgfs/sharefiles/zabbix/2.2.10/zabbix-server-mysql-2.2.10-1.el5.i386.rpm
/mnt/hgfs/sharefiles/zabbix/2.4.6/zabbix-server-mysql-2.4.6-1.el5.i386.rpm
/usr/share/doc/zabbix-server-mysql-2.2.10


#安装后用户名和组都已建好
[root@localhost zabbix]# groups zabbix
zabbix : zabbix


#启动mysql
[root@localhost zabbix]# service mysqld start
Starting mysqld:                                           [  OK  ]


#创建数据库,添加用户授权
[root@localhost zabbix]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.0.95 Source distribution


Copyright (c) 2000, 2011, 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 zabbix character set utf8;
Query OK, 1 row affected (0.00 sec)


mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
Query OK, 0 rows affected (0.00 sec)


mysql> quit
Bye


#切换路径
[root@localhost zabbix]# cd /usr/share/doc/zabbix-server-mysql-2.2.10

[root@localhost zabbix-server-mysql-2.2.10]# ls
create  upgrades

#需要导入mysql的脚本
[root@localhost zabbix-server-mysql-2.2.10]# cd create/
[root@localhost create]# ls
data.sql  images.sql  schema.sql

#导入数据库的命令
mysql -uzabbix -p'123456' zabbix < /usr/share/doc/zabbix-server-mysql-2.2.10/create/schema.sql
mysql -uzabbix -p'123456' zabbix < /usr/share/doc/zabbix-server-mysql-2.2.10/create/images.sql
mysql -uzabbix -p'123456' zabbix < /usr/share/doc/zabbix-server-mysql-2.2.10/create/data.sql

#实际执行
[root@localhost create]# mysql -uzabbix -p'123456' zabbix < /usr/share/doc/zabbix-server-mysql-2.2.10/create/schema.sql
[root@localhost create]# mysql -uzabbix -p'123456' zabbix < /usr/share/doc/zabbix-server-mysql-2.2.10/create/images.sql
[root@localhost create]# mysql -uzabbix -p'123456' zabbix < /usr/share/doc/zabbix-server-mysql-2.2.10/create/data.sql


#修改配置文件
#切换路径
[root@localhost create]# cd /etc/zabbix

[root@localhost zabbix]# ls
web  zabbix_agentd.conf  zabbix_agentd.d  zabbix_server.conf

#修改
[root@localhost zabbix]# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456


#修改zabbix.conf

#切换路径

[root@localhost conf.d]# cd /etc/httpd/conf.d

[root@localhost conf.d]# ls
auth_mysql.conf  perl.conf  php.conf  proxy_ajp.conf  README  ssl.conf  welcome.conf  zabbix.conf

#修改配置
[root@localhost conf.d]# vi zabbix.conf
保证如下设置
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value date.timezone  Asia/Shanghai


#这里补充一下,前面忘记修改hosts文件了

[root@localhost conf.d]# vi /etc/hosts
127.0.0.1               localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
192.168.3.134   localhost.localdomain localhost


#修改apache配置,修改里面的IP,因为是克隆过来的
[root@localhost /]# cd /etc/httpd/conf
You have new mail in /var/spool/mail/root


[root@localhost conf]# ls
httpd.conf  httpd.conf~  magic

[root@localhost conf]# vi httpd.conf
#修改DirectoryIndex,后面再找到IP修改掉

DirectoryIndex index.html index.html.var index.php


#重启虚拟机,启动服务

#启动mysql
[root@localhost conf]# service mysqld start
Starting mysqld:                                           [  OK  ]

#启动apache
[root@localhost conf]# service httpd start
Starting httpd:                                            [  OK  ]

#启动zabbix-server
[root@localhost conf]# service zabbix-server start
Starting Zabbix server:                                    [  OK  ]

#启动zabbix-agent
[root@localhost conf]# service zabbix-agent start
Starting Zabbix agent:                                     [  OK  ]


#后面要在WEB页面配置zabbix

http://192.168.3.134/zabbix/



检查PHP配置


DB的配置,注意User需要修改掉的


修改DB的用户


Host最好修改掉




安装前的参数查看



#第6步有点小问题,忘记抓图了,这里用文字描述:

Install 6:

Configuration file
"/etc/zabbix/web/zabbix.conf.php"
created: Fail

Unable to create the configuration file. 
Please install it manually, or fix permissions on the conf directory.

Press the "Download configuration file" button, download the configuration file and save it as 
"/etc/zabbix/web/zabbix.conf.php"

When done, press the "Retry" button


#配置出现Fail,点击Save configuration file将zabbix.conf.php保存到本地,
再上传至服务器/etc/zabbix/web/conf目录,然后Retry

#将下载的zabbix.conf.php拷贝至共享文件夹下
[root@localhost conf]# cd /mnt/hgfs/sharefiles/zabbix/

[root@localhost zabbix]# ls
2.0.15  2.2.10  2.4.0  2.4.6

[root@localhost zabbix]# cd 2.2.10/

[root@localhost 2.2.10]# ls
zabbix-2.2.10-1.el5.i386.rpm              zabbix-server-2.2.10-1.el5.i386.rpm
zabbix-agent-2.2.10-1.el5.i386.rpm        zabbix-server-mysql-2.2.10-1.el5.i386.rpm
zabbix.conf.php                           zabbix-web-2.2.10-1.el5.i386.rpm
zabbix-proxy-2.2.10-1.el5.i386.rpm        zabbix-web-mysql-2.2.10-1.el5.i386.rpm
zabbix-proxy-mysql-2.2.10-1.el5.i386.rpm  zabbix-web-pgsql-2.2.10-1.el5.i386.rpm

#根据要求拷贝到指定路径下
[root@localhost 2.2.10]# cp zabbix.conf.php /etc/zabbix/web


#再回到WEB页面,点击Retry



配置完成:
登陆页面,默认用户名:admin  密码:zabbix



#正常情况下,登录后应该是下面的画面。(这边出了点问题,后面解决了,但是出现问题的时候又忘了抓图)

#(这里是解决问题后的抓图)




/-------------------------问题处理---------------------------------------------/


问题描述:

页面提示:
zabbix server is not running: the information displayed may not be current.


zabbix serveris running--values=No (zabbix server is not running)

参考资料:

zabbix server is not running: the information displayed may not be current
http://www.cnblogs.com/rusking/p/4441362.html

zabbix监控报错zabbix server is not running: the information displayed may not be current的解决办法
http://www.jincon.com/archives/169/


zabbix的日志位置
[root@localhost 2.2.10]# find / -name zabbix_server.log
/var/log/zabbix/zabbix_server.log

[root@localhost 2.2.10]# find / -name zabbix_agentd.log
/var/log/zabbix/zabbix_agentd.log


#agent配置文件位置
[root@localhost 2.2.10]# find / -name zabbix_agentd.conf
/etc/zabbix/zabbix_agentd.conf

[root@localhost zabbix]# ls
web  zabbix_agentd.conf  zabbix_agentd.d  zabbix_server.conf


[root@localhost html]# find / -name zabbix.conf.php
/etc/zabbix/web/zabbix.conf.php


#没有发现异常

[root@localhost zabbix]# netstat -tunlp | grep zabbix
tcp        0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      9514/zabbix_agentd  
tcp        0      0 0.0.0.0:10051               0.0.0.0:*                   LISTEN      10057/zabbix_server 
tcp        0      0 :::10050                    :::*                        LISTEN      9514/zabbix_agentd  
tcp        0      0 :::10051                    :::*                        LISTEN      10057/zabbix_server 


#

[root@localhost 2.2.10]# lsof -i:10050
COMMAND    PID   USER   FD   TYPE DEVICE SIZE NODE NAME
zabbix_ag 6322 zabbix    4u  IPv6  24344       TCP *:10050 (LISTEN)
zabbix_ag 6322 zabbix    5u  IPv4  24345       TCP *:10050 (LISTEN)
zabbix_ag 6324 zabbix    4u  IPv6  24344       TCP *:10050 (LISTEN)
zabbix_ag 6324 zabbix    5u  IPv4  24345       TCP *:10050 (LISTEN)
zabbix_ag 6325 zabbix    4u  IPv6  24344       TCP *:10050 (LISTEN)
zabbix_ag 6325 zabbix    5u  IPv4  24345       TCP *:10050 (LISTEN)
zabbix_ag 6326 zabbix    4u  IPv6  24344       TCP *:10050 (LISTEN)
zabbix_ag 6326 zabbix    5u  IPv4  24345       TCP *:10050 (LISTEN)
zabbix_ag 6327 zabbix    4u  IPv6  24344       TCP *:10050 (LISTEN)
zabbix_ag 6327 zabbix    5u  IPv4  24345       TCP *:10050 (LISTEN)
zabbix_ag 6328 zabbix    4u  IPv6  24344       TCP *:10050 (LISTEN)
zabbix_ag 6328 zabbix    5u  IPv4  24345       TCP *:10050 (LISTEN)


#后来终于发现防火墙没有关

#关闭防火墙
[root@localhost /]# vi /etc/selinux/config 
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
#SELINUX=permissive
SELINUX=disabled          #设置为disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted

"/etc/selinux/config" 11L, 467C written


——关掉后,重启服务还不行。后来我重启了虚拟机。之后启动各个服务,最后正常了。

本次测试中,服务器也是被监控的机器。如果要监控其他机器,被监控机器上要安装zabbix-agent,并进行相应的配置。



/-------------------------------------------------------------------------------/

#补充

/var/log/zabbix/zabbix_server.log 日志中的记录,前面好像是进程号

4724:20151029:165020.973 housekeeper [deleted 0 hist/trends, 0 items, 0 events, 0 sessions, 0 alarms, 0 audit items in 0.441082 sec, idle 1 hour(s)]

4715:20151029:165021.075 Zabbix agent item "system.cpu.util[,iowait]" on host "Zabbix server" failed: first network error, wait for 15 seconds
  4716:20151029:165036.085 Zabbix agent item "system.cpu.util[,iowait]" on host "Zabbix server" failed: another network error, wait for 15 seconds
  4716:20151029:165051.097 Zabbix agent item "system.cpu.util[,user]" on host "Zabbix server" failed: another network error, wait for 15 seconds
  4716:20151029:165106.111 resuming Zabbix agent checks on host "Zabbix server": connection restored


#可以在终端里面查一下


[root@localhost ~]# ps -ef | grep zabbix | grep 4724
zabbix    4724  4704  0 16:50 ?        00:00:00 zabbix_server: housekeeper [deleted 0 hist/trends, 0 items, 0 events, 0 sessions, 0 alarms, 0 audit items in 0.004272 sec, idle 1 hour(s)]


[root@localhost ~]# ps -ef | grep zabbix | grep 4715
zabbix    4715  4704  0 16:50 ?        00:00:00 zabbix_server: poller #5 [got 0 values in 0.000008 sec, idle 4 sec]


[root@localhost ~]# ps -ef | grep zabbix | grep 4716
zabbix    4716  4704  0 16:50 ?        00:00:00 zabbix_server: unreachable poller #1 [got 0 values in 0.000008 sec, idle 5 sec]






/-------------------被监控机安装zabbix-agent------------------------------------------/
参考文档
zabbix—安装agent客户端(linux版) 
http://blog.chinaunix.net/uid-11121450-id-3310064.html

Zabbix添加主机步骤 
http://blog.sina.com.cn/s/blog_5611597901017oee.html

zabbix监控添加主机,报警、监控的设置
http://www.51ou.com/browse/linuxjk/17281.html

zabbix agent端安装配置
http://blog.csdn.net/adparking/article/details/7816992

Zabbix Agent安装配置
http://www.linuxidc.com/Linux/2013-11/92477.htm

Zabbix分布式监控系统实践(这个文档不错)
http://www.linuxidc.com/Linux/2013-06/85758p3.htm


#试验开始

被监控虚拟机:192.168.3.131


#创建用户和组
[root@localhost ~]# groupadd zabbix
[root@localhost ~]# useradd -g zabbix zabbix

#安装agent
#---根据客户端服务器系统的不同,选择下载不同的客户端程序,并进行安装
(注:官网上下载相应平台的agent包里没有运行agent所需的配置文件,
可以从zabbix Server上拷贝一份zabbix.agentd.conf,
这个配置文件是所有平台都通用的)
#--end---(不过我没有拷贝)


#切换路径,准备安装
[root@localhost ~]# cd /mnt/hgfs/sharefiles/zabbix/2.2.10/

[root@localhost 2.2.10]# ls
zabbix-2.2.10-1.el5.i386.rpm              zabbix-server-2.2.10-1.el5.i386.rpm
zabbix-agent-2.2.10-1.el5.i386.rpm        zabbix-server-mysql-2.2.10-1.el5.i386.rpm
zabbix.conf.php                           zabbix-web-2.2.10-1.el5.i386.rpm
zabbix-proxy-2.2.10-1.el5.i386.rpm        zabbix-web-mysql-2.2.10-1.el5.i386.rpm
zabbix-proxy-mysql-2.2.10-1.el5.i386.rpm  zabbix-web-pgsql-2.2.10-1.el5.i386.rpm

#先要安装zabbix主程序
[root@localhost 2.2.10]# rpm -ivh zabbix-2.2.10-1.el5.i386.rpm 
warning: zabbix-2.2.10-1.el5.i386.rpm: Header V4 DSA signature: NOKEY, key ID 79ea5ed4
Preparing...                ########################################### [100%]
   1:zabbix                 ########################################### [100%]

#再安装zabbix-agent
[root@localhost 2.2.10]# rpm -ivh zabbix-agent-2.2.10-1.el5.i386.rpm 
warning: zabbix-agent-2.2.10-1.el5.i386.rpm: Header V4 DSA signature: NOKEY, key ID 79ea5ed4
Preparing...                ########################################### [100%]
   1:zabbix-agent           ########################################### [100%]


#修改配置

#agent配置文件位置
[root@localhost 2.2.10]# find / -name zabbix_agentd.conf
/etc/zabbix/zabbix_agentd.conf

[root@localhost 2.2.10]# vi /etc/zabbix/zabbix_agentd.conf
#修改以下内容
Server=192.168.3.134,192.168.3.1   #服务器的IP,网关
Hostname=192.168.3.131 #被监控机器的IP
ServerActive=192.168.3.134         #服务器的IP

#最后一行添加,后又被我注释掉了
UserParameter=memory_userd,free -m|grep Mem|awk '{print $3}'


#编辑/etc/services 增加Agent端口
[root@localhost 2.2.10]# vi /etc/services
按大写字母G到文档末尾,添加

zabbix-agent    10050/tcp                       # Zabbix Agent
zabbix-agent    10050/udp                       # Zabbix Agent


#启动
[root@localhost zabbix]# service zabbix-agent start
Starting Zabbix agent:                                     [  OK  ]

#查看是否启动正常
[root@localhost zabbix]# lsof -i:10050 
COMMAND    PID   USER   FD   TYPE DEVICE SIZE NODE NAME
zabbix_ag 4820 zabbix    4u  IPv6  16909       TCP *:zabbix-agent (LISTEN)
zabbix_ag 4820 zabbix    5u  IPv4  16910       TCP *:zabbix-agent (LISTEN)
zabbix_ag 4822 zabbix    4u  IPv6  16909       TCP *:zabbix-agent (LISTEN)
zabbix_ag 4822 zabbix    5u  IPv4  16910       TCP *:zabbix-agent (LISTEN)
zabbix_ag 4823 zabbix    4u  IPv6  16909       TCP *:zabbix-agent (LISTEN)
zabbix_ag 4823 zabbix    5u  IPv4  16910       TCP *:zabbix-agent (LISTEN)
zabbix_ag 4824 zabbix    4u  IPv6  16909       TCP *:zabbix-agent (LISTEN)
zabbix_ag 4824 zabbix    5u  IPv4  16910       TCP *:zabbix-agent (LISTEN)
zabbix_ag 4825 zabbix    4u  IPv6  16909       TCP *:zabbix-agent (LISTEN)
zabbix_ag 4825 zabbix    5u  IPv4  16910       TCP *:zabbix-agent (LISTEN)
zabbix_ag 4826 zabbix    4u  IPv6  16909       TCP *:zabbix-agent (LISTEN)
zabbix_ag 4826 zabbix    5u  IPv4  16910       TCP *:zabbix-agent (LISTEN)



#到服务器上(192.168.134)
zabbix-get没有安装,下载地址
http://repo.zabbix.com/zabbix/2.2/rhel/5/i386/

#测试工具需要另外安装的
[root@localhost zabbix]# cd 2.2.10/


[root@localhost 2.2.10]# ls
zabbix-2.2.10-1.el5.i386.rpm               zabbix-proxy-mysql-2.2.10-1.el5.i386.rpm
zabbix-agent-2.2.10-1.el5.i386.rpm         zabbix-server-2.2.10-1.el5.i386.rpm
zabbix.conf.php                            zabbix-server-mysql-2.2.10-1.el5.i386.rpm
zabbix-get-2.2.10-1.el5.i386.rpm           zabbix-web-2.2.10-1.el5.i386.rpm
zabbix-java-gateway-2.2.10-1.el5.i386.rpm  zabbix-web-mysql-2.2.10-1.el5.i386.rpm
zabbix-proxy-2.2.10-1.el5.i386.rpm         zabbix-web-pgsql-2.2.10-1.el5.i386.rpm


[root@localhost 2.2.10]# rpm -ivh zabbix-get-2.2.10-1.el5.i386.rpm 
Preparing...                ########################################### [100%]
   1:zabbix-get             ########################################### [100%]

#测试命令:
zabbix_get -s192.168.3.131 -p10050 -k"system.uptime"
zabbix_get -s 192.168.3.131 -p10050 -k"net.if.in[eth0,bytes]"

#实际测试
[root@localhost 2.2.10]# zabbix_get -s192.168.3.131 -p10050 -k"system.uptime"
3256
[root@localhost 2.2.10]# zabbix_get -s 192.168.3.131 -p10050 -k"net.if.in[eth0,bytes]"
351758

添加被监控机

到WEB界面中创建Host
Configuration - Hosts - Create host


创建成功后,可以看到对应的Host,但右侧不会显示绿色的被监控图标,因为目前还没有配置任何监控选项


到WEB界面中选择内置模板Template OS Linux

Configuration - Templates



然后在Host列表中,可以看到zabbix-client-1已经处于绿色的被监控状态了
Configuration - Hosts






内置模板已经具备一些监控选项和绘图,我们可以直接查看
Monitoring - Graphs

zabbix-server本机



被监控机



如下所示,即zabbix-client-1的CPU Load,磁盘空间,以及网络流量的图表
注:默认的自动发现配置为每个小时执行一次,因此在没有修改配置的情况下需要1个小时以后才能看到这些图表。
(手动修改可以通过 Configuration - Hosts - zabbix-client-1 - Discovery rules中修改对应的 Interval的值)


Configuration - Hosts 



192.168.3.131,Discovery rules



Discovery rules中修改对应的 Interval的值



具体位置:



——下面都是可选项,根据需要自行添加。可选项还是蛮多的,如果还不够就需要自己写脚本添加到Template中。



——红色部分需要双击进去再选择。


监控示例:



——测试结束。








0 0