1.zabbix-agent安装
- 配置yum源
rpm -ihv http://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
- 安装zabbix-agent
[root@localhost ~]# yum install zabbix-agent -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package zabbix-agent.x86_64 0:3.0.14-1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================
Package Arch Version Repository Size
===================================================================================================================
Installing:
zabbix-agent x86_64 3.0.14-1.el6 zabbix 334 k
Transaction Summary
===================================================================================================================
Install 1 Package(s)
Total download size: 334 k
Installed size: 1.3 M
Downloading Packages:
zabbix-agent-3.0.14-1.el6.x86_64.rpm | 334 kB 00:01
warning: rpmts_HdrFromFdno: Header V4 DSA/SHA1 Signature, key ID 79ea5ed4: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
Importing GPG key 0x79EA5ED4:
Userid : Zabbix SIA <packager@zabbix.com>
Package: zabbix-release-3.0-1.el6.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : zabbix-agent-3.0.14-1.el6.x86_64 1/1
Verifying : zabbix-agent-3.0.14-1.el6.x86_64 1/1
Installed:
zabbix-agent.x86_64 0:3.0.14-1.el6
Complete!
当然也可以使用源码安装,在编译时候指定agent(但是不建议使用源码安装时候新建zabbix账户,因为考虑系统的安全性。建议建立无法登陆的账号)
./configure --prefix=/usr/local/zabbix-3.0.3/ --enable-agent
2. 配置zabbix-agent配置文件
vi /etc/zabbix/zabbix_agentd.conf
修改如下参数:
Server=server端ip地址 #用于被动模式,数据获取
ServerActive=server端ip地址 #用于主动模式,数据提交
Hostname=mysql5.6 #该值跟zabbixweb上配置的主机名称要一致(配置-》主机-》主机名称)
Include=/etc/zabbix/zabbix_agentd.d/userparameter_percona_mysql.conf #此配置用于设置mysql插件监控 如果没有设置可以保持默认
ListenPort=10050 #默认是10050端口,这行是注释掉的可以更其他监控端口
3. 启动和防火墙设置
[root@localhost tmp]# service zabbix-agent start
Starting Zabbix agent: [确定]
[root@localhost tmp]# ps -ef|grep zabbix
zabbix 1671 1 0 14:34 ? 00:00:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix 1672 1671 0 14:34 ? 00:00:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix 1673 1671 0 14:34 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix 1674 1671 0 14:34 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix 1675 1671 0 14:34 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix 1676 1671 0 14:34 ? 00:00:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
在启动时候会遇到两个问题,启动时候,发现没有zabbix进程,原因没有关闭selinux服务,临时关闭有时候也无效,建议修改/etc/selinux/config,修改后重启主机。再次启动就可以了
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled #此项改为disable
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
在一个问题是启动了,但是在web端配置时候发现还是连不上需要修改防火墙配置
vi /etc//etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
#ZABBIX PORT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10041 -j ACCEPT (根据你的配置设置端口号)
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
service iptables restart
再就是主机启动以后zabbix的服务自动启动,可以如下设置:其他想开机启动也可以像如下设置
echo "service zabbix-agent start">>/etc/rc.local
4.web端设置



网友评论