文章目录
- proxy
proxy
# 安装mysql 8.0# 获取源码包【https://www.zabbix.com/cn/download_sources】
mkdir -p /data/zabbix_proxy/{data,install,logs,php}
mkdir -p /var/run/zabbix_proxy
tar xf zabbix-6.4.3.tar.gz -C /data/zabbix_proxy/install/
cd /data/zabbix_proxy/install && mv zabbix-6.4.3/* . # 初始化mysql
> create database zabbix_proxy charset utf8 collate utf8_bin;
> CREATE USER 'zabbix_proxy'@'192.168.20.64' IDENTIFIED BY 'Zabb@321';
> GRANT all PRIVILEGES on zabbix_proxy.* to 'zabbix_proxy'@'192.168.20.64';
> CREATE USER 'zabbix_proxy'@'localhost' IDENTIFIED BY 'Zabb@321';
> GRANT all PRIVILEGES on zabbix_proxy.* to 'zabbix_proxy'@'localhost';
> flush privileges;
> use zabbix_proxy;
> source /data/zabbix_proxy/install/database/mysql/schema.sql# yum依赖
yum install -y mysql-devel pcre-devel openssl-devel zlib-devel \
libxml2-devel net-snmp-devel net-snmp libssh2-devel OpenIPMI-devel \
libevent-devel openldap-devel libcurl-devel gcc gcc-c++ unixODBC-devel \
gnutls-devel gnutls groupadd zabbix
useradd zabbix -g zabbix
echo "Os@pass12"| passwd --stdin zabbix# 安装[安装jdk,见附录]
cd /data/zabbix_proxy/install
export CFLAGS="-std=gnu99"
./configure --prefix=/data/zabbix_proxy/data --enable-proxy \
--with-mysql=/usr/bin/mysql_config \
--with-net-snmp --with-libxml2 --with-ssh2 --with-openipmi --with-zlib \--with-libpthread --with-libevent --with-openssl --with-ldap \--with-libcurl --with-libpcre --enable-java --with-unixodbc \--with-jabber #--with-gnutlsmake install# 配置文件
chown zabbix.zabbix /data/zabbix_proxy/{data,logs}/ -R
chown zabbix.zabbix /var/run/zabbix_proxy/ -R
cd /data/zabbix_proxy/data/etc/
cp zabbix_proxy.conf zabbix_proxy.conf.bk #vi zabbix_proxy.conf
ListenPort=10051
LogFile=/data/zabbix_proxy/logs/zabbix_proxy.log
Server=192.168.20.61;192.168.20.62
DBHost=192.168.20.64
DBName=zabbix_proxy
DBUser=zabbix_proxy
DBPassword=Zabb@321
DBPort=3306
# 0为主动 1为被动
ProxyMode=0
# 允许zabbix server执行远程命令
EnableRemoteCommands=1
# 已经提交到zabbix server的数据保留时间
ProxyLocalBuffer=720
# 未提交到zabbix server的时间保留时间
ProxyOfflineBuffer=720
# 启动的数据采集器数量
StartPollers=10
# java gateway服务器地址 当需要监控java的时候必须配置否则监控不到数据
JavaGateway=192.168.20.64
JavaGatewayPort=10052
StartJavaPollers=10
# 监控项超时时间 单位为秒
Timeout=30
# 保存监控项而占用的最大内存
CacheSize=2048M
# 保存监控历史数据占用的最大内存
HistoryCacheSize=512M
# 历史索引缓存的大小
HistoryIndexCacheSize=16M
# 毫秒 多久的数据库查询会被记录到日志
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
SocketDir=/var/run/zabbix_proxy
PidFile=/var/run/zabbix_proxy/zabbix_proxy.pid # 启动
# vi /usr/lib/systemd/system/zabbix-proxy.service
[Unit]
Description=Zabbix PROXY
After=syslog.target
After=network.target
After=mysqld.service[Service]
User=zabbix
Group=zabbix
Environment="CONFFILE=/data/zabbix_proxy/data/etc/zabbix_proxy.conf"
Type=forking
PIDFile=/var/run/zabbix_proxy/zabbix_proxy.pid
Restart=on-failure
KillMode=control-group
ExecStart=/data/zabbix_proxy/data/sbin/zabbix_proxy -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s[Install]
WantedBy=multi-user.targetsystemctl daemon-reload
systemctl start zabbix-proxy
systemctl status zabbix-proxy
systemctl enable zabbix-proxy# 访问server,添加proxy# 添加proxy下的agent