编译安装zabbix-agent
在centos 上编译安装zabbix agent 程序,并配置自启动服务。
前期依赖程序安装,下载zabbix相对应的软件包。
下载zabbix
1 2
| yum update yum install epel-release gcc pcre-devel net-snmp-devel libevent-devel openssl-devel libxml2 libssh2-devel
|
下载源代码归档
下载地址zabbix download page,下载,解压源码.
1
| tar -zxvf zabbix-3.4.15.tar.gz
|
创建用户
创建用户
1 2
| groupadd --system zabbix useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -C "Zabbix Monitoring System" zabbix
|
编译安装
编译安装
1 2
| ./configure --enable-agent --prefix=/usr/local/zabbix make install
|
更改配置文件
1 2 3 4 5 6
| cat /usr/local/zabbix/etc/zabbix_agentd.conf | grep -Ev '^#|^$' PidFile=/tmp/zabbix_agentd.pid LogFile=/tmp/zabbix_agentd.log Server=zabbix_server_or_proxy ServerActive=zabbix_server_or_proxy Hostname=your_computer_hostname
|
添加开机启动项
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| [Unit] Description=Zabbix Agent After=syslog.target After=network.target
[Service] User=zabbix Group=zabbix Environment="CONFFILE=/usr/local/zabbix/etc/zabbix_agentd.conf" Type=forking Restart=on-failure PIDFile=/tmp/zabbix_agentd.pid KillMode=control-group ExecStart=/usr/local/zabbix/sbin/zabbix_agentd -c $CONFFILE ExecStop=/bin/kill -SIGTERM $MAINPID RestartSec=10s TimeoutSec=0
[Install] WantedBy=multi-user.target
|
防火墙配置
防火墙配置
1 2 3
| firewall-cmd --permanent --add-port=10050/tcp firelwall-cmd --permanent --add-port=10051/tcp firewall-cmd --complete-reload
|
启动服务
最后启动服务就完事了
1 2
| systemctl start zabbix-agent systemctl enable zabbix-agent
|