天天看点

CentOS6.5安装zabbix3.0.1

最近公司要求搭建zabbix以监控网络设备、×××及服务器,无奈以前并未接触过zabbix,且Linux正在学习中,这对我来说是个很大的挑战。幸好,网络上有很多很棒的教程,其中

http://enzhi.blog.51cto.com/11193298/1745388

  和

http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=17238776&id=4594985

这两篇博文给我了很大的帮助,在此表示感谢。

由于通过页面查看,所以没有安装配置zabbix客户端。

下面将zabbix服务端安装配置总结一下:

一、安装前环境准备

1、系统环境

[[email protected] ~]# uname -r 2.6.32-431.el6.x86_64 [[email protected] ~]# uname -m x86_64 [[email protected] ~]# cat /etc/redhat-release CentOS release 6.5 (Final)

2、关闭iptables和selinux

[[email protected] ~]# /etc/init.d/iptables stop

            #关闭防火墙

iptables: Flushing firewall rules:    [ OK ] [[email protected] ~]# chkconfig iptables off     

          #设置防火墙开机不自启动

[[email protected] ~]# chkconfig --list|grep iptables

   #查看防火墙看机自启动是否正确

iptables   0:off  1:off  2:off  3:off  4:off  5:off  6:off

[[email protected] ~]# getenforce

                 #查看selinux的状态

Disabled  

        #若不是Disabled,请到/etc/sysconfig/selinux内修改,修改完成后请重启系统以生效。

3、安装zabbix需要的组件

[[email protected] ~]# yum -y install beecrypt beecrypt-devel curl curl-devel freetype \

freetype-devel fontconfig fontconfig-devel gettext gettext-devel ImageMagick  \

ImageMagick-devel mingw32-iconv.noarch libmcrypt libmcrypt-devel libpng libpng-devel \

libxml2 libxml2-devel libxslt libxslt-devel mhash mhash-devel mcrypt zlib zlib-debel gd  \

gd-devel libjpeg libjpeg-devel

4、创建zabbix用户组及zabbix用户

[[email protected] ~]# groupadd -g 201 zabbix

[roo[email protected] ~]# useradd -g zabbix -u 201 -s /sbin/nolgoin zabbix

注:此处gid和uid并非一定要为201

二、安装LAMP环境

[[email protected] ~]# yum install gcc gcc-c++ autoconf httpd php mysql mysql-server \

php-mysql httpd-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 openldap* libssh*

三、配置LAMP环境

1、配置PHP参数

[[email protected] ~]# cp /etc/php.ini /etc/php.ini.bak_20160408

[[email protected] ~]#

sed -i "s@;[email protected] = Asia/[email protected]" /etc/php.ini

[[email protected] ~]#

sed -i "[email protected]_execution_time = [email protected]_execution_time = [email protected]" /etc/php.ini

[[email protected] ~]#

sed -i "[email protected]_max_size = [email protected]_max_size = [email protected]" /etc/php.ini

[[email protected] ~]#

sed -i "[email protected]_input_time = [email protected]_input_time = [email protected]" /etc/php.ini

[[email protected] ~]#

sed -i "[email protected]_limit = [email protected]_limit = [email protected]" /etc/php.ini

[[email protected] ~]#

sed -i "s@;mbstring.func_overload = [email protected]_overload = [email protected]" /etc/php.ini

2、启动HTTP及MYSQL服务

[[email protected] ~]# /etc/init.d/httpd start      #启动http服务

[[email protected] ~]# /etc/init.d/mysqld start     

#启动mysql服务

[[email protected] ~]# chkconfig httpd on         #设置http服务开机自启动

[[email protected] ~]# chkconfig --list|grep httpd   

#查看http服务开机自启动设置情况

[[email protected] ~]# chkconfig mysqld on       

#设置mysql服务开机自启动

[[email protected] ~]# chkconfig --list|grep mysqld   

#查看mysql服务开机自启动设置情况

四、配置zabbixServer

1、下载zabbix(目前最新版为3.0.1)

[[email protected] ~]#

wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.0.1/zabbix-3.0.1.tar.gz/download

注:也可以在windows上下载好,通过FileZilla等工具传到zabbix所在额CentOS系统。

2、安装zabbix

[[email protected] ~]#

tar xf zabbix-3.0.1.tar.gz

[[email protected] ~]# cd xf zabbix-3.0.1.tar.gz

[[email protected] ~]#

./configure --prefix=/usr --sysconfdir=/etc/zabbix --enable-server \

--enable-proxy --enable-agent --enable-ipv6 --with-mysql=/usr/bin/mysql_config --with-net-snmp \

--with-libcurl --with-openipmi --with-unixodbc --with-ldap --with-ssh2 --enable-java 

[[email protected] ~]# 

make&& make install

3、添加zabbix到系统服务文件

[[email protected] ~]

# vim /etc/services

在最下面添加一下内容:

zabbix-agent   10050/tcp          #ZabbixAgent 

zabbix-agent   10050/udp          #ZabbixAgent 

zabbix-trapper 10051/tcp           #ZabbixTrapper 

zabbix-trapper 10051/udp           #ZabbixTrapper

4、创建zabbix数据库及相关表

[[email protected] ~]

#

mysql -e "create database zabbix default charset utf8;"

[[email protected] ~]

#

mysql -e "grant all on zabbix.* to [email protected] identified by 'zabbix';"

[[email protected] ~]

#

mysql -uzabbix -pzabbix zabbix  

#测试数据库连接是否正常

[[email protected] ~]

#

mysql -uzabbix -pzabbix zabbix<./database/mysql/schema.sql

[[email protected] ~]

#

mysql -uzabbix -pzabbix zabbix<./database/mysql/p_w_picpaths.sql

[[email protected] ~]

#

mysql -uzabbix -pzabbix zabbix<./database/mysql/data.sql

5、配置启动文件信息

[[email protected]

~]# mkdir /var/log/zabbix

[[email protected] ~]# chown zabbix.zabbix /var/log/zabbix

[[email protected] ~]# cp /root/zabbix-2.4.5/misc/init.d/fedora/core/zabbix_* /etc/init.d

[[email protected] ~]# chmod 755 /etc/init.d/zabbix_*

6、修改/etc/init.d下zabbix_seraver及zabbix_agentd启动文件

[[email protected] ~]#

sed -i "[email protected]=/usr/[email protected]=/usr/local/[email protected]" /etc/init.d/zabbix_server

[[email protected] ~]#

sed -i "[email protected]=/usr/[email protected]=/usr/local/[email protected]" /etc/init.d/zabbix_agentd

7、修改/etc/zabbix/zabbix_server.conf

[[email protected] ~]# sed -i "[email protected][email protected][email protected]" /etc/zabbix/zabbix_server.conf

[[email protected] ~]# sed -i "s@#[email protected][email protected]" /etc/zabbix/zabbix_server.conf

8、修改/etc/zabbix/zabbix_agentd.conf

[[email protected] ~]#

sed -i "[email protected]=127.0.0.1@Server=127.0.0.1,[email protected]" /etc/zabbix/zabbix_agentd.conf

[[email protected] ~]#

sed -i "[email protected][email protected]=192.168.0.36:[email protected]" /etc/zabbix/zabbix_agentd.conf

[[email protected] ~]#

sed -i "[email protected]/[email protected]/log/zabbix/[email protected]" /etc/zabbix/zabbix_agentd.conf

[[email protected] ~]#

sed -i "s@^#UnsafeUserParamet[email protected]=1\[email protected]" /etc/zabbix/zabbix_agentd.conf

注:此处的IP地址192.168.0.36为zabbix服务端的IP地址。

9、复制zabbix站点文件到/var/www/html/

[[email protected] ~]#

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

[[email protected] ~]#

hown -Rapache.apache /var/www/html/zabbix/

[[email protected] ~]#

chkconfigzabbix_server on

[[email protected] ~]#

chkconfigzabbix_agentd on

[[email protected] ~]#

/etc/init.d/zabbix_server start

[[email protected] ~]#

/etc/init.d/zabbix_agentdstart

五、通过web界面配置zabbix

1、在浏览器中输入http://zbbixserver-ip/zabbix/setup.php

CentOS6.5安装zabbix3.0.1

点击“Next”,进入PHP配置检查界面。

2、PHP配置检查界面

CentOS6.5安装zabbix3.0.1

若结果是OK表示正常,如果是fail状态,请修改相关的php配置参数,并重启httpd服务。

3、填写数据库相关信息端口及zabbix授权用户及密码

CentOS6.5安装zabbix3.0.1

注:填写好信息后一定要点击“Test connection”,若测试结果不是OK,请检查填写的信息

4、填写zabbix的server地址

CentOS6.5安装zabbix3.0.1

5、配置结果预览

CentOS6.5安装zabbix3.0.1

6、安装完成

CentOS6.5安装zabbix3.0.1

至此,Zabbix服务端就安装成功了。

转载于:https://blog.51cto.com/unclemao/1761879