Zabbix最新版本(6.0LTS)安装-yum安装方式

Zabbix最新版本(6.0LTS)安装-yum安装方式

一,安装方案

一,什么时候部署proxy

我们采用简单生产环境来部署,如果说你管理的服务器规模小于500台可直接连接到server端而不必通过proxy来接入,那么什么情况下才会用到proxy呢?

1.网络异构,比如公司环境是分开的,各个域间网络不互通或不允许大批量主机互通,这时候就要设置边界代理来完成网络互联。
2.高可用,proxy是支持高可用的,即在客户端配置2个proxy地址,当其中一个proxy异常后agent会通过另一个proxy来完成数据上报,7.0版本以后proxy支持负载均衡。
3.负载均衡,当机器规模较大时,单一的server可能无法完成大量主机监控,这时候就要通过proxy来分担压力。

我们当前按照简单生产环境来部署,proxy可以部署也可以不部署

二,服务器规划

角色IP地址操作系统
ZabbixServer192.168.26.144RockyLinux9
ZabbixProxy192.168.26.137RockyLinux9
ZabbixAgent192.168.26.138RockyLinux9
图片[1]|Zabbix最新版本(6.0LTS)安装-yum安装方式|运维导航|专心做运维|运维技术分享

二,安装部署Server端

一,关闭SELinux,防火墙

# 关闭Selinux
setenforce 0
sed -i 's/selinux=enforcing/selinux=disabled/' /etc/selinux/config
# 关闭防火墙,可以不关闭,放行端口即可,server/proxy端放行10051端口,服务端放行10050端口,这里选择关闭防火墙,如何是生产环境放行对应端口即可。
systemctl stop firewalld
systemctl disable firewalld
image-20240415002553076

二,配置yum仓库

# yum源可以在zabbix官网获取
# https://www.zabbix.com/download
# 配置yum源
rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-6.0-4.el9.noarch.rpm
yum clean all
image-20240415002148825

三,安装ZabbixServer

# 安装zabbix server端和server主机上的agent端
# 在 192.168.26.144主机上操作
dnf install zabbix-web zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent  --nobest
# 这里加了 --nobest参数,你们安装的时候可以不加,因为这时候zabbix-web和其他组件版本差一个小版本,所以会出现冲突,但是实际是可以兼容运行的
image-20240415003624067

四,安装Mysql客户端和服务端

# 安装mariadb-server和mariadb
yum install mariadb-server mariadb -y
image-20240415003946102

五,初始化数据库

# 启动数据库服务端,初始化数据库
systemctl enable --now mariadb
image-20240415004100057
# 设置数据库密码
mysql_secure_installation
# 按下面操作即可,这里设置root为123456
image-20240415004217478
image-20240415004234532

六,创建zabbix数据库并导入初始数据

# 创建zabbix数据库
mysql -uroot -p123456
password
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
mysql> create user zabbix@localhost identified by '123456';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> set global log_bin_trust_function_creators = 1;
mysql> flush privileges;
mysql> quit;
image-20240415004610219
# 导入zabbix默认数据库及表
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
# 导入后可登录数据库查看表是否已经有了
image-20240415004905091
# 导入数据库架构后禁用log_bin_trust_function_creators选项。
mysql -uroot -p123456
mysql> set global log_bin_trust_function_creators = 0;
mysql> quit;

七,修改服务端数据库名和密码,修改前端配置

# 6.0LTS服务端配置文件在:/etc/zabbix_server.conf
# 6.0以前版本配置文件在/etx/zabbix/zabbix_server.conf
image-20240415005852962
# 修改zabbix.conf.php文件
# 文件在/usr/share/zabbix/conf目录下
cp zabbix.conf.php.example  zabbix.conf.php
# 修改内容为以下内容,这里我们仅修改数据库密码,因为数据库和服务端安装在了一起
image-20240415010259289

八,启动服务端与前端

# 启动服务端和前端
systemctl restart zabbix-server zabbix-agent httpd php-fpm
systemctl enable zabbix-server-mysql zabbix-agent httpd php-fpm
image-20240415010936026

九,打开前端页面并配置

# 浏览器打开zabbix-server服务器IP地址
http://192.168.26.144/zabbix
image-20240415011351625
image-20240415011421456
image-20240415011442870
image-20240415012612586
image-20240415012618118
image-20240415012624661
image-20240415012643325
# 服务端安装结束以后我们进入zabbix界面会有一台客户端已经被监控,这台就是server服务器启动的agent
# 下面我们开始安装proxy端
image-20240415012927733

三,安装部署Proxy端

一,安装Proxy

# 关闭防火墙步骤和配置yum源步骤参考服务端配置
 dnf install zabbix-proxy-mysql zabbix-sql-scripts zabbix-selinux-policy
image-20240415013311300
image-20240415013700868

二,安装数据库

# 数据库安装及初始化步骤的截图参考服务端数据库搭建即可,以下是proxy数据库安装与初始化,只是没有了截图
# 安装mariadb-server和mariadb
yum install mariadb-server mariadb -y
systemctl enable --now mariadb
[root@zabbix-proxy ~]# mysql_secure_installation     

Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
 ... Success!

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

Change the root password? [Y/n] y
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/n] 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? [Y/n] n
 ... 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/n] 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/n] 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!

# 创建proxy数据库及表
# mysql -uroot -p
password
mysql> create database zabbix_proxy character set utf8mb4 collate utf8mb4_bin;
mysql> create user zabbix@localhost identified by '123456';
mysql> grant all privileges on zabbix_proxy.* to zabbix@localhost;
mysql> set global log_bin_trust_function_creators = 1;
mysql> quit;

# 导入默认数据
cat /usr/share/zabbix-sql-scripts/mysql/proxy.sql | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix_proxy

# 关闭 log_bin_trust_function_creators选项
# mysql -uroot -p 
password
mysql> set global log_bin_trust_function_creators = 0;
mysql> quit;

三,修改zabbix_proxy.conf文件配置

# 修改截图中配置即可,其中Hostname为自定义名称,方便你自己识别是哪个代理即可
image-20240415014613570

四,启动proxy并在服务端添加代理

# 启动代理端
systemctl enable --now zabbix-proxy-mysql
image-20240415014728183
# 在服务端界面添加代理
image-20240415014818400
image-20240415014912473
# 添加后等待几十秒,当Last Sceen有数据以后代表代理端添加成功
image-20240415015703424

四,安装Agent端

# 安装Agent的流程是比较简单并且时我们经常要做的,所以最好根据自己的环境来编写一个自动化安装脚本
# 这里演示如何安装客户端
# 生产环境中我们对客户端的注册是采用自动注册的方式,毕竟几千台机子不可能一台一台手动确认,这个流程将在后续的课程中介绍

一,安装Agent

# 配置yum源并安装
rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-6.0-4.el9.noarch.rpm
dnf clean all
dnf install zabbix-agent
image-20240415020456651

二,修改Agent配置

# 修改Agent配置
# 6.0版本的所有配置都在/etc/下
# 6.0以前版本都在/etc/zabbix/目录下
# 我们修改/etc/zabbix_agentd.conf文件
# 只需要修改下面三项即可
# 修改后启动agent
# Server和ServerActive地址填写代理地址,如果写Server端则会注册到Server上
systemctl enable --now zabbix-agent
image-20240415020757942

三,服务端添加客户端

image-20240415021400399
image-20240415021410073
# 等待一会,后面的可用性变绿即代表接入正常
image-20240415022237599

© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容