This topic describes how to scale out an OceanBase cluster by using obshell-sdk-go.
Note
We recommend that you read Quick start for a better understanding of how to use obshell-sdk-go.
Considerations
Before scaling out an OceanBase cluster, take note of the following considerations:
Make sure that the node corresponding to the client instance that you use belongs to the cluster to be scaled out.
Make sure that OceanBase Shell (obshell) runs normally.
Make sure that the node to be added has not joined any cluster.
Sample code
package main
import (
"github.com/oceanbase/obshell-sdk-go/services"
)
func main() {
var err error // Handle errors in the production environment.
// Create a client instance, with the IP address of "10.10.10.1" and the port number of 2886.
// Enter the root@sys password "****" for the cluster.
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "***")
configs = {
"datafile_size": "24G", "log_disk_size": "24G",
"cpu_count": "16", "memory_limit": "16G", "system_memory": "8G",
"enable_syslog_recycle": "true", "enable_syslog_wf": "true"}
// Add the OBServer node with the IP address of '10.10.10.4' and the port number of 2886 to zone 3 of the cluster. The configurations are specified as configs.
req := client.V1().NewScaleOutRequest("10.10.10.4", 2886, "zone3", configs)
_, err = client.V1().ScaleOutSyncWithRequest(req)
}
package main
import (
"github.com/oceanbase/obshell-sdk-go/services"
)
func main() {
var err error // Handle errors in the production environment.
// Create a client instance, with the IP address of "10.10.10.1" and the port number of 2886.
// Enter the root@sys password "****" for the cluster.
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "***")
configs = {
"datafile_size": "24G", "log_disk_size": "24G",
"cpu_count": "16", "memory_limit": "16G", "system_memory": "8G",
"enable_syslog_recycle": "true", "enable_syslog_wf": "true"}
// Add the OBServer node with the IP address of '10.10.10.4' and the port number of 2886 to zone 3 of the cluster. The configurations are specified as configs.
req := client.V1().NewScaleOutRequest("10.10.10.4", 2886, "zone3", configs)
dag, err := client.V1().ScaleOutWithRequest(req)
// Wait for the task to complete.
_, err = client.V1().WaitDagSucceed(dag.GenericID)
}
References
For more information about the API operation, see AddNode.
For more information about how to call the API operation by using obshell-sdk-python, see Scale out a cluster.