Zabbix-proxy
Zabbix-proxy

Zabbix-proxy

#ubuntu
[root@zabbix-proxy]#wget
https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+focal_all.deb
[root@zabbix-proxy]#dpkg -i zabbix-release_5.0-1+bionic_all.deb
[root@zabbix-proxy]#sed -i's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/apt/sources.list.d/zabbix.list
[root@zabbix-proxy]#apt update
[root@zabbix-proxy]#apt -y install zabbix-proxy-mysql zabbix-agent
[root@zabbix-proxy]#systemc enable zabbix-proxy.service zabbix-agent.service

#rocky
[root@zabbix-proxy-active ~]#rpm -Uvh
https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
[root@zabbix-proxy-active ~]#rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/8/x86_64/zabbix-release-4.0-
2.el8.noarch.rpm
#修改为阿里云源
[root@zabbix-proxy-active ~]#vim /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/8/x86_64/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
#或者sed修改
[root@zabbix-proxy-active ~]#sed -i.bak 's/repo.zabbix.com/mirrors.aliyun.com\/zabbix/' /etc/yum.repos.d/zabbix.repo
[root@zabbix-proxy-active ~]#yum -y install zabbix-proxy-mysql zabbix-agent

配置数据库

[root@jpress1 ~]#apt -y install mysql-server
[root@jpress1 ~]#echo "default_authentication_plugin=mysql_native_password" >> /etc/mysql/mysql.conf.d/mysqld.cnf
[root@jpress1 ~]#systemctl restart mysql.service 

[root@jpress1 ~]#mysql 
mysql> create database zabbix_proxy_active character set utf8 collate utf8_bin;
Query OK, 1 row affected, 2 warnings (0.01 sec)
mysql> create user proxy@'localhost' identified by '123456';
Query OK, 0 rows affected (0.03 sec)
mysql> grant all on zabbix_proxy_active.* to proxy@'localhost' ;
Query OK, 0 rows affected (0.01 sec)

[root@jpress1 ~]#zcat /usr/share/doc/zabbix-proxy-mysql/schema.sql.gz | mysql -uproxy -p123456 -hlocalhost zabbix_proxy_active

修改proxy配置文件

[root@jpress1 ~]#vim /etc/zabbix/zabbix_proxy.conf 
ProxyMode=0
Server=10.0.0.162
Hostname=10.0.0.204
DBHost=localhost
DBName=zabbix_proxy_active
DBUser=proxy
DBPassword=123456
[root@jpress1 ~]#systemctl restart zabbix-proxy.service 
[root@jpress1 ~]#systemctl status zabbix-proxy.service 
● zabbix-proxy.service - Zabbix Proxy
     Loaded: loaded (/lib/systemd/system/zabbix-proxy.service; disabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-10-10 19:50:14 CST; 7s ago
    Process: 201070 ExecStart=/usr/sbin/zabbix_proxy -c $CONFFILE (code=exited, status=0/SUCCESS)
   Main PID: 201081 (zabbix_proxy)
      Tasks: 1 (limit: 2236)
     Memory: 16.7M
     CGroup: /system.slice/zabbix-proxy.service
             └─201081 /usr/sbin/zabbix_proxy -c /etc/zabbix/zabbix_proxy.conf

10月 10 19:50:14 jpress1.sh systemd[1]: Starting Zabbix Proxy...
10月 10 19:50:14 jpress1.sh systemd[1]: Started Zabbix Proxy.

[root@jpress1 ~]#ss -tnl
State             Recv-Q            Send-Q                       Local Address:Port                        Peer Address:Port            Process            
LISTEN            0                 4096                         127.0.0.53%lo:53                               0.0.0.0:*                                  
LISTEN            0                 128                                0.0.0.0:22                               0.0.0.0:*                                  
LISTEN            0                 4096                               0.0.0.0:10051                            0.0.0.0:*                                  
LISTEN            0                 70                               127.0.0.1:33060                            0.0.0.0:*                                  
LISTEN            0                 151                              127.0.0.1:3306                             0.0.0.0:*                                  
LISTEN            0                 511                                0.0.0.0:80                               0.0.0.0:*                                  
LISTEN            0                 128                                   [::]:22                                  [::]:*                                  
LISTEN            0                 4096                                     *:10050                                  *:*                                  
LISTEN            0                 4096                                  [::]:10051                               [::]:*                                  

服务端配置代理