Metadb POSTGRESQL Upgrade
Background: With the continuous upgrade of the HENGSHI SENSE service version, the internal Metadb (postgresql) component version of HENGSHI SENSE is also continuously upgraded. You can choose to maintain the current version or upgrade to the latest built-in version.
This article introduces how to upgrade the Metadb data operation and how to roll back the database version if issues arise during the upgrade process.
- Standalone/Cluster Deployment Upgrade
- Container Deployment Upgrade
- k8s Deployment Upgrade
- Windows Deployment Upgrade
Standalone/Cluster Deployment
Pre-Upgrade Verification
cd /opt/hengshi
bin/hengshi-sense-bin start metadb ## Start metadb operation
2
If this prompt appears, it indicates that your metadb version is lower than the current HENGSHI SENSE default built-in version. Please proceed with the following upgrade operation.
Version Upgrade
cd /opt/hengshi
bin/hengshi-sense-bin stop metadb ## Ensure the metadb service is stopped before the upgrade operation.
bin/hengshi-sense-bin upgrade metadb ## Upgrade operation
2
3
The above prompt indicates that your metadb database has been successfully upgraded.
Version Rollback
- If an exception occurs during the upgrade process, please perform the following operations to complete the version rollback.
cd /opt/hengshi
rm -rf pg_data
mv pg_data_bak pg_data
cd /opt/hengshi/lib
rm -rf pgsql
ln -s postgresql-9.6.2 pgsql
2
3
4
5
6
Container Deployment
Pre-Upgrade Verification
Please contact the after-sales service to confirm the current metadb version information and upgrade the metadb version information.
Version Upgrade
- To upgrade the Metadb service version, you need to use the upgrade image hengshi-sense:metadb-upgrade for the upgrade operation.
- Modify the .env file, set HS_IMAGE_TAG=$TAG to the metadb-upgrade upgrade image tag.
- Modify the docker-compose.yaml file, add the following configuration under the metadb service, note that 9.6.2 is the current metadb version number.
environment:
OLDER_METADB_VERSION: 9.6.2
2
- Perform the upgrade operation
cd single
docker-compose run --rm metadb upgrade metadb
2
5. The above prompt indicates that your metadb database has been successfully upgraded.
Version Rollback
- If an exception occurs during the upgrade process, please perform the following operations to complete the version rollback.
- Confirm the env configuration file information, HSHOME address information.
cd $HSHOME # Go to the directory configured by HSHOME
cd hsdata
rm -rf pg_data
mv pg_data_bak pg_data
2
3
4
- After the rollback is complete, restore the image tag in the .env file to the old version.
k8s Deployment
Pre-Upgrade Verification
Please contact the after-sales service to confirm the current metadb version information and upgrade the metadb version information.
Version Upgrade
- To upgrade the Metadb service version, you need to use the upgrade image hengshi-sense:metadb-upgrade for the upgrade operation.
- Modify the metadb.yaml file, change the image version in image: registry.hengshi.org/hengshi-sense:rc to hengshi-sense:metadb-upgrade.
- Modify the configmap.yaml configuration parameters, add the following configuration, note that 9.6.2 is the current metadb version number.
OLDER_METADB_VERSION: 9.6.2
- Perform the following upgrade operation
kubectl -n hengshi apply metadb.yaml
kubectl -n hengshi exec -it metadb-0 -- /docker-entrypoint.sh upgrade metadb single
2
5. The above prompt indicates that your metadb database has been successfully upgraded.
Version Rollback
- If an exception occurs during the upgrade process, please perform the following operations to complete the version rollback.
kubectl -n hengshi exec -it metadb-0 -- /bin/bash
cd /opt/hengshi
rm -rf pg_data
mv pg_data_bak pg_data
2
3
4
- After the rollback is complete, restore the image tag in the metadb.yaml file to the old version.
Windows Deployment
Pre-Upgrade Verification
Determine the current version by checking the content of the installation directory\pg_data\PG_VERSION file to determine the current metadb version.
Please note
Confirm that the upgrade-before metadb version program exists in the *installation directory\lib* directory. For example, if the PG_VERSION file content is 9.6, the lib\ directory should contain the postgresql-9.6.2-windows-64 program directory.
Version Upgrade
Start the upgrade, enter the program name of the version to be upgraded.
Click the start upgrade button.
The Upgrade Complete prompt indicates that the upgrade is complete.
- Tip: After the upgrade, a pg_data_bak directory appears, which is the old version database file. This file can be cleaned up after confirming that the upgraded database is correct.
Version Rollback
- If an exception occurs during the upgrade process, please perform the following operations to complete the version rollback.
- Delete the pg_data directory, rename the pg_data_bak directory to pg_data.
- Edit the installation directory\bat\common.bat file, change the pgsql variable to pgsql=postgresql-9.6.2-windows-64.