centos7 源码安装zabbix
1. 下载源码包
# wget -O zabbix-4.4.4.tar.gz https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/4.4.4/zabbix-4.4.4.tar.gz/download
2. 安装依赖
# yum -y install net-snmp-devel libxml2-devel libcurl-deve libevent libevent-devel
3. 解压缩并编译安装
# tar -zxvf zabbix-4.4.4.tar.gz # cd zabbix-4.4.4 # ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 # make && make install
4. 创建用户
# useradd zabbix
# cd /usr/local && chown -R zabbix:zabbix zabbix/
5. 创建数据库,导入数据
mysql> create database if not exists zabbix default character set utf8 collate utf8_general_ci; mysql> use zabbix; mysql> source /root/zabbix-4.4.4/database/mysql/schema.sql; mysql> source /root/zabbix-4.4.4/database/mysql/images.sql; mysql> source /root/zabbix-4.4.4/database/mysql/data.sql; mysql> grant all privileges on zabbix.* to zabbix@'localhost' identified by 'zabbix';
6. 创建日志目录
# cd /usr/local/zabbix # mkdir logs # chown -R zabbix:zabbix logs/
7. 修改配置文件
[root@localhost ~]# vim /usr/local/zabbix/etc/zabbix_server.conf LogFile=/usr/local/zabbix/logs/zabbix_server.log PidFile=/tmp/zabbix_server.pid DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix DBSocket=/tmp/mysql.sock Include=/usr/local/zabbix/etc/zabbix_server.conf.d/*.conf
[root@localhost ~]# vim /usr/local/zabbix/etc/zabbix_agentd.conf PidFile=/tmp/zabbix_agentd.pid LogFile=/usr/local/zabbix/logs/zabbix_agentd.log Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
8. 启动服务
[root@localhost ~]# /usr/local/zabbix/sbin/zabbix_server
[root@localhost ~]# /usr/local/zabbix/sbin/zabbix_agentd
9. 开放防火墙端口
# firewall-cmd --zone=public --add-port=10050/tcp # firewall-cmd --zone=public --add-port=10050/tcp --permanent # firewall-cmd --zone=public --add-port=10051/tcp # firewall-cmd --zone=public --add-port=10051/tcp --permanent
10. 拷贝web应用程序至nginx 的html 目录下
[root@localhost ~]# cp zabbix-4.4.4/frontends/php/ /usr/local/nginx/html/zabbix/
11. 访问web界面
http://ip/zabbix/index.php
账号:Admin,密码:zabbix
12. 服务器端测试
# zabbix_get -s 127.0.0.1 -p 10050 -k "system.cpu.load[all,avg1]" 0.080000 # zabbix_get -s 192.168.80.132 -p 10050 -k "system.cpu.load[all,avg1]" 0.070000
13. web界面操作