一、与rebalance相关的参数如下:
gbase> show variables like '%reba%';
+-------------------------------------------------------+-----------+
| Variable_name | Value |
+-------------------------------------------------------+-----------+
| _t_gcluster_rebalance_mirror_node | 0 |
| gcluster_load_rebalance_seed | 5 |
| gcluster_rebalancing_concurrent_count | 5 |
| gcluster_rebalancing_ignore_mirror | OFF |
| gcluster_rebalancing_immediate_recover_internal_table | OFF |
| gcluster_rebalancing_parallel_degree | 4 |
| gcluster_rebalancing_random_table_quick_mode | 1 |
| gcluster_rebalancing_step | 100000000 |
| gcluster_rebalancing_update_status_on_drop_table | ON |
| gcluster_shrink_to_rebalance | ON |
+-------------------------------------------------------+-----------+
10 rows in set (Elapsed: 00:00:00.00)
二、具体参数介绍
1、_t_gcluster_rebalance_mirror_node
控制是否启用节点离线后主本转镜像,默认值为0,取值范围为0、1,【1】代表打开,【0】代表关闭。
2、gcluster_load_rebalance_seed
加载任务负载均衡参数,默认值为5,取值范围为0-9223372036854775807。
3、gcluster_rebalancing_concurrent_count
控制并发执行重分布表的数量,默认值是5,取值范围为0-9223372036854775807,设置为0时表示阻止rebalance任务被执行。Rebalance定时查询,当running的个数小于设置的值时,从starting队列中根据优先级选任务(任务个数为参数设置的值-处于running状态的任务个数)执行rebalance,确保执行重分布的表数量为设定的值。
4、gcluster_rebalancing_ignore_mirror
控制rebalance时是否忽略镜像表,默认值是0,取值范围为0、1。【0】:不忽略,同时操作主表和镜像表;【1】代表忽略,不对镜像表操作。使用场景:仅用于节点替换场景。
5、gcluster_rebalancing_immediate_recover_internal_table
控制rebalance操作处于“Move data to inter table”状态时与gcrecover恢复rebalance中间表操作互斥还是并发。
默认值是0,【0】表示rebalance操作处于“Move data to inter table”状态时与gcrecover恢复rebalance中间表操作互斥;【1】表示rebalance操作处于“Move data to inter table”状态时与gcrecover恢复rebalance中间表操作可以并发,且需要在gc_recover.cnf设置data_recover_ignore_rebalancetable = 0一起配合使用才能生效。
6、gcluster_rebalancing_parallel_degree
控制rebalance表时在gnode上执行SIS时使用的gbase_parallel_degree值,默认值是4,取值范围为0-1024。
7、gcluster_rebalancing_random_table_quick_mode
对随机分布表执行rebalance操作时使用快速模式,默认值是1,取值范围为0、1,【1】代表开启,【0】代表关闭。
8、gcluster_rebalancing_step
指定rebalance操作时每一批重分布数据条数,默认值是100000000,取值范围为0-无上限,【0】代表rebalance操作不分批。gcluster_rebalancing_step参数值事实上是原表的每个分片每一批向中间表重分布的数据行数。参数取值越大,从原表向中间表重分布数据的速度越快,rebalance过程中暂停时等待的时间就越长。如果rebalance过程中基本不需要暂停任务,那么可以设置gcluster_rebalancing_step 为较大的值。如果rebalance过程中需要多次暂停任务,那么可以设置gcluster_rebalancing_step为较小值。
为了提高可用性,rebalancing过程分批执行。每一批次在单分片上执行的条数上限由参数gcluster_rebalancing_step(global变量)给定。每执行完一批更新一次状态。多分片下,直接搬移分片的方式,不分批。单分片重分布中,批次由rowid来切分。
gcluster_rebalancing_step预估方法:原表单个分片的行数/预计分批数。
9、gcluster_rebalancing_update_status_on_drop_table
控制在做rebalance时,如果有drop table是否更新gclusterdb.rebalancing_status表,默认值是1,取值范围为0、1,【0】代表不更新,【1】代表更新。
10、gcluster_shrink_to_rebalance
采用类似rebalance的方式实现shrink space功能,默认值是1,取值范围为0、1,【0】代表关闭,【1】代表开启。
1)打开gcluster_shrink_to_rebalance 参数时,可以提升shrink spaces性能,不阻塞insert select、load等append only类型的DML操作,支持对rebalance中的表的DQL;执行 alter table t1 shrink space full 或者 alter table t1 shrink space full block_reuse_ratio=命令时走rebalance逻辑,创建中间表,使用SIS把原表数据转存到中间表,删除原表,rename中间表为原表达到shrink功能目标。
2)本功能不会导致数据量在各分片间转移,属于n1分片的数据仍然属于n1,不会转移到n2。
3)本功能支持failover。在执行过程中发生failover,依据宕机时正在执行的步骤决定接管后是继续完成,还是会滚到初始状态。
4)参数gcluster_rebalancing_step、gcluster_rebalancing_parallel_degree、gcluster_rebalancing_immediate_recover_internal_table对本功能生效。
5)本功能执行时不更新gcluster_rebalancing_status系统表。