火影 发表于 2024-8-25 07:44:41

Rocky Linux 9.4 部署Zabbix 7.0

Zabbix基本概念

zabbix官方文档
zabbix介绍

下图来自百度百科
https://img-blog.csdnimg.cn/img_convert/6cccd0606699c223300ea4fbb79fa97d.png
用通俗易懂的话来说,Zabbix是一个监控系统,它可以帮助我们实时检查装备的状态,好比服务器、网络装备等。当装备出现题目时,它会实时关照我们,让我们可以采取措施来解决。同时,它还可以把收集到的数据转化成图表和报告,让我们更直观地了解装备的运行情况
zabbix特性

数据收罗:Zabbix Agent方式会定期收集装备的各种指标数据,好比CPU利用率、内存占用、网络流量等。这些数据会被Zabbix Server主动获取。
触发检测告警:Zabbix会根据我们事先设定的阈值和触发条件,对收罗到的数据举行检测。如果某个指标超过了阈值或满足了触发条件,Zabbix会触发一个告警。Zabbix会根据事先设置的关照方式,好比邮件、短信等,关照相干的人员或团队。这样我们可以实时知道装备出现了题目。
数据存储:Zabbix将收罗到的数据存储在数据库中
数据展示:Zabbix提供了丰富的可视化功能,可以将收罗到的数据转化成各种图表和报表。这样我们可以直观地了解装备的运行状态和趋势。
zabbix布局

https://img-blog.csdnimg.cn/img_convert/4654b072d5e9de4bec51d0b70f3a0231.png
    Zabbix-server:收集监控数据,盘算是否满足触发条件,向用户发送关照
Zabbix-database:全部配置信息和Zabbix收集到的数据都被存储在数据库中
Zabbix-Web:为了在任何地方和任何平台都能轻松地访问Zabbix,Zabbix提供了基于Web的界面。该界面是
Zabbix Server的一部分,通常跟Zabbix Server运行在同一台物理机器上。
Zabbix-proxy:Zabbix Proxy可以替Zabbix Server收集性能和可用性数据。Proxy署理服务器是Zabbix 软件可选择部署的一部分。当然,Proxy署理服务器可以帮助单台Zabbix Server分担负载压力。
Zabbix-agent:Zabbix Agents监控署理部署在监控目的上,主动监控本地资源和应用(硬件驱动,内存等)
安装Zabbix

   节点规划
IP主机名节点操作系统192.168.200.10zabbix-serverServer节点Rocky Linux 9192.168.200.20zabbix-agentAgent节点Centos 7.9.2009 主机名配置

一台server节点一台agent节点
# hostnamectl set-hostname zabbix-server
# bash
#

# hostnamectl set-hostname zabbix-agent
# bash
#
配置Zabbix-Server

配置server的YUM源我这里利用的是Rocky Linux 9操作系统,访问官网页面,选择zabbix版本、操作系统、操作系统版本、zabbix组件、数据库和Web服务器
如下图zabbix官方下载说明页面
https://img-blog.csdnimg.cn/img_convert/16ce88e04fc35d66cde6b647df826f8c.png
选择好后第二步就是安装,官方文档也有详细的说明安装步骤,以下配置均参考官方文档
(1)禁用EPEL提供的Zabbix软件包

编辑配置文件 /etc/yum.repos.d/epel.repo 并添加以下语句

...
excludepkgs=zabbix*
安装所需版本的zabbix仓库
rpm -Uvh https://repo.zabbix.com/zabbix/7.0/rocky/9/x86_64/zabbix-release-7.0-2.el9.noarch.rpm && yum clean all
查察一下里面的内容,可以看到连接的是官方镜像仓库,有可能由于我们网络不给力可能会下载不了,以是我们更改为阿里云的镜像仓库
vim /etc/yum.repos.d/zabbix.repo
https://img-blog.csdnimg.cn/img_convert/5483ed10bb412933c2a9755528d65d28.png
# 修改完后内容如下

name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/7.0/rocky/9/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-B5333005


name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/9/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-08EFA7DD
gpgcheck=1


name=Zabbix Official Repository source code - $basearch
baseurl=https://repo.zabbix.com/zabbix/7.0/rocky/9/SRPMS
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-B5333005
gpgcheck=1
(2)安装Zabbix Server、Web前端、Agent

yum install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent -y
(3)创建初始数据库

zabbix文档没有写这一步,他只做了简朴提示让启动并运行数据库服务器
安装数据库
yum install -y mariadbmariadb-server
启动mariadb
systemctl enable mariadb --now
初始化mariadb数据库
# mysql_secure_installation # 初始化脚本

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none):# 按回车设置或更改root用户的密码
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication y# 切换到unix_socket身份验证
Enabled successfully!
Reloading privilege tables..
... Success!


You already have your root account protected, so you can safely answer 'n'.

Change the root password? y # 更改root密码
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.This is intended only for testing, and to make the installation
go a bit smoother.You should remove them before moving into a
production environment.

Remove anonymous users? y # 删除匿名用户
... Success!

Normally, root should only be allowed to connect from 'localhost'.This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? n# 限制root远程登录
... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? y # 删除测试数据库和访问权限
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? y# 重新加载权限表
... Success!

Cleaning up...

All done!If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
在数据库上运行以下代码
# 登陆数据库
mysql -uroot -p
# 创建名为zabbix的数据库,并设置字符集为utf8mb4,排序规则为utf8mb4_bin
create database zabbix character set utf8mb4 collate utf8mb4_bin;
# 创建名为zabbix的用户,并设置其密码为'000000'
create user zabbix@localhost identified by '000000';
# 授予zabbix用户在zabbix数据库上的所有权限
grant all privileges on zabbix.* to zabbix@localhost;
# 设置全局变量log_bin_trust_function_creators为1
set global log_bin_trust_function_creators = 1;
# 退出MariaDB
quit;
导入初始架构和数据,系统将提示您输入新创建的暗码
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
导入数据库架构后禁用log_bin_trust_function_creators选项
# 登陆mysql
mysql -uroot -p
# 设置全局变量log_bin_trust_function_creators为0
set global log_bin_trust_function_creators = 0;
# 退出MariaDB
quit;
(4)Zabbix server配置数据库

编辑配置文件 /etc/zabbix/zabbix_server.conf
DBPassword=password# zabbix数据库密码
(5)为Zabbix前端配置PHP

编辑配置文件 /etc/nginx/conf.d/zabbix.conf 取消注释并设置“listen”和“server_name”指令。
# listen 8080;
# server_name example.com;
(6)启动Zabbix server和agent进程

启动Zabbix server和agent进程,并为它们设置开机自启:
systemctl enable zabbix-server zabbix-agent nginx php-fpm --now
(7)放行端口

放行80(nginx),8080(zabbix自定义端口),10050(agent端口),3306(数据库端口)
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --add-port=10050/tcp --permanent
firewall-cmd --add-port=8080/tcp --permanent
firewall-cmd --add-port=3306/tcp --permanent
firewall-cmd --reload
(8)浏览器访问

http://本机IP:8080/setup.php
(9)配置zabbix


[*]选择语言
https://img-blog.csdnimg.cn/img_convert/535727c86f4fa6ae6c51fe347a8f1131.png

[*]检查必要条件,默认下一步
https://img-blog.csdnimg.cn/img_convert/8bf277c62e2d5ed35f757a97ab7de67e.png

[*]配置数据库连接
https://img-blog.csdnimg.cn/img_convert/c12d83a22e5cef05215bbe7cb49292b2.png

[*]设置zabbix主机名称、时区、主题
https://img-blog.csdnimg.cn/img_convert/2c2ded88175c9ce7db5117ec75cd66df.png

[*]安装前汇总
https://img-blog.csdnimg.cn/img_convert/c0017a26ed8891928af6593d009ea825.png

[*]完成安装
https://img-blog.csdnimg.cn/img_convert/d5d6792363a59131fa278d80e5867c77.png

[*]登陆,默认用户名Admin暗码zabbix
https://img-blog.csdnimg.cn/img_convert/1c3dd90aa2725cc53a3df8a1a7db7190.png
https://img-blog.csdnimg.cn/img_convert/3c603567405aec545ffead6fd80a4e6e.png
配置Zabbix-agent

在官网选择zabbix服务平台
https://img-blog.csdnimg.cn/img_convert/b717955b47b1f4ea506306f285f65420.png
(1)配置zabbix仓库

rpm -Uvh https://repo.zabbix.com/zabbix/7.0/rhel/7/x86_64/zabbix-release-7.0-1.el7.noarch.rpm && yum clean all
还是一样,修改仓库地址为阿里云镜像仓库
vim /etc/yum.repos.d/zabbix.repo
# 修改完后的内容如下name=Zabbix Official Repository - $basearchbaseurl=https://mirrors.aliyun.com/zabbix/zabbix/7.0/rhel/7/$basearch/enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-B5333005name=Zabbix Official Repository non-supported - $basearchbaseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearch/enabled=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIXgpgcheck=1name=Zabbix Official Repository debuginfo - $basearchbaseurl=https://repo.zabbix.com/zabbix/7.0/rhel/7/$basearch/debuginfo/enabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-B5333005gpgcheck=1name=Zabbix Official Repository source code - $basearchbaseurl=https://repo.zabbix.com/zabbix/7.0/rhel/7/SRPMSenabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-B5333005gpgcheck=1 (2)下载Zabbix Agent

yum install -y zabbix-agent
(3)修改Zabbix Agent配置文件

vim /etc/zabbix/zabbix_agentd.conf
# 修改如下内容
Server=zabbix-server IP      # 这里写Zabbix-server 节点的IP(被动监控)
ServerActive=zabbix-server IP# 这里写Zabbix-server 节点的IP(主动监控)
Hostname=zabbix-agent          # 被监控的主机名
(4)启动Zabbix agent进程

systemctl enable zabbix-agent --now
(5)放行端口

# 放行10050端口
firewall-cmd --add-port=10050/tcp --permanent
firewall-cmd --reload
(6)登陆zabbix监控平台添加主机

左侧栏 >> 数据收罗 >> 主机 >> 创建主机(右上角)
https://img-blog.csdnimg.cn/img_convert/351ed1db5564caf418d86df43c43e4a0.png
添加完后查察zabbix-server节点的日志文件
https://img-blog.csdnimg.cn/img_convert/2fbf7c1690bc5edcfe39fca40989904d.png
启动成功,再次刷新zabbix页面,可用性已经变为绿色了
https://img-blog.csdnimg.cn/img_convert/d7c8b89377140b2f99de43eaaa566f01.png
一些题目

乱码

在zabbix服务端找到defines.inc.php文件;找不到的可以利用find 方法查找
find / -name defines.inc.php
找到这个目录进入,这里必要修改两处地方
vim /usr/share/zabbix/include/defines.inc.php
#修改两处地方;
#修改一:可以查找到这个单词“ZBX_GRAPH_FONT_NAME”,默认应该是在72行;
原:define('ZBX_GRAPH_FONT_NAME',         'graphfont'); // font file name
改为:define('ZBX_GRAPH_FONT_NAME',         'zabbix'); // font file name

#修改二:可以查找到这个单词“ZBX_FONT_NAME”,默认应该是在113行;
原:define('ZBX_FONT_NAME', 'graphfont');
改为:define('ZBX_FONT_NAME', 'zabbix');
将Windows的字体上传到服务器上并放到指定目录
首先我们如今windows上找到存放字体的地方,默认的位置在 C:\Windows\Fonts 目录下;
找到之后我们可以找出本身想要的字体,但是为了能看懂还是选择中文较好;
https://img-blog.csdnimg.cn/img_convert/1a60fb29a9c11938ccbe33b145dc2c9a.png
上传至服务器上,这个一样平常就存放到 /usr/share/zabbix/assets/fonts/ 目录下
mv /root/simkai.ttf /usr/share/zabbix/assets/fonts/zabbix.ttf
# 重启服务
systemctl restart zabbix-server.service
https://img-blog.csdnimg.cn/img_convert/dc70a6eb9ac02c1eda805e2890f4fb59.png
不能选中文

安装zh_CN语言包
dnf install langpacks-zh_CN.noarch
安装glibc-common实现对语言包的识别
dnf reinstall glibc-common
测试安装是否成功,如果看到zh_CN语言已安装,则表现成功
locale -a | grep zh_CN
安装完成后,回到web页面刷新,可以看到中文语言已可以选中
   上述内容参考:
解决Zabbix 5.0不能选择中文和中文乱码题目 - 不羁的罗恩 - 博客园 (cnblogs.com)
Zabbix下载安装页面官方文档
【zabbix】解决zabbix在web页面表现中文乱码题目_zabbix网页乱码-CSDN博客

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: Rocky Linux 9.4 部署Zabbix 7.0