最近公司要求搭建zabbix以监控网络设备、***及服务器,无奈以前并未接触过zabbix,且Linux正在学习中,这对我来说是个很大的挑战。幸好,网络上有很多很棒的教程,其中http://enzhi.blog.运维网.com/11193298/1745388 和 http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=17238776&id=4594985 这两篇博文给我了很大的帮助,在此表示感谢。
由于通过页面查看,所以没有安装配置zabbix客户端。
下面将zabbix服务端安装配置总结一下:
一、安装前环境准备
1、系统环境
[root@sh-zabbix ~]# uname -r
2.6.32-431.el6.x86_64
[root@sh-zabbix ~]# uname -m
x86_64
[root@sh-zabbix ~]# cat /etc/redhat-release
CentOS release 6.5 (Final) |
2、关闭iptables和selinux
[root@sh-zabbix ~]# /etc/init.d/iptables stop #关闭防火墙
iptables: Flushing firewall rules: [ OK ]
[root@sh-zabbix ~]# chkconfig iptables off #设置防火墙开机不自启动
[root@sh-zabbix ~]# chkconfig --list|grep iptables #查看防火墙看机自启动是否正确
iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@sh-zabbix ~]# getenforce #查看selinux的状态
Disabled #若不是Disabled,请到/etc/sysconfig/selinux内修改,修改完成后请重启系统以生效。
|
3、安装zabbix需要的组件
[root@sh-zabbix ~]# 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用户
[root@sh-zabbix ~]# groupadd -g 201 zabbix
[root@sh-zabbix ~]# useradd -g zabbix -u 201 -s /sbin/nolgoin zabbix
| 注:此处gid和uid并非一定要为201
二、安装LAMP环境
[root@sh-zabbix ~]# 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参数
[root@sh-zabbix ~]# cp /etc/php.ini /etc/php.ini.bak_20160408[root@sh-zabbix ~]# sed -i "s@;date.timezone=@date.timezone = Asia/Shanghai@g" /etc/php.ini
[root@sh-zabbix ~]# sed -i "s@max_execution_time = 30@max_execution_time = 300@g" /etc/php.ini
[root@sh-zabbix ~]# sed -i "s@post_max_size = 8M@post_max_size = 32M@g" /etc/php.ini
[root@sh-zabbix ~]# sed -i "s@max_input_time = 60@max_input_time = 300@g" /etc/php.ini
[root@sh-zabbix ~]# sed -i "s@memory_limit = 128M@memory_limit = 128M@g" /etc/php.ini
[root@sh-zabbix ~]# sed -i "s@;mbstring.func_overload = 0@ambstring.func_overload = 2@g" /etc/php.ini
|
2、启动HTTP及MYSQL服务
[root@sh-zabbix ~]# /etc/init.d/httpd start #启动http服务
[root@sh-zabbix ~]# /etc/init.d/mysqld start #启动mysql服务
[root@sh-zabbix ~]# chkconfig httpd on #设置http服务开机自启动
[root@sh-zabbix ~]# chkconfig --list|grep httpd #查看http服务开机自启动设置情况
[root@sh-zabbix ~]# chkconfig mysqld on #设置mysql服务开机自启动
[root@sh-zabbix ~]# chkconfig --list|grep mysqld #查看mysql服务开机自启动设置情况
|
四、配置zabbixServer
1、下载zabbix(目前最新版为3.0.1)
[root@sh-zabbix ~]# 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
[root@sh-zabbix ~]# tar xf zabbix-3.0.1.tar.gz
[root@sh-zabbix ~]# cd xf zabbix-3.0.1.tar.gz
[root@sh-zabbix ~]# ./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
[root@sh-zabbix ~]# make&& make install
|
3、添加zabbix到系统服务文件
[root@sh-zabbix ~]# 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数据库及相关表
[table][tr][td=1,1,714][root@sh-zabbix ~]# mysql -e "create database zabbix default charset utf8;" [root@sh-zabbix ~]# mysql -e "grant all on zabbix.* to zabbix@localhost identified by 'zabbix';"
[root@sh-zabbix ~]# mysql -uzabbix -pzabbix zabbix #测试数据库连接是否正常
[root@sh-zabbix ~]# mysql -uzabbix -pzabbix zabbix |