Centos7 下安装部署zabbix-agent客户端
一、环境介绍
官网地址:http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/
二、代理安装
1、将代理程序拷贝至Node1服务器的/usr/src/zabbix3.4.5/目录下
下载路径:
http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-agent-3.4.5-1.el7.x86_64.rpm
http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-sender-3.4.5-1.el7.x86_64.rpm
将上传(xshell可用put上传)rpm软件包放入自己可找到的目录下,通过yum安装,如下:
进入服务器,查看,两个安装包已上传
[root@Node3 zabbix3.4.5]# scp zabbix-agent-3.4.5-1.el7.x86_64.rpm zabbix-sender-3.4.5-1.el7.x86_64.rpm root@node1:/usr/src/zabbix3.4.5/ root@node1's password: zabbix-agent-3.4.5-1.el7.x86_64.rpm 100% 359KB 29.9MB/s 00:00 zabbix-sender-3.4.5-1.el7.x86_64.rpm 100% 260KB 33.2MB/s 00:00
2、代理通过yum的方式来安装
[root@Node1 zabbix3.4.5]# yum install -y *.rpm ./ //通过yum方式安装当前目录下的rpm包 Loaded plugins: fastestmirror, langpacks Examining zabbix-agent-3.4.5-1.el7.x86_64.rpm: zabbix-agent-3.4.5-1.el7.x86_64 Marking zabbix-agent-3.4.5-1.el7.x86_64.rpm to be installed Examining zabbix-sender-3.4.5-1.el7.x86_64.rpm: zabbix-sender-3.4.5-1.el7.x86_64 Marking zabbix-sender-3.4.5-1.el7.x86_64.rpm to be installed CentOS7.4 | 3.6 kB 00:00:00 (1/2): CentOS7.4/group_gz | 156 kB 00:00:00 (2/2): CentOS7.4/primary_db | 3.1 MB 00:00:00 Determining fastest mirrors No package ./ available. Resolving Dependencies --> Running transaction check ---> Package zabbix-agent.x86_64 0:3.4.5-1.el7 will be installed ---> Package zabbix-sender.x86_64 0:3.4.5-1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ===================================================================================================================================================== Package Arch Version Repository Size ===================================================================================================================================================== Installing: zabbix-agent x86_64 3.4.5-1.el7 /zabbix-agent-3.4.5-1.el7.x86_64 1.4 M zabbix-sender x86_64 3.4.5-1.el7 /zabbix-sender-3.4.5-1.el7.x86_64 1.0 M Transaction Summary ===================================================================================================================================================== Install 2 Packages Total size: 2.4 M Installed size: 2.4 M Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : zabbix-sender-3.4.5-1.el7.x86_64 1/2 Installing : zabbix-agent-3.4.5-1.el7.x86_64 2/2 Verifying : zabbix-agent-3.4.5-1.el7.x86_64 1/2 Verifying : zabbix-sender-3.4.5-1.el7.x86_64 2/2 Installed: zabbix-agent.x86_64 0:3.4.5-1.el7 zabbix-sender.x86_64 0:3.4.5-1.el7 Complete! [root@Node1 zabbix3.4.5]# id zabbix uid=991(zabbix) gid=986(zabbix) groups=986(zabbix) [root@Node1 zabbix3.4.5]#
3、修改/etc/zabbix/zabbix_agentd.conf配置文件
[root@Node1 ~]# vim /etc/zabbix/zabbix_agentd.conf [root@Node1 ~]# grep -n "^[a-Z]" /etc/zabbix/zabbix_agentd.conf 13:PidFile=/var/run/zabbix/zabbix_agentd.pid 32:LogFile=/var/log/zabbix/zabbix_agentd.log 43:LogFileSize=0 57:DebugLevel=3 //日志级别,默认为3 97:Server=172.17.21.208 //用于被动模式,数据获取 138:ServerActive=172.17.21.208 //用于主动模式,数据提交
149:Hostname=Node1.contoso.com //必须与创建主机时的hostname一致
267:Include=/etc/zabbix/zabbix_agentd.d/*.conf //包含子配置文件的路径 286:UnsafeUserParameters=1 //允许所有字符的参数传递给用户定义的参数,默认为0,即没有启用
4、启动zabbix_agent服务器,并设置开机自启动
[root@Node1 ~]# systemctl start zabbix-agent.service [root@Node1 ~]# systemctl enable zabbix-agent.service Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service. [root@Node1 ~]# ss -tnl | grep 100 LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 *:10050 *:* LISTEN 0 100 ::1:25 :::* LISTEN 0 128 :::10050 :::*
三、Zabbix Server上添加主机
1、点击Configuration–>Hosts–>Greate host,然后点击Add,进行添加即可
2、点击添加之后,进入Configuration–>Hosts界面进行模板关联
3、选择 Node1节点这后,点击Templates,选择所需要的模板进行关联,然后点击Add,然后Update即可
4、然后看到以下界面,说明模板已经关联,发现ZBX为绿色,代表正常:
5、在zabbix服务器获取相关参数值:
[root@Node3 zabbix3.4.5]# zabbix_get -s 172.17.21.206 -p 10050 -k "system.hostname" //获取主机名 Node1.contoso.com [root@Node3 zabbix3.4.5]# zabbix_get -s 172.17.21.206 -p 10050 -k "system.uptime" //运行时间 125985 [root@Node3 zabbix3.4.5]# zabbix_get -s 172.17.21.206 -p 10050 -k "vm.memory.size[total]" //获取总内存,以下为4G 4143792128 [root@Node3 zabbix3.4.5]#
6、在Web界面查看可用内存如下:
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/281704.html