本篇主要围绕设置rebalance任务的优先级展开描述。
1、首先需要设置参数gcluster_rebalancing_concurrent_count=0,将当前允许执行的rebalance任务数设置为零,意为阻止任务被执行;
2、然后利用rebalance instance/database/table等把当前需要数据重分布的表加入到系统表gclusterdb.rebalancing_status中;
查看rebalance状态
gbase> select index_name, status, percentage,priority from gclusterdb.rebalancing_status;
+------------+-----------+------------+------------+
| index_name | status | percentage | priority
+------------+-----------+------------+------------+
| test.t1 | STARTING | 0 | 5
| test.t2 | STARTING | 0 | 5
| test.t3 | STARTING | 0 | 5
| test.t4 | STARTING | 0 | 5+------------+-----------+------------+------------+
4 rows in set (Elapsed: 00:00:00.04)
3、调整每个表的 rebalance 任务的优先级;
update gclusterdb.rebalancing_status set priority = <priority_value> where index_name='database_name.table_name';
其中,priority_value为指定的优先级值,默认是5,范围为int数值类型范围;
举例:
gbase> update gclusterdb.rebalancing_status set priority = 6 where index_name='test.t3';
Query OK, 1 row affected
Rows matched: 1 Changed: 1 Warnings: 0
gbase> update gclusterdb.rebalancing_status set priority = 4 where index_name='test.t2';
Query OK, 1 row affected
Rows matched: 1 Changed: 1 Warnings: 0
gbase> update gclusterdb.rebalancing_status set priority = 0 whereindex_name='test.t1';
Query OK, 1 row affected
Rows matched: 1 Changed: 1 Warnings: 0
gbase> select index_name, status, priority from gclusterdb.rebalancing_status;
+------------+----------+----------+
| index_name | status | priority |
+------------+----------+----------+
| test.t1 | STARTING | 0 |
| test.t2 | STARTING | 4 |
| test.t3 | STARTING | 6 |
| test.t4 | STARTING | 5 |
+------------+----------+----------+
4 rows in set
4、设置gcluster_rebalancing_concurrent_count 为需要的并发数,然后rebalance任务就可以按照并发数和优先级顺序执行;
gbase> set global gcluster_rebalancing_concurrent_count = 1;
Query OK, 0 rows affected
gbase> select index_name, status, priority from gclusterdb.rebalancing_status;
+------------+----------+----------+
| index_name | status | priority |
+------------+----------+----------+
| test.t3 | STARTING | 6 |
| test.t2 | STARTING | 4 |
| test.t1 | RUNNING | 0 |
| test.t4 | STARTING | 5 |
+------------+----------+----------+
4 rows in set




