CentOS 8 安装Zabbix Agent

2021年3月3日 41点热度 0人点赞 0条评论

CentOS 8 安装Zabbix Agent。

为了使用Zabbix监控Linux服务器,可在服务器安装Zabbix-agent,使用Zabbix-agent进行监控,获取的信息相对SNMP更多。

环境

系统:CentOS8
Zabbix-agent 5.2

安装

安装Zabbix仓库

[root@localhost ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.2/rhel/8/x86_64/zabbix-release-5.2-1.el8.noarch.rpm
bbix-release-5.2-1.el8.noarch.rpms://repo.zabbix.com/zabbix/5.2/rhel/8/x86_64/zb
Retrieving https://repo.zabbix.com/zabbix/5.2/rhel/8/x86_64/zabbix-release-5.2-m
warning: /var/tmp/rpm-tmp.N7iwJX: Header V4 RSA/SHA512 Signature, key ID a14fe5Y
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-5.2-1.el8         ################################# [100%]

清理工作

[root@localhost ~]# dnf clean all
20 files removed

安装Zabbix-agent

[root@localhost ~]# dnf install zabbix-agent
CentOS-8 - AppStream                            104 kB/s | 6.3 MB     01:01    
CentOS-8 - Base                                 110 kB/s | 2.3 MB     00:21    
CentOS-8 - Extras                               6.5 kB/s | 9.2 kB     00:01    
Zabbix Official Repository - x86_64              15 kB/s |  72 kB     00:04    
Zabbix Official Repository non-supported - x86_ 1.3 kB/s | 1.2 kB     00:00    
Dependencies resolved.
================================================================================
 Package              Architecture   Version               Repository      Size
================================================================================
Installing:
 zabbix-agent         x86_64         5.2.5-1.el8           zabbix         472 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 472 k
Installed size: 2.0 M
Is this ok [y/N]: y
Downloading Packages:
zabbix-agent-5.2.5-1.el8.x86_64.rpm              17 kB/s | 472 kB     00:28    
--------------------------------------------------------------------------------
Total                                            17 kB/s | 472 kB     00:28     
warning: /var/cache/dnf/zabbix-7872307036b55ebb/packages/zabbix-agent-5.2.5-1.eY
Zabbix Official Repository - x86_64             285 kB/s | 1.7 kB     00:00    
Importing GPG key 0xA14FE591:
 Userid     : "Zabbix LLC <packager@zabbix.com>"
 Fingerprint: A184 8F53 52D0 22B9 471D 83D0 082A B56B A14F E591
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Running scriptlet: zabbix-agent-5.2.5-1.el8.x86_64                        1/1 
  Installing       : zabbix-agent-5.2.5-1.el8.x86_64                        1/1 
  Running scriptlet: zabbix-agent-5.2.5-1.el8.x86_64                        1/1 
  Verifying        : zabbix-agent-5.2.5-1.el8.x86_64                        1/1 
Installed products updated.

Installed:
  zabbix-agent-5.2.5-1.el8.x86_64                                               

Complete!

启动Zabbix-agent

启动Zabbix-agent

[root@localhost ~]# systemctl start zabbix-agent

开机启动zabbix-agent

[root@localhost ~]# systemctl enable zabbix-agent
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-agent.servic.

查看Zabbix-agent状态

[root@localhost ~]# systemctl status zabbix-agent
● zabbix-agent.service - Zabbix Agent
   Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled; vendo>
   Active: active (running) since Wed 2021-03-03 13:43:16 CST; 22min ago
 Main PID: 13997 (zabbix_agentd)
    Tasks: 6 (limit: 12505)
   Memory: 3.9M
   CGroup: /system.slice/zabbix-agent.service
           ├─13997 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
           ├─13998 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
           ├─13999 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
           ├─14000 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
           ├─14001 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
           └─14002 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

Mar 03 13:43:15 localhost.localdomain systemd[1]: Starting Zabbix Agent...
Mar 03 13:43:16 localhost.localdomain systemd[1]: zabbix-agent.service: Can't o>
Mar 03 13:43:16 localhost.localdomain systemd[1]: Started Zabbix Agent.

查看是否已经监听端口

[root@localhost ~]# netstat -tunpl | grep 1005
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      13997/zabbix_agentd 
tcp6       0      0 :::10050                :::*                    LISTEN      13997/zabbix_agentd

配置防火墙

Zabbix-agent监听TCP 10050端口,如果Zabbix-agent所的主机开启了防火墙,需要放开TCP 10050端口。

[root@localhost ~]# firewall-cmd --add-port=10050/tcp --permanent
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# firewall-cmd --list-port
10050/tcp

在Zabbix-server所在的主机测试Zabbix-agent所在主机的TCP 10050端口是否可以连接。

<H3C>telnet 10.1.1.12 10050
Trying 10.1.1.12 ...
Press CTRL+K to abort
Connected to 10.1.1.12 ...

The connection was closed by the remote host!

因为Zabbix-agent也需要连接Zabbix的服务器端,Zabbix-server所在的主机要放开Zabbix-server的TCP 10051端口。

修改Zabbix-agent的配置

Zabbix-agent的配置文件/etc/zabbix/zabbix_agentd.conf

将配置文件中的默认配置Server=127.0.0.1修改为Zabbix-server的IP,如Server=10.1.1.11

### Option: TLSCipherAll13
#       Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3.
#       Override the default ciphersuite selection criteria for certificate- and PSK-based encryption.
##### Passive checks related

### Option: Server
#       List of comma delimited IP addresses, optionally in CIDR notation, or DNN
S names of Zabbix servers and Zabbix proxies.
#       Incoming connections will be accepted only from the hosts listed here.
#       If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127..
0.0.1' are treated equally
#       and '::/0' will allow any IPv4 or IPv6 address.
#       '0.0.0.0/0' can be used to allow any IPv4 address.
#       Example: Server=127.0.0.1,192.168.1.0/24,::1,2001:db8::/32,zabbix.exampll
e.com
#
# Mandatory: yes, if StartAgents is not explicitly set to 0
# Default:
# Server=

#Server=127.0.0.1
Server=10.1.1.11

如果不设置Server的IP,在Zabbix web界面中,Hosts菜单看到的被监控主机的Availability显示红色的“ZBX”。

参考资料

官方安装教程
官方文档

 

arben

这个人很懒,什么都没留下

文章评论