Zabbix5.0+Grafana可视化试用(七):通过zabbix agent(yum安装方式)实现CentOS8数据采集及监控

首先关闭防火墙及SELinux,开始安装agent:

[root@localhost ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
Retrieving https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
warning: /var/tmp/rpm-tmp.nxYZKN: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Verifying…                          ################################# [100%]
Preparing…                          ################################# [100%]
Updating / installing…
   1:zabbix-release-5.0-1.el8         ################################# [100%]
[root@localhost ~]#

开始安装:

[root@localhost ~]# yum install zabbix-agent
Failed to set locale, defaulting to C.UTF-8
CentOS-8 – AppStream                          6.8 kB/s | 4.3 kB     00:00   
CentOS-8 – Base                               6.7 kB/s | 3.9 kB     00:00   
CentOS-8 – Extras                             3.2 kB/s | 1.5 kB     00:00   
Extra Packages for Enterprise Linux 8 – x86_6  13 kB/s | 8.4 kB     00:00   
Extra Packages for Enterprise Linux 8 – x86_6 102 kB/s | 6.8 MB     01:08   
nginx stable repo                             7.0 kB/s | 2.9 kB     00:00   
Zabbix Official Repository – x86_64           9.3 kB/s |  25 kB     00:02   
Zabbix Official Repository non-supported – x8 541  B/s | 1.2 kB     00:02   
Dependencies resolved.
==============================================================================
  Package              Architecture   Version             Repository      Size
==============================================================================
Installing:
  zabbix-agent         x86_64         5.0.1-1.el8         zabbix         454 k

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

Total download size: 454 k
Installed size: 1.9 M
Is this ok [y/N]: y
Downloading Packages:
zabbix-agent-5.0.1-1.el8.x86_64.rpm           122 kB/s | 454 kB     00:03   
——————————————————————————
Total                                         122 kB/s | 454 kB     00:03    
warning: /var/cache/dnf/zabbix-b7349cbb4866b08d/packages/zabbix-agent-5.0.1-1.el8.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Zabbix Official Repository – x86_64           1.6 MB/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.0.1-1.el8.x86_64                      1/1
  Installing       : zabbix-agent-5.0.1-1.el8.x86_64                      1/1
  Running scriptlet: zabbix-agent-5.0.1-1.el8.x86_64                      1/1
  Verifying        : zabbix-agent-5.0.1-1.el8.x86_64                      1/1

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

Complete!
[root@localhost ~]#

完成安装后,开始配置zabbix_agentd.conf配置文件:

Server=192.168.10.218
ServerActive=192.168.10.218
Hostname=localhost.localdomain

完成后保存退出。

配置文件修改后,开始启动服务:

启动服务:

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

添加开机启动功能:

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

查看agent服务是否已启动:

[root@localhost ~]# ps -ef | grep zabbix
zabbix   14732     1  0 06:32 ?        00:00:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix   14733 14732  0 06:32 ?        00:00:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix   14734 14732  0 06:32 ?        00:00:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix   14735 14732  0 06:32 ?        00:00:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix   14736 14732  0 06:32 ?        00:00:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix   14737 14732  0 06:32 ?        00:00:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
root     14763 26603  0 06:33 pts/1    00:00:00 grep –color=auto zabbix
[root@localhost ~]#
[root@localhost ~]# ss -tnl | grep 10050
LISTEN   0         128                 0.0.0.0:10050            0.0.0.0:*      
LISTEN   0         128                    [::]:10050               [::]:*      
[root@localhost ~]#

如上,已发现agentd进程运行,并且10050端口已启动。

开始添加至ZABBIX5.0平台中,打开zabbix server主界面,选择“配置‘->”主机“,点击右上角的”创建“按扭,创建一台主机,如下图

zabbix5.0_42

链接zabbix agent for linux模板:

zabbix5.0_44

完成后可以看到列表中已经有刚才不回的主机,过几分钟后,可用性一栏中的ZBX变绿即表示监控正常。

zabbix5.0_45

Leave a Reply