Description
You can call this operation to perform a batch switchover between the primary and standby tenants.
Call description
Prerequisites
You have the permission to modify tenants.
For more information about the permissions, see Users and Permissions Overview.
You have passed the authentication for the OceanBase Cloud Platform (OCP) application service.
Request path
POST /api/v2/ob/clusters/{id}/tenants/switchover
Request parameters
Path parameters
| Parameter | Type | Required | Example value | Description |
|---|---|---|---|---|
| id | Integer | Yes | 1 | The ID of the cluster. |
Body parameters
| Parameter | Type | Required | Example value | Description |
|---|---|---|---|---|
| tenantParamList | SwitchoverObTenantParam | Yes | - | Each item represents a pair of primary and standby tenants for switchover. For more information, see Data structure of SwitchoverObTenantParam. |
Data structure of SwitchoverObTenantParam
| Parameter | Type | Required | Example value | Description |
|---|---|---|---|---|
| tenantId | Long | Yes | 1 | The ID of the primary tenant. |
| standbyTenantId | Long | Yes | 2 | The ID of the standby tenant. |
Response parameters
| Parameter | Type | Description |
|---|---|---|
| data | TaskInstance | The information about multiple asynchronous tasks. For more information, see Task return structure. |
| successful | Boolean | Indicates whether the request was successful. |
| timestamp | Datetime | The timestamp when the server completed the request. |
| duration | Integer | The amount of time taken by the server to process the request, in milliseconds. |
| status | Integer | The HTTP status code. |
| traceId | String | The trace ID of the request. This trace ID is used for troubleshooting. |
| server | String | The address of the application server that responded to the request. |
Examples
Sample request
POST /api/v2/ob/clusters/{id}/tenants/switchover
Body:
{
"tenantParamList": [
{
"tenantId": 1,
"standbyTenantId": 2,
}
]
}
Sample response
{
"data": {
"contents": [
{
"clusterId": 3000010,
"creator": "admin",
"executor": "xxx.xxx.xxx.xxx",
"id": 12022221,
"name": "Switchover ob tenant for network mode",
"operation": "EXECUTE",
"prohibitRollback": false,
"startTime": "2024-07-23T17:38:33.977+08:00",
"status": "RUNNING",
"subtasks": [
{
"description": "Update log restore source",
"downstreams": [
13025765
],
"id": 13025763,
"name": "Update log restore source",
"nodeType": "JAVA_TASK",
"operation": "EXECUTE",
"parallelIdx": 0,
"prohibitRollback": false,
"runTime": 1,
"seriesId": 7,
"status": "PENDING",
"timeout": 900,
"upstreams": [
13025759
]
},
{
"description": "Switchover standby tenant to primary",
"downstreams": [
13025759
],
"id": 13025760,
"name": "Switchover standby tenant to primary",
"nodeType": "JAVA_TASK",
"operation": "EXECUTE",
"parallelIdx": -1,
"prohibitRollback": true,
"runTime": 1,
"seriesId": 5,
"status": "PENDING",
"timeout": 1800,
"upstreams": [
13025758
]
},
{
"description": "Reset log restore source",
"downstreams": [
13025763
],
"id": 13025759,
"name": "Reset log restore source",
"nodeType": "JAVA_TASK",
"operation": "EXECUTE",
"parallelIdx": -1,
"prohibitRollback": false,
"runTime": 1,
"seriesId": 2,
"status": "PENDING",
"timeout": 1800,
"upstreams": [
13025760
]
},
{
"description": "Create standby tenant read only user",
"downstreams": [
13025757
],
"id": 13025762,
"name": "Create standby tenant read only user",
"nodeType": "JAVA_TASK",
"operation": "EXECUTE",
"parallelIdx": -1,
"prohibitRollback": false,
"runTime": 1,
"seriesId": 0,
"status": "PENDING",
"timeout": 1800,
"upstreams": [
13025761
]
},
{
"description": "Reset switchover tenant info",
"downstreams": [],
"id": 13025764,
"name": "Reset switchover tenant info",
"nodeType": "JAVA_TASK",
"operation": "EXECUTE",
"parallelIdx": -1,
"prohibitRollback": false,
"runTime": 1,
"seriesId": 3,
"status": "PENDING",
"timeout": 120,
"upstreams": [
13025766
]
},
{
"description": "Wait all relation tenants accessible",
"downstreams": [
13025758
],
"id": 13025757,
"name": "Wait all relation tenants accessible",
"nodeType": "JAVA_TASK",
"operation": "EXECUTE",
"parallelIdx": -1,
"prohibitRollback": false,
"runTime": 1,
"seriesId": 8,
"status": "PENDING",
"timeout": 3600,
"upstreams": [
13025762
]
},
{
"description": "Restart tenant service name if started",
"downstreams": [
13025766
],
"id": 13025765,
"name": "Restart tenant service name if started",
"nodeType": "JAVA_TASK",
"operation": "EXECUTE",
"parallelIdx": -1,
"prohibitRollback": false,
"runTime": 1,
"seriesId": 6,
"status": "PENDING",
"timeout": 600,
"upstreams": [
13025763
]
},
{
"description": "Update tenant role in meta",
"downstreams": [
13025764
],
"id": 13025766,
"name": "Update tenant role in meta",
"nodeType": "JAVA_TASK",
"operation": "EXECUTE",
"parallelIdx": -1,
"prohibitRollback": false,
"runTime": 1,
"seriesId": 9,
"status": "PENDING",
"timeout": 120,
"upstreams": [
13025765
]
},
{
"description": "Switch primary tenant to standby",
"downstreams": [
13025760
],
"id": 13025758,
"name": "Switch primary tenant to standby",
"nodeType": "JAVA_TASK",
"operation": "EXECUTE",
"parallelIdx": -1,
"prohibitRollback": false,
"runTime": 1,
"seriesId": 4,
"status": "PENDING",
"timeout": 1800,
"upstreams": [
13025757
]
},
{
"description": "Prepare switchover tenant",
"downstreams": [
13025762
],
"id": 13025761,
"name": "Prepare switchover tenant",
"nodeType": "JAVA_TASK",
"operation": "EXECUTE",
"parallelIdx": -1,
"prohibitRollback": false,
"runTime": 1,
"seriesId": 1,
"status": "READY",
"timeout": 60,
"upstreams": []
}
],
"taskDefinitionId": -1,
"tenantId": 2000025,
"type": "MANUAL"
}
]
},
"duration": 331,
"server": "3af57a8e6b",
"status": 200,
"successful": true,
"timestamp": "2024-07-23T17:38:34.021+08:00",
"traceId": "1d576119daa4860a"
}