首批通过分布式安全可靠测评,为关键业务系统打造
集群扩容
更新时间:2026-04-10 11:58:35
本文介绍如何通过 obshell-sdk-go 对集群进行扩容。
说明
建议先查看 obshell-sdk-go 快速上手 内容,了解如何使用 obshell-sdk-go。
注意事项
对集群进行扩容前,需注意以下要求:
请求的 client 对应的节点需在待扩容的集群中。
obshell 需正常运行。
待添加到集群中的扩容节点从未加入过任何集群。
示例代码
package main
import (
"github.com/oceanbase/obshell-sdk-go/services"
)
func main() {
// 创建 client 实例,节点地址为 '10.10.10.1',端口为 2886。
// 所在集群的 root@sys 密码为 '****'。
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "***")
if err != nil {
panic(err)
}
configs := map[string]string{
"datafile_size": "24G", "log_disk_size": "24G",
"cpu_count": "16", "memory_limit": "16G", "system_memory": "8G",
"enable_syslog_recycle": "true", "enable_syslog_wf": "true"}
// 向集群添加节点 '10.10.10.4:2886',OBServer 节点位于 zone3,配置为 configs。
req := client.V1().NewScaleOutRequest("10.10.10.4", 2886, "zone3", configs)
if _, err = client.V1().ScaleOutSyncWithRequest(req); err != nil {
panic(err)
}
}
package main
import (
"github.com/oceanbase/obshell-sdk-go/services"
)
func main() {
// 创建 client 实例,节点地址为 '10.10.10.1',端口为 2886。
// 所在集群的 root@sys 密码为 '****'。
client, err := services.NewClientWithPassword("10.10.10.1", 2886, "***")
if err != nil {
panic(err)
}
configs := map[string]string{
"datafile_size": "24G", "log_disk_size": "24G",
"cpu_count": "16", "memory_limit": "16G", "system_memory": "8G",
"enable_syslog_recycle": "true", "enable_syslog_wf": "true"}
// 向集群添加节点 '10.10.10.4:2886',OBServer 节点位于 zone3,配置为 configs。
req := client.V1().NewScaleOutRequest("10.10.10.4", 2886, "zone3", configs)
dag, err := client.V1().ScaleOutWithRequest(req)
if err != nil {
panic(err)
}
// 等待任务成功
if _, err = client.V1().WaitDagSucceed(dag.GenericID); err != nil {
panic(err)
}
}