官方文档https://www.zabbix.com/documentation/3.4/zh/manual
操作环境CentOS7:
zabbix-server:172.16.80.103
zabbix-agent :172.16.80.101
- 服务器安装包
zabbix-server-mysql
zabbix-web-mysql
zabbix-get
zabbix-agent
zabbix-sender
- 客户端安装包
zabbix-agent
zabbix-sender
服务器初始化
1、安装zabbix
[root@zabbix-server ~]#yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-get zabbix-agent zabbix-sender
2、初始化zabbix
创建数据库
[root@zabbix-server ~]#mysql
MariaDB [(none)]> create database zabbix character set 'utf8';
MariaDB [(none)]> grant all on zabbix.* to 'zabbix'@'172.16.80.%' identified by 'zabbix';
MariaDB [(none)]> grant all on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> quit
导入zabbix表格
[root@zabbix-server ~]#rpm -ql zabbix-server-mysql
...部分略
/usr/share/doc/zabbix-server-mysql-3.4.2/create.sql.gz
#zabbix-server-mysql这个包有个数据库模板create.sql.gz,我们可以用它导进数据库中
[root@zabbix-server ~]#cp /usr/share/doc/zabbix-server-mysql-3.4.2/create.sql.g ./
[root@zabbix-server ~]#gzip -d create.sql.gz
[root@zabbix-server ~]#mysql -uzabbix -pzabbix -h172.16.80.103 zabbix <create.sql
3、配置
zabbix服务配置文件/etc/zabbix/zabbix_server.conf
四个部分:
- GENERAL PARAMETERS
- ADVANCED PARAMETERS
- LOADABLE MODULES
- TLS-RELATED PARAMETERS
[root@zabbix-server zabbix]#cat zabbix_server.conf |grep ^[^#]
ListenPort=10051
SourceIP=172.16.80.103
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
DBPort=3306
如果要用到zabbix-web,那么我们还得改一下/etc/httpd/conf.d/zabbix.conf文件
[root@zabbix-server conf.d]#cat /etc/httpd/conf.d/zabbix.conf |grep timezone
php_value date.timezone Asia/Shanghai
#把timezone改成Asia/Shanghai,因为zabbix是依赖与于imezone的
4、启动服务
[root@zabbix-server zabbix]#systemctl start zabbix-server
[root@centos7d zabbix]#ss -ntl |grep 10051
LISTEN 0 128 *:10051 *:*
LISTEN 0 128 :::10051 :::*
#如果启动失败,请查看日志文件、检查配置文件和数据库、数据库帐号
[root@zabbix-server conf.d]#systemctl start httpd
#zabbix默认用的是httpd的模块,启动时注意不要与nginx服务冲突,否则起不来。
5、登录zabbix
此处默认用户名admin、密码zabbix,建议登录后修改
客户端初始化
1、安装客户端包
[root@zabbix-agent~]#yum install zabbix-agent zabbix-sender
2、配置/etc/zabbix/zabbix_agentd.conf
[root@zabbix-agent zabbix]#cat /etc/zabbix/zabbix_agentd.conf |grep ^[^#]
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=172.16.80.103
ListenPort=10050
ListenIP=0.0.0.0
StartAgents=3
ServerActive=172.16.80.103
Hostname=zabbix-agent
Include=/etc/zabbix/zabbix_agentd.d/*.conf
3、
[root@zabbix-agent zabbix]#systemctl start zabbix-agent