🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] ## **服务端安装Zabbix-server-5.0** * 安装常用的开发软件 * 主要是Development Tools工具组 ``` yum groups install "Development Tools" ``` * 查看工具包 ``` yum groups info "Development Tools" ``` * 关闭防火墙 ``` systemctl stop firewalld systemctl disable firewalld ``` * 安装Zabbix5.0仓库 ``` rpm -ivh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86\_64/zabbix-release-5.0-1.el7.noarch.rpm yum clean all ``` * 修改zabbix 为国内源 ``` vim /etc/yum.repos.d/zabbix.repo ``` ``` [zabbix] name=Zabbix Official Repository - $basearch baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 [zabbix-frontend] name=Zabbix Official Repository frontend - $basearch baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/frontend enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 [zabbix-debuginfo] name=Zabbix Official Repository debuginfo - $basearch baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/debuginfo/ enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 gpgcheck=1 [zabbix-non-supported] name=Zabbix Official Repository non-supported - $basearch baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearch/ enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX gpgcheck=1 ``` * 安装Zabbix server and agent ``` yum install zabbix-server-mysql zabbix-agent ``` * 启用Red Hat软件集合 ``` yum install centos-release-scl -y ``` * 启用zabbix-deprecated repository * 编辑/etc/yum.repos.d/zabbix.repo 修改成下面的内容 ~~~ [zabbix-frontend] name=Zabbix Official Repository frontend - $basearch baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/frontend enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 ~~~ * 安装zabbix前端 ``` yum install zabbix-web-mysql-scl zabbix-apache-conf-scl ``` * 安装mysql数据库 ``` yum -y install mariadb-server mariadb ``` * 启动mariadb ``` systemctl start mariadb systemctl enable mariadb ``` * 创建zabbix数据库 ``` mysql create database zabbix character set utf8 collate utf8_bin; show databases; grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; flush privileges; exit ``` * 导入Zabbix数据库结构和数据 ``` cd /usr/share/doc/zabbix-server-mysql-5.0.1/ gunzip create.sql.gz mysql use zabbix; source create.sql exit; ``` * 配置Zabbix server ``` vim /etc/zabbix/zabbix\_server.conf DBPassword=zabbix ``` * 为Zabbix前端配置PHP * 编辑/etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf文件, ``` vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf php_value[date.timezone] = Asia/Shanghai ``` * 启动Zabbix服务 ``` systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm ``` ## **客户端Zabbix-agent-5.0** * 离线安装Zabbix-agent-5.0 ``` rpm -ivh zabbix-agent-5.0.1-1.el7.x86_64.rpm ``` * 修改/etc/zabbix/zabbix\_agentd.conf配置文件中Server、ServerActive、Hostname三个参数,主机名取为zabbix\_learn,web前端配置的hostname需要和这个主机名保存一致 vim /etc/zabbix/zabbix_agentd.conf ``` #Server负责被动监控 #ServerActive负责主动监控 #这两个参数指向Server的IP地址 Server=10.176.233.24 ServerActive=10.176.233.24 #需要和web前端配置的hostname保存一致 Hostname=zabbix_learn ``` * 启动zabbix-agent ``` #启动 systemctl start zabbix-agent #查看 systemctl status zabbix-agent #设置开机自启 systemctl enable zabbix-agent ```