实验环境:
主机 | 操作系统 | IP地址 | 主要软件 |
Zabbix服务端 | Red Hat 7.3 (X86_64) | 172.17.216.38 | mysql-5.7.27-el7-x86_64.tar.gz php-7.2.23.tar.gz nginx-1.17.4.tar.gz zabbix-4.2.6.tar.gz(server端) orabbix-1.2.3.zip(监控Oracle,可选) |
Zabbix客户端 | Red Hat 7.3 (X86_64) | 172.17.195.216 | zabbix-4.2.6.tar.gz(agent端) Oracle 11.2(Server) |
Zabbix客户端 | Red Hat 7.3 (X86_64) | 172.17.216.135 | zabbix-4.2.6.tar.gz(agent端) |
#1.1 下载Zabbix安装包
#进入Zabbix官网下载自己对应版本的php
#下载地址:https://www.zabbix.com/download_sources
#我这里下载zabbix-4.2.6.tar.gz版本(下载地址:https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/4.2.6/zabbix-4.2.6.tar.gz/download)
#通过SFTP上传Zabbix安装包
cd /backup
ls -lhrt | grep zabbix
[root@ZabbixServer backup]# ls -lhrt | grep zabbix
-rw------- 1 root root 18M Sep 30 16:00 zabbix-4.2.6.tar.gz
[root@ZabbixServer backup]#
#1.2 安装依赖包
yum install mysql-devel -y
#1.3 解压并安装
tar -zxf zabbix-4.2.6.tar.gz -C /usr/local/src/
cd /usr/local/src/zabbix-4.2.6/
#预编译
./configure --prefix=/usr/local/zabbix/ --enable-server --enable-agent --enable-java --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-libevent=/opt/libevent/
#安装
make && make install
#1.4 配置zabbix数据库
#登录到mysql并创建zabbix库和专用用户
mysql -uroot -p123456
CREATE USER 'zabbix'@'%' IDENTIFIED BY 'zabbix';
create database if not exists zabbix default character set utf8 collate utf8_general_ci;
#切换库
use zabbix;
#应用相关脚本
source /usr/local/src/zabbix-4.2.6/database/mysql/schema.sql
source /usr/local/src/zabbix-4.2.6/database/mysql/images.sql
source /usr/local/src/zabbix-4.2.6/database/mysql/data.sql
quit;
#1.5 创建zabbix用户
#添加不可登录用户
useradd -s /sbin/nologin zabbix
#创建日志目录
mkdir -p /usr/local/zabbix/logs
#修改属组
chown -R zabbix:zabbix /usr/local/zabbix
#1.6 配置zabbix服务端文件
cat /usr/local/zabbix/etc/zabbix_server.conf|grep -v ^#|grep -v ^$
LogFile=/usr/local/zabbix/logs/zabbix_server.log
LogFileSize=10
PidFile=/usr/local/zabbix/logs/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/tmp/mysql.sock
DBPort=3306
ExportFileSize=1G
StartPollers=50
StartPreprocessors=20
StartPollersUnreachable=1
StartTrappers=40
StartPingers=1
StartEscalators=20
ListenIP=172.17.216.38
CacheSize=1G
CacheUpdateFrequency=60
HistoryCacheSize=256M
HistoryIndexCacheSize=128M
TrendCacheSize=256M
ValueCacheSize=256M
Timeout=4
LogSlowQueries=3000
Include=/usr/local/zabbix/etc/zabbix_server.conf.d/*.conf
StatsAllowedIP=127.0.0.1
#1.7 配置zabbix客户端文件
cat /usr/local/zabbix/etc/zabbix_agentd.conf |grep -v ^#|grep -v ^$
PidFile=/usr/local