首批通过分布式安全可靠测评,为关键业务系统打造
扩容与组件变更
更新时间:2025-09-09 17:04:35
本节介绍如何为 obd 管理的集群进行扩容、组件新增、组件删除操作。
前提条件
在开始之前,请确保您已满足以下条件:
操作涉及的集群已处于运行中状态。
环境中已安装 obd V2.5.0 或以上版本。
环境中已安装 OBClient。
集群扩容
您可为集群中包含的除 oblogproxy 和 obbinlog-ce 组件外的任意组件进行扩容,假设存在一个部署集群名(deploy name)为 test 的集群,本节以为该集群中 oceanbase-ce 组件扩容为例讲解如何操作。
创建待新增节点的配置文件。
[admin@test ~]$ vim scale_out.yaml此处以配置文件名为
scale_out.yaml为例,实际操作时您可自由定义文件名。配置文件内容如下:oceanbase-ce: servers: - name: server2 ip: 10.10.10.2 server2: mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. home_path: /home/admin/observer zone: zone2您仅可在新建的配置文件中配置新节点的信息,不允许在该配置文件中修改原集群配置中的
depends、global或其他server部分的配置。配置文件的格式及各个组件的配置项说明可参见 配置文件说明。执行扩容命令。
[admin@test ~]$ obd cluster scale_out test -c scale_out.yamlobd cluster scale_out命令的详细介绍可参见 集群命令组。命令执行成功返回如下信息:
Execute ` obd cluster display test ` to view the cluster status Trace ID: 3777cea4-dd1a-11ee-b38d-00163e0808cc If you want to view detailed obd logs, please run: obd display-trace 3777cea4-dd1a-11ee-b38d-00163e0808cc验证扩容结果。
复制命令行输出的
obd cluster display命令并执行,可查看集群的状态,命令输出示例如下:+----------------------------------------------+ | oceanbase-ce | +------------+---------+------+-------+--------+ | ip | version | port | zone | status | +------------+---------+------+-------+--------+ | 10.10.10.1 | 4.2.1.2 | 2881 | zone1 | ACTIVE | | 10.10.10.2 | 4.2.1.2 | 2881 | zone2 | ACTIVE | +------------+---------+------+-------+--------+ obclient -h10.10.10.1 -P2881 -uroot -p'********' -Doceanbase -A您可复制并执行上述输出的 obclient 命令登录 OceanBase 数据库,执行
select svr_ip,id,zone,status from __all_server;命令查看集群中的节点信息,命令输出示例如下:+------------+----+-------+--------+ | svr_ip | id | zone | status | +------------+----+-------+--------+ | 10.10.10.1 | 1 | zone1 | ACTIVE | | 10.10.10.2 | 2 | zone2 | ACTIVE | +------------+----+-------+--------+租户内资源扩容
OceanBase 集群扩容成功后,租户内的资源扩容详见 租户内资源扩容和缩容概述。
组件新增
您可向运行的集群中新增组件,目前支持通过 obd 部署的组件中,除 obbinlog-ce 外均支持新增。新增组件前需确认集群中不存在该组件。
此处假设存在一个部署集群名(deploy name)为 test 的集群,以向该集群中新增 obagent 组件为例讲解如何操作。
查看集群组件信息。
[admin@test ~]$ obd cluster edit-config test输出如下,集群中仅存在 oceanbase-ce 组件和 obproxy 组件。
##Only need to configure when remote login is required user: username: admin key_file: /home/admin/.ssh/id_rsa oceanbase-ce: servers: - name: server1 ip: 10.10.10.1 - name: server2 ip: 10.10.10.2 - name: server3 ip: 10.10.10.3 global: cluster_id: 1 mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started. rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started. home_path: /home/admin/observer ······ # 省略部分配置项 server1: zone: zone1 server2: zone: zone2 server3: zone: zone3 obproxy-ce: depends: - oceanbase-ce servers: - 10.10.10.1 global: listen_port: 2883 # External port. The default value is 2883. prometheus_listen_port: 2884 # The Prometheus port. The default value is 2884. rpc_listen_port: 2885 home_path: /home/admin/obproxy enable_cluster_checkout: false skip_proxy_sys_private_check: true enable_strict_kernel_release: false obproxy_sys_password: ******** # obproxy sys user password, can be empty. When a depends exists, obd gets this value from the oceanbase-ce of the depends.创建新增
obagent组件的配置文件。[admin@test ~]$ vim addtional_component.yaml此处以配置文件名为
addtional_component.yaml为例,实际操作时您可自由定义文件名。配置文件内容如下:obagent: depends: - oceanbase-ce servers: - name: server1 ip: 10.10.10.1 - name: server2 ip: 10.10.10.2 - name: server3 ip: 10.10.10.3 global: home_path: /home/admin/obagent配置文件的格式及各个组件的配置项说明可参见 配置文件说明 一文。
注意
obagent组件配置文件中的servers部分需和oceanbase-ce组件中servers部分配置保持完全一致,即使用相同的name和ip进行配置。执行新增组件命令。
[admin@test ~]$ obd cluster component add test -c addtional_component.yamlobd cluster component add命令的详细介绍可参见 集群命令组。命令执行成功返回如下信息:
+---------------------------------------------------------------+ | obagent | +------------+--------------------+--------------------+--------+ | ip | mgragent_http_port | monagent_http_port | status | +------------+--------------------+--------------------+--------+ | 10.10.10.1 | 8089 | 8088 | active | | 10.10.10.2 | 8089 | 8088 | active | | 10.10.10.3 | 8089 | 8088 | active | +------------+--------------------+--------------------+--------+ test running Trace ID: ae0122ea-ddd9-11ee-9b38-00163e0808cc If you want to view detailed obd logs, please run: obd display-trace ae0122ea-ddd9-11ee-9b38-00163e0808cc结果验证。
新增组件命令执行完成后,可执行
obd cluster display命令查看集群的状态,示例如下:[admin@test ~]$ obd cluster display test输出如下,集群中已存在
obagent组件信息。+----------------------------------------------+ | oceanbase-ce | +------------+---------+------+-------+--------+ | ip | version | port | zone | status | +------------+---------+------+-------+--------+ | 10.10.10.1 | 4.2.1.2 | 2881 | zone1 | ACTIVE | | 10.10.10.2 | 4.2.1.2 | 2881 | zone2 | ACTIVE | | 10.10.10.3 | 4.2.1.2 | 2881 | zone3 | ACTIVE | +------------+---------+------+-------+--------+ obclient -h10.10.10.1 -P2881 -uroot -p'********' -Doceanbase -A Connect to obproxy ok +----------------------------------------------+ | obproxy-ce | +------------+------+-----------------+--------+ | ip | port | prometheus_port | status | +------------+------+-----------------+--------+ | 10.10.10.1 | 2883 | 2884 | active | +------------+------+-----------------+--------+ obclient -h10.10.10.1 -P2883 -uroot@proxysys -p'********' -Doceanbase -A Connect to Obagent ok +---------------------------------------------------------------+ | obagent | +------------+--------------------+--------------------+--------+ | ip | mgragent_http_port | monagent_http_port | status | +------------+--------------------+--------------------+--------+ | 10.10.10.1 | 8089 | 8088 | active | | 10.10.10.2 | 8089 | 8088 | active | | 10.10.10.3 | 8089 | 8088 | active | +------------+--------------------+--------------------+--------+
组件删除
您可删除运行的集群中的组件,删除组件前需确认集群中存在该组件。
此处假设存在一个部署集群名(deploy name)为 test 的集群,以删除该集群中 obagent 和 obproxy-ce 组件为例讲解如何操作。
查看集群组件信息。
[admin@test ~]$ obd cluster edit-config test输出如下,集群中存在
oceanbase-ce组件、obproxy-ce组件和obagent组件。##Only need to configure when remote login is required user: username: admin key_file: /home/admin/.ssh/id_rsa oceanbase-ce: servers: - name: server1 ip: 10.10.10.1 - name: server2 ip: 10.10.10.2 - name: server3 ip: 10.10.10.3 global: cluster_id: 1 mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started. rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started. home_path: /home/admin/observer ······ # 省略部分配置项 server1: zone: zone1 server2: zone: zone2 server3: zone: zone3 obproxy-ce: depends: - oceanbase-ce servers: - 10.10.10.1 global: listen_port: 2883 # External port. The default value is 2883. prometheus_listen_port: 2884 # The Prometheus port. The default value is 2884. rpc_listen_port: 2885 home_path: /home/admin/obproxy enable_cluster_checkout: false skip_proxy_sys_private_check: true enable_strict_kernel_release: false obproxy_sys_password: ******** # obproxy sys user password, can be empty. When a depends exists, obd gets this value from the oceanbase-ce of the depends. obagent: depends: - oceanbase-ce servers: - name: server1 ip: 10.10.10.1 - name: server2 ip: 10.10.10.2 - name: server3 ip: 10.10.10.3 global: home_path: /home/admin/obagent执行删除组件命令。
[admin@test ~]$ obd cluster component del test obagent obproxy-ceobd cluster component del命令的详细介绍可参见 集群命令组。结果验证。
删除组件命令执行完成后,可执行
obd cluster display命令查看集群的状态。[admin@test ~]$ obd cluster display test输出如下,集群中已不存在 ODP 和 OBAgent 的组件信息。
+----------------------------------------------+ | oceanbase-ce | +------------+---------+------+-------+--------+ | ip | version | port | zone | status | +------------+---------+------+-------+--------+ | 10.10.10.1 | 4.2.1.2 | 2881 | zone1 | ACTIVE | | 10.10.10.2 | 4.2.1.2 | 2881 | zone2 | ACTIVE | | 10.10.10.3 | 4.2.1.2 | 2881 | zone3 | ACTIVE | +------------+---------+------+-------+--------+ obclient -h10.10.10.1 -P2881 -uroot -p'********' -Doceanbase -A
相关文档
本文中使用到的 obd 命令的详细介绍可参见 集群命令组。
本文操作涉及的配置文件及配置项的详细说明可参见 配置文件说明。
为集群中
oceanbase-ce组件扩容后,您还可以为租户或资源池扩容,详细操作可参见 《OceanBase 数据库》文档 租户资源水平扩缩容。使用 OBClient 登录 OceanBase 数据库的详细介绍可参见《OceanBase 数据库》文档 通过 OBClient 连接 OceanBase 租户。