Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1155177
  • 博文数量: 220
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1769
  • 用 户 组: 普通用户
  • 注册时间: 2015-03-13 16:19
个人简介

努力, 努力, 再努力

文章分类

全部博文(220)

文章存档

2018年(8)

2017年(46)

2016年(75)

2015年(92)

我的朋友

分类: 服务器与存储

2015-12-29 15:35:00


. 系统环境描述

         1. 系统版本: CentOS release 6.5 (Final)

         2. 内核版本: 2.6.32-431.el6.x86_64

         3. zabbix 版本: ver 2.4.5

. 安装依赖包

1.  增加用户zabbix, 不创建家目录和允许登录

useradd -M -s /sbin/nologin zabbix   #注意:-M 不创建home目录

 

     2. 安装zabbixYUM

rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm

     2.  安装依赖包:

yum install gcc gcc-c++ autoconf net-snmp net-snmp-devel net-snmp-util openssl openssl-devel libxml2-devel libcurl-devel curl-devel httpd mysql mysql-server mysql-devel mod-ssl mod-perl mod_auth_mysql php php-gd php-xml php-sockets php-libxml php-bcmath php-mbstring php-mysql.x86_64 java java-devel fping unixODBC unixODBC-devel mysql-connector-odbc

 

php-bcmath如果不安装,页面提示php-bcmath失败

php-mbstring如果不安装,页面提示php-mbstring失败

php-mysql.x86_64 如果不安装,页面提示php databases失败

 

 

3. 下载安装: iksemel-1.4.tar.gz   该包选装,它与jabber有关

iksemel-1.4.tar.gz

tar -zxvf iksemel-1.4.tar.gz

cd iksemel-1.4

./configure --prefix=/usr/local

*** The libgnutls-config script installed by LIBGNUTLS could not be found

*** If LIBGNUTLS was installed in PREFIX, make sure PREFIX/bin is in

*** your path, or set the LIBGNUTLS_CONFIG environment variable to the

*** full path to libgnutls-config.

如果iksemel-1.4.tar.gz不安装,则zabbix 配置时--with-jabber=/usr/local/ 也不需要

make -j4  #同时开起4个线程

make install

 

4.    安装OpenIPMI-devel开放的智能平台管理接口

yum install OpenIPMI-devel -y

 

5.    安装jdk

jdk-6u37-linux-x64.bin这是一个自解压文件

./jdk-6u37-linux-x64.bin

mv jdk1.6.0_37/  /opt/jdk16

 

vim /etc/profile

追加以下3

export JAVA_HOME=/opt/jdk16

export PATH=$JAVA_HOME/bin:$PATH

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

导入配置文件:/etc/profile

Env命令验证

 

 

. 安装zabbix 2.4.5

1.       下载zabbix

wget

 

2.       解压: zabbix-2.4.5.tar.gz

tar -zxvf zabbix-2.4.5.tar.gz

3.       配置

./configure --prefix=/usr/local/zabbix --enable-server --with-mysql --with-net-snmp --with-jabber=/usr/local/ --with-libcurl --with-openipmi --enable-agent --enable-proxy --with-libxml2  --enable-ipv6 --enable-java

虚拟机经常会出现上述故障,修改一下时间就正常了
Configuration:

 

  Detected OS:           linux-gnu

  Install path:          /usr/local/zabbix

  Compilation arch:      linux

 

  Compiler:              gcc

  Compiler flags:        -g -O2  -I/usr/include/mysql  -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC   -DUNIV_LINUX -DUNIV_LINUX    -I/usr/local//include -I/usr/include/libxml2   -I/usr/include/rpm -I/usr/local/include -I/usr/lib64/perl5/CORE -I. -I/usr/include  -I/usr/include  

 

  Enable server:         yes

  Server details:

    With database:         MySQL

    WEB Monitoring:        cURL

    Native Jabber:         yes

    SNMP:                  yes

    IPMI:                  yes

    SSH:                   no

    ODBC:                  no

    Linker flags:          -rdynamic      -L/usr/lib64/mysql    -L/usr/local//lib    -L/usr/lib64  -L/usr/lib 

    Libraries:             -lm -ldl -lrt  -lresolv    -lmysqlclient     -liksemel -lxml2    -lnetsnmp  -lOpenIPMI -lOpenIPMIposix   -lcurl

 

  Enable proxy:          no

 

  Enable agent:          yes

  Agent details:

    Linker flags:          -rdynamic    

    Libraries:             -lm -ldl -lrt  -lresolv     -lcurl

 

  Enable Java gateway:   yes

  Java gateway details:

    Java compiler:         javac

    Java archiver:         jar

 

  LDAP support:          no

  IPv6 support:          yes

 

***********************************************************

*            Now run 'make install'                       *

*                                                         *

*            Thank you for using Zabbix!                  *

*                                  *

***********************************************************

4.       编译

make–j4

5.       安装

make install

        

 

. 配置zabbix

1.       配置mysql

启动mysql  : /etc/init.d/mysqld start

 

2.       创建库并分配权限

mysql -uroot -p

mysql> create database zabbix default charset utf8;

mysql> grant all on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix123';

mysql> flush privileges;

 

3.       导入SQL数据

cd /root/zabbix-2.4.5/database/mysq

# mysql -uzabbix -pzabbix123 zabbix < schema.sql

# mysql -uzabbix -pzabbix123 zabbix < images.sql

# mysql -uzabbix -pzabbix123 zabbix < data.sql


 

4.       配置zabbix启动

cp /root/zabbix-2.4.5/misc/init.d/fedora/core/zabbix_* /etc/init.d/

chmod 755 /etc/init.d/zabbix_*

vim /usr/local/zabbix/etc/zabbix_server.conf

30 LogFile=/tmp/zabbix_server.log改为LogFile=/var/log/zabbix_server.log

69 DBHost=localhost这一行取消注释

95 DBUser=root改为DBUser=zabbix

103 # DBPassword=改为DBPassword= zabbix123

118 # DBPort=3306这一行取消注释

13  #ListenPort=10051这一行取消注释

207 # JavaGatewayPort=10052这一行取消注释

110 # DBSocket=/tmp/mysql.sock这一行取消注释并改为

           DBSocket=/var/lib/mysql/mysql.sock

 

vim /etc/init.d/zabbix_server

22         BASEDIR=/usr/local改为BASEDIR=/usr/local/zabbix

 

vim /etc/init.d/zabbix_agentd

22         BASEDIR=/usr/local改为BASEDIR=/usr/local/zabbix

 

5.       配置php

vim /etc/php.ini

440 max_execution_time = 30改为440 max_execution_time = 300

449 max_input_time = 60改为max_input_time = 300

729 post_max_size = 8M改为post_max_size = 50M

946 ;date.timezone =改为date.timezone = Asia/Shanghai

 

6.       配置前端页面

cp -rv /root/zabbix-2.4.5/frontends/php /var/www/html/zabbix

                   cd /var/www/html

                   chown -R apache.apache zabbix/

                   配置httpd.conf

vim /etc/httpd/conf/httpd.conf

                   在最后增加如下虚拟机:

        


ServerName zabbix.xqzh.com

DocumentRoot /var/www/html/zabbix

DirectoryIndex index.php

         Options -Indexes FollowSymLinks

         Order allow,deny

         Allow from all

AllowOverride None

AddType application/x-httpd-php .php
   

 

将该行注释去掉,再添加有意义的服务器名

         276 ServerName www.zabbix.ucas.cn:80

 

         检查http语法

         # httpd–t

 

         重启httpd : /etc/init.d/httpd restart

 

7.       设置zabbix为自启动

chkconfig zabbix_server on

chkconfig zabbix_agentd on

        

         9.启动zabbix_server

         # /etc/init.d/zabbix_server start

         Starting zabbix_server:  /usr/local/zabbix/sbin/zabbix_server: error while loading shared libraries: libiksemel.so.3: cannot open shared object file: No such file or directory

                                                           [FAILED]

 

解决办法:ln -s /usr/local/lib/libiksemel.so.3 /usr/lib64/

 

[root@master /]# /etc/init.d/zabbix_server start

Starting zabbix_server:  zabbix_server [9798]: cannot open [/var/log/zabbix_server.log]: [13] Permission denied

[  OK  ]

 

解决方法:新建zabbix_server.log,然后授权

[root@master log]#  touch /var/log/zabbix_server.log

[root@master log]# chown zabbix.zabbix /var/log/zabbix_server.log

 

[root@master log]# /etc/init.d/zabbix_server restart

Shutting down zabbix_server:                               [  OK  ]

Starting zabbix_server:                                    [  OK  ]
         10.
启动zabbix_agent

         [root@master log]# /etc/init.d/zabbix_agentd restart

Shutting down zabbix_agentd:                               [  OK  ]

Starting zabbix_agentd:                                    [  OK  ]

 

但问题是:

zabbix_server的进程可以看到,但10051端口,用netstat–atupno命令没有看到。

 

[root@masteretc]# ps -ef |grepzabbix_server |grep -v grep

zabbix   10898     1  0 18:27 ?        00:00:00 /usr/local/zabbix/sbin/zabbix_server

[root@masteretc]# netstat -atupno |grep 1005

tcp        0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      10426/zabbix_agentd off (0.00/0/0)

tcp        0      0 :::10050                    :::*                        LISTEN      10426/zabbix_agentd off

 

原因:/usr/local/zabbix/etc/zabbix_server.conf里的配置错误

DBUser=root  改为DBUser=zabbix

再重启zabbix_server就好了

根本原因是: zabbix_server连接数据库失败

 

. 通过WEB页面初始化


 

点击下一步


点击下一步

 


输入mysql端口号3306, 数据库连接的用户名zabbix, 密码: zabbix123


 


登录名:admin  密码:zabbix


 

改为中文界面:

 


 


 

===========================================================================

.  zabbix客户端的安装

         1. linux下安装----centOS6.5

              a. 安装zabbixYUM

rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm

b. YUM安装zabbix-agent

yum install zabbix-agent-2.4.5 -y

 

Installing : zabbix-2.4.6-1.el6.x86_64  这是zabbix的支持包                                                                

Installing : zabbix-agent-2.4.5-1.el6.x86_64 

 

c. 设置zabbix-agent的客户端配置文件

 vim /etc/zabbix/zabbix_agentd.conf

  #Server=127.0.0.1  改为#Server=192.168.1.20 (说明: zabbix-serverIP地址)

 #ServerActive=127.0.0.1 改为#ServerActive=192.168.1.20  (zabbix-serverIP地址)

  #Hostname=Zabbix server 改为#Hostname=master.sql.com 为本机命名

d. 启动zabbix-agent

  /etc/init.d/zabbix-agent start

  注意: 关闭防火墙或者在防火墙上开放相应的端口

e. 设置为开机自启动

   chkconfig zabbix-agent on

 

2. windows下安装zabbix客户端

 a. 下载windows下的zabbix客户端:

选择Zabbix pre-compiled agents,然后选择适当的版本, 平台,架构

 

b. 解压安装zabbix-agentwindows客户端, 此处以winxp32位为例

        zabbix_agents_2.4.4.win.zip 解压至C盘根目录, 出现bin, conf目录

 

c. 修改zabbix-agent的配置文件

  用写字板打开c:\conf\zabbix_agentd.win.conf

     Server=127.0.0.1  改为 Server=192.168.1.20

    ServerActive= 127.0.0.1 改为ServerActive=192.168.1.20

    Hostname=Windows host 改为 Hostname=rx-xp

    注意: 192.168.1.20 zabbix-serverIP地址

   

    d. 安装zabbix-agent

在开始-->运行-->cmd, 打开dos窗口, 输入如下:

    C:\bin\win32>zabbix_agentd.exe -c c:\conf\zabbix_agentd.win.conf --install

截图:


e. 启动zabbix-agent

 C:\bin\win32>zabbix_agentd.exe --start


f. zabbix-agent成为了windows的服务


 

 

                 

 

 

阅读(1808) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~