当前位置:网站首页>ZABBIX 6.0 source code installation and ha configuration
ZABBIX 6.0 source code installation and ha configuration
2022-07-01 12:52:00 【51CTO】
Zabbix 6.0 Has been released , Now the version is released to 6.0.6 , Among them, the original HA function , This function solves Zabbix Server Single point problem , Count as Zabbix 6.0 A relatively large function point , Let's see how this function is configured . in addition Zabbix 6.0 After release , The recommended operating system for official support is CentOS 8 Or above ,CentOS 8 The compiled installation package is not provided below , You need to compile it yourself , And the minimum version of the database is MySQL 8.0 ,PHP The minimum version requirement of is 7.2.5 , But not supported 8.0 .
Introduction to the environment
We need 3 Taiwan machine , The operating system is CentOS 7.4 , The database has chosen MySQL 8.0.28 ,PHP I chose 7.4.30, Mechanical IP And uses are
- 192.168.1.10 : Used for deployment MySQL database
- 192.168.1.11 : Used for deployment Zabbix Server Master、Zabbix Web
- 192.168.1.12 : Used for deployment Zabbix Server Slave
Zabbix 6.0 Source code installation
The source code installation needs to be prepared MySQL Environmental Science , Then compile , Modify the configuration file after compilation .
Get ready MySQL Database environment
First , We are 192.168.1.10 Machine deployment MySQL 8.0 database , To give Zabbix Server Provide data storage . This deployment MySQL 8.0.28 , You need to prepare the following installation packages :
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-server-8.0.28-1.el7.x86_64.rpm
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-client-8.0.28-1.el7.x86_64.rpm
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-common-8.0.28-1.el7.x86_64.rpm
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-devel-8.0.28-1.el7.x86_64.rpm
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-libs-8.0.28-1.el7.x86_64.rpm
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-libs-compat-8.0.28-1.el7.x86_64.rpm
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-icu-data-files-8.0.28-1.el7.x86_64.rpm
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
If you need to install other versions MySQL edition , Can be in MySQL Archive address of https://downloads.mysql.com/archives/community/ Select the version to download .
Download above MySQL 8.0.28 Of 8 Software dependent packages to the specified directory , And then use yum Unified installation
After installation, modify the database configuration file /etc/my.cnf Maximum number of connections in , Otherwise, there are too many connections , The default value is not enough , Add the following string to the last line of the file :
Then start the database instance
After starting, it will be in /var/log/mysqld.log Search log files for password keyword , find MySQL The initial password for , The field storing the password looks like this , You will be forced to change this password when logging in for the first time .
2022-06-30T21:17:24.373611Z 6 [Note] [MY-010454] [Server] A temporary password is generated for [email protected]: qPWHk<Rgh1lq
- 1.
After the database is started , Next, we can initialize the database , There are two steps , One is to create libraries and users , The other is import SQL file . First create the database and user :
[[email protected] ~]# msyql -uroot -pqPWHk<Rgh1lq
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewMysqlRootPasswrod';
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
mysql> create user 'zabbix_server'@'%' identified by 'ZBX_SER_PSW';
mysql> grant all privileges on zabbix.* to 'zabbix_server'@'%';
mysql> quit;
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
Next we download Zabbix Server Source file , Because the database initialization script is in the source file ,
Unzip this compressed file , Then enter the directory , hold schema.sql、images.sql、data.sql 3 Just import files .
[[email protected] <sub>]# cd database/mysql/
[[email protected] </sub>]# mysql -uzabbix_server -p zabbix < schema.sql
[[email protected] <sub>]# mysql -uzabbix_server -p zabbix < images.sql
[[email protected] </sub>]# mysql -uzabbix_server -p zabbix < data.sql
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
At this time, the database can be used , Let's record the database name first 、 user name 、 password 、IP Address , Configure later Zabbix Server It will be used .
notes :Zabbix Server You can build your own database in experiments or other less important places , In the production environment of the enterprise, it is suggested to invite DBA Students to build , We provide initialization SQL Just the papers ,DBA There will be some standard requirements and appropriate tuning for the database , These are good for us . without DBA Words of support , Then do it yourself . Therefore, this article does not involve any database optimization projects .
Prepare the compilation environment
The next in 192.168.1.11 Compile and deploy on Zabbix Server. CentOS 7 Installed by default MariaDB Of lib package , Because we want to use it uniformly MySQL, So uninstall this package first .
Next, install the tools needed for compilation
among net-snmp-devel It is used for monitoring snmp When you need to use , If you don't need it, you don't need to install . among unixODBC unixODBC-devel mysql-connector-odbc freetds It's through ODBC The monitoring database uses , If you don't need it, you don't need to install . Next, create the directory structure
After installing these compilation dependencies and creating the deployment directory , download Zabbix Source package .
Decompress the package
Next, enter the directory and start compiling :
If necessary, you can add the following compilation options
-
--with-net-snmp We should use snmp -
--enable-java We should use Java Of JMX -
--with-unixodbc=/usr/bin/odbc_config To pass the ODBC Monitoring the database .
After compilation, the following prompt will appear , If not, there is a problem with the compilation , Just solve the problems you encounter .
Next make install , Just wait for the execution to end , After execution, the whole compilation process is over .
modify Zabbix Server To configure
After compiling, the configuration file is in /opt/zabbix-server/etc/zabbix_server.conf , Modify this file , Put the... Of the database above IP Address 、 Database name 、 The user name and password of the database are configured , It's basically OK .
zabbix_server.conf There are still many places to adjust , I'll see it later .
After configuring the configuration file , Add one /usr/lib/systemd/system/zabbix-server.service file , This file is used to start 、 restart Zabbix Server.
[Unit]
Description=Zabbix Server
After=syslog.target
After=network.target
[Service]
Environment="CONFFILE=/opt/zabbix-server/etc/zabbix_server.conf"
Type=forking
Restart=on-failure
PIDFile=/opt/zabbix-server/run/zabbix_server.pid
KillMode=control-group
ExecStart=/opt/zabbix-server/sbin/zabbix_server -c $CONFFILE
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
TimeoutSec=0
LimitNOFILE=100000
[Install]
WantedBy=multi-user.target
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
install Zabbix Web
because Zabbix Web The page is using PHP Written , So you need a PHP, And need Nginx Acting as agent , Put the page out . because Zabbix You need a greater than 7.2.5 Less than 8.0 Version of , So we install PHP 7.4.30, This is a 7.x The latest version . This version can be downloaded from the official website for compilation and installation , But for convenience , We use yum Installation , We need a yum Source , We installed remi Of yum Source , It contains the latest PHP Installation package , The default source can only be installed 5.4.16 Of PHP.
perform yum list |grep php74 You can find something that can be used PHP 7.4.30 And corresponding extensions .
Next we install
Start after installation PHP,
After starting, it will Zabbix In the source UI Copy the file to the corresponding directory .
I'm going to modify PHP Configuration file for , The configuration file /etc/opt/remi/php74/php.ini
among date.timezone The comment of should be opened , It is amended as follows date.timezone = "Asia/Shanghai" , Refer to for other parameters
https://www.zabbix.com/documentation/6.0/en/manual/installation/frontend Make changes . Modify the system PHP After the configuration file , Revise Zabbix Of Web The configuration file , Rename the template file first , So that it can be used in the back .
modify zabbix.conf.php , In fact, it is mainly the link information of the configuration database ,Zabbix Server Information on 6.0 Stored in the database , There is no need to configure , as follows
Come here Zabbix Web Just configure it . Parse to download a Nginx , Add this configuration to Nginx in , And start up Zabbix .
server{
listen 80;
server_name zabbix.erdong.site;
root /opt/zabbix-web/frontends/;
location /
{
try_files $uri $uri/ /index.php?$args;
}
location <sub> ^(.+.php)(.*)$ {
fastcgi_split_path_info ^(.+.php)(.*)$;
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_buffer_size 128k;
fastcgi_buffers 32 32k;
fastcgi_connect_timeout 1200;
fastcgi_read_timeout 1200;
fastcgi_send_timeout 1200;
}
location </sub>* ^.+\.(ico|gif|jpg|jpeg|png|html|css|htm|bmp|js|svg)$ {
root /opt/zabbix-web/frontends/;
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
Up to now Zabbix Server 6.0 Just configure it , After mapping the domain name, you can pass http://zabbix.erdong.site/zabbix/index.php Visited
Turn on HA function
We just configured the single point Zabbix Server, Next, let's open a double point , Make it HA . First of all we have 192.168.1.12 It's compiling and installing Zabbix Server, And in 192.168.1.11 Same as above , But there is no need to install Zabbix Web. And then modify Zabbix Server The configuration file of is in zabbix_server.conf Remove... From the configuration file HANodeName and NodeAddress Comment on parameters , Just configure the name .
stay Master 192.168.1.11 Add... To the machine
stay Slave 192.168.1.12 Add... To the machine
Restart first Master machine , And then restart Slave , This configuration takes effect , We can see on the page HA Cluster It's started .

Use zabbix_server The command can also see the current state .
[[email protected] sbin]# ./zabbix_server -R ha_status
Failover delay: 60 seconds
Cluster status:
# ID Name Address Status Last Access
1. cl50nx5ou0001jaryp82xvfya Erdong-1-11 192.168.1.11:10051 active 0s
2. cl50nxaq10001lzrzkcn9wwbq Erdong-1-12 192.168.1.12:10051 standby 3s
[[email protected] sbin]#
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
Then let's test , close Master machine , And then check it out :
[[email protected] sbin]# ./zabbix_server -R ha_status
Failover delay: 60 seconds
Cluster status:
# ID Name Address Status Last Access
1. cl50nx5ou0001jaryp82xvfya Erdong-1-11 192.168.1.11:10051 stopped 2m 37s
2. cl50nxaq10001lzrzkcn9wwbq Erdong-1-12 192.168.1.12:10051 active 3s
[[email protected] sbin]#
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
You can also see the switch on the page .

And then Master get up , There is no change seen from the page . But in fact, there are already 2 It's a machine .

Come here HA Also configured ,Zabbix Proxy and Zabbix Agent Yes HA Of Zabbix Server Just put two Server Just configure your address , Just separate them with commas .
边栏推荐
- [today in history] July 1: the father of time sharing system was born; Alipay launched barcode payment; The first TV advertisement in the world
- flinkcdc要实时抽取oracle,对oracle要配置什么东西?
- ustime写出了bug
- 基于开源流批一体数据同步引擎 ChunJun 数据还原 —DDL 解析模块的实战分享
- 基因检测,如何帮助患者对抗疾病?
- 79. Word search [DFS + backtracking visit + traversal starting point]
- 我花上万学带货:3天赚3元,成交靠刷单
- 【邂逅Django】——(二)数据库配置
- VS Code 设置单击打开新文件窗口,不覆盖前一个窗口
- Need your own cognition
猜你喜欢

Detailed explanation of OSPF LSA of routing Foundation

数论基础及其代码实现

Operations related to sequence table

项目部署,一点也不难!

redis探索之缓存击穿、缓存雪崩、缓存穿透

Operator-1 first acquaintance with operator
![[brain opening] west tide and going to the world series](/img/b2/444af296e170d19629800b3d4c50fa.jpg)
[brain opening] west tide and going to the world series
![leetcode:226. Flip binary tree [DFS flip]](/img/b8/6c5596ac30de59f0f347bb0bddf574.png)
leetcode:226. Flip binary tree [DFS flip]

【历史上的今天】7 月 1 日:分时系统之父诞生;支付宝推出条码支付;世界上第一支电视广告

I spent tens of thousands of dollars to learn and bring goods: I earned 3 yuan in three days, and the transaction depends on the bill
随机推荐
Function test process in software testing
Circular linked list--
工具箱之 IKVM.NET 项目新进展
ROS2 Foxy depthai_ros教程
Flinkcdc should extract Oracle in real time. What should be configured for oracle?
天青色等烟雨
There are risks in trading
Zabbix 6.0 源码安装以及 HA 配置
Topic 2612: the real topic of the 12th provincial competition of the Blue Bridge Cup in 2021 - the least weight (enumerating and finding rules + recursion)
王兴的无限游戏迎来“终极”一战
Zero copy technology of MySQL
Like the three foot platform
Blocking sockets的读写操作该怎么玩?
leetcode:329. 矩阵中的最长递增路径【dfs + cache + 无需回溯 + 优雅】
Redis explores cache consistency
Will it affect the original MySQL database to read the data of a MySQL table in full by flick MySQL CDC
数字化转型再下一城,数字孪生厂商优锘科技宣布完成超3亿元融资
leetcode:226. Flip binary tree [DFS flip]
Shell script imports stored procedures into the database
Queue operation---