说明:
Zabbix用于监控主机状态信息,分为服务端和被监听端。
一、Zabbix服务端安装/配置:
安装存储库MySQL5.7.37(一章,和Zabbix5.0服务端同一台机器):
https://blog.youkuaiyun.com/a526001650a/article/details/123188040?spm=1001.2014.3001.5501
1.安装Zabbix Repository:
[root@localhost ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
[root@localhost ~]# yum clean all
2.安装Zabbix server和agent:
[root@localhost ~]# yum -y install zabbix-server-mysql zabbix-agent
3.安装Zabbix前端(管理页):
(1)启用Red Hat软件集合:
[root@localhost ~]# yum -y install centos-release-scl
(2)启用zabbix-frontend存储库(vi /etc/yum.repos.d/zabbix.repo):
[zabbix-frontend]
...
enabled=1 #改为1启用
...
(3)安装Zabbix frontend(基于nginx):
[root@localhost ~]# yum -y install zabbix-web-mysql-scl zabbix-nginx-conf-scl
4.创建zabbix数据库并导入数据:
(1)登录mysql:
[root@localhost ~]# mysql -u root -p
Enter password:
(2)创建zabbix数据库、用户zabbix、密码password:
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> SET GLOBAL validate_password_length=2;
mysql> SET GLOBAL validate_password_policy=0;
mysql> create user zabbix@localhost identified by 'password';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> quit;
(3)导入数据(输入密码:password):
[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password:
5.修改Zabbix server数据库密码(vi /etc/zabbix/zabbix_server.conf):
...
DBPassword=password #去掉注释,添加zabbix用户的密码
...
6.Zabbix前端配置PHP:
(1)配置虚拟主机(vi /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf):
listen 80; #去掉注释
server_name example.com; #去掉注释
(2)添加nginx监听(vi /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf):
...
listen.acl_users = apache,nginx #默认只有apache,此处添加nginx监听
...
php_value[date.timezone] = Asia/Shanghai #改为中国时区
...
7.启动Zabbix server和agent进程:
[root@localhost ~]# systemctl start zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
[root@localhost ~]# systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
8.Zabbix前端页面配置/访问:
(1)打开Zabbix前端页面进行配置:
http://192.168.233.128:80
官方前端页面配置说明文档:
https://www.zabbix.com/documentation/5.0/zh/manual/installation/frontend
(2)访问Zabbix前端首页(登录用户名Admin/密码zabbix):
http://192.168.233.128:80/index.php
二、被监控端主机安装/配置Zabbix:
1.安装Zabbix Repository:
[root@localhost ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
[root@localhost ~]# yum clean all
2.安装Zabbix agent:
[root@localhost ~]# yum -y install zabbix-agent
3.配置Zabbix(vi /etc/zabbix/zabbix_agentd.conf):
...
Server=192.168.233.128 #zabbix服务端地址(被动模式使用)
ListenPort=10050 #监听端口
ListenIP=0.0.0.0 #监听所有IP
ServerActive=192.168.233.128 #zabbix服务端地址(主动模式使用)
Hostname=Zabbix-client01 #本机名称,在Zabbix前端页面左侧菜单Configuration -> 下拉选中Hosts -> 和Name中一致
4.启动Zabbix:
[root@localhost ~]# systemctl start zabbix-agent
[root@localhost ~]# systemctl enable zabbix-agent
三、Zabbix前端管理页中添加需要被监控的主机:
访问Zabbix前端首页(登录用户名Admin/密码zabbix):
http://192.168.233.128:80/index.php
1.创建需要被监听主机(Zabbix前端首页 -> 左侧菜单Configuration -> 下拉选中Hosts,点右上角"创建主机"按钮,按图示设置需要的参数):
2.浏览监控页面: