跳转至

seabox reconstruct

seabox reconstruct

SeaboxMPP数据库重分布管理,包括扩容/缩容等

语法

``` bash seabox reconstruct [OPTIONS]

Options: -h, –help show this help, then exit

其中Commands可为以下命令之一:

``` bash
  clean   cleanup reconstruct schema.
  expand  seabox expand coordinator or executor.
  shrink  seabox shrink coordinator or executor.

描述

SeaboxMPP数据库重分布管理,支持集群扩缩容和清理扩缩容的辅助数据

  • 注意:如有注意事项,补充
选项

该命令支持选项说明如下:

Options

命令支持的选项

-h, --help
使用该选项时返回seabox reconstruct命令的帮助信息
Commands

seabox reconstruct支持的命令,包括以下:

clean
清理扩缩容的辅助数据
expand
SeaboxMPP集群coordinator或executor扩容
shrink
SeaboxMPP集群coordinator或executor缩容
注解

如有具体的使用限制及注意事项,在这部分列出。

注意: seabox reconstruct命令要求使用SeaboxMPP数据库集群安装用户seabox,或root用户,且需通过以下命令设置正确的环境变量:

source $SDHOME/seaboxmpp_path.sh

其中,$SDHOME为安装SeaboxMPP数据库服务的主目录。

示例

以下是seabox reconstruct --help的执行结果:

seabox reconstruct management.

Usage: 
  seabox reconstruct [OPTIONS]

Options:
  -h, --help  show this help, then exit

Commands:
  clean   cleanup reconstruct schema.
  expand  seabox expand coordinator or executor.
  shrink  seabox shrink coordinator or executor.
扩容示例

以下是扩容集群executor的示例

当前集群中executor信息如下:

[seabox@sy1 ~]$ seabox status -a -m executor
executor:
+------+---------+------+----------+------+--------+------+---------+-------+----------------+---------------------------------------------+
| dbid | content | role | pre_role | mode | status | host | address |  port | preferred_host | datadir                                     |
+------+---------+------+----------+------+--------+------+---------+-------+----------------+---------------------------------------------+
|    2 | 0       | p    | p        | s    | normal | sy1  | sy1     | 33712 | sy1            | /home/seabox/mpp/data/executordd/primary/0  |
|    3 | 1       | p    | p        | s    | normal | sy1  | sy1     | 33713 | sy1            | /home/seabox/mpp/data/executordd/primary/1  |
|    4 | 2       | p    | p        | s    | normal | sy1  | sy1     | 33714 | sy1            | /home/seabox/mpp/data/executordd/primary/2  |
|    5 | 3       | p    | p        | s    | normal | sy2  | sy2     | 33712 | sy2            | /home/seabox/mpp/data/executordd/primary/3  |
|    6 | 4       | p    | p        | s    | normal | sy2  | sy2     | 33713 | sy2            | /home/seabox/mpp/data/executordd/primary/4  |
|    7 | 5       | p    | p        | s    | normal | sy2  | sy2     | 33714 | sy2            | /home/seabox/mpp/data/executordd/primary/5  |
|    8 | 0       | a    | a        | s    | normal | sy2  | sy2     | 33722 | sy2            | /home/seabox/mpp/data/executordd/mirror/0/0 |
|    9 | 1       | a    | a        | s    | normal | sy2  | sy2     | 33723 | sy2            | /home/seabox/mpp/data/executordd/mirror/0/1 |
|   10 | 2       | a    | a        | s    | normal | sy2  | sy2     | 33724 | sy2            | /home/seabox/mpp/data/executordd/mirror/0/2 |
|   11 | 3       | a    | a        | s    | normal | sy1  | sy1     | 33722 | sy1            | /home/seabox/mpp/data/executordd/mirror/0/3 |
|   12 | 4       | a    | a        | s    | normal | sy1  | sy1     | 33723 | sy1            | /home/seabox/mpp/data/executordd/mirror/0/4 |
|   13 | 5       | a    | a        | s    | normal | sy1  | sy1     | 33724 | sy1            | /home/seabox/mpp/data/executordd/mirror/0/5 |
+------+---------+------+----------+------+--------+------+---------+-------+----------------+---------------------------------------------+

计划增加两个executor,准备expand_input_simple文件,写入如下内容:

[seabox@sy1 ~]$ cat expand_input_simple 
sy1|sy1|9935|/home/seabox/mpp/data/executordd/primary/6|14|6|p
sy1|sy1|9936|/home/seabox/mpp/data/executordd/mirror/0/6|15|6|m
这个文件由多行组成,每一行代表一个扩展的executor。每一行中由多个‘|’进行分隔,分别由新增executor的下列元素组成:hostname;host的地址(同host);端口;数据目录;dbid;contentid;role。其中,dbid要与集群中已有的executor的最大dbid连续,并且不能重复。role包括‘p’或者‘m’。

根据上面executor的状态,看到当前集群中最大的dbid为13,contentid最大为5,因此为计划增加的一对executor指定dbid 14和15,contentid为6,角色为p和m,数据目录也根据规律进行指定

接下来执行扩容命令:

[seabox@sy1 ~]$ seabox reconstruct expand --input expand_input_simple 
2022-07-07 08:08:23 UTC [19861] scexpand sy1:seabox WARNING: thread to kill set to 0
2022-07-07 08:08:23 UTC [19861] scexpand sy1:seabox WARNING: seabox lock /seabox/locks/scexpand start
2022-07-07 08:08:23 UTC [19861] scexpand sy1:seabox INFO: begin create lease
2022-07-07 08:08:23 UTC [19861] scexpand sy1:seabox INFO: create lease ok
2022-07-07 08:08:23 UTC [19861] scexpand sy1:seabox INFO: lock begin refresh lease 6604953088030486722
2022-07-07 08:08:23 UTC [19861] scexpand sy1:seabox INFO: lock status change from try_lock to have_lease

......

2022-07-07 08:09:46 UTC [21817] scexpand sy1:seabox INFO: shutting down scexpand...
2022-07-07 08:09:46 UTC [21817] scexpand sy1:seabox WARNING: seabox lock begin to stop
2022-07-07 08:09:46 UTC [21817] scexpand sy1:seabox INFO: scdcs lock stop check
2022-07-07 08:09:46 UTC [21817] scexpand sy1:seabox INFO: lock stop check
2022-07-07 08:09:46 UTC [21817] scexpand sy1:seabox INFO: scdcs lock stop refresh
2022-07-07 08:09:46 UTC [21817] scexpand sy1:seabox INFO: lock stop refresh lease 6604953088030488980
2022-07-07 08:09:46 UTC [21817] scexpand sy1:seabox WARNING: seabox lock release lock

查看executor状态,发现扩容成功

[seabox@sy1 ~]$ seabox status -a -m executor
executor:
+------+---------+------+----------+------+--------+------+---------+-------+----------------+---------------------------------------------+
| dbid | content | role | pre_role | mode | status | host | address |  port | preferred_host | datadir                                     |
+------+---------+------+----------+------+--------+------+---------+-------+----------------+---------------------------------------------+
|    2 | 0       | p    | p        | s    | normal | sy1  | sy1     | 33712 | sy1            | /home/seabox/mpp/data/executordd/primary/0  |
|    3 | 1       | p    | p        | s    | normal | sy1  | sy1     | 33713 | sy1            | /home/seabox/mpp/data/executordd/primary/1  |
|    4 | 2       | p    | p        | s    | normal | sy1  | sy1     | 33714 | sy1            | /home/seabox/mpp/data/executordd/primary/2  |
|    5 | 3       | p    | p        | s    | normal | sy2  | sy2     | 33712 | sy2            | /home/seabox/mpp/data/executordd/primary/3  |
|    6 | 4       | p    | p        | s    | normal | sy2  | sy2     | 33713 | sy2            | /home/seabox/mpp/data/executordd/primary/4  |
|    7 | 5       | p    | p        | s    | normal | sy2  | sy2     | 33714 | sy2            | /home/seabox/mpp/data/executordd/primary/5  |
|    8 | 0       | a    | a        | s    | normal | sy2  | sy2     | 33722 | sy2            | /home/seabox/mpp/data/executordd/mirror/0/0 |
|    9 | 1       | a    | a        | s    | normal | sy2  | sy2     | 33723 | sy2            | /home/seabox/mpp/data/executordd/mirror/0/1 |
|   10 | 2       | a    | a        | s    | normal | sy2  | sy2     | 33724 | sy2            | /home/seabox/mpp/data/executordd/mirror/0/2 |
|   11 | 3       | a    | a        | s    | normal | sy1  | sy1     | 33722 | sy1            | /home/seabox/mpp/data/executordd/mirror/0/3 |
|   12 | 4       | a    | a        | s    | normal | sy1  | sy1     | 33723 | sy1            | /home/seabox/mpp/data/executordd/mirror/0/4 |
|   13 | 5       | a    | a        | s    | normal | sy1  | sy1     | 33724 | sy1            | /home/seabox/mpp/data/executordd/mirror/0/5 |
|   14 | 6       | p    | p        | s    | normal | sy1  | sy1     |  9935 | sy1            | /home/seabox/mpp/data/executordd/primary/6  |
|   15 | 6       | m    | m        | s    | normal | sy1  | sy1     |  9936 | sy1            | /home/seabox/mpp/data/executordd/mirror/0/6 |
+------+---------+------+----------+------+--------+------+---------+-------+----------------+---------------------------------------------+
缩容示例

以下是缩容集群executor的示例

接下来执行缩容命令,保留6对executor,将扩的14和15再缩掉:

[seabox@sy1 ~]$ seabox reconstruct shrink executor --count=6
2022-07-07 09:15:49 UTC [42661] scexpand sy1:seabox WARNING: thread to kill set to 0
2022-07-07 09:15:49 UTC [42661] scexpand sy1:seabox WARNING: seabox lock /seabox/locks/scexpand start
2022-07-07 09:15:49 UTC [42661] scexpand sy1:seabox INFO: begin create lease
2022-07-07 09:15:49 UTC [42661] scexpand sy1:seabox INFO: create lease ok
2022-07-07 09:15:49 UTC [42661] scexpand sy1:seabox INFO: lock begin refresh lease 6604953088030569111
2022-07-07 09:15:49 UTC [42661] scexpand sy1:seabox INFO: lock status change from try_lock to have_lease

......

2022-07-07 09:16:01 UTC [43054] scexpand sy1:seabox INFO: shutting down scexpand...
2022-07-07 09:16:01 UTC [43054] scexpand sy1:seabox WARNING: seabox lock begin to stop
2022-07-07 09:16:01 UTC [43054] scexpand sy1:seabox INFO: scdcs lock stop check
2022-07-07 09:16:01 UTC [43054] scexpand sy1:seabox INFO: lock stop check
2022-07-07 09:16:01 UTC [43054] scexpand sy1:seabox INFO: scdcs lock stop refresh
2022-07-07 09:16:01 UTC [43054] scexpand sy1:seabox INFO: lock stop refresh lease 6604953088030569400
2022-07-07 09:16:01 UTC [43054] scexpand sy1:seabox WARNING: seabox lock release lock

查看executor状态,发现缩容成功

[seabox@sy1 ~]$ seabox status -a -m executor
executor:
+------+---------+------+----------+------+--------+------+---------+-------+----------------+---------------------------------------------+
| dbid | content | role | pre_role | mode | status | host | address |  port | preferred_host | datadir                                     |
+------+---------+------+----------+------+--------+------+---------+-------+----------------+---------------------------------------------+
|    2 | 0       | p    | p        | s    | normal | sy1  | sy1     | 33712 | sy1            | /home/seabox/mpp/data/executordd/primary/0  |
|    3 | 1       | p    | p        | s    | normal | sy1  | sy1     | 33713 | sy1            | /home/seabox/mpp/data/executordd/primary/1  |
|    4 | 2       | p    | p        | s    | normal | sy1  | sy1     | 33714 | sy1            | /home/seabox/mpp/data/executordd/primary/2  |
|    5 | 3       | p    | p        | s    | normal | sy2  | sy2     | 33712 | sy2            | /home/seabox/mpp/data/executordd/primary/3  |
|    6 | 4       | p    | p        | s    | normal | sy2  | sy2     | 33713 | sy2            | /home/seabox/mpp/data/executordd/primary/4  |
|    7 | 5       | p    | p        | s    | normal | sy2  | sy2     | 33714 | sy2            | /home/seabox/mpp/data/executordd/primary/5  |
|    8 | 0       | a    | a        | s    | normal | sy2  | sy2     | 33722 | sy2            | /home/seabox/mpp/data/executordd/mirror/0/0 |
|    9 | 1       | a    | a        | s    | normal | sy2  | sy2     | 33723 | sy2            | /home/seabox/mpp/data/executordd/mirror/0/1 |
|   10 | 2       | a    | a        | s    | normal | sy2  | sy2     | 33724 | sy2            | /home/seabox/mpp/data/executordd/mirror/0/2 |
|   11 | 3       | a    | a        | s    | normal | sy1  | sy1     | 33722 | sy1            | /home/seabox/mpp/data/executordd/mirror/0/3 |
|   12 | 4       | a    | a        | s    | normal | sy1  | sy1     | 33723 | sy1            | /home/seabox/mpp/data/executordd/mirror/0/4 |
|   13 | 5       | a    | a        | s    | normal | sy1  | sy1     | 33724 | sy1            | /home/seabox/mpp/data/executordd/mirror/0/5 |
+------+---------+------+----------+------+--------+------+---------+-------+----------------+---------------------------------------------+
相关命令