root@nodeN:~# apt install ucarp
root@nodeN:~# less /usr/share/doc/ucarp/README.Debian root@nodeN:~# less /etc/network/if-up.d/ucarp 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:~# less /usr/share/ucarp/vip-up
#!/bin/sh /sbin/ifup $1:ucarp
root@nodeN:~# less /usr/share/ucarp/vip-down
#!/bin/sh /sbin/ifdown $1:ucarp
root@nodeN:~# ifdown --force eth0 root@nodeN:~# ifup eth0
root@nodeN:~# ps ax | grep carp root@nodeN:~# ifconfig eth0:ucarp root@nodeN:~# pkill -USR1 ucarp root@nodeN:~# killall -USR1 ucarp root@nodeN:~# grep carp /var/log/syslog
wincmd:\> arp -a masternode# pkill -USR2 ucarp masternode# killall -USR2 ucarp wincmd:\> arp -a
[nodeN:~] # pkg install ucarp
[nodeN:~] # less /usr/local/etc/rc.d/ucarp [nodeN:~] # cat /etc/rc.conf
... ucarp_src="192.168.X.N" ucarp_enable="YES" ucarp_vhid="1" ucarp_if="em0" ucarp_addr="192.168.X.254" ucarp_pass="secret" ucarp_upscript="/usr/local/sbin/ucarp-up" ucarp_downscript="/usr/local/sbin/ucarp-down"
[nodeN:~] # cat /usr/local/sbin/ucarp-up
#!/bin/sh ... /sbin/ifconfig "$1" alias "$2" netmask 255.255.255.255
[nodeN:~] # cat /usr/local/sbin/ucarp-down
#!/bin/sh ... /sbin/ifconfig "$1" -alias "$2" ...
[nodeN:~] # service ucarp start
root@nodeN:~# apt-get install ucarp
root@nodeN:~# cat /etc/vip-up.sh
#!/bin/sh /sbin/ip addr add 192.168.X.254/32 dev "$1"
root@nodeN:~# cat /etc/vip-down.sh
#!/bin/sh /sbin/ip addr del 192.168.X.254/32 dev "$1"
root@nodeN:~# chmod +x /etc/vip-up.sh /etc/vip-down.sh
root@node1:~# ucarp -i eth0 -s 192.168.X.1 -v 1 -p secret -a 192.168.X.254 -u /etc/vip-up.sh -d /etc/vip-down.sh -z -B root@node2:~# ucarp -i eth0 -s 192.168.X.2 -v 1 -p secret -a 192.168.X.254 -u /etc/vip-up.sh -d /etc/vip-down.sh -z -B
Примечания:
root@nodeN:~# ip addr show dev eth0
root@nodeN:~# killall ucarp
# man carp
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