yum安装zabbix 5.0 LTS


Zabbix 5.0 版本于 5 月 12日正式发布,是最新的 LTS(长期支持)版本,5.0 带来很多功能和特性,后面会陆续推出文章介绍,下面主要介绍 5.0 版本的安装。

一、环境要求

5.0 版本对基础环境的要求有大的变化,最大的就是对 php 版本的要求,最低要求 7.2.0 版本,对 php 扩展组件版本也有要求,详见官网文档

二、 安装

基本环境:Centos 7.2(最小化安装)

2.1 安装好操作系统后,建议关闭防火墙、SELinux

$ sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
$ systemctl disable --now firewalld
$ reboot

2.2 安装 zabbix rpm 源,鉴于国内网络情况,使用阿里云 zabbix 源

$ rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
$ sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo
$ yum clean all

2.3 安装 Zabbix server 和 agent

$ yum install zabbix-server-mysql zabbix-agent -y

2.4 安装 Software Collections,便于后续安装高版本的 php,默认 yum 安装的 php 版本为 5.4 过低

$ yum install centos-release-scl -y

2.5 启用 Zabbix 前端源,修改/etc/yum.repos.d/zabbix.repo,将[zabbix-frontend]下的 enabled 改为 1

$ vim /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
……………………………………

2.6 安装 Zabbix 前端和相关环境

$ yum install zabbix-web-mysql-scl zabbix-apache-conf-scl -y

2.7 由于使用 yum 安装 zabbix,不自动依赖安装数据库,因此需要手动安装数据库,这里使用 yum 安装 centos7 默认的 mariadb 数据库

$ yum install mariadb-server -y
$ systemctl enable --now mariadb

2.8 初始化 mariadb 并配置 root 密码

$ mysql_secure_installation

2.9 创建 zabbix 数据库,注意数据库编码

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> create user zabbix@localhost identified by 'zabbix';
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
MariaDB [(none)]> quit;

2.10 导入 zabbix 数据库,zabbix 数据库用户为 zabbix,,密码为zabbix

$ zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix zabbix

2.11 修改zabbix server配置文件

$ grep -Ev '^$|#' /etc/zabbix/zabbix_server.conf
ListenPort=10051
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
ListenIP=0.0.0.0
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1

2.12 修改php配置文件

$ echo 'php_value[date.timezone] = Asia/Shanghai' >> /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf

2.13 启动相关服务

$ systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
$ systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm

2.14 浏览器访问http://ip/zabbix 即可访问zabbix的web页面

20200721224455
20200721224508
20200721224522
20200721224545
20200721224554
20200721224602
20200721224616
20200721224631

2.15 修改字体,避免中文显示小方块

$ yum install google-noto-sans-simplified-chinese-fonts.noarch -y
# 安装谷歌字体
$ mv /etc/alternatives/zabbix-web-font /etc/alternatives/zabbix-web-font_bak
# 备份原字体
$ ln -s /usr/share/fonts/google-noto/NotoSansSC-Regular.otf /etc/alternatives/zabbix-web-font
# 软链接新字体
*************** 当你发现自己的才华撑不起野心时,就请安静下来学习吧!***************
原文地址:https://www.cnblogs.com/lvzhenjiang/p/14199196.html