CentOS 7.4 安装配置zabbix-agent
CentOS 7.X 安装配置zabbix-agent
前面文章有写安装zabbix -server,也就是zabbix服务端,这里安装zabbix-agent,也就是客户端。客户端也就是安装在你要监控的主机上面,当然也可以安装在服务端,用来监控服务端(就是在一台机器上同时安装zabbix-server和zabbix-agent)。不管安装在哪,方法都是一样的。我们这里来监控另外一台主机,安装方法如下:
系统环境: CentOS Linux release 7.4.1708 (7.4)
主机IP : 192.168.178.14
#新建一个存放源码包的目录
[root@localhost /]# mkdir /tools
[root@localhost /]# cd /tools
[root@localhost tools]#
#下载zabbix源码包
[root@localhost tools]# wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.2.6/zabbix-3.2.6.tar.gz
#解压源码包
[root@localhost tools]# ls
zabbix-3.2.6.tar.gz
[root@localhost tools]# tar zxf zabbix-3.2.6.tar.gz
[root@localhost tools]# ls
zabbix-3.2.6 zabbix-3.2.6.tar.gz
[root@localhost tools]#
#预编译&安装zabbix-agent
[root@localhost tools]# cd zabbix-3.2.6
[root@localhost zabbix-3.2.6]# ./configure --prefix=/usr/local/zabbix --enable-agent
[root@localhost zabbix-3.2.6]# make && make install
此zabbix-agent安装完成,安装路径在/usr/local/zabbix
需要到/usr/local/zabbix/etc/下修改zabbix_agentd.conf配置文件
[root@localhost zabbix-3.2.6]# cd /usr/local/zabbix/etc/
[root@localhost etc]# ls
zabbix_agentd.conf zabbix_agentd.conf.d
#备份默认配置文件
[root@localhost etc]# cp zabbix_agentd.conf zabbix_agentd.conf.bak
[root@localhost etc]#
#修改配置文件zabbix_agentd.conf
[root@localhost etc]# cat > zabbix_agentd.conf << EOF
LogFile=/tmp/zabbix_agentd.log #zabbix-agent日志log
Server=192.168.149.128 #zabbix-server的IP地址
ServerActive=192.168.149.128 #zabbix主动 监控server的IP地址
Hostname = 192.168.149.129 #本机IP 即zabbix-agent的IP地址
EOF
#创建zabbix用户
[root@localhost etc]# useradd zabbix
[root@localhost etc]# usermod -s /sbin/nologin zabbix
[root@localhost etc]#
#启动zabbix
[root@localhost etc]# /usr/local/zabbix/sbin/zabbix_agentd
[root@localhost etc]#
#查看zabbix-agent进程
[root@localhost etc]# ps -ef |grep zabbix
zabbix 20374 1 0 09:40 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_agentd
zabbix 20375 20374 0 09:40 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix 20376 20374 0 09:40 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix 20377 20374 0 09:40 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix 20378 20374 0 09:40 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix 20379 20374 0 09:40 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
root 20398 1088 0 09:42 pts/0 00:00:00 grep --color=auto zabbix
[root@localhost etc]#