Sie sind auf Seite 1von 9

Instalacin y conguracin de un cluster con heartbeat 2 y pacemaker | systemadmin.

es

06/05/13

e m s y te a s d m n .i Tu referencia para la administracin de sistemas

herramientas

series de artculos

sobre el autor

subscribete

systemadmin.es Clustering Instalacin y configuracin de un cluster con heartbeat 2 y pacemaker

yn ic al ats nI re k m a e c a p
La versin 2 de heart beat ha cambiado bastante respecto la versin 1 . Vamos a ver como inst alar heart beat y como configurar un servicio con pacemaker con una VIP asociada . Para esta configuracin vamos a suponer dos host s : host1 host2 Empezaremos instalando el reposit orio de clust erlabs e instalando todos los paquetes necesarios en ambos nodos (deberemos t ener inst alado previament e
el resposit orio EPEL):

escribe aqu...

buscar

sodaca t seD
Linux 3.0 : Ya tenemos la versin 3.0 del kernel Linux. Lo ha anunciado Linus Torvalds en la lista de desarrollo... Como cambiar el t ext o del men Inicio de Windows por ot ro : Anteriormente ya coment (Jugando con IDA Pro) como con un amigo nos entretuvimos hace ya aos a mod... Wargame behemot h: Nivel 1 : Siguiendo con el wargame a continuacin del narnia tenemos el behemoth, vamos a ver como

solucionar ... wget -O /etc/yum.repos.d/pacemaker.repo http://clusterlabs.org/rpm/epel-5/clusterlabs.repo yum install heartbeat cluster-glue resource-agents pacemaker -y

sa i r oge t aC
Aplicaciones Backup BSD Buscador Clustering Correo Curiosidades DBA Desktop DNS Hardware Instalaciones Kernel LAMP y web Monitorizacin Programacin Redes Rendimiento SAN Script Seguridad Sistemas de ficheros Sistemas empotrados Storage systemadmin.es otros Utilidades Virtualizacin

A continuacin deberemos modificar el fichero /et c/host s , aadiendo los dos nodos del cluster:
172.16.2.10 host1 172.16.2.11 host2

A continuacin, en uno de los dos nodos generamos el fichero /et c/ha.d/ha.cf con lo siguiente:
autojoin none bcast eth0

warntime 5 deadtime 15 initdead 60 keepalive 2

node host1 node host2

pacemaker respawn

Los parmetros son los siguientes:


aut ojoin: Indicamos que no queremos que haga aut ojoin, indicamos

estticamente los nodos del cluster en la configuracin mediante node


bcast : Mediante bcast indicamos por que interfaz y mediante broadcast se

pasaran mensajes entre los nodos del cluster. Podemos hacerlo tambin por
mult icast (mcast ) pero si tenemos una VLAN para el cluster y no hay ms de

un cluster en la VLAN podemos dejarlo con broadcast . Mediante warnt ime , deadt ime , init dead , keepalive indicamos diferentes valores globales de timeouts.
http://systemadmin.es/2011/03/instalacion-y-conguracion-de-heartbeat-2 1/9

Instalacin y conguracin de un cluster con heartbeat 2 y pacemaker | systemadmin.es

06/05/13

pacemaker respawn: En caso que el pacemaker se muera por algun motivo, se

vuelve a iniciar. A continuacin deberemos generar el fichero de aut ent icacin mediant e pwgen:
yum install pwgen -y

En uno de los nodos generamos el fichero con lo siguiente:


cat <<EOF >/etc/ha.d//authkeys auth 1 1 sha1 $(pwgen 30 | openssl sha1) EOF chmod 600 /etc/ha.d/authkeys

A continuacin deberemos propagar los ficheros mediante ha_propagat e :


# /usr/share/heartbeat/ha_propagate

A continuacin levantaremos el daemon en todos los nodos:


/etc/init.d/heartbeat start

Podemos ver con ps que lo tenemos levantado:


# ps auxf | grep [h]eart root root root root 102 102 root root 102 102 2220 2223 2224 2225 2228 2229 2230 2231 2232 2233 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 0.3 0.6 0.3 1.2 0.4 0.5 5572 5544 5540 5540 4960 8312 5080 6260 7828 7908 5572 ? 5544 ? 5540 ? 5540 ? 1884 ? 3384 ? 1644 ? 6260 ? 2368 ? 2708 ? SLs SL SL SL S S S SL S S 13:08 13:08 13:08 13:08 13:08 13:08 13:08 13:08 13:08 13:08 0:00 heartbeat: master control process 0:00 0:00 0:00 0:00 0:00 0:00 0:00 0:00 0:00 \_ heartbeat: FIFO reader \_ heartbeat: write: bcast eth0 \_ heartbeat: read: bcast eth0 \_ /usr/lib/heartbeat/ccm \_ /usr/lib/heartbeat/cib \_ /usr/lib/heartbeat/lrmd -r \_ /usr/lib/heartbeat/stonithd \_ /usr/lib/heartbeat/attrd \_ /usr/lib/heartbeat/crmd

Mediante crm st at us podemos ver el estado del cluster:


# crm status ============ Last updated: Thu Mar 17 13:12:23 2011 Stack: Heartbeat Current DC: host2 (a49ba348-6ace-4bb3-a51f-831a72b7cdf3) - partition with quorum Version: 1.0.10-da7075976b5ff0bee71074385f8fd02f296ec8a3 2 Nodes configured, unknown expected votes 0 Resources configured. ============

Online: [ host1 host2 ]

A continuacin verificamos la configuracin:


# crm_verify -L crm_verify[2340]: 2011/03/17_13:34:14 ERROR: unpack_resources: Resource start-up disabled since no STONITH resources have crm_verify[2340]: 2011/03/17_13:34:14 ERROR: unpack_resources: Either configure some or disable STONITH with the stonith-e crm_verify[2340]: 2011/03/17_13:34:14 ERROR: unpack_resources: NOTE: Clusters with shared data need STONITH to ensure data
http://systemadmin.es/2011/03/instalacion-y-conguracion-de-heartbeat-2 2/9

Instalacin y conguracin de un cluster con heartbeat 2 y pacemaker | systemadmin.es

06/05/13

Errors found during check: config not valid -V may provide more details

ST ONIT H (clust er-glue ) se encarga de reiniciar los nodos en caso que se

encuentren en un estado indeterminado para permitir levantar sus servicios en otro nodo. De momento lo podemos dejar deshabilitado:
crm configure property stonith-enabled=false

T ambin deberemos definir el nmero de votos con los que indicamos que el cluster tiene quorum :
2 Nodes configured, unknown expected votes

En el caso de dos nodos, tiene poco sentido, por lo que se lo dejaremos en 2 :


crm configure property expected-quorum-votes="2"

Indicaremos a continuacin que siga funcionando el cluster en caso que no t enga


quorum (uno de los dos nodos desaparezca). En caso que no lo hiciramos, si uno

de los nodos lo apagramos, el otro apagara t odos los servicios al perder


quorum : crm configure property no-quorum-policy=ignore

Para evitar que los servicios hagan fail-back (vuelvan al otro nodo cuando se recupere de un fallo):
crm configure rsc_defaults resource-stickiness=100

A continuacin aadiremos servicios, primero de todo tenemos que obtener el listado de clases que podemos aadir:
# crm ra classes heartbeat lsb ocf / heartbeat pacemaker stonith

Mediante crm ra list podemos listar los scripts de control de una de las clases:
# crm ra list ocf heartbeat AoEtarget IPaddr Route VirtualDomain eDir88 oralsnr AudibleAlarm IPaddr2 SAPDatabase WAS iSCSILogicalUnit pgsql CTDB IPsrcaddr SAPInstance WAS6 iSCSITarget pingd ClusterMon LVM SendArp WinPopup ids portblock Delay LinuxSCSI ServeRAID Xen iscsi postfix Dummy MailTo SphinxSearchDaemon Xinetd ldirectord proftpd Ev Ma Sq an my rs

A continuacin mediante crm ra info podemos obtener los datos de funcionamiento de un script en concreto:
# crm ra info ocf:heartbeat:IPaddr2 Manages virtual IPv4 addresses (Linux specific version) (ocf:heartbeat:IPaddr2)

This Linux-specific resource manages IP alias IP addresses. It can add an IP alias, or remove one.
http://systemadmin.es/2011/03/instalacion-y-conguracion-de-heartbeat-2 3/9

Instalacin y conguracin de un cluster con heartbeat 2 y pacemaker | systemadmin.es

06/05/13

In addition, it can implement Cluster Alias IP functionality if invoked as a clone resource.

Parameters (* denotes required, [] the default):

ip* (string): IPv4 address The IPv4 address to be configured in dotted quad notation, for example "192.168.1.1".

nic (string, [eth0]): Network interface The base network interface on which the IP address will be brought online.

If left empty, the script will try and determine this from the routing table.

Do NOT specify an alias interface in the form eth0:1 or anything here; rather, specify the base interface only.

cidr_netmask (string): CIDR netmask The netmask for the interface in CIDR format (e.g., 24 and not 255.255.255.0)

If unspecified, the script will also try to determine this from the routing table.

broadcast (string): Broadcast address Broadcast address associated with the IP. If left empty, the script will determine this from the netmask.

iflabel (string): Interface label You can specify an additional label for your IP address here. This label is appended to your interface name. If a label is specified in nic name, this parameter has no effect.

lvs_support (boolean, [false]): Enable support for LVS DR Enable support for LVS Direct Routing configurations. In case a IP address is stopped, only move it to the loopback device to allow the local node to continue to service requests, but no longer advertise it on the network.

mac (string): Cluster IP MAC address Set the interface MAC address explicitly. Currently only used in case of the Cluster IP Alias. Leave empty to chose automatically.

clusterip_hash (string, [sourceip-sourceport]): Cluster IP hashing function Specify the hashing algorithm used for the Cluster IP functionality.

unique_clone_address (boolean, [false]): Create a unique address for cloned instances If true, add the clone ID to the supplied value of ip to create a unique address to manage

arp_interval (integer, [200]): ARP packet interval in ms Specify the interval between unsolicited ARP packets in milliseconds.

arp_count (integer, [5]): ARP packet count


http://systemadmin.es/2011/03/instalacion-y-conguracion-de-heartbeat-2 4/9

Instalacin y conguracin de un cluster con heartbeat 2 y pacemaker | systemadmin.es

06/05/13

Number of unsolicited ARP packets to send.

arp_bg (string, [yes]): ARP from background Whether or not to send the arp packets in the background.

arp_mac (string, [ffffffffffff]): ARP MAC MAC address to send the ARP packets too.

You really shouldn't be touching this.

Operations' defaults (advisory minimum):

start stop status monitor_0

timeout=20s timeout=20s interval=10s timeout=20s interval=10s timeout=20s

Aadiremos una IP de clust er (VIP) como servicio con crm configure primit ive :
crm configure primitive haip1 ocf:heartbeat:IPaddr2 params ip=172.16.2.100 cidr_netmask=32 op monitor interval=30s

Mediante crm st at us podemos apreciar que se ha levantado y en que nodo:


# crm status ============ Last updated: Thu Mar 17 13:36:33 2011 Stack: Heartbeat Current DC: host2 (a49ba348-6ace-4bb3-a51f-831a72b7cdf3) - partition with quorum Version: 1.0.10-da7075976b5ff0bee71074385f8fd02f296ec8a3 2 Nodes configured, unknown expected votes 1 Resources configured. ============

Online: [ host1 host2 ]

haip1 (ocf::heartbeat:IPaddr2): Started host1

En el nodo que se haya levantado podemos ver como esta presente mediante ip
addr show: # ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:0c:29:40:db:82 brd ff:ff:ff:ff:ff:ff inet 172.16.2.10/16 brd 172.16.255.255 scope global eth0 inet 172.16.2.100/32 brd 172.16.6.100 scope global eth0

A continuacin mediante ocf:heart beat :anyt hing podemos aadir cualquier daemon al cluster. Primero obtenemos los detalles con crm ra info :
# crm ra info ocf:heartbeat:anything Manages an arbitrary service (ocf:heartbeat:anything)

This is a generic OCF RA to manage almost anything.


http://systemadmin.es/2011/03/instalacion-y-conguracion-de-heartbeat-2 5/9

Instalacin y conguracin de un cluster con heartbeat 2 y pacemaker | systemadmin.es

06/05/13

Parameters (* denotes required, [] the default):

binfile* (string): Full path name of the binary to be executed The full name of the binary to be executed. This is expected to keep running with the same pid and not just do somethi

cmdline_options (string): Command line options Command line options to pass to the binary

pidfile (string, [/var/run//anything_undef.pid]): File to write STDOUT to File to read/write the PID from/to.

logfile (string): File to write STDOUT to

errlogfile (string): File to write STDERR to

user (string, [root]): User to run the command as

monitor_hook (string): Command to run in monitor operation

stop_timeout (string): Seconds to wait after having sent SIGTERM before sending SIGKILL in stop operation In the stop operation: Seconds to wait for kill -TERM to succeed before sending kill -SIGKILL. Defaults to 2/3 of the stop operation timeout.

Operations' defaults (advisory minimum):

start stop monitor_0

timeout=20s timeout=20s interval=10 timeout=20s

Por ejemplo, aadimos el daemon de memcached al clust er con el siguiente comando:


crm configure primitive memcache ocf:heartbeat:anything params binfile="/usr/bin/memcached" cmdline_options="-u\ memcached

Mediante crm st at us podemos apreciar como se ha aadido:


# crm status ============ Last updated: Thu Mar 17 15:19:51 2011 Stack: Heartbeat Current DC: host2 (a49ba348-6ace-4bb3-a51f-831a72b7cdf3) - partition with quorum Version: 1.0.10-da7075976b5ff0bee71074385f8fd02f296ec8a3 2 Nodes configured, 2 expected votes 2 Resources configured. ============

Online: [ host1 host2 ]

haip1 (ocf::heartbeat:IPaddr2): Started host1 memcache (ocf::heartbeat:anything): Started host2

http://systemadmin.es/2011/03/instalacion-y-conguracion-de-heartbeat-2

6/9

Instalacin y conguracin de un cluster con heartbeat 2 y pacemaker | systemadmin.es

06/05/13

A continuacin podemos indicar dos recursos con que puntuacin deben mantenerse juntos:
# crm configure colocation usage: colocation <id> <score>: [:] [:]

Mediante crm configure colocat ion indicamos que la VIP y el servicio de


memcache estn en el mismo nodo: crm configure colocation memcached-ip1 INFINITY: haip1 memcache

Revisamos con crm st at us como se han agrupado:


# crm status ============ Last updated: Thu Mar 17 15:25:09 2011 Stack: Heartbeat Current DC: host2 (a49ba348-6ace-4bb3-a51f-831a72b7cdf3) - partition with quorum Version: 1.0.10-da7075976b5ff0bee71074385f8fd02f296ec8a3 2 Nodes configured, 2 expected votes 2 Resources configured. ============

Online: [ host1 host2 ]

haip1 (ocf::heartbeat:IPaddr2): Started host1 memcache (ocf::heartbeat:anything): Started host1

A continuacin mediante order indicamos el orden en que se deben arrancar los servicios:
# crm configure order usage: order <id> score-type: <first-rsc>[:<action>] <then-rsc>[:<action<] [symmetrical=<bool>]

Por lo tanto, indicamos que primero se levante la IP y a continuacin el


memcached : crm configure order ip-memcache mandatory: haip1 memcache

Relacionados St at ement is not safe t o log in st at ement format ssh con daemont ools Replicacin en memcached Reinicio aut omt ico de memcached en la versin de Facebook Posiciones del fichero de configuracin de MySQL 6 Dentro de Clust ering March 21, 2011 Tags: Alt a disponibilidad , heart beat , pacemaker

Imprimir

http://systemadmin.es/2011/03/instalacion-y-conguracion-de-heartbeat-2

7/9

Instalacin y conguracin de un cluster con heartbeat 2 y pacemaker | systemadmin.es

ot stn e m m oc 6 reka m ecap y


edgar wrot e: 23. March 2011 at 1:04 am :

06/05/13

gracias amigos lo voy a practicar y les aviso que tal me va,no saben lo til que me es esto.
art uro wrot e: 2. May 2012 at 9:15 pm :

Debes empezar a usar Corosync


Jose wrot e: 27. Sept ember 2012 at 5:16 pm :

tengo problemas configurando el pacemaker y no hay muchas instrucciones aqui podras darme una mano con eso!?
marcelo wrot e: 13. November 2012 at 8:54 pm :

Alguien ha probado esta configuracin con asterisk?


Os wrot e: 25. November 2012 at 9:56 pm :

Hola muy buen tutorial entre este y otros tutoriales he conseguido hasta el momento Crear mi pequeo Cluster con 2 Nodos y una IP virtual. Ahora voy a intentar poner mysql en Alta Disponibilidad. Gracias
David wrot e: 3. April 2013 at 8:4 6 am :

Podria alguien ayudarme diciendome como agregaria el servicio de proxy http (squid) y dansguardian que es lo que tengo montado para agregarlo al cluster? Gracias desde ya!

n e m oc n u a je D
Nombre (obligat orio ) Ant iBot : Suma de 2 y 5 ? Email (obligat orio , no se muestra) Website (no se muestra) XHT ML - Tags permitidos:<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

enviar
http://systemadmin.es/2011/03/instalacion-y-conguracion-de-heartbeat-2 8/9

Instalacin y conguracin de un cluster con heartbeat 2 y pacemaker | systemadmin.es

06/05/13

2008 systemadmin.es Legal subscribete mediante RSS

http://systemadmin.es/2011/03/instalacion-y-conguracion-de-heartbeat-2

9/9

Das könnte Ihnen auch gefallen