nginx¼¯ÈºÔõô×ö
nginx ¼¯ÈºÍ¨¹ý½«¶à¸öʵÀýÅþÁ¬ÆðÀ´ÊµÏÖ¸ºÔØƽºâºÍÈÝ´í£¬Ìá¸ß¿ÉÓÃÐÔ¡¢ÐÔÄܺͿÉÀ©Õ¹ÐÔ¡£°²ÅÅÒªÁì°üÀ¨»ùÓÚÐéÄâ ip ºÍ dns¡£¸ºÔØƽºâËã·¨ÓÐÂÖѯ¡¢¼ÓȨÂÖѯºÍ×îСÅþÁ¬¡£¹ÊÕÏתÒÆ»úÖÆͨ¹ý¿µ½¡¼ì²éºÍ×Ô¶¯¹ÊÕÏתÒÆÀ´Ó¦¶Ô¹ÊÕÏ¡£¿ÉÒÔʹÓà haproxy¡¢keepalived ºÍ ansible µÈ¹¤¾ß°²ÅźÍÖÎÀí nginx ¼¯Èº£¬´øÀ´¸ß¿ÉÓÃÐÔ¡¢¸ºÔØƽºâ¡¢¿ÉÀ©Õ¹ÐÔºÍïÔÌÍ£»úʱ¼äµÈÀûÒæ¡£
Nginx ¼¯ÈºµÄʵÏÖ
¼ò½é
Nginx ¼¯ÈºÊÇÒ»ÖÖͨ¹ý½«¶à¸ö Nginx ʵÀýÅþÁ¬ÔÚÒ»ÆðÒÔʵÏÖ¸ºÔØƽºâºÍÈÝ´íµÄÊÖÒÕ¡£Ëü¿ÉÒÔÌá¸ßÍøÕ¾ºÍÓ¦ÓóÌÐòµÄ¿ÉÓÃÐÔ¡¢ÐÔÄܺͿÉÀ©Õ¹ÐÔ¡£
°²ÅÅ
ÓÐÁ½ÖÖÖ÷ÒªµÄÒªÁìÀ´°²ÅÅ Nginx ¼¯Èº£º
»ùÓÚÐéÄâ IP£¨VIP£©µÄ¼¯Èº£º½¨Éè¾ßÓÐרÓà IP µØµãµÄ VIP£¬¸ÃµØµã½«Ö¸Ïò¼¯ÈºÖеÄÿ¸ö Nginx ʵÀý¡£ËùÓÐÇëÇ󶼽«·¢Ë͵½ VIP£¬È»ºóÓɸºÔØƽºâÆ÷½«ÇëÇóת·¢µ½Êʵ±µÄʵÀý¡£
»ùÓÚ DNS µÄ¼¯Èº£ºÊ¹Óà DNS ÂÖѯ»ò DNS ¸ºÔØƽºâÀ´½«ÓòÃûÓ³Éäµ½¼¯ÈºÖи÷¸ö Nginx ʵÀýµÄ IP µØµã¡£µ±¿Í»§¶Ë·¢³öÇëÇóʱ£¬DNS ЧÀÍÆ÷½«ÒÔÑ»··½·¨·µ»ØÕâЩ IP µØµãÖ®Ò»¡£
¸ºÔØƽºâ
Nginx ¼¯ÈºÖеĸºÔØƽºâËã·¨¾öÒéÁËÇëÇóÔõÑù·ÖÅɸø²î±ðµÄʵÀý¡£³£ÓõÄËã·¨°üÀ¨£º
ÂÖѯ£ºÒÀ´Î½«ÇëÇó·ÖÅɸøÿ¸öʵÀý¡£
¼ÓȨÂÖѯ£ºÆ¾Ö¤ÊµÀýµÄÈÝÁ¿»òÐÔÄÜΪÿ¸öʵÀý·ÖÅÉȨÖØ¡£
×îСÅþÁ¬£º½«ÇëÇó·ÖÅɸøÅþÁ¬Êý×îÉÙµÄʵÀý¡£
¹ÊÕÏתÒÆ
Nginx ¼¯Èº»¹Ìṩ¹ÊÕÏתÒƹ¦Ð§£¬µ±Ä³¸öʵÀý·ºÆð¹ÊÕÏʱ£¬¿ÉÒÔ×Ô¶¯½«ÇëÇóת·¢µ½ÆäËû¿ÉÓÃʵÀý¡£Õâͨ¹ýÒÔÏ»úÖÆʵÏÖ£º
¿µ½¡¼ì²é£º°´ÆÚ¼ì²éÿ¸öʵÀýµÄ¿µ½¡×´Ì¬£¬²¢±ê¼Ç²»¿ÉÓõÄʵÀý¡£
×Ô¶¯¹ÊÕÏתÒÆ£ºÈôÊǼì²âµ½¹ÊÕÏ£¬¸ºÔØƽºâÆ÷½«×èÖ¹½«ÇëÇóת·¢µ½¹ÊÕÏʵÀý£¬²¢½«Æä´Ó¼¯ÈºÖÐÒƳý¡£
°²ÅŹ¤¾ß
ÓжàÖÖ¹¤¾ß¿ÉÓÃÓÚ×ÊÖú°²ÅźÍÖÎÀí Nginx ¼¯Èº£¬°üÀ¨£º
HAProxy£ºÒ»¸ö¸ßÐÔÄܸºÔØƽºâÆ÷£¬¿ÉÒÔÓë Nginx Ò»ÆðʹÓá£
Keepalived£ºÒ»¸öÐéÄâ IP£¨VIP£©ÖÎÀí¹¤¾ß£¬¿ÉÒÔʵÏÖ¹ÊÕÏתÒÆ¡£
Ansible£ºÒ»¸öÉèÖÃÖÎÀí¹¤¾ß£¬¿ÉÒÔ×Ô¶¯»¯ Nginx ¼¯ÈºµÄ°²ÅźÍÖÎÀí¡£
ÀûÒæ
ʵÏÖ Nginx ¼¯ÈºÌṩÁËÒÔÏÂÀûÒ棺
¸ß¿ÉÓÃÐÔ£º±ÜÃâµ¥¸öʵÀý¹ÊÕϵ¼ÖÂЧÀÍÖÐÖ¹¡£
¸ºÔØƽºâ£ºÌá¸ßÍøÕ¾ºÍÓ¦ÓóÌÐòµÄÐÔÄÜ£¬ÓÈÆäÊÇÔÚ¸ßÁ÷Á¿ÇéÐÎÏ¡£
¿ÉÀ©Õ¹ÐÔ£ºÇáËÉÌí¼Ó»òɾ³ýʵÀýÒÔ˳ӦÐèÇóµÄÔöÌí¡£
ïÔÌÍ£»úʱ¼ä£º¹ÊÕÏתÒÆ»úÖÆ¿É¿ìËÙ½«ÇëÇóת·¢µ½¿ÉÓÃʵÀý£¬´Ó¶ø×î´óÏ޶ȵØïÔÌÍ£»úʱ¼ä¡£
ÒÔÉϾÍÊÇnginx¼¯ÈºÔõô×öµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡