This topic describes how to take over a cluster by using obshell-sdk-python.
Note
Before you proceed, we recommend that you read the Quick Start topic to learn how to use obshell-sdk-python.
Considerations
Before you take over a cluster, make sure that obshell is decompressed and installed on each server. You can manually decompress and install obshell, or use obshell-sdk-python to decompress and install obshell. For more information about how to use obshell-sdk-python to decompress and install obshell, see Install obshell.
Sample code
from obshell import takeover, NodeConfig
def init_nodes():
ips = [
"10.10.10.1",
"10.10.10.2",
"10.10.10.3",
]
work_dir = "/data/ob" # The working directory of OceanBase Database.
nodes_config = []
for _, ip in enumerate(ips):
node = NodeConfig(ip, work_dir)
nodes_config.append(node)
# Take over the cluster.
# Parameters:
# password: the password of the root@sys account of the cluster to be taken over.
# configs: the node configuration information.
takeover("pwd", nodes_config)
References
For more information about how to request an API by using obshell-sdk-go, see Take over a cluster.