@Zabbix6.0 HA原生高可用集群部署方案(Ubuntu 20.04)

2024-01-26 09:40

本文主要是介绍@Zabbix6.0 HA原生高可用集群部署方案(Ubuntu 20.04),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

文章目录

    • 1.基础系统优化
    • 2.zabbix6.0支持配置
      • 1)系统支持
      • 2)软件支持
    • 3.服务器准备
    • 4.zabbix6.0部署
    • 5.数据库部署
      • 1)数据库安装
      • 2)数据库配置
    • 6.zabbix配置及web配置
    • 7.zabbix web配置
    • 6.zabbix web中文字符安装

在这里插入图片描述

1.基础系统优化

【ubuntu基本优化】

2.zabbix6.0支持配置

1)系统支持

【zabbix官网】

在这里插入图片描述

2)软件支持

【DB支持】

在这里插入图片描述

web前端支持

在这里插入图片描述

3.服务器准备

主机IPoszabbix节点
zabbix server192.168.1.220Ubuntu server 20.04v6.0zabbix01
zabbix server192.168.1.221Ubuntu server 20.04v6.0zabbix02
mysql192.168.1.222Ubuntu server 20.04v8.0DB01
mysql192.168.1.223Ubuntu server 20.04v8.0DB02
proxy192.168.1.224Ubuntu server 20.04v6.0proxy

4.zabbix6.0部署

#版本查看
root@zabbix01:~# cat /etc/issue
Ubuntu 20.04.4 LTS \n \l#下载zabbix安装源仓库
root@zabbix01:~# wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-1%2Bubuntu20.04_all.deb#安装zabbix官方仓库源
root@zabbix01:~# dpkg -i zabbix-release_6.0-1+ubuntu20.04_all.deb
root@zabbix02:~# dpkg -i zabbix-release_6.0-1+ubuntu20.04_all.deb#更新仓库
root@zabbix01:~# apt update
root@zabbix02:~# apt update#zabbix相关组件安装
root@zabbix01:~# apt install zabbix-server-mysql zabbix-frontend-php zabbix-sql-scripts  zabbix-agent2
root@zabbix02:~# apt install zabbix-server-mysql zabbix-frontend-php zabbix-sql-scripts  zabbix-agent2#nginx组件(web可选择其一即可)
root@zabbix01:~# apt install  zabbix-nginx-conf
root@zabbix01:~# apt install  zabbix-apache-conf#查看安装相关软件包
root@zabbix01:~# dpkg -l |grep zabbix
ii  zabbix-agent2                         1:6.0.5-1+ubuntu20.04             amd64        Zabbix network monitoring solution - agent
ii  zabbix-apache-conf                    1:6.0.5-1+ubuntu20.04             all          Zabbix network monitoring solution - apache configuration for front-end
ii  zabbix-frontend-php                   1:6.0.5-1+ubuntu20.04             all          Zabbix network monitoring solution - PHP front-end
ii  zabbix-release                        1:6.0-1+ubuntu20.04               all          Zabbix official repository configuration
ii  zabbix-server-mysql                   1:6.0.5-1+ubuntu20.04             amd64        Zabbix network monitoring solution - server (MySQL)

5.数据库部署

1)数据库安装

#更新安装源(默认阿里云源就可以)
root@DB01:~# apt-get update
root@DB02:~# apt-get update#安装mysql server
root@DB01:~# apt install -y mysql-server
root@DB02:~# apt install -y mysql-server#查看版本
root@DB01:~# mysql -V
mysql  Ver 8.0.29-0ubuntu0.20.04.3 for Linux on x86_64 ((Ubuntu)
root@DB02:~# mysql -V
mysql  Ver 8.0.29-0ubuntu0.20.04.3 for Linux on x86_64 ((Ubuntu))

2)数据库配置

#进入数据库(mysql8.0之上,新安装的数据库进入不需要密码,我们可直接进入数据库重设)
root@DB02:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.29-0ubuntu0.20.04.3 (Ubuntu)Copyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> select  version();
+-------------------------+
| version()               |
+-------------------------+
| 8.0.29-0ubuntu0.20.04.3 |
+-------------------------+
1 row in set (0.00 sec)mysql>#初始化配置root用户密码
root@DB01:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.29-0ubuntu0.20.04.3 (Ubuntu)Copyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY "zeny";
Query OK, 0 rows affected (0.08 sec)mysql> flush privileges;mysql> exit#测试root登录mysql
root@DB01:~# mysql -uroot -pzeny
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.29-0ubuntu0.20.04.3 (Ubuntu)Copyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>#配置zabbix数据库账户及密码
root@DB01:~# mysql -uroot -pzeny
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.29-0ubuntu0.20.04.3 (Ubuntu)Copyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected, 2 warnings (0.01 sec)mysql> create user zabbix@"%" identified by 'Zabbix@2022';
Query OK, 0 rows affected (0.11 sec)mysql> grant all privileges on zabbix.* to zabbix@"%";
Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)mysql> quit
Bye
root@DB01:~##测试zabbix用户(如下表示zabbix用户正常使用)
root@DB01:~# mysql -uzabbix -pZabbix@2022
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.29-0ubuntu0.20.04.3 (Ubuntu)Copyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>#测试zabbix用户远程连接
root@DB01:~# mysql -h127.0.0.1 -uzabbix -pZabbix@2022
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 8.0.29-0ubuntu0.20.04.3 (Ubuntu)Copyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>#修改监听的地址
root@DB01:~# egrep "^[^#]" /etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld]
user            = mysql
bind-address            = 0.0.0.0
mysqlx-bind-address     = 127.0.0.1
key_buffer_size         = 16M
myisam-recover-options  = BACKUP
log_error = /var/log/mysql/error.log
max_binlog_size   = 100M#重启mysql,并加入开机自启
root@DB01:~# systemctl restart  mysql.service
root@DB01:~# systemctl enable  mysql.service
Synchronizing state of mysql.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable mysql#查看服务状态
root@DB01:~# netstat -lntp |grep mysql
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      15208/mysqld
tcp        0      0 127.0.0.1:33060         0.0.0.0:*               LISTEN      15208/mysqld#远程测试
root@DB02:~# mysql -uzabbix -h192.168.1.222 -p"Zabbix@2022"
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.29-0ubuntu0.20.04.3 (Ubuntu)Copyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> ^DBye
root@DB02:~#

6.zabbix配置及web配置

#zabbix架构数据导入mysql
root@zabbix01:~# zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz  | mysql -uzabbix -h192.168.1.222  -p"Zabbix@2022" zabbix
mysql: [Warning] Using a password on the command line interface can be insecure.
root@zabbix01:~# #配置zabbix_server
root@zabbix01:~# egrep "^[^#]" /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/run/zabbix/zabbix_server.pid
SocketDir=/run/zabbix
DBHost=192.168.1.222
DBName=zabbix
DBUser=zabbix
DBPassword=Zabbix@2022
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
FpingLocation=/usr/bin/fping
Fping6Location=/usr/bin/fping6
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
#HA配置
HANodeName=zabbix01
NodeAddress=192.168.1.220:10051root@zabbix02:~# egrep "^[^#]" /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/run/zabbix/zabbix_server.pid
SocketDir=/run/zabbix
DBHost=192.168.1.222
DBName=zabbix
DBUser=zabbix
DBPassword=Zabbix@2022
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
FpingLocation=/usr/bin/fping
Fping6Location=/usr/bin/fping6
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
#HA配置
HANodeName=zabbix02
NodeAddress=192.168.1.221:10051
root@zabbix02:~##配置zabbix_agent2
root@zabbix01:~# egrep "^[^#]" /etc/zabbix/zabbix_agent2.conf
PidFile=/var/run/zabbix/zabbix_agent2.pid
LogFile=/var/log/zabbix/zabbix_agent2.log
LogFileSize=0
Server=192.168.1.220,192.168.1.221
ServerActive=192.168.1.220,192.168.1.221
Hostname=zabbix01
Include=/etc/zabbix/zabbix_agent2.d/*.conf
ControlSocket=/tmp/agent.sock
Include=./zabbix_agent2.d/plugins.d/*.conf
root@zabbix02:~# egrep "^[^#]" /etc/zabbix/zabbix_agent2.conf
PidFile=/var/run/zabbix/zabbix_agent2.pid
LogFile=/var/log/zabbix/zabbix_agent2.log
LogFileSize=0
Server=192.168.1.220,192.168.1.221
ServerActive=192.168.1.220,192.168.1.221
Hostname=zabbix02
Include=/etc/zabbix/zabbix_agent2.d/*.conf
ControlSocket=/tmp/agent.sock
Include=./zabbix_agent2.d/plugins.d/*.conf
root@zabbix02:~##编辑web配置文件,nginx服务(去掉以下两行内容注释即可)
root@zabbix01:~# egrep "^[^#]" /etc/nginx/conf.d/zabbix.conf
server {listen          80;              #打开监听端口server_name     192.168.1.220;   #web访问server的地址root    /usr/share/zabbix;index   index.php;location = /favicon.ico {log_not_found   off;}location / {try_files       $uri $uri/ =404;}location /assets {access_log      off;expires         10d;}location ~ /\.ht {deny            all;}location ~ /(api\/|conf[^\.]|include|locale) {deny            all;return          404;}location /vendor {deny            all;return          404;}location ~ [^/]\.php(/|$) {fastcgi_pass    unix:/var/run/php/zabbix.sock;fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_index   index.php;fastcgi_param   DOCUMENT_ROOT   /usr/share/zabbix;fastcgi_param   SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name;fastcgi_param   PATH_TRANSLATED /usr/share/zabbix$fastcgi_script_name;include fastcgi_params;fastcgi_param   QUERY_STRING    $query_string;fastcgi_param   REQUEST_METHOD  $request_method;fastcgi_param   CONTENT_TYPE    $content_type;fastcgi_param   CONTENT_LENGTH  $content_length;fastcgi_intercept_errors        on;fastcgi_ignore_client_abort     off;fastcgi_connect_timeout         60;fastcgi_send_timeout            180;fastcgi_read_timeout            180;fastcgi_buffer_size             128k;fastcgi_buffers                 4 256k;fastcgi_busy_buffers_size       256k;fastcgi_temp_file_write_size    256k;}
}root@zabbix02:~# vim /etc/zabbix/nginx.conf
server {listen          80;              #打开监听端口server_name     192.168.1.221;   #web访问server的地址#启动所有zabbix相关服务(两个sercer节点执行)
root@zabbix01:~# systemctl enable  zabbix-server zabbix-agent2.service nginx.service php7.4-fpm.service
Synchronizing state of zabbix-server.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable zabbix-server
Synchronizing state of zabbix-agent2.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable zabbix-agent2
Synchronizing state of nginx.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable nginx
Synchronizing state of php7.4-fpm.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable php7.4-fpm
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-server.service → /lib/systemd/system/zabbix-server.service.
root@zabbix01:~# #服务状态查看确认
root@zabbix01:~# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      34001/nginx: master
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      852/systemd-resolve
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      922/sshd: /usr/sbin
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      25847/sshd: root@pt
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      34016/zabbix_server
tcp6       0      0 :::80                   :::*                    LISTEN      34001/nginx: master
tcp6       0      0 :::22                   :::*                    LISTEN      922/sshd: /usr/sbin
tcp6       0      0 ::1:6010                :::*                    LISTEN      25847/sshd: root@pt
tcp6       0      0 :::10050                :::*                    LISTEN      33973/zabbix_agent2
tcp6       0      0 :::10051                :::*                    LISTEN      34016/zabbix_server

7.zabbix web配置

web访问:
http://server_ip/setup.php

在这里插入图片描述

检查php配置是否ok

在这里插入图片描述

web配置数据库

在这里插入图片描述

配置zabbix server name
配置web主题

在这里插入图片描述

查看全部配置信息

在这里插入图片描述
在这里插入图片描述

用户登录
Admin:zabbix

在这里插入图片描述

现在我们就成功登录web监控平台了

在这里插入图片描述

系统节点查看:可以看到当前已运行一个节点,有一个备用节点

在这里插入图片描述

6.zabbix web中文字符安装

#安装中文语言包
root@zabbix01:~# sudo apt install language-pack-zh-hans#system使用中文语言包(打开中文配置项:zh_CN.UTF-8 UTF-8)
root@zabbix01:~# sudo vim /etc/locale.gen
zh_CN.UTF-8 UTF-8#重启php服务即可(语言包即生效)
root@zabbix02:~# systemctl restart php7.4-fpm.service

选择配置中文语言:

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

这篇关于@Zabbix6.0 HA原生高可用集群部署方案(Ubuntu 20.04)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/646392

相关文章

通过Docker容器部署Python环境的全流程

《通过Docker容器部署Python环境的全流程》在现代化开发流程中,Docker因其轻量化、环境隔离和跨平台一致性的特性,已成为部署Python应用的标准工具,本文将详细演示如何通过Docker容... 目录引言一、docker与python的协同优势二、核心步骤详解三、进阶配置技巧四、生产环境最佳实践

Nginx部署HTTP/3的实现步骤

《Nginx部署HTTP/3的实现步骤》本文介绍了在Nginx中部署HTTP/3的详细步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学... 目录前提条件第一步:安装必要的依赖库第二步:获取并构建 BoringSSL第三步:获取 Nginx

MyBatis Plus实现时间字段自动填充的完整方案

《MyBatisPlus实现时间字段自动填充的完整方案》在日常开发中,我们经常需要记录数据的创建时间和更新时间,传统的做法是在每次插入或更新操作时手动设置这些时间字段,这种方式不仅繁琐,还容易遗漏,... 目录前言解决目标技术栈实现步骤1. 实体类注解配置2. 创建元数据处理器3. 服务层代码优化填充机制详

防止Linux rm命令误操作的多场景防护方案与实践

《防止Linuxrm命令误操作的多场景防护方案与实践》在Linux系统中,rm命令是删除文件和目录的高效工具,但一旦误操作,如执行rm-rf/或rm-rf/*,极易导致系统数据灾难,本文针对不同场景... 目录引言理解 rm 命令及误操作风险rm 命令基础常见误操作案例防护方案使用 rm编程 别名及安全删除

Python实现批量CSV转Excel的高性能处理方案

《Python实现批量CSV转Excel的高性能处理方案》在日常办公中,我们经常需要将CSV格式的数据转换为Excel文件,本文将介绍一个基于Python的高性能解决方案,感兴趣的小伙伴可以跟随小编一... 目录一、场景需求二、技术方案三、核心代码四、批量处理方案五、性能优化六、使用示例完整代码七、小结一、

C#使用Spire.Doc for .NET实现HTML转Word的高效方案

《C#使用Spire.Docfor.NET实现HTML转Word的高效方案》在Web开发中,HTML内容的生成与处理是高频需求,然而,当用户需要将HTML页面或动态生成的HTML字符串转换为Wor... 目录引言一、html转Word的典型场景与挑战二、用 Spire.Doc 实现 HTML 转 Word1

使用Python实现Word文档的自动化对比方案

《使用Python实现Word文档的自动化对比方案》我们经常需要比较两个Word文档的版本差异,无论是合同修订、论文修改还是代码文档更新,人工比对不仅效率低下,还容易遗漏关键改动,下面通过一个实际案例... 目录引言一、使用python-docx库解析文档结构二、使用difflib进行差异比对三、高级对比方

redis-sentinel基础概念及部署流程

《redis-sentinel基础概念及部署流程》RedisSentinel是Redis的高可用解决方案,通过监控主从节点、自动故障转移、通知机制及配置提供,实现集群故障恢复与服务持续可用,核心组件包... 目录一. 引言二. 核心功能三. 核心组件四. 故障转移流程五. 服务部署六. sentinel部署

Ubuntu如何升级Python版本

《Ubuntu如何升级Python版本》Ubuntu22.04Docker中,安装Python3.11后,使用update-alternatives设置为默认版本,最后用python3-V验证... 目China编程录问题描述前提环境解决方法总结问题描述Ubuntu22.04系统自带python3.10,想升级

Redis中哨兵机制和集群的区别及说明

《Redis中哨兵机制和集群的区别及说明》Redis哨兵通过主从复制实现高可用,适用于中小规模数据;集群采用分布式分片,支持动态扩展,适合大规模数据,哨兵管理简单但扩展性弱,集群性能更强但架构复杂,根... 目录一、架构设计与节点角色1. 哨兵机制(Sentinel)2. 集群(Cluster)二、数据分片