1.集群规划
进程 | 虚拟机节点1 | 虚拟机节点2 | 虚拟机节点3 |
---|---|---|---|
zabbix-agent | √ | √ | √ |
zabbix-server | √ | ||
PostgreSQL | √ | ||
zabbix-web | √ |
2.准备工作
默认在虚拟机节点2安装kafka、在虚拟机节点3安装redis2.1关闭3台节点防火墙
sudo systemctl stop firewalld.service
sudo systemctl disable firewalld.service
2.2关闭3台节点上的SELinux
1)修改配置文件/etc/selinux/configvim /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 three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
2)重启虚拟机
reboot
2.3配置3台节点的Zabbix yum源
2.3.1安装yum仓库
**1)**** 安装 zabbix 的软件仓库配置包**分别在三个节点下运行一下这个命令
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-latest.el7.noarch.rpm
2)安装Software Collections仓库
分别在三个节点下运行一下这个命令
yum install -y centos-release-scl
2.3.2修改zabbix仓库配置文件
**1)查看原始zabbix.repo文件**cat /etc/yum.repos.d/zabbix.repo##查看内容如下所示
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://repo.zabbix.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://repo.zabbix.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://repo.zabbix.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://repo.zabbix.com/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
2)执行以下命令完成全局替换,修改为阿里云的镜像
sed -i 's/http:\/\/repo.zabbix.com/https:\/\/mirrors.aliyun.com\/zabbix/g' /etc/yum.repos.d/zabbix.repo
3)查看修改之后的zabbix.repo文件
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/$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
4)打开/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
2.4安装zabbix
在节点1、节点2、节点3分别执行以下安装命令##节点1
yum install zabbix-server-pgsql zabbix-agent
yum install zabbix-web-pgsql-scl zabbix-apache-conf-scl##节点2
yum install zabbix-agent##节点3
yum install zabbix-agent
2.5配置zabbix
2.5.1创建zabbix数据库
##在数据库主机上运行以下代码
sudo -u postgres createuser --pwprompt zabbix
sudo -u postgres createdb -O zabbix zabbix
2.5.2导入建表语句
zcat /usr/share/doc/zabbix-server-pgsql-5.0.44/create.sql.gz | sudo -u zabbix psql zabbix
2.5.3配置zabbix-server(节点1)
vim /etc/zabbix/zabbix_server.confDBHost=节点1ip地址
DBName=zabbix
DBUser=root
DBPassword=123456
2.5.4配置zabbix_agent(三台节点)
##节点1
vim /etc/zabbix/zabbix_agent.conf
##修改内容如下
Server=节点1ip地址##节点2
vim /etc/zabbix/zabbix_agent.conf
##修改内容如下
Server=节点1ip地址##节点3
vim /etc/zabbix/zabbix_agent.conf
##修改内容如下
Server=节点1ip地址
2.5.5配置Zabbix_Web时区
vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf##修改内容如下
listen = /var/opt/rh/rh-php72/run/php-fpm/zabbix.sock
listen.acl_users = apache
listen.allowed_clients = 127.0.0.1pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 200php_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
2.6启动zabbix
2.6.1启动zabbix
##节点1
systemctl start zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm##节点2
systemctl start zabbix-agent
systemctl enable zabbix-agent##节点3
systemctl start zabbix-agent
systemctl enable zabbix-agent
2.6.2停止zabbix
##节点1
systemctl stop zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl disable zabbix-server zabbix-agent httpd rh-php72-php-fpm##节点2
systemctl stop zabbix-agent
systemctl disable zabbix-agent##节点3
systemctl stop zabbix-agent
systemctl disable zabbix-agent
2.6.3连接Zabbix_Web数据库
1)浏览器访问** http://节点1ip地址/zabbix/**2)检查配置
3)配置数据库
4)配置 zabbix-server
2.6.4登录zabbix
1)用户名:Admin 密码:zabbix2)点击User Setting,语言设置为中文