obshell supports two methods for initiating tenant-level restore in OceanBase Database:
Calling APIs
Using obshell commands
This topic describes how to initiate tenant-level restore using obshell commands in a three-node OceanBase cluster.
Prerequisites
You have taken over the OceanBase cluster by using obshell. For more information, see Take over a non-obshell-deployed cluster.
All OBServer nodes and obshell are running.
Deployment mode
The following table describes the three servers used in this topic (obshell uses the default port 2886):
| Role | IP address | Remarks |
|---|---|---|
| OBServer node | 10.10.10.1 | Zone 1 of OceanBase Database |
| OBServer node | 10.10.10.2 | Zone 2 of OceanBase Database |
| OBServer node | 10.10.10.3 | Zone 3 of OceanBase Database |
Initiate restore by calling APIs
Note
obshell performs security verification on the called APIs. Therefore, you must first encrypt the request and configure the encrypted request header (${request_headers}) and request body (${request_body}) in the curl command before each API call. For more information, see API hybrid encryption.
Step 1: Initiate tenant-level restore
You can call the /api/v1/tenant/restore API of any obshell to initiate tenant-level restore.
For more information about how to call this API in the CLI, see Initiate tenant restore. This API creates an asynchronous task. You can call the Get task details API to query the task progress. Wait for the task to complete, and then the restore is completed.
[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/tenant/restore
The request body before encryption is as follows:
{
"data_backup_uri": "file:///data/backup/data",
"restore_tenant_name": "tenant1",
"zone_list":
[
{
"name": "zone1",
"unit_config_name": "unit1",
"unit_num": 1
}
],
"archive_log_uri": "file:///data/backup/archive"
}
For more information about how to call this API by using obshell-sdk-python, see Initiate tenant restore.
...
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
client.v1.post_tenant_restore_sync(
data_backup_uri="file:///data/backup/data",
tenant_name="tenant1",
zone_list=[
tenant.ZoneParam("zone1", "unit1",1),
],
archive_log_uri="file:///data/backup/archive",
)
...
For more information about how to call this API by using obshell-sdk-go, see Initiate tenant restore.
...
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
request := client.V1().NewRestoreRequest(
"tenant1",
"file:///data/backup/data",
[]v1.ZoneParam{{
Name: "zone1",
UnitConfigName: "unit1",
UnitNum: 1,
}})
request.SetArchiveLogUri("file:///data/backup/archive")
dag, err := client.V1().RestoreWithRequest(request)
...
Step 2: Query the tenant-level restore task
You can call the /api/v1/tenant/:name/restore/overview API of any obshell to query the tenant-level restore task.
For more information about how to call this API in the CLI, see View tenant restore.
[admin@test001 ~]$ curl
-H "Content-Type: application/json"
-X GET
http://10.10.10.1:2886/api/v1/tenant/tenant1/restore/overview
For more information about how to call this API by using obshell-sdk-python, see View tenant restore.
...
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
client.v1.get_tenant_restore_overview("tenant1")
...
For more information about how to call this API by using obshell-sdk-go, see View tenant restore.
...
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****")
res, err := client.V1().GetTenantRestoreOverview("tenant1")
...
Initiate restore by using obshell commands
Step 1: Execute the restore command
You can execute the obshell tenant restore command on any node to initiate tenant restore. For more information about this command, see obshell tenant commands.
[admin@test001 ~]$ /home/admin/oceanbase/bin/obshell tenant restore tenant1 -d 'file:///data/backup/data' -u unit1 -z zone1 -a 'file:///data/backup/archive'
Step 2: Query the restore information
For more information about this command, see obshell restore commands.
[admin@test001 ~]$ /home/admin/oceanbase/bin/obshell restore show tenant1