环境
主机名 | IP | 类型 |
server01 | 192.168.134.165 | zabbix-server |
server02 | 192.168.134.166 | zabbix-agent |
官方部署文档
1 .安装yum源
[root@server01 ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
[root@server01 ~]# yum clean all
[root@server01 ~]# yum makecache fast
2.安装zabbix server , Web前端和agent相关软件
[root@server01 ~]# yum -y install zabbix-agent zabbix-get zabbix-sender zabbix-server-mysql
3.安装zabbix 前端
[root@server01 ~]# yum install centos-release-scl
编辑配置文件 /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
...
enabled=1
...
安装前端包
[root@server01 ~]# yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl
4.创建初始化数据
mysql> create user zabbix@localhost identified by 'Aren@123';
mysql> grant all privileges on zabbix.* to 'zabbix'@'%' identified by "Aren@123";
mysql> set global log_bin_trust_function_creators = 1;
mysql> \q
Bye
导入初始架构和数据,系统将提示您输入新创建的密码
[root@server01 ~]# rpm -ql zabbix-server-mysql
/etc/logrotate.d/zabbix-server
/etc/zabbix/zabbix_server.conf
/usr/lib/systemd/system/zabbix-server.service
/usr/lib/tmpfiles.d/zabbix-server.conf
/usr/lib/zabbix/alertscripts
/usr/lib/zabbix/externalscripts
/usr/sbin/zabbix_server_mysql
/usr/share/doc/zabbix-server-mysql-5.0.39
/usr/share/doc/zabbix-server-mysql-5.0.39/AUTHORS
/usr/share/doc/zabbix-server-mysql-5.0.39/COPYING
/usr/share/doc/zabbix-server-mysql-5.0.39/ChangeLog
/usr/share/doc/zabbix-server-mysql-5.0.39/NEWS
/usr/share/doc/zabbix-server-mysql-5.0.39/README
/usr/share/doc/zabbix-server-mysql-5.0.39/create.sql.gz
/usr/share/doc/zabbix-server-mysql-5.0.39/double.sql
/usr/share/man/man8/zabbix_server.8.gz
/var/log/zabbix
/var/run/zabbix[root@server01 ~]# zcat /usr/share/doc/zabbix-server-mysql-5.0.39/create.sql.gz | mysql -uzabbix -pAren@123 zabbix
5.为Zabbix server配置数据库
[root@server01 ~]# vim /etc/zabbix/zabbix_server.conf
DBPassword=Aren@123
6. 为Zabbix前端配置PHP
- 编辑配置文件 /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf 取消注释并设置“listen”和“server_name”指令。
# listen 80;
# server_name example.com;
[root@server01 ~]# vim /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf
- 编辑配置文件 /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf 做一下修改
7.修改文件权限
[root@server01 ~]# chown .nginx /var/opt/rh/rh-php72/lib/php/session/[root@server01 ~]# chown nginx.nginx -R /etc/zabbix/web/[root@server01 ~]# vim /etc/opt/rh/rh-nginx116/nginx/nginx.conf
####将server模块注释或者删除
server {
...
...
}
启动
启动Zabbix server和agent进程,并为它们设置开机自启:
[root@server01 ~]# systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
[root@server01 ~]# systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/rh-nginx116-nginx.service to /usr/lib/systemd/system/rh-nginx116-nginx.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/rh-php72-php-fpm.service to /usr/lib/systemd/system/rh-php72-php-fpm.service.
在浏览器中访问
监控过程配置
当我们把监控端配置启动以后,我们需要来设置一下我们的监控端,我们在被监控的主机安装好agent,设置好他的server,并把他添加到server端,就能将其纳入我们的监控系统中去了。
①客户端配置
[root@server02 ~]# rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
[root@server02 ~]# yum clean all
[root@server02 ~]# yum install zabbix-agent zabbix-sender -y
修改配置文件:
Server=192.168.134.165 #指明服务器是谁
ListenPort=10050 #自己监听的端口
ListenIP=0.0.0.0 #自己监听的地址,0.0.0.0表示本机所有地址
StartAgents=3 #优化时使用的ServerActive=192.168.134.165 #主动监控时的服务器
Hostname=server02 #自己能被server端识别的名称
启动客户端
[root@server02 ~]# systemctl start zabbix-agent
②创建主机及主机群组
- 然后我们就可以去添加主机了
- 创建监控项
定义完成,我们回到所有主机,等待5秒,我们可以看到,我们server02节点后面的选项已经有变成绿色的了:
③查看监控的数据
监测===>最新数据===>图形