OceanBase Shell (OBShell) supports the following OceanBase Database upgrade methods:
Upgrade a cluster by calling API operations
Upgrade a cluster by using the CLI
This topic uses an OceanBase cluster with three replicas as an example to describe how to upgrade an OceanBase cluster by using OBShell.
Prerequisites
The OceanBase cluster is managed by OBShell. For more information, see Take over an OceanBase cluster not deployed by OBShell.
All OBServer nodes and OBShell processes in the OceanBase cluster are running normally.
Before the upgrade, the tenants in the OceanBase cluster are not undergoing a major compaction.
Deployment mode
The following table describes the three machines in the OceanBase cluster, with OBShell using the default port 2886.
| Role | Machine | Remarks |
|---|---|---|
| OBServer node | 10.10.10.1 | In OceanBase Database Zone 1 |
| OBServer node | 10.10.10.2 | In OceanBase Database Zone 2 |
| OBServer node | 10.10.10.3 | In OceanBase Database Zone 3 |
Upgrade a cluster by calling API operations
Note
OBShell verifies the security of requested API operations. Therefore, you must encrypt the request before you call an API operation. For more information, see Hybrid encryption for API operations. You must also specify ${request_headers} and ${request_body} in the curl command.
Step 1: Upload the RPM packages of the target version
Call the /api/v1/upgrade/package API operation in any OBShell process to upload the packages. The oceanbase-ce and oceanbase-ce-libs packages are required. For more information, see UploadPkg.
[admin@test001 ~]$ curl -H 'X-OCS-Header:${request_headers}' -X POST -F "file=@/data/upgrade/oceanbase-ce-4.2.2.0-xxx.el7.x86_64.rpm" http://10.10.10.1:2886/api/v1/upgrade/package
[admin@test001 ~]$ curl -H 'X-OCS-Header:${request_headers}' -X POST -F "file=@/data/upgrade/oceanbase-ce-libs-4.2.2.0-xxx.el7.x86_64.rpm" http://10.10.10.1:2886/api/v1/upgrade/package
(Optional) Step 2: Call the upgrade check API operation
Call the /api/v1/ob/upgrade/check API operation in any OBShell process to perform the upgrade check. The upgrade check verifies the upgrade environment, whether the packages of the target version have been uploaded, and whether the products required for the upgrade are all obtained. For more information, see ObUpgradeCheck. The API operation creates an asynchronous task. For more information about how to query the task progress, see GetDagDetails. Wait for the upgrade check task to complete.
[admin@test001 ~]$ curl -H "Content-Type: application/json" -H 'X-OCS-Header:${request_headers}' -X POST -d '${request_body}' http://10.10.10.1:2886/api/v1/ob/upgrade/check
Step 3: Call the upgrade API operation
Call the /api/v1/ob/upgrade API operation in any OBShell process to perform the upgrade. For more information, see UpgradeOb. The API operation creates an asynchronous O&M task. For more information about how to query the task progress, see GetDagDetails. Wait for the upgrade task to complete.
[admin@test001 ~]$ curl -H "Content-Type: application/json" -H 'X-OCS-Header:${request_headers}' -X POST -d '${request_body}' http://10.10.10.1:2886/api/v1/ob/upgrade
Step 4: Verify the upgrade result
Log on to the
systenant of OceanBase Database as therootuser, and run the following command to query the database version:obclient [oceanbase]> select build_version from oceanbase.dba_ob_servers;Run the following command to query the OBShell version:
obclient [oceanbase]> select version from ocs.all_agent;
Upgrade a cluster by using the CLI
Step 1: Run the upgrade command to perform the upgrade
Run the obshell cluster upgrade command on any OBServer node. Use -d to specify the path to the packages of the target version. For more information, see obshell cluster upgrade.
[admin@test001 ~]$ /home/admin/oceanbase/bin/obshell cluster upgrade -d /home/admin/oceanbase/upgrade/
Step 2: Verify the upgrade result
Log on to the
systenant of OceanBase Database as therootuser, and run the following command to query the database version:obclient [oceanbase]> select build_version from oceanbase.dba_ob_servers;Run the following command to query the OBShell version:
obclient [oceanbase]> select version from ocs.all_agent;