This topic describes how to take over a cluster by using the obshell-sdk-go package.
Note
Before you proceed, we recommend that you read the Quick Start topic to learn how to use the obshell-sdk-go package.
Considerations
Before you take over a cluster, make sure that the obshell package is decompressed and installed on each server. You can manually decompress and install the obshell package, or use the obshell-sdk-go package to decompress and install the obshell package. For more information about how to use the obshell-sdk-go package to decompress and install the obshell package, see Install obshell.
Sample code
func main() {
ips := []string{
"10.10.10.1",
"10.10.10.2",
"10.10.10.3",
}
workDir := "/data/ob" // The working directory of OceanBase Database
nodeConfigs := make([]util.NodeConfig, 0)
for _, ip := range ips {
nodeConfigs = append(nodeConfigs, util.NewNodeConfig(ip, workDir, 2886))
}
// Parameter description:
// password: the password of the root@sys user of the cluster to be taken over.
// configs: the node configurations.
if err := util.Takeover("pwd", nodeConfigs...); err != nil {
panic(err)
}
}
References
For more information about how to request an API by using the obshell-sdk-python package, see Take over a cluster.