zabbix分布式监控被动模式代理

分布式:所谓的分布式,其实指的是,多台分布在不同位置的zabbix主机,通过 间接模式 合理的组合在一起,实现监控数据的统一管理方式。适用场景:多机房、多区域、多网络等

简介:Zabbix 代理是一种可以代表 Zabbix 服务器从终端设备收集性能和可用性数据的服务。这样,代理可以自己承担一些收集数据的负载甚至在某种程度上替代 Zabbix 服务器。

proxy模式

 proxy 可以有多个,每个proxy收集并保存其可以连接的agent,然后将数据统一发送给给zabbix
server进行展示。其实,我们可以将 proxy 理解为一个精简版的zabbix server。

案例1:被动模式代理

代理服务器 10.0.0.13 proxy
zabbix    10.0.0.12 zabbix-server
client    10.0.0.14
client    10.0.0.15

a.配置代理服务器(proxy-server)

1.配置数据库
[root@proxy ~]#apt -y install mariadb-server
[root@proxy ~]#mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:                    #数据库密码为123456
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n]
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n]
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n]
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n]
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
#测试数据库
[root@proxy ~]#mysql -uroot -p123456 -e "show databases"
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+

#修改绑定地址
[root@proxy ~]#vim /etc/mysql/mariadb.conf.d/50-server.cnf
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 0.0.0.0
[root@proxy ~]#systemctl status mariadb.service
#

2.安装proxy
#检查服务端的zabbix server的版本
zabbix_server -V
#软件源配置
wget https://repo.zabbix.com/zabbix/5.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.4-
1+ubuntu20.04_all.deb
dpkg -i zabbix-release_5.4-1+ubuntu20.04_all.deb
apt update
# 安装软件
apt install -y zabbix-proxy-mysql zabbix-sql-scripts
#查看版本
zabbix_proxy -V

#创建用户以及授权权限
MariaDB [(none)]> create database zabbix_proxy character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.000 sec)

MariaDB [(none)]> grant all privileges on zabbix_proxy.* to 'zabbix'@'localhost' identified by'zabbix';
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> grant all privileges on zabbix_proxy.* to 'zabbix'@'%' identified by 'zabbix';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> exit

#初始化数据库
[root@proxy ~]#zcat /usr/share/doc/zabbix-sql-scripts/mysql/schema.sql.gz  | mysql -uzabbix -p'zabbix' zabbix_proxy

编辑zabbix配置文件

[root@proxy ~]#vim /etc/zabbix/zabbix_proxy.conf
 12 # Default:
 13 ProxyMode=1     #默认是主动模式,我们先使用被动模式
 14
 15 ### Option: Server
 
 
 28 # Server=
 29
 30 Server=10.0.0.12  #zabbix server端的地址


256 # Default:
257 ConfigFrequency=5
258
259 ### Option: DataSenderFrequency

# Mandatory: no
# Default:
DBPassword=zabbix

### Option: DBSocket
#   Path to MySQL socket

#修改后最终效果
[root@proxy ~]#grep -Env "#|$^" /etc/zabbix/zabbix_proxy.conf
13:ProxyMode=1
30:Server=10.0.0.12
49:Hostname=Zabbix proxy
91:LogFile=/var/log/zabbix/zabbix_proxy.log
102:LogFileSize=0
143:PidFile=/run/zabbix/zabbix_proxy.pid
153:SocketDir=/run/zabbix
178:DBName=zabbix_proxy
193:DBUser=zabbix
201:DBPassword=zabbix
257:ConfigFrequency=5
423:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
499:Timeout=4
550:FpingLocation=/usr/bin/fping
561:Fping6Location=/usr/bin/fping6
580:LogSlowQueries=3000
686:StatsAllowedIP=127.0.0.1
[root@proxy ~]#systemctl restart zabbix-proxy.service
[root@proxy ~]#systemctl status zabbix-proxy.service

配置服务端agent(10.0.0.14,10.0.0.15)

#最后修改结果 10.0.0.14
root@ubuntu2004:~# grep -Env "#|^$" /etc/zabbix/zabbix_agentd.conf
13:PidFile=/run/zabbix/zabbix_agentd.pid
32:LogFile=/var/log/zabbix/zabbix_agentd.log
43:LogFileSize=0
117:Server=10.0.0.13     #代理服务器地址
169:Hostname=Zabbix server
310:Include=/etc/zabbix/zabbix_agentd.d/*.conf
#10.0.0.15
[root@ubuntu2004 ~]#grep -Env "#|^$" /etc/zabbix/zabbix_agentd.conf
13:PidFile=/run/zabbix/zabbix_agentd.pid
32:LogFile=/var/log/zabbix-agent/zabbix_agentd.log
43:LogFileSize=0
98:Server=10.0.0.13      #代理服务器地址
148:Hostname=10.0.0.15
269:Include=/etc/zabbix/zabbix_agentd.conf.d/*.conf
重启服务并设置为开机自启动
systemctl restart zabbix-proxy
systemctl enable zabbix-proxy
查看效果
tail -f /var/log/zabbix/zabbix_proxy.log

创建代理:

 

创建主机

 

 

 

 

查看日志:

 

[root@proxy ~]#tail -f /var/log/zabbix/zabbix_proxy.log
  4601:20220323:204806.457 received configuration data from server at "10.0.0.12", datalen 21366
  4599:20220323:204811.465 received configuration data from server at "10.0.0.12", datalen 21366
  4600:20220323:204816.464 received configuration data from server at "10.0.0.12", datalen 21366
  4598:20220323:204821.453 received configuration data from server at "10.0.0.12", datalen 21366
  4601:20220323:204826.464 received configuration data from server at "10.0.0.12", datalen 21366
  4600:20220323:204831.489 received configuration data from server at "10.0.0.12", datalen 21366
  4599:20220323:204836.484 received configuration data from server at "10.0.0.12", datalen 21366
  4632:20220323:204840.820 enabling Zabbix agent checks on host "10.0.0.15": interface became available
  4601:20220323:204841.511 received configuration data from server at "10.0.0.12", datalen 21366
  4597:20220323:204846.499 received configuration data from server at "10.0.0.12", datalen 21366


 4629:20220323:204302.585 enabling Zabbix agent checks on host "10.0.0.14": interface became available
  4601:20220323:204306.226 received configuration data from server at "10.0.0.12", datalen 21366
  4598:20220323:204311.010 received configuration data from server at "10.0.0.12", datalen 21366
  4599:20220323:204316.016 received configuration data from server at "10.0.0.12", datalen 21366
  4597:20220323:204321.005 received configuration data from server at "10.0.0.12", datalen 21366
  4600:20220323:204326.017 received configuration data from server at "10.0.0.12", datalen 21366
  4599:20220323:204331.025 received configuration data from server at "10.0.0.12", datalen 21366
  4600:20220323:204336.035 received configuration data from server at "10.0.0.12", datalen 21366
  4600:20220323:204341.042 received configuration data from server at "10.0.0.12", datalen 21366
  4598:20220323:204346.035 received configuration data from server at "10.0.0.12", datalen 21366
  4601:20220323:204351.031 received configuration data from server at "10.0.0.12", datalen 21366

[root@zabbix ~]#tail /var/log/zabbix/zabbix_server.log
 17642:20220323:212141.682 sending configuration data to proxy "zabbix-proxy" at "10.0.0.13", datalen 38633, bytes 5661 with compression ratio 6.8
 17644:20220323:212146.680 sending configuration data to proxy "zabbix-proxy" at "10.0.0.13", datalen 38633, bytes 5661 with compression ratio 6.8
 17645:20220323:212151.680 sending configuration data to proxy "zabbix-proxy" at "10.0.0.13", datalen 38633, bytes 5661 with compression ratio 6.8
 17650:20220323:212156.688 sending configuration data to proxy "zabbix-proxy" at "10.0.0.13", datalen 38633, bytes 5661 with compression ratio 6.8
 17651:20220323:212201.694 sending configuration data to proxy "zabbix-proxy" at "10.0.0.13", datalen 38633, bytes 5661 with compression ratio 6.8
 17647:20220323:212206.698 sending configuration data to proxy "zabbix-proxy" at "10.0.0.13", datalen 38633, bytes 5661 wit

查看数据:

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zhu1241jie

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值