如果集群开启,先关闭集群。因为安装 Zabbix 前,需要重启虚拟机。
分别在 hadoop 102、103 和 104 上执行
sudo systemctl stop firewalld.service
sudo systemctl disable firewalld.service
A、修改配置文件 /etc/selinux/config
[fancy@hadoop102 ~]$ sudo vim /etc/selinux/config
修改如下内容
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
B、重启服务器
[fancy@hadoop102 ~]$ sudo reboot
A、安装 zabbix 的软件仓库配置包
这个包包含了 yum (软件包管理器) 的配置文件。
[fancy@hadoop102 ~]$ sudo rpm -Uvh
https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
[fancy@hadoop103 ~]$ sudo rpm -Uvh
https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
[fancy@hadoop104 ~]$ sudo rpm -Uvh
https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
B、安装 Software Collections 仓库
[fancy@hadoop102 ~]$ sudo yum install -y centos-release-scl
[fancy@hadoop103 ~]$ sudo yum install -y centos-release-scl
[fancy@hadoop104 ~]$ sudo yum install -y centos-release-scl
hadoop102、hadoop103、hadoop104 三台节点,依次执行如下步骤。
A、查看原始 zabbix.repo 文件
[fancy@hadoop102 ~]$ sudo cat /etc/yum.repos.d/zabbix.repo
查看内容如下
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/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=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=http://repo.zabbix.com/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=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
B、执行以下命令完成全局替换,修改为阿里云镜像
[fancy@hadoop102 ~]$ sudo sed -i
's/http:\/\/repo.zabbix.com/https:\/\/mirrors.aliyun.com\/zabbix/g' /etc/yum.repos.d/zabbix.repo
C、查看修改之后的 zabbix.repo 文件
[fancy@hadoop102 ~]$ sudo cat /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=0
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/$base
arch/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
D、打开/etc/yum.repos.d/zabbix.repo 文件,启用 zabbix-web 仓库
[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
在 hadoop102、hadoop103、hadoop104 三台节点分别执行以下安装命令
[fancy@hadoop102 ~]$ sudo yum install -y zabbix-server-mysql zabbix-agent zabbix-web-mysql-scl zabbix-apache-conf-scl
[fancy@hadoop103 ~]$ sudo yum install -y zabbix-agent
[fancy@hadoop104 ~]$ sudo yum install -y zabbix-agent
[fancy@hadoop102 ~]$ mysql -uroot -p123456 -e "create database zabbix character set utf8 collate utf8_bin"
[fancy@hadoop102 ~]$ zcat
/usr/share/doc/zabbix-server-mysql-5.0.18/create.sql.gz | mysql -uroot -p123456 zabbix
修改 zabbix-server 配置文件
[fancy@hadoop102 ~]$ sudo vim /etc/zabbix/zabbix_server.conf
DBHost=hadoop102
DBName=zabbix
DBUser=root
DBPassword=123456
修改 zabbix-agent 配置文件
[fancy@hadoop102 ~]$ sudo vim /etc/zabbix/zabbix_agentd.conf
修改如下内容:
Server=hadoop102
#ServerActive=127.0.0.1
#Hostname=Zabbix server
修改/etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf 文件
[fancy@hadoop102 ~]$ sudo vim
/etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
修改如下内容:
[zabbix]
user = apache
group = apache
listen = /var/opt/rh/rh-php72/run/php-fpm/zabbix.sock
listen.acl_users = apache
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
php_value[session.save_handler] = files
php_value[session.save_path] =
/var/opt/rh/rh-php72/lib/php/session/
php_value[max_execution_time] = 300
php_value[memory_limit] = 128M
php_value[post_max_size] = 16M
php_value[upload_max_filesize] = 2M
php_value[max_input_time] = 300
php_value[max_input_vars] = 10000
php_value[date.timezone] = Asia/Shanghai
[fancy@hadoop102 ~]$ sudo systemctl start zabbix-server zabbix-agent httpd rh-php72-php-fpm
[fancy@hadoop102 ~]$ sudo systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
[fancy@hadoop103 ~]$ sudo systemctl start zabbix-agent
[fancy@hadoop103 ~]$ sudo systemctl enable zabbix-agent
[fancy@hadoop104 ~]$ sudo systemctl start zabbix-agent
[fancy@hadoop104 ~]$ sudo systemctl enable zabbix-agent
[fancy@hadoop102 ~]$ sudo systemctl stop zabbix-server zabbix-agent
httpd rh-php72-php-fpm
[fancy@hadoop102 ~]$ sudo systemctl disable zabbix-server
zabbix-agent httpd rh-php72-php-fpm
[fancy@hadoop103 ~]$ sudo systemctl stop zabbix-agent
[fancy@hadoop103 ~]$ sudo systemctl disable zabbix-agent
[fancy@hadoop104 ~]$ sudo systemctl stop zabbix-agent
[fancy@hadoop104 ~]$ sudo systemctl disable zabbix-agent
A、浏览器访问 http://hadoop102/zabbix/
B、检查配置
C、配置数据库
A、用户名:Admin 密码:zabbix
B、点击 User Settings,语言设成中文
注意:这里默认会对 Zabbix Server 进行监控,但是我们可以看到目前该主机是红色,不可用的状态,原因是主机的地址不能使用 127.0.0.1 需要后续我们单独配置。