zabbix_agent编译安装与配置使用
1、安装编译环境
yum -y install gcc gcc-c++
2、安装pcre软件包
yum install -y pcre*
3、创建用户zabbix
groupadd zabbix
useradd -g zabbix zabbix -s /sbin/nologin
4、安装zabbix_agent
[root@localhost ~]# wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.4.15/zabbix-3.4.15.tar.gz
[root@localhost ~]# tar xzf zabbix-3.4.15.tar.gz -C /opt/
[root@localhost ~]# cd /opt/zabbix-3.4.15
[root@localhost ~]# ./configure --prefix=/opt/zabbix/ --enable-agent
[root@localhost ~]# make && make install
[root@localhost ~]# cd /opt/zabbix
[root@localhost zabbix]# mkdir log run
[root@localhost opt]# chown -R zabbix:zabbix zabbix
5、zabbix配置文件
PidFile=/opt/zabbix/run/zabbix_agentd.pid
LogFile=/opt/zabbix/log/zabbix_agentd.log
LogFileSize=0
Server=
ServerActive=
Hostname=
HostMetadata=
Include=/opt/zabbix/etc/zabbix_agentd.conf.d/*.conf
UnsafeUserParameters=1
6、启动zabbix_agent
/opt/zabbix/sbin/zabbix_agentd
- 设置为systemd服务
/usr/lib/systemd/system/zabbix-agent.service
[Unit]
Description=Zabbix Agent
After=syslog.target
After=network.target
[Service]
User=zabbix
Group=zabbix
Environment="CONFFILE=/opt/zabbix/etc/zabbix_agentd.conf"
Type=forking
Restart=on-failure
PIDFile=/opt/zabbix/run/zabbix_agentd.pid
KillMode=control-group
ExecStart=/opt/zabbix/sbin/zabbix_agentd -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
TimeoutSec=0
[Install]
WantedBy=multi-user.target
- 启动服务并设置为开机自启
systemctl start zabbix-agent
systemctl enable zabbix-agent
zabbix_proxy编译安装与配置使用
安装依赖包
yum install -y mysql-devel net-snmp net-snmp-devel libssh2-devel
源码安装proxy
[root@localhost ~]# tar xzf zabbix-3.4.15.tar.gz
[root@localhost ~]# cd /opt/zabbix-3.4.15
[root@localhost zabbix-3.4.15]# ./configure --prefix=/opt/zabbix-proxy --enable-proxy --with-net-snmp --with-mysql --with-ssh2
[root@localhost zabbix-3.4.15]# make && make install
[root@localhost zabbix-proxy]# mkdir log run
[root@localhost opt]# chown -R zabbix:zabbix zabbix-proxy
安装mariadb或者msyql数据库
yum install -y mariadb mariadb-server mariadb-devel
创建数据库
Zabbix proxy 是将数据储存在本地,然后传输到 Zabbix Server 的。所以我们需要创建 Zabbix proxy 的数据库。
# 创建数据库
create database zabbix_proxy character set utf8 collate utf8_bin;
# 创建用户
grant all privileges on zabbix_proxy.* to zabbix@localhost identified by 'password';
导入数据,zabbix proxy 不需要将所有的数据库数据都导入,只需要导入 schema.sql
mysql -u zabbix -ppasswd zabbix_proxy </opt/zabbix-3.4.15/database/mysql/schema.sql
更改Zabbix proxy 配置文件
server=ip
Hostname=
LogFile=
DBHost=localhost
DBName=zabbix_proxy
DBUser=zabbix
DBPassword=zabbix
ConfigFrequency=120 #主动去server端去拉去配置更新的频率120秒一次
DataSenderFrequency=60 #发送采集的监控数据到服务器端,默认是1秒,我们一分钟发送一次
设置为 systemd 服务
[Unit]
Description=Zabbix Proxy
After=syslog.target
After=network.target
[Service]
User=zabbix
Group=zabbix
Environment="CONFFILE=/opt/zabbix-proxy/etc/zabbix_proxy.conf"
Type=forking
Restart=on-failure
PIDFile=/opt/zabbix-proxy/run/zabbix_proxy.pid
KillMode=control-group
ExecStart=/opt/zabbix-proxy/sbin/zabbix_proxy -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
TimeoutSec=0
[Install]
WantedBy=multi-user.target
启动服务并设置为开机自启
systemctl restart zabbix-proxy
systemctl enable zabbix-proxy
rpm安装zabbix-agent
wget http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-agent-3.4.15-1.el7.x86_64.rpm
rpm -ivh zabbix-agent-3.4.15-1.el7.x86_64.rpm
systemctl start zabbix-agent
网友评论