Zabbix 5.0 及 web 界面 centos7 yum 安装
- 前言
- 一、配置 yum 源
-
- 1. 更换 yum 阿里源
- 2. 配置 epel 仓库
-
- 1)安装 epel-release
- 2)添加wlnmp一键包源
- 3)强制更换清华镜像(可选)
- 3. 配置 remi 仓库 (清华镜像)
-
- 1)下载 wget
- 2)下载并安装 remi 仓库
- 3) 更改 remi 配置
- 4)更新 yum
- 二、php 7.2 安装
-
- 1.配置 remi
- 2.安装 php 7.2
- 三、Zabbix 5.0 安装
-
- 1. 添加 Zabbix 阿里镜像源
- 2. 关闭防火墙 和 SElinux
- 3. 安装 Zabbix server 和 agent
- 4. 安装 Software Collections
- 5. 安装 Zabbix 前端和相关环境
- 6. 安装并配置 centos7 默认的 mariadb 数据库
- 7. 使用 root 用户进入 mysql,并建立 zabbix 数据库
- 8. 导入 zabbix 数据库
- 9. 修改 zabbix server 配置文件
- 10. 修改 zabbix 的 php 时区配置
- 11. 启动相关服务,并配置开机自动启动
- 四、Zabbix web 前端 安装
-
- 1. 使用浏览器访问 http://ip/zabbix 访问 Zabbix 的 web 页面
- 2. 确保满足所有软件先决条件
- 3. 输入用于连接数据库的详细信息(Zabbix 数据库必须已经创建)
- 4. 输入 Zabbix 服务器详细信息
- 5. 查看设置摘要
- 6. 下载并放置配置文件
- 7. 完成安装
- 8. 登录
- 9. 更多(java 网关,前端的使用)
- 参考资料
前言
本文所安装的系统是纯净的新系统。
本文中所有操作都经过本人亲自操作,当中可能走了弯路,新人请谅解。
安装 zabbix 的目的为学习和熟悉,因此采用了yum的快速安装方式。
如果想要稳定,可控 请使用编译安装
提示:所有步骤均使用 root 用户
一、配置 yum 源
1. 更换 yum 阿里源
#备份本地yum源
[[email protected] ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak
#获取阿里yum源配置文件
[[email protected] ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#清除yum缓存
[[email protected] ~]# yum clean all
#更新yum缓存
[[email protected] ~]# yum makecache
2. 配置 epel 仓库
1)安装 epel-release
[[email protected] ~]# yum install epel-release
2)添加wlnmp一键包源
rpm -ivh http://mirrors.wlnmp.com/centos/wlnmp-release-centos.noarch.rpm
3)强制更换清华镜像(可选)
PS:这一步请自行选择。在清华的镜像帮助中写道:“当前tuna已经在epel的官方镜像列表里,所以不需要其他配置,mirrorlist机制就能让你的服务器就近使用tuna的镜像。”。 本人是因为原本的官方太慢所以强制清华。各位可以先体验一下官方的,如果感觉可以接受就不要强制换。
以下摘自清华镜像网站的帮助(https://mirrors.tuna.tsinghua.edu.cn/help/epel/)
如果你想强制 你的服务器使用tuna的镜像,可以修改/etc/yum.repos.d/epel.repo,将mirrorlist和metalink开头的行注释掉。
接下来,取消注释这个文件里baseurl开头的行,并将其中的http://download.fedoraproject.org/pub替换成https://mirrors.tuna.tsinghua.edu.cn。
可以用如下命令自动替换:(来自 https://github.com/tuna/issues/issues/687)
sed -e 's!^metalink=!#metalink=!g' \
-e 's!^#baseurl=!baseurl=!g' \
-e 's!//download\.fedoraproject\.org/pub!//mirrors.tuna.tsinghua.edu.cn!g' \
-e 's!http://mirrors\.tuna!https://mirrors.tuna!g' \
-i /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo
3. 配置 remi 仓库 (清华镜像)
PS: 除去清华镜像 其他国内各大镜像网站也可以 本次使用的是清华镜像
1)下载 wget
提示:执行防止未安装 wegt
[[email protected] ~]# yum install -y wget
2)下载并安装 remi 仓库
[[email protected] ~]# wget https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-7.rpm
[[email protected] ~]# rpm -Uvh remi-release-7.rpm
[[email protected] ~]# rm -rf remi-release-7.rpm
3) 更改 remi 配置
PS:使用 nano 只是玩树莓派留下的习惯。 vim 也是不错的
[[email protected] ~]# nano /etc/yum.repos.d/remi.repo
在文件中寻找这一段
[remi]
name=Remi's RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/remi/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/7/remi/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/remi/mirror
enabled=0 #把这里的0 改成 1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
修改后的这段文本是这样的
[remi]
name=Remi's RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/remi/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/7/remi/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
4)更新 yum
[[email protected] ~]# yum clean all
[[email protected] ~]# yum makecache
二、php 7.2 安装
1.配置 remi
PS:如果想要安装更高版本的只要将 “72” 改为 “73” 或 “74” 就可以了
[[email protected] ~]# nano /etc/yum.repos.d/remi-php72.repo
修改 [remi-php72]代码段中的”enabled = 0“
修改后的代码如下:
[remi-php72]
name=Remi's PHP 7.2 RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/php72/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/7/php72/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/php72/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
2.安装 php 7.2
[[email protected] ~]# yum install php72
三、Zabbix 5.0 安装
1. 添加 Zabbix 阿里镜像源
[[email protected] ~]# rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
[[email protected] ~]# nano /etc/yum.repos.d/zabbix.repo
将文件修改为以下内容:
注意 baseurl 改为国内 Zabbix 源
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/
enabled=1
gpgcheck=0
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=0
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=0
[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=0
2. 关闭防火墙 和 SElinux
[[email protected] ~]# systemctl stop firewalld
[[email protected] ~]# nano /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 pr$
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
3. 安装 Zabbix server 和 agent
[[email protected] ~]# yum install zabbix-server-mysql zabbix-agent -y
4. 安装 Software Collections
[[email protected] ~]# yum install centos-release-scl -y
5. 安装 Zabbix 前端和相关环境
[[email protected] ~]# yum install zabbix-web-mysql-scl zabbix-apache-conf-scl -y
6. 安装并配置 centos7 默认的 mariadb 数据库
#安装 mariadb 数据库
[[email protected] ~]# yum install mariadb-server -y
#启动数据库,并配置开机自动启动
[[email protected] ~]# systemctl enable --now mariadb
初始化 mariadb 并配置 root 密码
[[email protected] ~]# mysql_secure_installation
7. 使用 root 用户进入 mysql,并建立 zabbix 数据库
此处 用户 zabbix 的密码为 “password” 可根据需要自己修改
[[email protected] ~]# mysql -uroot -p
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> create user [email protected] identified by 'password';
MariaDB [(none)]> grant all privileges on zabbix.* to [email protected];quit;
8. 导入 zabbix 数据库
此处需要注意版本号
#请使用以下代码检查版本号
[[email protected] ~]# cd /usr/share/doc/
[[email protected] doc]# ll
#请在 ll 所得结果 中找到与 以下文字 相似的内容 (如未找到请重新安装 zabbix-server)
drwxr-xr-x. 2 root root 118 Aug 20 09:05 zabbix-server-mysql-5.0.2
#运行下一条命令时 请注意修改版本号 与上方查找的版本号对应
[[email protected] ~]# zcat /usr/share/doc/zabbix-server-mysql-5.0.2/create.sql.gz | mysql -uzabbix -p zabbix
#密码为 sql 中 上一步中 zabbix 用户 所设的密码
9. 修改 zabbix server 配置文件
[[email protected] ~]# nano /etc/zabbix/zabbix_server.conf
#在文件中寻找 DBPassword =
#在其后方输入数据库 zabbix 用户的密码 并取消注释
# 举例:DBPassword=password
10. 修改 zabbix 的 php 时区配置
[[email protected] ~]# nano /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
#在文件中寻找 php_value[date.timezone] 修改为
php_value[date.timezone] = Asia/Shanghai
11. 启动相关服务,并配置开机自动启动
[[email protected] ~]# systemctl start zabbix-server zabbix-agent httpd
[[email protected] ~]# systemctl restart rh-php72-php-fpm
[[email protected] ~]# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
四、Zabbix web 前端 安装
PS:以下内容均摘自 zabbix 官方手册 (https://www.zabbix.com/documentation/current/manual/installation/install)
1. 使用浏览器访问 http://ip/zabbix 访问 Zabbix 的 web 页面

2. 确保满足所有软件先决条件
列表中还可能包含可选的先决条件。失败的可选前提条件以橙色显示,并且具有警告状态。如果可选的先决条件失败,则设置可以继续。
3. 输入用于连接数据库的详细信息(Zabbix 数据库必须已经创建)
如果选中了TLS加密选项,则会以以下形式显示五个用于配置与数据库的TLS连接的其他字段。(仅适用于MySQL或PostgreSQL)
4. 输入 Zabbix 服务器详细信息
输入Zabbix服务器的名称是可选的,但是,如果提交了名称,它将显示在菜单栏和页面标题中。
5. 查看设置摘要
6. 下载并放置配置文件
PS:这部分按照页面提示的路径复制 zabbix.conf.php 就可以了
Note:如果Web服务器用户对conf /目录具有写访问权限,则配置文件将自动保存,并且可以立即进行下一步。
7. 完成安装
8. 登录
默认用户名为Admin,密码为zabbix。
9. 更多(java 网关,前端的使用)
请访问官网手册
参考资料
https://www.cnblogs.com/heqiuyong/p/11526706.html
https://blog.csdn.net/hl449006540/article/details/79726672
https://mirrors.tuna.tsinghua.edu.cn/remi/
https://blog.whsir.com/post-5373.html
https://mirrors.tuna.tsinghua.edu.cn/help/epel/
https://blog.csdn.net/qq_39583463/article/details/80571849
https://www.cnblogs.com/joycezhou/p/13439646.html
https://blog.csdn.net/sunylat/article/details/81869513
https://www.zabbix.com/documentation/current/manual/installation/install
https://www.cnblogs.com/zhy-1992/p/6179940.html
https://blog.csdn.net/weixin_44736359/article/details/107164195