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
解決辦法:
[root@zabbix-server 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 <sql.h>
解決辦法
# 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