You can upgrade OceanBase Shell (obshell) in the following ways:
Upgrade obshell by calling API operations
Upgrade obshell by running obshell commands
This topic describes how to upgrade obshell in 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.
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 obshell 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 package of the target version
Call the /api/v1/upgrade/package API operation in any obshell process to upload the package of the target version. The obshell package is 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/obshell-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_package("/data/upgrade/obshell-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/obshell-x.x.x.x-xxx.el7.x86_64.rpm") // Call /api/v1/upgrade/package.
dag, err := client.V1().UploadPkgWithRequest(req)
···
(Optional) Step 2: Call the upgrade check API operation
Call the /api/v1/agent/upgrade/check API operation in any obshell process to perform the upgrade check. The upgrade check verifies whether the package of the target version has 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 AgentUpgradeCheck. 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/agent/upgrade/check
For more information about how to call the corresponding API operation by using obshell-sdk-python, see Perform an agent upgrade check.
···
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
client.v1.upgrade_agent_check_sync("x.x.x.x", "xxx.el7") # Call /api/v1/agent/upgrade/check.
···
For more information about how to call the corresponding API operation by using obshell-sdk-go, see Perform an agent upgrade check.
···
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
req := client.V1().NewUpgradeAgentCheckRequest("x.x.x.x", "xxx.el7")
dag, err := client.V1().UpgradeAgentCheckSyncWithRequest(req) // Call /api/v1/agent/upgrade/check.
···
Step 3: Call the upgrade API operation
Call the /api/v1/agent/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 UpgradeAgent. 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/agent/upgrade
For more information about how to call the corresponding API operation by using obshell-sdk-python, see Upgrade agents.
···
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
client.v1.upgrade_agent_sync("x.x.x.x", "xxx.el7") # Call /api/v1/agent/upgrade.
···
For more information about how to call the corresponding API operation by using obshell-sdk-go, see Upgrade agents.
···
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
req := client.V1().NewUpgradeAgentRequest("x.x.x.x", "xxx.el7")
dag, err := client.V1().UpgradeAgentSyncWithRequest(req) // Call /api/v1/agent/upgrade.
···
Step 4: Verify the upgrade result
Log in to the sys tenant of OceanBase Database as the root user, and 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 package required for the upgrade.
client.v1.upload_pkg("/data/upgrade/obshell-x.x.x.x-xxx.el7.x86_64.rpm")
# Perform the pre-upgrade check.
client.v1.upgrade_agent_check_sync("x.x.x.x", "xxx.el7")
# Upgrade obshell.
client.v1.upgrade_agent_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 package to the cluster.
req1 := client.V1().NewUploadPkgRequest("/data/upgrade/obshell-x.x.x.x-xxx.el7.x86_64.rpm")
dag1, err := client.V1().UploadPkgWithRequest(req1)
// Perform the pre-upgrade check.
req2 := client.V1().NewUpgradeObCheckRequest("x.x.x.x", "xxx.el7")
dag2, err := client.V1().UpgradeObCheckSyncWithRequest(req2)
// Upgrade obshell.
req3 := client.V1().NewUpgradeObRequest("x.x.x.x", "xxx.el7")
dag3, err := client.V1().UpgradeObSyncWithRequest(req3)
}
Upgrade obshell 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 package of the target version. For more information, see obshell agent upgrade.
[admin@test001 ~]$ /home/admin/oceanbase/bin/obshell agent upgrade -d /data/upgrade/
Step 2: Verify the upgrade result
Log in to the sys tenant of OceanBase Database as the root user, and run the following command to query the obshell version:
obclient [oceanbase]> select version from ocs.all_agent;