FailOver Using Carp

FailOver Using Carp
  • Compile kernel Freebsd and add “device carp” on the KERNEL line
  • Set Sysctl /etc/sysctl.conf, and add line below :
net.inet.carp.allow=1
net.inet.carp.preempt=1
net.inet.carp.log=2
net.inet.carp.arpbalance=1

This setting must be same on both server.

  • Set Rc.conf /etc/rc.conf, and add line below :

web1 (master):

cloned_interfaces="carp0 carp1"
ifconfig_carp0="vhid 1 pass testist 172.16.1.157/23"
ifconfig_carp1="vhid 1 pass testist 203.101.123.11/23"

web2 (backup):

cloned_interfaces="carp0 carp1"
ifconfig_carp0="vhid 1 advskew 100 pass testist 172.16.1.157/23"
ifconfig_carp1="vhid 1 advskew 100 pass testist 203.101.123.11/23"

NB : advbase and advskew, which are used to control how frequently the host sends advertisements when it is the master for a virtual host, and pass which is used to authenticate carp advertisements. References “

example Master / Webserver1 :

webserver1# ifconfig
em0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
        ether 00:0c:29:2d:b3:89
        inet 172.16.1.151 netmask 0xfffffe00 broadcast 172.16.1.255
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
plip0: flags=8810<POINTOPOINT,SIMPLEX,MULTICAST> metric 0 mtu 1500
pfsync0: flags=0<> metric 0 mtu 1460
        syncpeer: 224.0.0.240 maxupd: 128
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=3<RXCSUM,TXCSUM>
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x4
        inet6 ::1 prefixlen 128
        inet 127.0.0.1 netmask 0xff000000
        nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
pflog0: flags=0<> metric 0 mtu 33200
carp0: flags=49<UP,LOOPBACK,RUNNING> metric 0 mtu 1500
        inet 172.16.1.157 netmask 0xfffffe00
        carp: MASTER vhid 1 advbase 1 advskew 0

example Backup / webserver2 :

webserver2# ifconfig
em0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
        ether 00:0c:29:74:7c:86
        inet 172.16.1.152 netmask 0xfffffe00 broadcast 172.16.1.255
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
plip0: flags=8810<POINTOPOINT,SIMPLEX,MULTICAST> metric 0 mtu 1500
pfsync0: flags=0<> metric 0 mtu 1460
        syncpeer: 224.0.0.240 maxupd: 128
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=3<RXCSUM,TXCSUM>
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x4
        inet6 ::1 prefixlen 128
        inet 127.0.0.1 netmask 0xff000000
        nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
pflog0: flags=0<> metric 0 mtu 33200
carp0: flags=49<UP,LOOPBACK,RUNNING> metric 0 mtu 1500
        inet 172.16.1.157 netmask 0xfffffe00
        carp: BACKUP vhid 1 advbase 1 advskew 100

Respond from messages log :

Oct  1 13:12:41 webserver2 kernel: carp0: link state changed to UP
Oct  1 13:14:38 webserver2 kernel: carp0: MASTER -> BACKUP (more frequent advertisement received)
Oct  1 13:14:38 webserver2 kernel: carp0: link state changed to DOWN

Line1 When the master server was down, carp tell to the backup server to up, and Line2 set the carp as a master server, and after that on Line3, is the message when the master server was up, the backup server state changed to down. And the master was set to Up again. Credited to : al

Incoming search terms:

8 Comments

  1. mantap kaka..

    keep posting ;p

    Reply
  2. eh, cara nge test nye begimane niyh
    rico recently posted..Proxy Server

    Reply
    • coba aja itu dua server, udah di test, begitu koq jalan :D cari ngetest nya di reboot aja yang master, terus di ifconfig, pindah ga jadi master yang server backup :D dah gitu test lagi idupin yang master, langsung balik lagi jadi master apa enggak, terus yang backup jadi backup server lagi.. :D
      Ridhoyp recently posted..FailOver Using Carp

      Reply
  3. wew.. keren kk.. baru tahu ane gan.. kek heartbeat..

    nice share :)

    Reply
  4. mantaaf gan, keep shared gan :D

    Reply
  5. When you find yourself seeking an Internet connection for the business,
    you need to know several things about the telecom world,
    just what the different circuits are, and most of all,
    what is guaranteed and what it is. The marketing hype can be extremely deceiving, which means you need to
    understand dedicated lines such as business Ethernet,
    T1 and similar. In addition, you need to find out where
    to seek out the best pricing and how to make sure it truly is
    reliable at the best prices possible.
    mpls ethernet recently posted..mpls ethernet

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badge