背景:
我目前有一个基于复制的工作HA设置,主站如下:
ha-策略/复制/主......
和奴隶:
ha-策略/复制/从属....
具有适当的集群连接设置..(我使用静态连接器)
我的理解是,这代表单个实时/备份对。
在网络隔离文档中,仲裁投票和备份投票部分均指出所需的最小活动/备份对数量为 3。
(请注意,我不希望使用新的实验性可插入仲裁投票功能。)
我的问题是:
3 个这样的实时/备份对的配置是什么样的? 是通过使用组名称和适当的集群连接吗?我不知道什么去了哪里,所以我们有 3 对互相了解的人。 我在源代码的examples文件夹中找不到示例。
最后,从部署拓扑的角度来看,拥有 3 个服务器,s1,s2,s3,主/从部署如下,为 HA 提供脑裂避免:
s1:主站1,从站3
s2:主站2,从站1
s3:主机3,从机2
您不一定需要做任何特别的事情来获得 3 个 HA 经纪人对。您可以将第一对的操作再重复两次。一旦您启动所有六个经纪人,他们将自动配对成 3 对。
但是,大多数人想要更具确定性的东西,因此他们通过配置将代理对“分组”在一起。
这两个选项都在文档中讨论,其中指出:
在集群中,备份服务器可以通过两种方式找到要复制的活动服务器,它们是:
。您可以指定备份服务器可以连接的一组实时服务器。这是通过在specifying a node group
或group-name
的master
元素中配置slave
来完成的。备份服务器只会连接到共享相同节点组名称的实时服务器broker.xml
。如果未配置connecting to any live
允许备份服务器连接到任何实时服务器,这将是行为group-name
发布具体示例以供进一步审查和编辑直至正确。请参阅其他答案以获取更多上下文。
这是尝试将原始问题中的 Justins 响应应用到实际配置中。
此配置尝试创建 3 个 HA 代理对 - 3 个主站,每个主站都有自己的从站。 3个主人互相认识,但主人奴隶不认识。
Master-1 (tcp://master1:61616)
<cluster-connections>
<cluster-connection name="cluster">
<connector-ref>connector-self</connector-ref>
<static-connectors>
<connector-ref>connector-slave1</connector-ref>
<connector-ref>connector-master2</connector-ref>
<connector-ref>connector-master3</connector-ref>
</static-connectors>
</cluster-connection>
</cluster-connections>
<connectors>
<connector name="connector-self">tcp://master1:61616</connector>
<connector name="connector-slave1">tcp://slave1:61626</connector>
<connector name="connector-master2">tcp://master2:61617</connector>
<connector name="connector-master3">tcp://master3:61618</connector>
</connectors>
<ha-policy>
<replication>
<master>
<!--we need this for auto failback-->
<check-for-live-server>true</check-for-live-server>
<group-name>master-1-pair</group-name>
</master>
</replication>
</ha-policy>
从机-1 (tcp://slave1:61626)
<cluster-connections>
<cluster-connection name="cluster">
<connector-ref>connector-self</connector-ref>
<static-connectors>
<connector-ref>connector-master1</connector-ref>
</static-connectors>
</cluster-connection>
</cluster-connections>
<connectors>
<connector name="connector-self">tcp://slave1:61626</connector>
<connector name="connector-master1">tcp://master1:61616</connector>
</connectors>
<ha-policy>
<replication>
<slave>
<allow-failback>true</allow-failback>
<group-name>master-1-pair</group-name>
</slave>
</replication>
</ha-policy>
Master-2 (tcp://master2:61617)
<cluster-connections>
<cluster-connection name="cluster">
<connector-ref>connector-self</connector-ref>
<static-connectors>
<connector-ref>connector-slave2</connector-ref>
<connector-ref>connector-master1</connector-ref>
<connector-ref>connector-master3</connector-ref>
</static-connectors>
</cluster-connection>
</cluster-connections>
<connectors>
<connector name="connector-self">tcp://master2:61617</connector>
<connector name="connector-slave2">tcp://slave2:61627</connector>
<connector name="connector-master1">tcp://master1:61616</connector>
<connector name="connector-master3">tcp://master3:61618</connector>
</connectors>
<ha-policy>
<replication>
<master>
<!--we need this for auto failback-->
<check-for-live-server>true</check-for-live-server>
<group-name>master-2-pair</group-name>
</master>
</replication>
</ha-policy>
Slave-2(tcp://slave2:61627)
<cluster-connections>
<cluster-connection name="cluster">
<connector-ref>connector-self</connector-ref>
<static-connectors>
<connector-ref>connector-master2</connector-ref>
</static-connectors>
</cluster-connection>
</cluster-connections>
<connectors>
<connector name="connector-self">tcp://slave2:61627</connector>
<connector name="connector-master2">tcp://master2:61617</connector>
</connectors>
<ha-policy>
<replication>
<slave>
<allow-failback>true</allow-failback>
<group-name>master-2-pair</group-name>
</slave>
</replication>
</ha-policy>
Master-3 (tcp://master3:61618)
<cluster-connections>
<cluster-connection name="cluster">
<connector-ref>connector-self</connector-ref>
<static-connectors>
<connector-ref>connector-slave3</connector-ref>
<connector-ref>connector-master1</connector-ref>
<connector-ref>connector-master2</connector-ref>
</static-connectors>
</cluster-connection>
</cluster-connections>
<connectors>
<connector name="connector-self">tcp://master3:61618</connector>
<connector name="connector-slave3">tcp://slave3:61628</connector>
<connector name="connector-master1">tcp://master1:61616</connector>
<connector name="connector-master2">tcp://master2:61617</connector>
</connectors>
<ha-policy>
<replication>
<master>
<!--we need this for auto failback-->
<check-for-live-server>true</check-for-live-server>
<group-name>master-3-pair</group-name>
</master>
</replication>
</ha-policy>
从机 3 (tcp://slave3:61628)
<cluster-connections>
<cluster-connection name="cluster">
<connector-ref>connector-self</connector-ref>
<static-connectors>
<connector-ref>connector-master3</connector-ref>
</static-connectors>
</cluster-connection>
</cluster-connections>
<connectors>
<connector name="connector-self">tcp://slave3:61628</connector>
<connector name="connector-master3">tcp://master3:61618</connector>
</connectors>
<ha-policy>
<replication>
<slave>
<allow-failback>true</allow-failback>
<group-name>master-3-pair</group-name>
</slave>
</replication>
</ha-policy>