Operations 11 min read

Step-by-Step Guide to Upgrading Zabbix 4.0→5.0 and Migrating Elasticsearch to 7.x

This article provides a comprehensive, ordered procedure for upgrading a Zabbix 4.0 monitoring system to version 5.0 using blue‑green deployment, backing up configurations, updating repositories, applying MySQL patches, and then migrating the associated Elasticsearch cluster from 6.1 to 7.x, including all necessary command‑line steps, configuration edits, and post‑upgrade validation.

Ops Development Stories
Ops Development Stories
Ops Development Stories
Step-by-Step Guide to Upgrading Zabbix 4.0→5.0 and Migrating Elasticsearch to 7.x

Upgrade Overview

During the upgrade, existing services remain operational; after the upgrade a short availability test is performed before replacing production monitoring.

Impact Scope

The upgrade will not affect the current system; it will continue to run normally.

Upgrade Method

A blue‑green deployment is used: a new 5.0 instance is deployed in a test environment, the original 4.0 configuration files are imported, and then the system is upgraded from 4.0 to 5.0. Direct installation of 5.0 with the 4.0 database would fail due to schema changes.

Post‑Upgrade Risks

Zabbix 5.0 is newly released and may contain bugs that will be fixed in later patches.

Upgrade Principles

Recreate the Zabbix service with the same configuration as the original 4.0 environment; upgrade components (e.g., MySQL) if required.

Isolate networks to avoid conflicts with the existing environment.

Ensure data availability by backing up databases and avoiding accidental data loss.

Follow a clear host‑naming convention; avoid name clashes with existing ES clusters.

After upgrade, ensure MySQL replication, ES node synchronization, ES health = green, Zabbix proxy‑server connectivity, and LAMP‑based web service.

Zabbix Upgrade Steps

1. Stop Zabbix and Web Processes

systemctl stop zabbix-server
systemctl stop zabbix-proxy
systemctl stop httpd php-fpm

2. Backup 4.0 Configuration Data

mysqldump -uzabbix -p --single-transaction --master-data=2 --databases zabbix > olddata.sql
mkdir /opt/zabbix-backup/
cp /etc/zabbix/zabbix_server.conf /opt/zabbix-backup/
cp /etc/httpd/conf.d/zabbix.conf /opt/zabbix-backup/
cp -R /usr/share/zabbix/ /opt/zabbix-backup/
cp -R /usr/share/doc/zabbix-* /opt/zabbix-backup/

3. Update Repository (Aliyun Mirror)

rm -rf /etc/repos.d/zabbix.repo
rpm -qa | grep zabbix-release && rpm -e zabbix-release
rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
sed -i '[email protected]@mirrors.aliyun.com/zabbix@g' /etc/yum.repos.d/zabbix.repo
yum clean all
yum makecache fast

4. Upgrade Zabbix Packages

yum upgrade zabbix-server-mysql zabbix-web-mysql zabbix-agent

5. Upgrade Zabbix Web Front‑End

yum remove zabbix-web
yum install centos-release-scl -y
yum install https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/frontend/zabbix-web-deps-scl-5.0.0-1.el7.noarch.rpm
yum install https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/frontend/zabbix-web-5.0.0-1.el7.noarch.rpm
yum install https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/frontend/zabbix-web-mysql-scl-5.0.0-1.el7.noarch.rpm
yum install https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/frontend/zabbix-apache-conf-scl-5.0.0-1.el7.noarch.rpm

6. Adjust PHP Timezone

vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai

7. Start Zabbix Services

systemctl start zabbix-server zabbix-agent httpd rh-php72-php-fpm

8. Apply MySQL Double‑Precision Patch

ALTER TABLE trends MODIFY value_min DOUBLE PRECISION DEFAULT '0.0000' NOT NULL,
MODIFY value_avg DOUBLE PRECISION DEFAULT '0.0000' NOT NULL,
MODIFY value_max DOUBLE PRECISION DEFAULT '0.0000' NOT NULL;
ALTER TABLE history MODIFY value DOUBLE PRECISION DEFAULT '0.0000' NOT NULL;

9. Update Zabbix PHP Config for DOUBLE_IEEE754

vim /etc/zabbix/web/zabbix.conf.php
$DB['DOUBLE_IEEE754'] = true;

10. Restart Zabbix Server

systemctl restart zabbix-server

Elasticsearch Upgrade Steps

1. Disable Zabbix ES Integration

vim /etc/zabbix/web/zabbix.conf.php
#//$HISTORY['url'] = 'http://192.168.179.134:9200';
#//$HISTORY['types']=['uint','dbl','str','log','text'];
vim /etc/zabbix/zabbix_server.conf
#HistoryStorageURL=http://192.168.179.134:9200
#HistoryStorageTypes=uint,dbl,str,log,text
#HistoryStorageDateIndex=1
systemctl restart zabbix-server

2. Disable Replica Allocation

PUT _cluster/settings
{
  "persistent": {
    "cluster.routing.allocation.enable": "primaries"
  }
}

3. Stop All ES Nodes

systemctl stop elasticsearch

4. Upgrade All Nodes (Binary Upgrade)

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.1-linux-x86_64.tar.gz
tar -zxvf elasticsearch-7.0.1-linux-x86_64.tar.gz

5. Copy Old Config to New Version

cp /elasticsearch/elasticsearch-6.1.0/config/elasticsearch.yml /elasticsearch-7.0.1/config/elasticsearch.yml

6. Start All Nodes

su elker
./elasticsearch-7.0.1/bin/elasticsearch

Verify node status shows version 7.0 and existing indices remain.

7. Re‑enable Replica Allocation After Primary Shards Recover

PUT _cluster/settings
{
  "persistent": {
    "cluster.routing.allocation.enable": null
  }
}

8. Re‑configure Zabbix to Use ES

vim /etc/zabbix/web/zabbix.conf.php
$HISTORY['url'] = 'http://192.168.179.134:9200';
$HISTORY['types'] = ['uint','dbl','str','log','text'];
vim /etc/zabbix/zabbix_server.conf
HistoryStorageURL=http://192.168.179.134:9200 HistoryStorageTypes=uint,dbl,str,log,text
HistoryStorageDateIndex=1
systemctl restart zabbix-server

Welcome to discuss together.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ElasticsearchLinuxmysqlupgradeSystem AdministrationZabbix
Ops Development Stories
Written by

Ops Development Stories

Maintained by a like‑minded team, covering both operations and development. Topics span Linux ops, DevOps toolchain, Kubernetes containerization, monitoring, log collection, network security, and Python or Go development. Team members: Qiao Ke, wanger, Dong Ge, Su Xin, Hua Zai, Zheng Ge, Teacher Xia.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.