Инструменты пользователя

Инструменты сайта


протокол_carp

Это старая версия документа.


Протокол CARP

Ubuntu

Установка

root@nodeN:~# apt-get install ucarp

Настройка

root@nodeN:~# less /usr/share/doc/ucarp/README.Debian

root@nodeN:~# less /etc/network/if-up.d/ucarp

root@nodeN:~# ifdown eth0

root@nodeN:~# cat /etc/network/interfaces
...
auto eth0
iface eth0 inet static
        address 192.168.X.N
        netmask 255.255.255.0
        ucarp-vid 1
        ucarp-vip 192.168.X.254
        ucarp-password secret

iface eth0:ucarp inet static
        address 192.168.X.254
        netmask 255.255.255.255
...
root@nodeN:~# cat /usr/share/ucarp/vip-up
#!/bin/sh

/sbin/ifup $1:ucarp
root@nodeN:~# cat /usr/share/ucarp/vip-down
#!/bin/sh

/sbin/ifdown $1:ucarp

Запуск

root@nodeN:~# ifup eth0

Проверка

root@nodeN:~# ps ax | grep carp

root@nodeN:~# ifconfig eth0:ucarp

Остановка

root@nodeN:~# ifdown eth0:ucarp

FreeBSD (user land)

Установка

[nodeN:~] # pkg_add -r ucarp

Настройка

[node1:~] # cat /etc/rc.conf
...
ucarp_enable="YES"
ucarp_vhid="1"
ucarp_if="em0"
ucarp_src="192.168.X.1"
ucarp_addr="192.168.X.254"
# ucarp_advskew="50"
# ucarp_preempt="YES" # For always use master with lover advskew
ucarp_pass="secret"
ucarp_upscript="/usr/local/etc/vip-up.sh"
ucarp_downscript="/usr/local/etc/vip-down.sh"
[node2:~] # cat /etc/rc.conf
...
ucarp_enable="YES"
ucarp_vhid="1"
ucarp_if="em0"
ucarp_src="192.168.X.2"
ucarp_addr="192.168.X.254"
# ucarp_advskew="100"
# ucarp_preempt="YES"
ucarp_pass="secret"
ucarp_upscript="/usr/local/etc/vip-up.sh"
ucarp_downscript="/usr/local/etc/vip-down.sh"
[nodeN:~] # cat /usr/local/etc/vip-up.sh
#!/bin/sh
ifconfig em0 inet 192.168.X.254/32 alias
[nodeN:~] # chmod +x /usr/local/etc/vip-up.sh
[nodeN:~] # cat /usr/local/etc/vip-down.sh
#!/bin/sh
ifconfig em0 inet 192.168.X.254/32 -alias
[nodeN:~] # chmod +x /usr/local/etc/vip-down.sh
[nodeN:~] # /usr/local/etc/rc.d/ucarp start

Дополнительные материалы

FreeBSD (kernel land)

Настройка
node1# ifconfig carp0 create
node1# ifconfig carp0 vhid 1 pass testpass321 192.168.X.254/24

node2# ifconfig carp0 create
node2# ifconfig carp0 vhid 1 advskew 100 pass testpass321 192.168.X.254/24

node1# cat /etc/rc.conf
...
cloned_interfaces="carp0"
ifconfig_carp0="vhid 1 pass testpass321 192.168.X.254/24"
...
node2# cat /etc/rc.conf
...
cloned_interfaces="carp0"
ifconfig_carp0="vhid 1 advskew 100 pass testpass321 192.168.X.254/24"
...
Проверка
nodeN# ifconfig carp0
протокол_carp.1460706500.txt.gz · Последние изменения: 2016/04/15 10:48 — val