1. 服务器规划列表
主机名
IP地址
zabbix-server
192.168.100.252
zabbix-client01
192.168.100.214
2. 服务器zabbix-server端安装步骤
#关闭防火墙
# systemctl stop firewalld
# systemctl disable firewalld
#关闭selinux
# sed -i ‘s/=enforcing/=disabled/g‘ /etc/selinux/config
# grep "=disable" /etc/selinux/config
SELINUX=disabled
#安装LAMP架构
# yum install httpd mariadb mariadb-server php php-mysql php-devel php-xml php-bcmath php-mbstring php-gd php-ldap wget expect net-snmp gcc mysql-devel libxml2-devel net-snmp-devel libevent-devel curl-devel -y
#解压软件包并导入表到数据库
# tar zxvf zabbix-4.0.11.tar.gz
# cd zabbix-4.0.11/database/mysql
# mysql -uzabbix -pzabbix -e "use zabbix;source schema.sql;source images.sql;source data.sql;"
# mysql -uzabbix -pzabbix -e "use zabbix;show tables"
# cd ../../
#安装zabbix
# ./configure --prefix=/user/local/zabbix --enable-server --enable-agent --enable-java --enable-ipv6 --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi --with-unixodbc --with-openssl
报错
checking for xmlReadMemory in -lxml2... yes
checking for odbc_config... no
checking for SQLAllocHandle in -lodbc... no
configure: error: unixODBC library not found
解决办法:
[[email protected] zabbix-4.0.11]# yum install libssh2-devel
报错
checking for OPENIPMI support... no
configure: error: Invalid OPENIPMI directory - unable to find ipmiif.h
解决办法:
# yum install OpenIPMI-devel
报错
configure: error: Unable to find "javac" executable in path
解决办法
# yum -y install java-devel
# make
报错
odbc.c:24:17: fatal error: sql.h: No such file or directory
#include
解决办法
# yum install -y unixODBC*
# 修改zabbix配置文件
# cd /user/local/zabbix/etc
# sed -i s/‘# DBPassword=‘/‘DBPassword=zabbix‘/g zabbix_server.conf
# grep "DBPassword" zabbix_server.conf
### Option: DBPassword
DBPassword=zabbix
# mkdir /var/www/html/zabbix
# cd /zabbix/zabbix-4.0.11/
# cp -r frontends/php/ /var/www/html/zabbix
# ls /var/www/html/zabbix/php
# sed -i s/‘^max_execution_time.*‘/‘max_execution_time = 300‘/g /etc/php.ini
# sed -i s/‘^max_input_time.*‘/‘max_input_time = 300‘/g /etc/php.ini
# sed -i s/‘^post_max_size.*‘/‘post_max_size = 16M‘/g /etc/php.ini
# sed -i s/‘;^date.timezone.*‘/‘date.timezone = Asia\/Shanghai‘/g /etc/php.ini
# grep -E "max_execution_time|max_input_time|post_max_size|date.timezone" /etc/php.ini
; max_input_time
max_execution_time = 300
max_input_time = 300
post_max_size = 16M
; http://php.net/date.timezone
date.timezone = Asia/Shanghai
# systemctl restart httpd && systemctl restart mariadb
# systemctl status httpd && systemctl status mariadb
# cd
# zabbix_server
# cd /zabbix/zabbix-4.0.11/misc/init.d/tru64
# cp zabbix_server /etc/init.d/
# vim /etc/init.d/zabbix_server
#修改配置文件的如下内容
#chkconfig: 345 95 95
#description: Zabbix_Server
DAEMON=/user/local/zabbix/sbin/zabbix_server
... ...
#启动服务
# chkconfig zabbix_server on
# service zabbix_server start
3. 客户端zabbix-client安装和配置步骤
#关闭防火墙
# systemctl stop firewalld
# systemctl disable firewalld
#关闭selinux
# sed -i ‘s/=enforcing/=disabled/g‘ /etc/selinux/config
# grep "=disable" /etc/selinux/config
SELINUX=disabled
#创建zabbix用户和组
# groupadd zabbix
# useradd -g zabbix zabbix -s /sbin/nologin
#解压zabbix源码包并编译安装
# yum install -y gcc gcc-c++ make
# tar zxvf zabbix-4.0.11.tar.gz
# cd /zabbix-agent/zabbix-4.0.11
# ./configure --prefix=/usr/local/zabbix-agent --enable-agent
# make && make install
#拷贝zabbix客户端启动脚本到/etc/init.d目录下
# cd /zabbix-agent/zabbix-4.0.11/misc
# cp init.d/tru64/zabbix_agentd /etc/init.d/
# chmod +x /etc/init.d/zabbix_agentd
# vim /etc/init.d/zabbix_agentd
#修改该启动文件内容为
#!/bin/sh
#chkconfig: 345 95 95
#description: Zabbix_agentd
# Zabbix
SERVICE="Zabbix agent"
DAEMON=/usr/local/zabbix-agent/sbin/zabbix_agentd
PIDFILE=/tmp/zabbix_agentd.pid
case $1 in
‘start‘)
if [ -x ${DAEMON} ]
then
$DAEMON
# Error checking here would be good...
echo "${SERVICE} started."
else
echo "Can‘t find file ${DAEMON}."
echo "${SERVICE} NOT started."
fi
;;
‘stop‘)
if [ -s ${PIDFILE} ]
then
if kill `cat ${PIDFILE}` >/dev/null 2>&1
then
echo "${SERVICE} terminated."
rm -f ${PIDFILE}
fi
fi
;;
‘restart‘)
$0 stop
sleep 10
$0 start
;;
*)
echo "Usage: $0 start|stop|restart"
;;
esac
# /usr/local/zabbix-agent/etc
# cp zabbix_agentd.conf zabbix_agentd.conf.bak
# sed -i ‘s#Server=127.0.0.1#Server=192.168.100.252#‘ zabbix_agentd.conf
# grep ‘Server=‘ zabbix_agentd.conf
# Example: Server=192.168.100.252,192.168.1.0/24,::1,2001:db8::/32,zabbix.example.com
# Server=
Server=192.168.100.252
# grep -Ev "^#|^$" zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
Server=192.168.100.252
ListenIP=192.168.100.214
ServerActive=127.0.0.1
Hostname=Zabbix server
# grep -E "chkconfig|description" /etc/init.d/zabbix_agentd
#chkconfig: 345 95 95
#description: Zabbix_agentd
# chkconfig zabbix_agentd on
# service zabbix_agentd start
# netstat -antp | grep zabbix
tcp 0 0 192.168.100.214:10050 0.0.0.0:* LISTEN 84622/zabbix_agentd
# netstat -antp | grep :10050
4:安装过程中常见的故障汇总以及解决方法
zabbix源码安装报错1:configure: error: SSH2 library not found
解决方案:yum -y install libssh2-devel
zabbix源码安装报错2:configure: error: Invalid LDAP directory - unable to find ldap.h
解决方案:yum -y install openldap openldap-devel
zabbix源码安装报错3:configure: error: Unable to use libpcre (libpcre check failed)
网上解决方案:yum -y install pcre* 失败(报有其他错误,无法完成安装)
zabbix源码安装报错4:configure: error: MySQL library not found
解决方案:yum -y install mysql-devel
zabbix源码安装报错5:configure: error: unixODBC library not found
解决方案:yum -y install unixODBC-devel
zabbix源码安装报错6:configure: error: Invalid OPENIPMI directory - unable to find ipmiif.h
解决方案:yum -y install OpenIPMI-devel
zabbix源码安装报错7:configure: error: Unable to use libevent (libevent check failed)
解决方案:um -y install libxml2-devel libcurl-devel libevent-devel (主要是安装libevent-devel,其它几个可能用不到)
zabbix源码安装报错7:configure: error: Unable to find "javac" executable in path
解决方案:yum -y install java-devel
zabbix安装报错8:configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config
解决方案:安装net-snmp-devel,yum -y install net-snmp-devel
rpm安装报错:Error: Package: zabbix-server-mysql-1.8.22-1.el6.x86_64 (epel)Requires: libiksemel.so.3()(64bit)解决方案:安装iksemel yum -y install iksemel-1.4-2.puias6.x86_64.rpm,需要下载iksemel-1.4-2.puias6.x86_64.rpm