ÔõÑù´î½¨¸ß¿ÉÓõÄLinux¼¯ÈºÇéÐÎ
ÔõÑù´î½¨¸ß¿ÉÓõÄLinux¼¯ÈºÇéÐÎ
¸ÅÊö£º
Ëæ×Å»¥ÁªÍøµÄ¿ìËÙÉú³¤ºÍÓªÒµÐèÇóµÄÒ»Ö±ÔöÌí£¬¸ß¿ÉÓÃÐÔ³ÉΪÏÖ´úÅÌËãϵͳÉè¼ÆµÄÖ÷ҪĿµÄÖ®Ò»¡£Linux¼¯ÈºÇéÐÎÊÇʵÏָ߿ÉÓÃÐÔµÄÒ»ÖÖ³£¿´·¨¾ö¼Æ»®¡£±¾ÎĽ«ÏÈÈÝÔõÑù´î½¨¸ß¿ÉÓõÄLinux¼¯ÈºÇéÐΣ¬²¢ÌṩÏêϸµÄ´úÂëʾÀý¡£
Ò»¡¢Ñ¡È¡ºÏÊʵļ¯ÈºÈí¼þ
LinuxϵͳÓжàÖÖ¿ÉÑ¡µÄ¼¯ÈºÈí¼þ£¬ÈçPacemaker¡¢Keepalived¡¢HeartbeatµÈ¡£ÔÚÑ¡Ôñ¼¯ÈºÈí¼þʱ£¬ÐèҪ˼Á¿ÒÔÏÂÒòËØ£º
ϵͳÎȹÌÐÔ£ºÑ¡Ôñ¾Óɺã¾ÃʹÓá¢ÎȹÌÐԽϺõÄÈí¼þ£»
ÉçÇøÖ§³Ö£ºÑ¡ÔñÓлîÔ¾ÉçÇøÖ§³ÖºÍºã¾Ãά»¤µÄÈí¼þ£»
¹¦Ð§¸»ºñÐÔ£ºÑ¡Ôñ¾ß±¸ËùÐ蹦ЧµÄÈí¼þ£»
Ò×ÓÃÐÔ£ºÑ¡ÔñÒ×ÓÚÉèÖúÍÖÎÀíµÄÈí¼þ¡£
¶þ¡¢×°ÖÃÉèÖü¯ÈºÈí¼þ
ÒÔPacemaker×÷ΪʾÀý£¬ÏÈÈÝÆä×°ÖúÍÉèÖÃÀú³Ì¡£
×°Öü¯ÈºÈí¼þ£º
ÔÚËùÓнڵãÉÏÖ´ÐÐÒÔÏÂÏÂÁî×°ÖÃPacemaker£º
sudo apt-get install pacemaker corosync
µÇ¼ºó¸´ÖÆ
ÉèÖü¯ÈºÈí¼þ£º
±à¼corosyncµÄÉèÖÃÎļþ/etc/corosync/corosync.conf£¬ÉèÖýڵã¼äͨѶºÍ¼¯ÈºIPµØµãµÈ²ÎÊý£º
totem { version: 2 secauth: off cluster_name: mycluster transport: udpu } nodelist { node { ring0_addr: <node1_IP> nodeid: 1 } node { ring0_addr: <node2_IP> nodeid: 2 } } quorum { provider: corosync_votequorum two_node: 1 }
µÇ¼ºó¸´ÖÆ
±àдPacemakerµÄÉèÖÃÎļþ/etc/corosync/cib.xml£¬ÉèÖü¯Èº×ÊÔ´ºÍÔ¼ÊøµÈÐÅÏ¢¡£
ÀýÈ磬½¨ÉèÒ»¸ö»ù±¾µÄApacheÐéÄâIP×ÊÔ´£º
<cib ...> <configuration> <resources> <primitive id="virtual_ip" class="ocf:heartbeat:IPaddr2"> <instance_attributes ip="192.168.1.100" cidr_netmask="24"/> <operations> <op name="monitor" interval="10s"/> <op name="start" interval="0s"/> <op name="stop" interval="0s"/> </operations> </primitive> </resources> <constraints> <rsc_location rule="1000" score="-INFINITY" id="constraint_virtual_ip" node="node1"/> </constraints> </configuration> </cib>
µÇ¼ºó¸´ÖÆ
Æô¶¯¼¯ÈºÐ§ÀÍ£º
ÔÚËùÓнڵãÉÏÖ´ÐÐÒÔÏÂÏÂÁîÆô¶¯¼¯ÈºÐ§ÀÍ£º
sudo service corosync start sudo service pacemaker start
µÇ¼ºó¸´ÖÆ
Èý¡¢ÑéÖ¤¼¯ÈºÇéÐÎ
Éó²é¼¯Èº×´Ì¬£º
Ö´ÐÐÒÔÏÂÏÂÁîÉó²é¼¯Èº×´Ì¬£º
sudo crm_mon
µÇ¼ºó¸´ÖÆ
ÈôÊÇÊä³öÖÐÏÔʾËùÓнڵ㶼Õý³£ÔËÐУ¬ÔòÌåÏÖ¼¯ÈºÇéÐÎÒÑÀֳɴ¡£
²âÊÔ×ÊԴǨá㣺
Ö´ÐÐÒÔÏÂÏÂÁî²âÊÔ×ÊԴǨá㹦Ч£º
sudo crm resource migrate virtual_ip node2
µÇ¼ºó¸´ÖÆ
ÈôÊÇ×ÊԴǨáãÀֳɣ¬²¢ÇÒÐéÄâIPµØµã±»×ªÒƵ½ÁËnode2½Úµã£¬ÔòÌåÏÖ×ÊԴǨá㹦ЧÕý³£¡£
ËÄ¡¢×ܽá
ͨ¹ýÑ¡ÔñºÏÊʵļ¯ÈºÈí¼þ£¬×°ÖÃÉèÖü¯ÈºÈí¼þ£¬ÒÔ¼°ÑéÖ¤¼¯ÈºÇéÐΣ¬ÎÒÃÇÀֳɴÁ˸߿ÉÓõÄLinux¼¯ÈºÇéÐΡ£ÔÚÏÖʵӦÓÃÖУ¬»¹ÐèҪƾ֤ÏêϸӪҵÐèÇó£¬ÉèÖÃÆäËû¸ß¿ÉÓÃ×ÊÔ´£¬ÈçÊý¾Ý¿â¡¢Ó¦ÓÃЧÀ͵ȡ£Í¨¹ýºÏÀíÉèÖúÍÖÎÀí£¬¿ÉÒÔÈ·±£¸ß¿ÉÓÃÐÔ£¬²¢Ìṩ¿É¿¿µÄЧÀÍ¡£
ÒÔÉϾÍÊÇÔõÑù´î½¨¸ß¿ÉÓõÄLinux¼¯ÈºÇéÐεÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡