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


在这里插入图片描述

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:10051

root@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

选择配置中文语言:

在这里插入图片描述

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

posted @ 2022-08-11 22:52  ଲ小何才露煎煎饺  阅读(400)  评论(0编辑  收藏  举报