GBase 8a分布策略distribution的不同pattern样例

本文介绍GBase 8a的分布策略distribution的不同方案pattern的结果样例,方便用户创建高可用程度更高的集群。

环境

我们准备了9个IP,分成3组(rack),代表3个机柜,看每种策略的主备策略的结果。

gcChangeInfo.xml

<?xml version="1.0" encoding="utf-8"?>
<servers>
    <rack>
        <node ip="10.0.2.103"/>
        <node ip="10.0.2.104"/>
        <node ip="10.0.2.105"/>
    </rack>
    <rack>
        <node ip="10.0.2.106"/>
        <node ip="10.0.2.107"/>
        <node ip="10.0.2.108"/>
    </rack>
    <rack>
        <node ip="10.0.2.109"/>
        <node ip="10.0.2.110"/>
        <node ip="10.0.2.111"/>
    </rack>
</servers>

parttern 1负载均衡默认

该模式,是将第1个副本,放到下一个rack的下一个位置,副本2,则放在上一个rack的上一个位置。

1个副本的1+1模式

副本位置是下一个rack的下一个位置,比如

  • rack1的节点1,副本1放到rack2的节点2
  • rack1的节点2,副本1放到rack2的节点3
  • 同理
  • rack2的节点3,副本1放到rack3的节点4

如果节点超过了末尾,则转到开头,比如rack之后3个节点,那么

  • rack1的节点3,副本1放到rack2的节点1(回到开头)

实际样例

GBase 8a分布策略distribution的不同pattern样例 pattern 1 ,1副本
GBase 8a分布策略distribution的不同pattern样例 pattern 1 ,1副本
[gbase@gbase_rh7_003 gcinstall]$ gcadmin distribution gcChangeInfo.xml p 1 d 1 pattern 1
gcadmin generate distribution ...

NOTE: node [10.0.2.103] is coordinator node, it shall be data node too
gcadmin generate distribution successful

[gbase@gbase_rh7_003 gcinstall]$ gcadmin showdistribution

                                 Distribution ID: 1 | State: new | Total segment num: 9

             Primary Segment Node IP                   Segment ID                 Duplicate Segment node IP
========================================================================================================================
|                   10.0.2.103                   |         1          |                   10.0.2.107                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.104                   |         2          |                   10.0.2.108                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.105                   |         3          |                   10.0.2.106                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.106                   |         4          |                   10.0.2.110                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.107                   |         5          |                   10.0.2.111                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.108                   |         6          |                   10.0.2.109                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.109                   |         7          |                   10.0.2.104                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.110                   |         8          |                   10.0.2.105                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.111                   |         9          |                   10.0.2.103                   |
========================================================================================================================

2个副本的1+2模式

副本2,则放在上一个rack的上一个位置,如果小于第一个,则返回末尾一个。

GBase 8a分布策略distribution的不同pattern样例 pattern 1 ,2副本
GBase 8a分布策略distribution的不同pattern样例 pattern 1 ,2副本
[gbase@gbase_rh7_003 gcinstall]$ gcadmin distribution gcChangeInfo.xml p 1 d 2 pattern 1
gcadmin generate distribution ...

gcadmin generate distribution successful

[gbase@gbase_rh7_003 gcinstall]$ gcadmin showdistribution

                                 Distribution ID: 2 | State: new | Total segment num: 9

             Primary Segment Node IP                   Segment ID                 Duplicate Segment node IP
========================================================================================================================
|                   10.0.2.103                   |         1          |                   10.0.2.107                   |
|                                                |                    |                   10.0.2.111                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.104                   |         2          |                   10.0.2.108                   |
|                                                |                    |                   10.0.2.109                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.105                   |         3          |                   10.0.2.106                   |
|                                                |                    |                   10.0.2.110                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.106                   |         4          |                   10.0.2.110                   |
|                                                |                    |                   10.0.2.105                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.107                   |         5          |                   10.0.2.111                   |
|                                                |                    |                   10.0.2.103                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.108                   |         6          |                   10.0.2.109                   |
|                                                |                    |                   10.0.2.104                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.109                   |         7          |                   10.0.2.104                   |
|                                                |                    |                   10.0.2.108                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.110                   |         8          |                   10.0.2.105                   |
|                                                |                    |                   10.0.2.106                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.111                   |         9          |                   10.0.2.103                   |
|                                                |                    |                   10.0.2.107                   |
========================================================================================================================

如果只有2个rack,采用了2副本

副本1不变,下一个rack的下一个位置,副本2则变成了本rack的下下一个位置,也就是位置+2。如下是2个rack的样例。

gcChangeInfo_rack2.xml

[gbase@gbase_rh7_003 gcinstall]$ cat gcChangeInfo_rack2.xml
<?xml version="1.0" encoding="utf-8"?>
<servers>
    <rack>
        <node ip="10.0.2.103"/>
        <node ip="10.0.2.104"/>
        <node ip="10.0.2.105"/>
        <node ip="10.0.2.106"/>
    </rack>
    <rack>
        <node ip="10.0.2.107"/>
        <node ip="10.0.2.108"/>
        <node ip="10.0.2.109"/>
        <node ip="10.0.2.110"/>
    </rack>

结果样例

[gbase@gbase_rh7_003 gcinstall]$ gcadmin distribution gcChangeInfo_rack2.xml p 1 d 2 pattern 1
gcadmin generate distribution ...

gcadmin generate distribution successful

[gbase@gbase_rh7_003 gcinstall]$ gcadmin showdistribution

                                 Distribution ID: 4 | State: new | Total segment num: 8

             Primary Segment Node IP                   Segment ID                 Duplicate Segment node IP
========================================================================================================================
|                   10.0.2.103                   |         1          |                   10.0.2.108                   |
|                                                |                    |                   10.0.2.105                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.104                   |         2          |                   10.0.2.109                   |
|                                                |                    |                   10.0.2.106                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.105                   |         3          |                   10.0.2.110                   |
|                                                |                    |                   10.0.2.103                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.106                   |         4          |                   10.0.2.107                   |
|                                                |                    |                   10.0.2.104                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.107                   |         5          |                   10.0.2.104                   |
|                                                |                    |                   10.0.2.109                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.108                   |         6          |                   10.0.2.105                   |
|                                                |                    |                   10.0.2.110                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.109                   |         7          |                   10.0.2.106                   |
|                                                |                    |                   10.0.2.107                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.110                   |         8          |                   10.0.2.103                   |
|                                                |                    |                   10.0.2.108                   |

pattern 2 高可用模式

该模式忽视rack,按照出现先后顺序,副本1在下一个节点,副本2在上一个节点。如果超过末尾,则返回第一个,如果低于第一个,则返回末尾。

输出样例

[gbase@gbase_rh7_003 gcinstall]$ gcadmin distribution gcChangeInfo.xml p 1 d 2 pattern 2
gcadmin generate distribution ...

NOTE: node [10.0.2.103] is coordinator node, it shall be data node too
gcadmin generate distribution successful

[gbase@gbase_rh7_003 gcinstall]$ gcadmin showdistribution

                                 Distribution ID: 3 | State: new | Total segment num: 9

             Primary Segment Node IP                   Segment ID                 Duplicate Segment node IP
========================================================================================================================
|                   10.0.2.103                   |         1          |                   10.0.2.104                   |
|                                                |                    |                   10.0.2.111                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.104                   |         2          |                   10.0.2.105                   |
|                                                |                    |                   10.0.2.103                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.105                   |         3          |                   10.0.2.106                   |
|                                                |                    |                   10.0.2.104                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.106                   |         4          |                   10.0.2.107                   |
|                                                |                    |                   10.0.2.105                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.107                   |         5          |                   10.0.2.108                   |
|                                                |                    |                   10.0.2.106                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.108                   |         6          |                   10.0.2.109                   |
|                                                |                    |                   10.0.2.107                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.109                   |         7          |                   10.0.2.110                   |
|                                                |                    |                   10.0.2.108                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.110                   |         8          |                   10.0.2.111                   |
|                                                |                    |                   10.0.2.109                   |
------------------------------------------------------------------------------------------------------------------------
|                   10.0.2.111                   |         9          |                   10.0.2.103                   |
|                                                |                    |                   10.0.2.110                   |
========================================================================================================================

总结

为了最大限度的高可用,建议不小于3个机柜,避免某个机柜整体出问题,导致集群整体不可用的情况出现。

发表评论

您的电子邮箱地址不会被公开。