CentOS7 二进制安装 Zabbix 5.0

CentOS7 二进制安装 Zabbix 5.0

环境准备

MariaDB-10.4.22已安装

关闭防火墙和selinux

#关闭selinux
[root@centos7 ~]#sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

#关闭防火墙
[root@centos7 ~]#systemctl disable --now firewalld

#重启生效
[root@centos7 ~]#reboot

1. 安装zabbix rpm源

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

2. 安装zabbix server和agent

[root@centos7 ~]#yum install -y zabbix-server-mysql zabbix-agent

3. 安装Zabbix前端

[root@centos7 ~]#yum install -y centos-release-scl

#编辑配置文件 /etc/yum.repos.d/zabbix.repo
[root@centos7 ~]#vim /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
...
enabled=1
...

#安装Zabbix前端软件包
[root@centos7 ~]#yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl

4. 创建初始数据库

[root@centos7 ~]#mysql -uroot -p
Enter password:
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> create user zabbix@'10.0.0.%' identified by 'zabbix';
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@'10.0.0.%';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> quit;

[root@centos7 ~]#systemctl restart mysqld.service

#导入初始架构和数据
[root@centos7 ~]#zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix -h 10.0.0.7 zabbix

#在mysql主机查看生成的数据库
MariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
| alerts                     |
| application_discovery      |
| application_prototype      |
| application_template       |
| applications               |
| auditlog                   |
| auditlog_details           |
| autoreg_host               |
| conditions                 |
| ......                     |

5. 为Zabbix server配置数据库

#编辑配置文件 /etc/zabbix/zabbix_server.conf
[root@centos7 ~]#vim /etc/zabbix/zabbix_server.conf
ListenPort=10051
DBHost=10.0.0.7
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBPort=3306

6. 为Zabbix前端配置PHP

#编辑配置文件 /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
[root@centos7 ~]#vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai

7. 启动Zabbix server和agent进程

#启动Zabbix server和agent进程,并设置开机自启:
[root@centos7 ~]#systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@centos7 ~]#systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm

8. 配置Zabbix前端

#连接到新安装的Zabbix前端:http://10.0.0.7/zabbix

点击【下一步】

在这里插入图片描述

确认状态都OK,点击【下一步】

在这里插入图片描述

配置数据库连接,点击【下一步】

在这里插入图片描述

输入Zabbix server 详细信息,点击【下一步】

在这里插入图片描述

确认安装信息,点击【下一步】

在这里插入图片描述

完成安装在这里插入图片描述

9. 登录zabbix,默认用户名为Admin,密码为zabbix

在这里插入图片描述

zabbix首页在这里插入图片描述

10.配置中文语言

点击左下角【User settings】,选择【Chinese(zh_CH)】,点击【Update】更新

在这里插入图片描述

11. 监控项乱码问题解决

当前系统有些监控项部分显示有乱码,是由于web界面显示为中文但是系统没有相关字体支持,因此需要相关字体的支持才能正常显示。在这里插入图片描述

11.1 在windows拷贝字体

在windows上找到【C:\Windows\Fonts\楷体 常规(simkai.ttf)】(或者其他个人喜欢的中文字体),然后将字体拷贝到windows系统当前用户的桌面。

11.2 上传字体

上传字体到zabbix_server服务器的/usr/share/zabbix/assets/fonts/目录下。(需要用到 lrzsz 上传下载工具,如果没有安装,yum安装一下即可)

[root@centos7 ~]#cd /usr/share/zabbix/assets/fonts/
[root@centos7 fonts]#ll
total 11512
lrwxrwxrwx 1 root root       33 Jun 19 09:58 graphfont.ttf -> /etc/alternatives/zabbix-web-font
-rw-r--r-- 1 root root 11787328 Oct 15  2019 simkai.ttf

#修改权限
[root@centos7 fonts]#chown zabbix.zabbix ./*
[root@centos7 fonts]#ll
total 11512
lrwxrwxrwx 1 root   root         33 Jun 19 09:58 graphfont.ttf -> /etc/alternatives/zabbix-web-font
-rw-r--r-- 1 zabbix zabbix 11787328 Oct 15  2019 simkai.ttf

11.3 修改配置文件

[root@centos7 zabbix]#vim /usr/share/zabbix/include/defines.inc.php
#第81行
#define('ZBX_GRAPH_FONT_NAME',      'graphfont'); // font file name
define('ZBX_GRAPH_FONT_NAME',       'simkai'); // font file name

#第122行
#define('ZBX_FONT_NAME', 'graphfont');
define('ZBX_FONT_NAME', 'simkai');

11.4 验证字体是否生效

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_51867896/article/details/125261813