我想为在2个FreeBSD VM上运行的应用程序创建一个主动-被动群集,该应用程序由2个KVM centos 7主机虚拟化,每个虚拟机一个。
VM的每个主机都具有IP 192.168.1.2接口,而KVM主机具有其10.x.x.x私有ip,每个主机都不同。
VM由centos主机上的iptables处理。这些规则将端口从5000到39999(tcp和udp)的连接重定向到ip 192.168.1.2(FreeBSD VM)上的相同端口。
对于corosync,我需要使用单播,因为无法在端口5405的网络配置中使用多播。两个虚拟机均可访问该端口,我已经用tcpdump对其进行了测试。
DNS设置名称“ srv1”指向KVM主机1的专用IP(10.x.x.x),而“ srv2”名称指向KVM主机2的专用IP。
在VM srv1(FreeBSD)上,我在/ etc / hosts上对此进行了设置:
192.168.1.2 srv1
在VM srv2(FreeBSD)上,我在/ etc / hosts上对此进行了设置:
192.168.1.2 srv2
因此,corosync节点列表可以绑定到正确的接口,并使用DNS上的ip到达另一个接口。
这是corosync.conf:
totem {
version: 2
cluster_name: cluster
transport: udpu
interface {
ringnumber: 0
# bindnetaddr: 192.168.1.0
mcastaddr: 226.94.1.1
broadcast: yes
mcastport: 5405
}
}
quorum {
provider: corosync_votequorum
two_node: 1
}
nodelist {
node {
ring0_addr: srv1
name: primary
nodeid: 1
}
node {
ring0_addr: srv2
name: secondary
nodeid: 2
}
}
logging {
to_logfile: yes
logfile: /var/log/corosync/corosync.log
to_syslog: yes
timestamp: on
}
这不起作用,因为一个节点看到192.168.1.2的srv1和ip 10.x.x.x的srv2,另一个节点看到10.x.x.x的srv1和192.168.1.2的srv2 因此,在日志中,我可以看到一个成熟的成员资格创建:
Jun 30 16:07:10 [1889] vmsrv2.net.local corosync notice [TOTEM ] A new membership (192.168.1.2:18668) was formed. Members
Jun 30 16:07:10 [1889] vmsrv2.net.local corosync notice [VOTEQ ] Waiting for all cluster members. Current votes: 1 expected_votes: 2
Jun 30 16:07:10 [1889] vmsrv2.net.local corosync notice [VOTEQ ] Waiting for all cluster members. Current votes: 1 expected_votes: 2
Jun 30 16:07:10 [1889] vmsrv2.net.local corosync notice [QUORUM] Members[1]: 2
Jun 30 16:07:10 [1889] vmsrv2.net.local corosync notice [MAIN ] Completed service synchronization, ready to provide service.
Jun 30 16:07:10 [1889] vmsrv2.net.local corosync notice [TOTEM ] A new membership (192.168.1.2:18672) was formed. Members
Jun 30 16:07:10 [1889] vmsrv2.net.local corosync notice [VOTEQ ] Waiting for all cluster members. Current votes: 1 expected_votes: 2
Jun 30 16:07:10 [1889] vmsrv2.net.local corosync notice [VOTEQ ] Waiting for all cluster members. Current votes: 1 expected_votes: 2
Jun 30 16:07:10 [1889] vmsrv2.net.local corosync notice [QUORUM] Members[1]: 2
Jun 30 16:07:10 [1889] vmsrv2.net.local corosync notice [MAIN ] Completed service synchronization, ready to provide service.
Jun 30 16:07:10 [1889] vmsrv2.net.local corosync notice [TOTEM ] A new membership (192.168.1.2:18676) was formed. Members
Jun 30 16:07:10 [1889] vmsrv2.net.local corosync notice [VOTEQ ] Waiting for all cluster members. Current votes: 1 expected_votes: 2
Jun 30 16:07:10 [1889] vmsrv2.net.local corosync notice [VOTEQ ] Waiting for all cluster members. Current votes: 1 expected_votes: 2
Jun 30 16:07:10 [1889] vmsrv2.net.local corosync notice [QUORUM] Members[1]: 2
Jun 30 16:07:10 [1889] vmsrv2.net.local corosync notice [MAIN ] Completed service synchronization, ready to provide service.
Jun 30 16:07:11 [1889] vmsrv2.net.local corosync notice [TOTEM ] A new membership (192.168.1.2:18680) was formed. Members
Jun 30 16:07:11 [1889] vmsrv2.net.local corosync notice [VOTEQ ] Waiting for all cluster members. Current votes: 1 expected_votes: 2
Jun 30 16:07:11 [1889] vmsrv2.net.local corosync notice [VOTEQ ] Waiting for all cluster members. Current votes: 1 expected_votes: 2
Jun 30 16:07:11 [1889] vmsrv2.net.local corosync notice [QUORUM] Members[1]: 2
Jun 30 16:07:11 [1889] vmsrv2.net.local corosync notice [MAIN ] Completed service synchronization, ready to provide service.
Jun 30 16:07:11 [1889] vmsrv2.net.local corosync notice [TOTEM ] A new membership (192.168.1.2:18684) was formed. Members
Jun 30 16:07:11 [1889] vmsrv2.net.local corosync notice [VOTEQ ] Waiting for all cluster members. Current votes: 1 expected_votes: 2
因此,使用crm status
命令,我可以在vmsrv1上看到仅联机的主节点,而在vmsrv2上只能看到联机的辅助节点。
如何解决此问题,而无需在CentOS主机上设置corosync和起搏器?
谢谢。