- Estréllate y Arde - https://www.estrellateyarde.org -
Clusters UltraMonkey en Linux
Existen varios proyectos dedicados a facilitar la instalación de clusters HA (High Availability, alta disponibilidad), utilizados principalmente en granjas de servidores. Uno de ellos es UltraMonkey (ultramonkey.org), un proyecto que simplifica la instalación y configuración de un cluster HA integrando las herramientas LVS, HeartBeat y Ldirectord.
Recursos
Veamos un ejemplo de un cluster HA utilizando UltraMonkey:
deb http://www.ultramonkey.org/download/3/ sarge main deb-src http://www.ultramonkey.org/download/3 sarge main
Actualizaremos la lista de paquetes e instalaremos:
# apt-get update # apt-get install ultramonkey
Si nos pregunta:
Do you want to automatically load IPVS rules on boot? No
Select a daemon method: none
# Uncomment the next line to enable packet forwarding for IPv4 net.ipv4.conf.default.forwarding=1
Y ejecutaremos:
# sysctl -p
Esto es equivalente a:
# echo 1 > /proc/sys/net/ipv4/ip_forward
logfacility local0 bcast eth0 mcast eth0 225.0.0.1 694 1 0 auto_failback off respawn hacluster /usr/lib/heartbeat/ipfail apiauth ipfail gid=haclient uid=hacluster node loadb1 node loadb2
loadb1 IPaddr2::192.168.6.240/24/eth0/192.168.0.255
ldirectord::ldirectord.cf LVSSyncDaemonSwap::master
En este archivo se especifica el nombre del director master (loadb1), la IP virtual (192.168.6.240) y los demonios a monitorizar (ldirectord y LVSSyncDaemonSwap).
auth 3 3 md5 mi_password
Aquí definimos el mecanismo de autentificación (md5) y el password para que los dos demonios heartbeat de los servidores se autentifiquen uno contra el otro (mi_password). Sólo root debe tener permisos de lectura sobre /etc/heartbeat/authkeys por lo que haremos:
# chmod 600 /etc/heartbeat/authkeys
checktimeout=10 checkinterval=2 autoreload=no logfile="local0" quiescent=yes virtual=192.168.6.240:80 real=192.168.6.5:80 gate real=192.168.6.4:80 gate fallback=127.0.0.1:80 gate service=http request="ldirector.html" receive="Test Page" scheduler=rr protocol=tcp checktype=negotiate
# update-rc.d -f ldirectord remove # /etc/init.d/ldirectord stop
# Enable configuration of arp_ignore option net.ipv4.conf.all.arp_ignore = 1 # When an arp request is received on eth0, only respond if that # address is configured on eth0. In particular, do not respond if # the address is configured on lo net.ipv4.conf.eth0.arp_ignore = 1 # Ditto for eth1, add for all ARPing interfaces #net.ipv4.conf.eth1.arp_ignore = 1 # Enable configuration of arp_announce option net.ipv4.conf.all.arp_announce = 2 # When making an ARP request sent through eth0 Always use an address # that is configured on eth0 as the source address of the ARP request. # If this is not set, and packets are being sent out eth0 for an address # that is on lo, and an arp request is required, then the address on lo # will be used. As the source IP address of arp requests is entered into # the ARP cache on the destination, it has the effect of announcing this # address. This is not desirable in this case as adresses on lo on the # real-servers should be announced only by the linux-director. net.ipv4.conf.eth0.arp_announce = 2 # Ditto for eth1, add for all ARPing interfaces #net.ipv4.conf.eth1.arp_announce = 2
Y ejecutaremos en ambos nodos Apache:
# sysctl -p
Editaremos también /etc/network/interfaces y añadiremos las líneas:
auto lo:0 iface lo:0 inet static address 192.168.6.240 netmask 255.255.255.255 pre-up sysctl -p > /dev/null
Y ejecutaremos:
# ifup lo:0
Test Page
# /etc/init.d/heartbeat start
# ip addr sh eth0 2: eth0: <BROADCAST,MULTICAST,UP>mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:16:3e:40:18:e5 brd ff:ff:ff:ff:ff:ff inet 192.168.6.2/24 brd 192.168.0.255 scope global eth0 inet 192.168.6.240/24 brd 192.168.0.255 scope global secondary eth0
En el director backup no veremos la IP virtual:
# ip addr sh eth0 2: eth0: <BROADCAST,MULTICAST,UP>mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:16:3e:50:e3:3a brd ff:ff:ff:ff:ff:ff inet 192.168.6.3/24 brd 192.168.0.255 scope global eth0
# ldirectord ldirectord.cf status ldirectord for /etc/ha.d/ldirectord.cf is running with pid: 1455
En el director backup:
# ldirectord ldirectord.cf status
ldirectord is stopped for /etc/ha.d/ldirectord.cf
# ipvsadm -L -n IP Virtual Server version 1.2.1 (size=4096) Prot LocalAddress:Port Scheduler Flags ->RemoteAddress:Port Forward Weight ActiveConn InActConn TCP 192.168.6.240:80 rr ->192.168.6.5:80 Route 0 0 0 ->192.168.6.4:80 Route 0 0 0 ->127.0.0.1:80 Local 1 0 0
En el director backup:
# ipvsadm -L -n IP Virtual Server version 1.2.1 (size=4096) Prot LocalAddress:Port Scheduler Flags ->RemoteAddress:Port Forward Weight ActiveConn InActConn
# /etc/ha.d/resource.d/LVSSyncDaemonSwap master status master running (ipvs_syncmaster pid: 1591)
En el director backup:
# /etc/ha.d/resource.d/LVSSyncDaemonSwap master status
master stopped
# /etc/init.d/apache stop
# /etc/init.d/heartbeat stop
Esperaremos unos segundos y entraremos en http://192.168.6.240. Si podemos acceder a la web significa que loadb2 es ahora el nuevo director master.
# /etc/init.d/heartbeat start
Esperaremos unos segundos y comprobaremos que loadb1 vuelve a ser el master.
# ntpdate <server>
Para comprobar la hora del sistema:
# date
Article printed from Estréllate y Arde: https://www.estrellateyarde.org
URL to article: https://www.estrellateyarde.org/discover/cluster-ultramonkey-en-linux
Click here to print.
Copyright © 2010 Estrellate y Arde