OceanBase Shell (obshell) supports the following OceanBase Database upgrade methods:
Upgrade an OceanBase cluster by calling API operations
Upgrade an OceanBase cluster by running obshell commands
This topic describes how to use obshell to upgrade an OceanBase cluster with three replicas.
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 | Description |
|---|---|---|
| Existing OBServer node | 10.10.10.1 | In OceanBase Database Zone 1 |
| Existing OBServer node | 10.10.10.2 | In OceanBase Database Zone 2 |
| Existing OBServer node | 10.10.10.3 | In OceanBase Database Zone 3 |
Upgrade an OceanBase 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 of the target version. The oceanbase-ce and oceanbase-ce-libs packages are required.
For more information about how to call the corresponding API operation by using the CLI, see UploadPkg.
[admin@test001 ~]$ curl -H 'X-OCS-Header:${request_headers}' -X POST -F "file=@/data/upgrade/oceanbase-ce-x.x.x.x-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-x.x.x.x-xxx.el7.x86_64.rpm" http://10.10.10.1:2886/api/v1/upgrade/package
For more information about how to call the corresponding API operation by using obshell-sdk-python, see Upload an RPM package.
···
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
client.v1.upload_pkg("/data/upgrade/oceanbase-ce-x.x.x.x-xxx.el7.x86_64.rpm") # Call /api/v1/upgrade/package.
client.v1.upload_pkg("/data/upgrade/oceanbase-ce-libs-x.x.x.x-xxx.el7.x86_64.rpm") # Call /api/v1/upgrade/package.
···
For more information about how to call the corresponding API operation by using obshell-sdk-go, see Upload an RPM package.
···
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
req := client.V1().NewUploadPkgRequest("/data/upgrade/oceanbase-ce-x.x.x.x-xxx.el7.x86_64.rpm")
dag, err := client.V1().UploadPkgWithRequest(req) // Call /api/v1/upgrade/package.
req = client.V1().NewUploadPkgRequest("/data/upgrade/oceanbase-ce-libs-x.x.x.x-xxx.el7.x86_64.rpm")
dag, err = client.V1().UploadPkgWithRequest(req) // Call /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 about how to call the corresponding API operation by using the CLI, 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
For more information about how to call the corresponding API operation by using obshell-sdk-python, see Perform an OceanBase Database upgrade check.
···
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
client.v1.upgrade_ob_check_sync("x.x.x.x", "xxx.el7") # Call /api/v1/ob/upgrade/check.
···
For more information about how to call the corresponding API operation by using obshell-sdk-go, see Perform an OceanBase Database upgrade check.
···
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
req := client.V1().NewUpgradeObCheckRequest("x.x.x.x", "xxx.el7")
dag, err := client.V1().UpgradeObCheckSyncWithRequest(req) // Call /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 about how to call the corresponding API operation by using the CLI, see UpgradeOb. The API operation creates an asynchronous O&M task. 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
For more information about how to call the corresponding API operation by using obshell-sdk-python, see Upgrade OceanBase Database.
···
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
client.v1.upgrade_ob_sync("x.x.x.x", "xxx.el7") # Call /api/v1/ob/upgrade.
···
For more information about how to call the corresponding API operation by using obshell-sdk-go, see Upgrade OceanBase Database.
···
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
req := client.V1().NewUpgradeObRequest("x.x.x.x", "xxx.el7")
dag, err := client.V1().UpgradeObSyncWithRequest(req) // Call /api/v1/ob/upgrade.
···
Step 4: Verify the upgrade result
Log in 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;
Complete sample code
from obshell import ClientSet
from obshell.auth import PasswordAuth
client = ClientSet("10.10.10.1", PasswordAuth("****"))
# Upload the packages required for the upgrade.
client.v1.upload_pkg("/data/upgrade/oceanbase-ce-x.x.x.x-xxx.el7.x86_64.rpm")
client.v1.upload_pkg("/data/upgrade/oceanbase-ce-libs-x.x.x.x-xxx.el7.x86_64.rpm")
# Perform the pre-upgrade check.
client.v1.upgrade_ob_check_sync("x.x.x.x", "xxx.el7")
# Upgrade OceanBase Database.
client.v1.upgrade_ob_sync("x.x.x.x", "xxx.el7")
package main
import (
"github.com/oceanbase/obshell-sdk-go/services"
)
func main() {
var err error // Handle errors in the production environment.
// Create a client instance, with the IP address of "10.10.10.1" and the port number of 2886.
// Enter the root@sys password "****" for the cluster.
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "***")
// Upload the RPM packages to the cluster.
req1 := client.V1().NewUploadPkgRequest("/data/upgrade/oceanbase-ce-x.x.x.x-xxx.el7.x86_64.rpm")
dag1, err := client.V1().UploadPkgWithRequest(req1)
req2 := client.V1().NewUploadPkgRequest("/data/upgrade/oceanbase-ce-libs-x.x.x.x-xxx.el7.x86_64.rpm")
dag2, err := client.V1().UploadPkgWithRequest(req2)
// Perform the pre-upgrade check.
req3 := client.V1().NewUpgradeObCheckRequest("x.x.x.x", "xxx.el7")
dag3, err := client.V1().UpgradeObCheckSyncWithRequest(req3)
// Upgrade OceanBase Database.
req4 := client.V1().NewUpgradeObRequest("x.x.x.x", "xxx.el7")
dag4, err := client.V1().UpgradeObSyncWithRequest(req4)
}
Upgrade an OceanBase cluster by running obshell commands
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 in 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;