尊龙凯时人生就是博

ÔõÑùÔÚLinuxÉÏÉèÖø߿ÉÓõĶ˿Úת·¢

ÔõÑùÔÚlinuxÉÏÉèÖø߿ÉÓõĶ˿Úת·¢

Ò»¡¢Åä¾°¸ÅÊö

ÔÚÂþÑÜʽϵͳµÄ¼Ü¹¹ÖÐ £¬¶Ë¿Úת·¢ÊǷǾ­³£¼ûµÄÒ»ÖÖÍøÂçÊÖÒÕ¡£Í¨¹ý¶Ë¿Úת·¢ £¬¿ÉÒÔδÀ´×ÔÍⲿÍøÂçµÄÅþÁ¬ÇëÇóת·¢µ½ÄÚ²¿½ÚµãÉÏ £¬´Ó¶øʵÏÖ¶ÔÍâЧÀ͵ĸ߿ÉÓÃÐԺ͸ºÔØƽºâ¡£ÔÚLinux²Ù×÷ϵͳÉÏ £¬ÎÒÃÇ¿ÉÒÔʹÓÃһЩ¹¤¾ßºÍÉèÖÃÀ´ÊµÏָ߿ÉÓõĶ˿Úת·¢¡£±¾ÎĽ«ÏêϸÏÈÈÝÔõÑùʹÓÃLinux²Ù×÷ϵͳÉèÖúÍÖÎÀí¸ß¿ÉÓõĶ˿Úת·¢¡£

¶þ¡¢Ê¹ÓÃiptablesʵÏֶ˿Úת·¢

iptablesÊÇLinuxϵͳÉϳ£ÓõķÀ»ðǽÈí¼þ £¬Ò²¿ÉÒÔÓÃÀ´ÊµÏֶ˿Úת·¢¹¦Ð§¡£ÒÔÏÂÊÇÒ»¸öʹÓÃiptablesʵÏֶ˿Úת·¢µÄʾÀý£º

Ê×ÏÈ £¬ÐèҪȷÈÏiptablesÈí¼þÒѾ­×°ÖÃÔÚϵͳÉÏ¡£ÔÚÖÕ¶ËÉÏÖ´ÐÐÒÔÏÂÏÂÁ

sudo apt-get install iptables

µÇ¼ºó¸´ÖÆ

ÉèÖö˿Úת·¢¹æÔò¡£¼ÙÉèÎÒÃÇÐèҪδÀ´×Ô¹«ÍøIPµÄ»á¼ûÇëÇóת·¢µ½ÄÚÍøµÄij¸ö½ÚµãÉÏ £¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî¾ÙÐж˿Úת·¢ÉèÖãº

sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j DNAT --to 192.168.0.10:80
sudo iptables -A FORWARD -p tcp -d 192.168.0.10 --dport 80 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

µÇ¼ºó¸´ÖÆ

ÆäÖÐ £¬eth0ΪÍⲿÍøÂç½Ó¿Ú £¬192.168.0.10ΪÄÚÍø½ÚµãµÄIPµØµã £¬80ΪÐèҪת·¢µÄ¶Ë¿ÚºÅ¡£

ÉúÑÄÉèÖᣵ±ÒÔÉÏÉèÖÃÍê³Éºó £¬ÎÒÃÇÐèÒª½«ÉèÖÃÉúÑĵ½iptablesÉèÖÃÎļþÖÐ £¬ÒÔ±ãϵͳÖØÆôºó×Ô¶¯¼ÓÔØÉèÖá£Ö´ÐÐÒÔÏÂÏÂÁîÉúÑÄÉèÖãº

sudo sh -c "iptables-save > /etc/iptables.rules"

µÇ¼ºó¸´ÖÆ

Ìí¼Ó×ÔÆô¶¯¾ç±¾¡£ÎªÁËʹÉèÖÃÔÚϵͳÆô¶¯Ê±×Ô¶¯¼ÓÔØ £¬ÎÒÃÇ¿ÉÒÔ½¨ÉèÒ»¸ö×ÔÆô¶¯¾ç±¾ £¬²¢Ìí¼Óµ½ÏµÍ³µÄÆô¶¯Ð§ÀÍÖС£½¨ÉèÒ»¸öÃûΪiptables.shµÄ¾ç±¾ £¬ÄÚÈÝÈçÏ£º

#!/bin/sh
/sbin/iptables-restore < /etc/iptables.rules

µÇ¼ºó¸´ÖÆ

½«¾ç±¾ÉúÑĵ½/etc/init.dĿ¼Ï £¬²¢Îª¾ç±¾Ìí¼ÓÖ´ÐÐȨÏÞ£º

sudo chmod +x /etc/init.d/iptables.sh

µÇ¼ºó¸´ÖÆ

È»ºó £¬½«¾ç±¾Ìí¼Óµ½Æô¶¯Ð§ÀÍÖУº

sudo update-rc.d iptables.sh defaults 99

µÇ¼ºó¸´ÖÆ

ÖÁ´Ë £¬ÎÒÃÇÍê³ÉÁËʹÓÃiptablesʵÏֶ˿Úת·¢µÄÉèÖá£

Èý¡¢Ê¹ÓÃHAProxyʵÏָ߿ÉÓõĶ˿Úת·¢

³ýÁËʹÓÃiptablesÍâ £¬ÎÒÃÇ»¹¿ÉÒÔʹÓÃHAProxyÀ´ÊµÏָ߿ÉÓõĶ˿Úת·¢¡£HAProxyÊÇÒ»¿î¿É¿¿µÄ¡¢¸ßÐÔÄܵĸºÔØƽºâÈí¼þ £¬ÊÊÓÃÓÚÂþÑÜʽϵͳÖеĶ˿Úת·¢ÐèÇó¡£ÒÔÏÂÊÇÒ»¸öʹÓÃHAProxyÉèÖø߿ÉÓõĶ˿Úת·¢µÄʾÀý£º

Ê×ÏÈ £¬ÐèҪȷÈÏHAProxyÈí¼þÒѾ­×°ÖÃÔÚϵͳÉÏ¡£ÔÚÖÕ¶ËÉÏÖ´ÐÐÒÔÏÂÏÂÁ

sudo apt-get install haproxy

µÇ¼ºó¸´ÖÆ

±à¼­HAProxyµÄÉèÖÃÎļþ¡£·­¿ªÉèÖÃÎļþ/etc/haproxy/haproxy.cfg £¬Ìí¼ÓÒÔÏÂÄÚÈÝ£º

frontend http-in
     bind *:80
     default_backend backend_servers

backend backend_servers
     balance roundrobin
     server server1 192.168.0.10:80 check
     server server2 192.168.0.11:80 check

µÇ¼ºó¸´ÖÆ

ÆäÖÐ £¬192.168.0.10ºÍ192.168.0.11ΪÄÚ²¿½ÚµãµÄIPµØµã £¬80ΪÐèҪת·¢µÄ¶Ë¿ÚºÅ¡£

ÖØÆôHAProxyЧÀÍ¡£Ö´ÐÐÒÔÏÂÏÂÁîÖØÆôHAProxyЧÀÍ£º

sudo service haproxy restart

µÇ¼ºó¸´ÖÆ

´Ëʱ £¬HAProxy½«Æ¾Ö¤ÉèÖÃÎļþÖеĹæÔò £¬½«»á¼ûÇëÇóת·¢µ½ÄÚ²¿½ÚµãÉÏ £¬ÊµÏָ߿ÉÓõĶ˿Úת·¢¡£

ËÄ¡¢×ܽá

±¾ÎÄÏÈÈÝÁËÔÚLinux²Ù×÷ϵͳÉÏÉèÖø߿ÉÓõĶ˿Úת·¢µÄÒªÁì £¬»®·Öͨ¹ýiptablesºÍHAProxyÁ½ÖÖ·½·¨¾ÙÐÐʾÀý¡£ÔÚÏÖʵӦÓÃÖÐ £¬ÎÒÃÇ¿ÉÒÔƾ֤ÏêϸÐèÇóÑ¡ÔñºÏÊʵķ½·¨¾ÙÐÐÉèÖúͰ²ÅÅ¡£Í¨¹ýºÏÀíʹÓö˿Úת·¢ £¬¿ÉÒÔÌá¸ßϵͳµÄ¿É¿¿ÐԺ͸ºÔØÄÜÁ¦ £¬Ìṩ¸üÎȹ̺͸ßЧµÄЧÀÍ¡£

ÒÔÉϾÍÊÇÔõÑùÔÚLinuxÉÏÉèÖø߿ÉÓõĶ˿Úת·¢µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ