ÔõÑùÔÚLinuxÉÏÉèÖø߿ÉÓõÄÍøÂ縺ÔØƽºâ
ÔõÑùÔÚlinuxÉÏÉèÖø߿ÉÓõÄÍøÂ縺ÔØƽºâ
ÍøÂ縺ÔØƽºâÊÇÒ»ÖÖÖ÷ÒªµÄÍøÂçÊÖÒÕ£¬¿ÉÒÔ½«ÍøÂçÁ÷Á¿ÔȳƵطַ¢µ½¶à¸öЧÀÍÆ÷ÉÏ£¬Ìá¸ßϵͳµÄ¿ÉÓÃÐÔºÍÀ©Õ¹ÐÔ¡£ÔÚLinuxϵͳÉÏ£¬Í¨¹ýһЩ¹¤¾ßºÍÊÖÒÕ£¬¿ÉÒÔºÜÈÝÒ×µØʵÏָ߿ÉÓõÄÍøÂ縺ÔØƽºâ¡£±¾ÎĽ«ÏÈÈÝÔõÑùÉèÖÃLinuxϵͳÉϵĸ߿ÉÓÃÍøÂ縺ÔØƽºâ£¬²¢Ìṩ´úÂëʾÀý¡£
Ò»¡¢ÉèÖÃKeepalived
Keepalived ÊÇÒ»¸ö¿ªÔ´µÄ¸ß¿ÉÓýâ¾ö¼Æ»®£¬¿ÉÒÔʵÏÖЧÀÍÆ÷µÄ¹ÊÕÏתÒƺ͸ºÔØƽºâ¡£ÏÂÃæÊÇÉèÖÃKeepalivedµÄ°ì·¨£º
×°ÖÃKeepalived£º
ÔÚLinuxϵͳÉÏʹÓÃÒÔÏÂÏÂÁî×°ÖÃKeepalived£º
$ sudo apt-get install keepalived
µÇ¼ºó¸´ÖÆ
ÉèÖÃKeepalived£º
·¿ªKeepalivedÉèÖÃÎļþ£¬Í¨³£Î»ÓÚ/etc/keepalived/keepalived.conf£¬²¢Æ¾Ö¤ÏÂÃæµÄʾÀý¾ÙÐÐÉèÖãº
! Configuration File for keepalived vrrp_instance VI_1 { state MASTER interface eth0 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass mypassword } virtual_ipaddress { 192.168.0.100/24 } }
µÇ¼ºó¸´ÖÆ
ÉÏÊöÉèÖÃÖУ¬state MASTERÌåÏÖÄ¿½ñЧÀÍÆ÷ÊÇÖ÷½Úµã£¬interface eth0ÌåÏÖÍøÂç½Ó¿Ú£¬virtual_router_id 51ÊÇÐéÄâ·ÓÉÆ÷µÄID£¬priority 100ÊÇÓÅÏȼ¶£¬advert_int 1Êǹã¸æ¾àÀëʱ¼ä£¬auth_pass mypasswordÊÇÈÏÖ¤ÃÜÂ룬virtual_ipaddressÊÇÐéÄâIPµØµã¡£
ÀàËƵأ¬»¹¿ÉÒÔÉèÖÃÆäËûЧÀÍÆ÷×÷Ϊ±¸·Ý½Úµã¡£
Æô¶¯Keepalived£º
ʹÓÃÒÔÏÂÏÂÁîÆô¶¯KeepalivedЧÀÍ£º
$ sudo service keepalived start
µÇ¼ºó¸´ÖÆ
¶þ¡¢ÉèÖÃLVS
LVS£¨Linux Virtual Server£©ÊÇÒ»¸ö¿ªÔ´µÄÍøÂ縺ÔØƽºâÆ÷£¬¿ÉÒÔ½«ÍøÂçÁ÷Á¿·Ö·¢µ½¶à¸öºó¶ËЧÀÍÆ÷ÉÏ¡£ÏÂÃæÊÇÉèÖÃLVSµÄ°ì·¨£º
×°ÖÃLVS£º
ÔÚLinuxϵͳÉÏʹÓÃÒÔÏÂÏÂÁî×°ÖÃLVS£º
$ sudo apt-get install ipvsadm
µÇ¼ºó¸´ÖÆ
ÉèÖÃLVS£º
ʹÓÃÏÂÃæµÄÏÂÁîÉèÖÃLVS£º
$ sudo ipvsadm -A -t 192.168.0.100:80 -s rr $ sudo ipvsadm -a -t 192.168.0.100:80 -r 192.168.0.101 -g $ sudo ipvsadm -a -t 192.168.0.100:80 -r 192.168.0.102 -g
µÇ¼ºó¸´ÖÆ
ÉÏÊöÏÂÁîÖУ¬-AÌåÏÖÌí¼ÓÐéÄâЧÀÍÆ÷£¬-tÌåÏÖÐéÄâЧÀÍÆ÷µÄµØµãºÍ¶Ë¿Ú£¬-s rrÌåÏÖʹÓÃÂÖѯËã·¨¾ÙÐиºÔØƽºâ£¬-aÌåÏÖÌí¼Óºó¶ËЧÀÍÆ÷£¬-rÌåÏÖºó¶ËЧÀÍÆ÷µÄµØµãºÍ¶Ë¿Ú£¬-gÌåÏÖºó¶ËЧÀÍÆ÷ÒÔ×éµÄÐÎʽ±£´æ¡£
¿ÉÒÔƾ֤ÏÖʵÐèÇóÉèÖöà¸öÐéÄâЧÀÍÆ÷ºÍºó¶ËЧÀÍÆ÷¡£
Æô¶¯LVS£º
ʹÓÃÒÔÏÂÏÂÁîÆô¶¯LVSЧÀÍ£º
$ sudo service ipvsadm start
µÇ¼ºó¸´ÖÆ
ÒÔÉÏÊÇÔÚLinuxϵͳÉÏÉèÖø߿ÉÓÃÍøÂ縺ÔØƽºâµÄ¼òÆÓʾÀý¡£Í¨¹ýKeepalivedºÍLVSµÄÉèÖ㬿ÉÒÔʵÏÖЧÀÍÆ÷µÄ¹ÊÕÏתÒƺ͸ºÔØƽºâ£¬Ìá¸ßϵͳµÄ¿ÉÓÃÐÔºÍÐÔÄÜ¡£
Çë×¢ÖØ£¬Ê¾ÀýÖеÄÉèÖúÍÏÂÁîÊÇ»ùÓÚUbuntu²Ù×÷ϵͳ£¬¹ØÓÚÆäËûLinux¿¯Ðаæ¿ÉÄÜÉÔÓвî±ð¡£ÔÚÏÖʵʹÓÃÖУ¬Çëƾ֤×Ô¼ºµÄϵͳºÍÐèÇó¾ÙÐÐÏìÓ¦µÄÉèÖá£
Ï£ÍûÕâƪÎÄÕ¶ÔÄãÏàʶÔõÑùÔÚLinuxÉÏÉèÖø߿ÉÓÃÍøÂ縺ÔØƽºâÓÐËù×ÊÖú¡£ÈôÓÐÈκÎÎÊÌ⣬ÇëËæʱÌáÎÊ¡£
ÒÔÉϾÍÊÇÔõÑùÔÚLinuxÉÏÉèÖø߿ÉÓõÄÍøÂ縺ÔØƽºâµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡