Currently, obshell commands cannot be used to deploy ODP using. This topic describes how to deploy ODP by calling APIs and associate it with a three-replica OceanBase cluster.
Note
The procedures described in this topic do not depend on whether the OceanBase cluster to be associated with ODP is managed by obshell.
ODP deployment is supported starting from obshell V4.2.6.
Deployment mode
The following table lists the four servers used in this topic. obshell uses the default port 2886.
| Role | Server | Remarks |
|---|---|---|
| OBServer node | 10.10.10.1 | OceanBase database zone1 |
| OBServer node | 10.10.10.2 | OceanBase database zone2 |
| OBServer node | 10.10.10.3 | OceanBase database zone3 |
| ODP node | 10.10.10.4 | obshell is deployed on this node |
Procedure
Note
When you call an API using obshell commands, obshell performs security verification on the called API. Therefore, before calling an API, you must encrypt the request and configure the encrypted request headers (${request_headers}) and request body (${request_body}) in the curl command. For more information, see API hybrid encryption.
Step 1: Start obshell
Log in to the node where ODP is to be deployed and start obshell. For more information, see obshell agent start.
[admin@test004 ~]$ /home/admin/oceanbase/bin/obshell agent start --ip 10.10.10.4 -P 2886
Step 2: Set the node password
Call the /api/v1/agent/password API of obshell to set the node password.
For more information about how to call the corresponding API in the command line, see Set the node password.
[admin@test001 ~]$ curl -H "Content-Type: application/json" -H 'X-OCS-Header:${request_headers}' -X POST -d '${request_body}' http://10.10.10.4:2886/api/v1/agent/password
An example of the request body before encryption is as follows:
{
"password": "*****"
}
For more information about how to call the corresponding API through the obshell-sdk-python SDK, see Set the node password.
...
client = ClientSet("10.10.10.4", 2886)
client.v1.set_agent_password("*****")
# If the obshell node manages an OceanBase cluster, you must specify the root@sys password of the cluster when you create the client.
# client = ClientSet("10.10.10.4", 2886, PasswordAuth("***"))
...
Step 3: Create the proxyro@sys user
ODP needs to connect to the associated OceanBase cluster using the proxyro@sys user. If the target cluster does not have the proxyro user created under the sys tenant, you must manually create the proxyro user first.
If the target cluster is not managed by obshell, you can create the proxyro@sys user by referring to Create a user. If the target cluster is managed by obshell, you can use the /api/v1/tenant/{name}/user API of any obshell in the cluster to create the proxyro@sys user and grant the required privileges. Here is an example.
For more information about how to call the corresponding API interface in the command line, see Create a user. The sample command is as follows:
[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/sys/user
The request body before encryption is as follows:
{
"user_name": "proxyro",
"password": "*****",
"global_privileges": [
"CREATE",
"DELETE"
],
"db_privileges": [
{
"db_name": "oceanbase",
"privileges": [
"DROP"
]
}
],
"host_name": "%"
}
For more information about how to call the corresponding API method by using obshell-sdk-python, see Create a user. The sample code is as follows:
...
client = ClientSet("10.10.10.1", 2886, PasswordAuth("****"))
db_priv = {
"db_name": "oceanbase",
"privileges": ["SELECT"]
}
client.v1.create_user(user_name="proxyro", password="*****", db_privileges=[db_priv])
...
Step 4: Deploy ODP
You need to manually download the ODP installation package from OceanBase Download Center, copy it to the server where you want to deploy ODP, and decompress it to the working directory. Then, call the /api/v1/obproxy API of the target obshell to deploy ODP and associate it with the target cluster.
For more information about how to call the corresponding API in the command line, see Deploy ODP.
Note
After the API is called, an asynchronous O&M task is created. For more information about how to view the task progress, see Get task details. The ODP deployment is considered complete when the task is completed.
[admin@test001 ~]$ curl -H "Content-Type: application/json" -H 'X-OCS-Agent-Header:${request_headers}' -X POST -d '${request_body}' http://10.10.10.4:2886/api/v1/obproxy
The request body before encryption is as follows:
{
"home_path": "/data/obproxy",
"name": "myobproxy",
"sql_port": 2883,
"exporter_port": 2884,
"rpc_port": 2885,
"rs_list": "10.10.10.1:2881;10.10.10.2:2881;10.10.10.3:2881",
"proxyro_password": "********",
"obproxy_sys_password": "********",
"parameters": {
"server_tcp_keepidle": "5",
"enable_strict_kernel_release": "false"
}
}
For more information about how to request the corresponding API method using obshell-sdk-python, see Create ODP.
...
client = ClientSet("10.10.10.4", 2886, PasswordAuth(agent_password="****"))
client.v1.add_obproxy_sync(
home_path="/data/obproxy",
app_name="myobproxy",
rs_list="10.10.10.1:2881;10.10.10.2:2881:10.10.10.3:2881",
proxyro_password="********",
obproxy_sys_password="********",
)
...
Step 5: Verify whether ODP is deployed
You can run the following command to check whether an ODP process exists:
[admin@test001 ~]$ ps -ef | grep obproxy
You can also use the ODP to access the OceanBase cluster and verify whether you can connect to it.
obclient -h10.10.10.4 -uroot@sys#obdemo -P2883 -p -c -A
For more information about how to connect to an OceanBase cluster, see Connect to OceanBase Database.