This topic describes how to upgrade OceanBase Database by using OceanBase Deployer (OBD).
Upgrade solutions
To upgrade OceanBase Database using OBD, you have two options based on your requirements:
Solution 1: Online upgrade. If your server has internet access or you have configured an image repository with the RPM package for upgrading OceanBase Database, you can choose this solution for the upgrade. For more information, see Solution 1: Upgrade OceanBase Database online.
Solution 2: Offline upgrade. If your server does not have internet access and the configured image repository does not include an RPM package for upgrading OceanBase Database, you can run the
obd mirror clonecommand to add the RPM package for upgrading OceanBase Database to the local image repository, or download and install the all-in-one installation package of the corresponding version, and then proceed with the upgrade. For more information, see Solution 2: Upgrade OceanBase Database offline.
Procedure
Solution 1: Upgrade OceanBase Database online
Run the following command to enable the remote image repository:
obd mirror enable remote(Optional) Run the following command to upgrade OBD to the latest version:
obd updateRun the following command to query the version of OceanBase Database in the remote mirror repository:
obd mirror list oceanbase.community.stable | grep oceanbase-ceIn the following sample output, the strings displayed in the rightmost column are the hash values of the corresponding versions of OceanBase Database Community Edition.
| oceanbase-ce | 4.0.0.0 | 100000272022110114.el7 | x86_64 | 759074414c7b7b723013855353f62a7ba0aae0f493216ef2511825850ce77b51 | | oceanbase-ce | 4.0.0.0 | 100000282022112511.el7 | x86_64 | debb18ab3c0b3d16f145c41cd21c30686863580b721d45ddaa068e6309e03b64 | | oceanbase-ce | 4.0.0.0 | 102000032022120718.el7 | x86_64 | c63bb73384b17d74299b34fe3aceb0ae310fd319d2ccdb1acd39f31ba6673198 | | oceanbase-ce | 4.0.0.0 | 103000022023011215.el7 | x86_64 | ca467ed00a5e717f40d360ba9d08252595f4ce9de87c81e6006858fbae5755fa | | oceanbase-ce | 4.1.0.0 | 100000192023032010.el7 | x86_64 | a4a092156b5cfe6708a25813633145e0bbd75170e01e30b5c4b88fb230e10903 | | oceanbase-ce | 4.1.0.0 | 100000202023040520.el7 | x86_64 | b56ec3d6e75fd01da65abe0ebb8f8b6455d6a8563c77491ee3d19b33abc40e53 | | oceanbase-ce | 4.1.0.0 | 101000022023050809.el7 | x86_64 | fe7c4d26f18534e4116f75ddf8ecea59bfdba221e6d43c0f7ea6a24c118c3858 | | oceanbase-ce | 4.1.0.0 | 101010022023051821.el7 | x86_64 | 66882706a45d94c379dce7fd6c0b3c9c33cd780e95658d3a475029013a4b3451 | | oceanbase-ce | 4.1.0.1 | 102000042023061314.el7 | x86_64 | 126aa046ed03e191aad2481b1e4f82f43bb0017befc3b9569f4c8e215313c8ef | | oceanbase-ce | 4.1.0.2 | 103010012023082519.el7 | x86_64 | 3473fe01f6c5325a29bd325183377d102ea1f9cf1cd8bb5a0f36fac9852983cf | | oceanbase-ce | 4.2.0.0 | 100000152023080109.el7 | x86_64 | 1cbd1fde8c6d7695015265da09738478c97e0e2f908fca6745dc9cc531860e74 | | oceanbase-ce | 4.2.0.0 | 100010022023081817.el7 | x86_64 | 5cb4adf7a98754c09a82edadaf8f9485bfd6376184e4fe3109e8f607899cf8cf | | oceanbase-ce | 4.2.0.0 | 100010032023083021.el7 | x86_64 | 790596d146bd22abfbd87faf6bcacddd0d6936dafe0ff6958640bdb833256a48 | # Subsequent outputs omitted(Optional) View the primary zone configuration of tenants in the cluster.
Note
You must perform this step only when you upgrade OceanBase Database to V4.0.x, V4.1.x, or V4.2.0 BETA.
Log on to the sys tenant of the database as the root user and run the following command:
obclient [oceanbase]> select * from __all_tenant;The output is as follows:
+----------------------------+----------------------------+-----------+-------------+-------------------+--------------+--------+----------------+---------------+---------------------------------------------+-------------------+-----------------------+--------------------+------------------+--------+---------------+----------------------------+ | gmt_create | gmt_modified | tenant_id | tenant_name | zone_list | primary_zone | locked | collation_type | info | locality | previous_locality | default_tablegroup_id | compatibility_mode | drop_tenant_time | status | in_recyclebin | arbitration_service_status | +----------------------------+----------------------------+-----------+-------------+-------------------+--------------+--------+----------------+---------------+---------------------------------------------+-------------------+-----------------------+--------------------+------------------+--------+---------------+----------------------------+ | 2023-09-08 15:04:32.205665 | 2023-09-08 15:04:32.205665 | 1 | sys | zone1;zone2;zone3 | RANDOM | 0 | 0 | system tenant | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | | -1 | 0 | -1 | NORMAL | 0 | DISABLED | | 2023-09-08 15:13:49.119008 | 2023-09-08 15:14:09.573693 | 1001 | META$1002 | zone1;zone2;zone3 | RANDOM | 0 | 0 | | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | | -1 | 0 | -1 | NORMAL | 0 | DISABLED | | 2023-09-08 15:13:49.126607 | 2023-09-08 15:14:09.733515 | 1002 | ocp | zone1;zone2;zone3 | RANDOM | 0 | 0 | | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | | -1 | 0 | -1 | NORMAL | 0 | DISABLED | +----------------------------+----------------------------+-----------+-------------+-------------------+--------------+--------+----------------+---------------+---------------------------------------------+-------------------+-----------------------+--------------------+------------------+--------+---------------+----------------------------+If the value of the
primary_zonecolumn of a tenant isRANDOM, execute the following statement to specify different priorities for the zones of the tenant:obclient [oceanbase]> ALTER TENANT ocp primary_zone='zone1';For more information about the
ALTER TENANTstatement, see ALTER TENANT.Perform a major compaction of OceanBase Database.
Log on to the sys tenant as the root user and run the following command to perform a major compaction:
obclient [oceanbase]> ALTER SYSTEM MAJOR FREEZE;Run the following command to check whether the major compaction is completed:
obclient [oceanbase]> select name,value from oceanbase.__all_zone where name='frozen_version' or name='last_merged_version';Run the following command to upgrade OceanBase Database:
obd cluster upgrade obtest -c oceanbase-ce -V 4.2.0.0 --usable=790596d146bd22abfbd87faf6bcacddd0d6936dafe0ff6958640bdb833256a48In this example, the cluster name is
obtestand the target upgrade version is V4.2.0. You must replace the cluster name and the target version with the actual ones. For more information about the commands used in this step, see Cluster commands.Check whether the upgrade is successful.
Log on to the sys tenant of the OceanBase database as the root user and run the following command to view the database version:
obclient [oceanbase]> SELECT version();
Solution 2: Upgrade OceanBase Database offline
Configure the RPM package.
You can run the
obd mirror clonecommand to add the RPM package for upgrading OceanBase Database to the local image repository, or download and install the all-in-one installation package of the corresponding version.Method 1: Download the RPM packages of OceanBase Database and the required dependency library from the Releases page on GitHub or OceanBase Download Center, copy the packages to the server where OBD is installed, and run the following command in the directory where the packages are located to add the packages to the local image repository:
obd mirror clone oceanbase-ce-*.rpmMethod 2: Download the all-in-one installation package of the required version from OceanBase Download Center, copy the installation package to the server where OBD is installed, and run the following commands to decompress and install the package.
Notice
You must install the all-in-one installation package with the same account that you use to install OceanBase Database, such as the admin account.
If you have installed the all-in-one installation package, we recommend that you use the
upgrade.shscript to upgrade OBD after you download and decompress the package. To be specific, replace the./install.shcommand in the sample code with the./upgrade.shcommand.
[admin@test001 ~]$ tar -xzf oceanbase-all-in-one-*.tar.gz [admin@test001 ~]$ cd oceanbase-all-in-one/bin/ [admin@test001 bin]$ ./install.sh [admin@test001 bin]$ source ~/.oceanbase-all-in-one/bin/env.sh
Run the following command to disconnect from the remote image repository:
obd mirror disable remoteRun the following command to query the version of OceanBase Database in the local image repository:
obd mirror list local | grep oceanbase-ceIn the following sample output, the strings displayed in the rightmost column are the hash values of the corresponding versions of OceanBase Database Community Edition.
| oceanbase-ce | 4.1.0.1 | 102000042023061314.el7 | x86_64 | d03fafa6fa8ceb0636e4db05b5b5f6c3ac2256a3 | | oceanbase-ce-libs | 4.1.0.1 | 102000042023061314.el7 | x86_64 | c3f797aae1ce258ec9be77898b94e4e7a501cd0f | | oceanbase-ce | 4.2.0.0 | 100010022023081817.el7 | x86_64 | bf178e82c99ca1324a3df9e1a21cbbb8f8c4d46c | | oceanbase-ce-libs | 4.2.0.0 | 100010022023081817.el7 | x86_64 | f77ba7e678acf0645889967391c847ca9cf684b6 |(Optional) View the primary zone configuration of tenants in the cluster.
Note
You must perform this step only when you upgrade OceanBase Database to V4.0.x, V4.1.x, or V4.2.0 BETA.
Log on to the sys tenant of the database as the root user and run the following command:
obclient [oceanbase]> select * from __all_tenant;The output is as follows:
+----------------------------+----------------------------+-----------+-------------+-------------------+--------------+--------+----------------+---------------+---------------------------------------------+-------------------+-----------------------+--------------------+------------------+--------+---------------+----------------------------+ | gmt_create | gmt_modified | tenant_id | tenant_name | zone_list | primary_zone | locked | collation_type | info | locality | previous_locality | default_tablegroup_id | compatibility_mode | drop_tenant_time | status | in_recyclebin | arbitration_service_status | +----------------------------+----------------------------+-----------+-------------+-------------------+--------------+--------+----------------+---------------+---------------------------------------------+-------------------+-----------------------+--------------------+------------------+--------+---------------+----------------------------+ | 2023-09-08 15:04:32.205665 | 2023-09-08 15:04:32.205665 | 1 | sys | zone1;zone2;zone3 | RANDOM | 0 | 0 | system tenant | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | | -1 | 0 | -1 | NORMAL | 0 | DISABLED | | 2023-09-08 15:13:49.119008 | 2023-09-08 15:14:09.573693 | 1001 | META$1002 | zone1;zone2;zone3 | RANDOM | 0 | 0 | | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | | -1 | 0 | -1 | NORMAL | 0 | DISABLED | | 2023-09-08 15:13:49.126607 | 2023-09-08 15:14:09.733515 | 1002 | ocp | zone1;zone2;zone3 | RANDOM | 0 | 0 | | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | | -1 | 0 | -1 | NORMAL | 0 | DISABLED | +----------------------------+----------------------------+-----------+-------------+-------------------+--------------+--------+----------------+---------------+---------------------------------------------+-------------------+-----------------------+--------------------+------------------+--------+---------------+----------------------------+If the value of the
primary_zonecolumn of a tenant isRANDOM, execute the following statement to specify different priorities for the zones of the tenant:obclient [oceanbase]> ALTER TENANT ocp primary_zone='zone1';For more information about the
ALTER TENANTstatement, see ALTER TENANT.Perform a major compaction of OceanBase Database.
Log on to the sys tenant as the root user and run the following command to perform a major compaction:
obclient [oceanbase]> ALTER SYSTEM MAJOR FREEZE;Run the following command to check whether the major compaction is completed:
obclient [oceanbase]> select name,value from oceanbase.__all_zone where name='frozen_version' or name='last_merged_version';Run the following command to upgrade OceanBase Database:
obd cluster upgrade obtest -c oceanbase-ce -V 4.2.0.0 --usable=f77ba7e678acf0645889967391c847ca9cf684b6In this example, the cluster name is
obtestand the target upgrade version is V4.2.0. You must replace the cluster name and the target version with the actual ones. For more information about the commands used in this step, see Cluster commands.Check whether the upgrade is successful.
Log on to the sys tenant of the OceanBase database as the root user and run the following command to view the database version:
obclient [oceanbase]> SELECT version();