FreeBSD用CARP实现高可用性

如果用2台Freebsd的CARP只是单单的去实现HA,就简单多了,我们只需要建立一个carp0就够了

其他配置参考:FreeBSD用CARP实现负载均衡

重点配置如下:

fb01# cat /etc/rc.conf
sshd_enable=”YES”
ifconfig_le0=”inet 172.20.6.201  netmask 255.255.255.0″
ifconfig_le1=”inet 192.168.1.201  netmask 255.255.255.0″
defaultrouter=”172.20.6.2″
hostname=”fb01.abc.com”
cloned_interfaces=”carp0″
ifconfig_carp0=”vhid 1 advbase 5 advskew 10 pass aaa123 172.20.6.205/24″
ifconfig_pfsync0=”up syncif le1″
apache22_enable=”YES”

fb02# cat /etc/rc.conf
sshd_enable=”YES”
ifconfig_le0=”inet 172.20.6.202  netmask 255.255.255.0″
ifconfig_le1=”inet 192.168.1.202  netmask 255.255.255.0″
defaultrouter=”172.20.6.2″
hostname=”fb02.abc.com”
cloned_interfaces=”carp0″
ifconfig_carp0=”vhid 1 advbase 5 advskew 40 pass aaa123 172.20.6.205/24″
ifconfig_pfsync0=”up syncif le1″

重启后的网络状态:2台同时在线

fb01# ifconfig

carp0: flags=49<UP,LOOPBACK,RUNNING> metric 0 mtu 1500
inet 172.20.6.205 netmask 0xffffff00
carp: MASTER vhid 1 advbase 5 advskew 10

fb02# ifconfig

carp0: flags=49<UP,LOOPBACK,RUNNING> metric 0 mtu 1500
inet 172.20.6.205 netmask 0xffffff00
carp: BACKUP vhid 1 advbase 5 advskew 40

高可用测试:当你把fb01关掉之后,fb02会自动变为master,并且接管web的访问。

原文链接:,转发请注明来源!

发表评论