璐熻浇鍧囪

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了璐熻浇鍧囪相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/for' title='for'>for   cal   鑺傜偣   roc   web   href   瀹樼綉   received   鏈嶅姟   

鐩殑

  • 瑙e喅鍗曚釜鑺傜偣鍘嬪姏杩囧ぇ锛岄€犳垚 Web 鏈嶅姟鍝嶅簲杩囨參锛屼弗閲嶇殑鎯呭喌涓嬪鑷存湇鍔$槴鐥紝鏃犳硶姝e父鎻愪緵鏈嶅姟銆?/li>
  • 鎻愬崌 Web 鏈嶅姟鍣ㄥ搷搴旀€ц兘

nginx
  • HAProxy
  • LVS
  • Apache
  • http://nginx.org/en/docs/http/load_balancing.html

    • 杞惊锛堥粯璁わ級

    Nginx鏍规嵁璇锋眰娆℃暟锛屽皢姣忎釜璇锋眰鍧囧寑鍒嗛厤鍒版瘡鍙版湇鍔?/p>

    • 鍣ㄦ渶灏戣繛鎺?/li>

    灏嗚姹傚垎閰嶇粰杩炴帴鏁版渶灏戠殑鏈嶅姟鍣ㄣ€侼ginx浼氱粺璁″摢浜涙湇鍔″櫒鐨勮繛鎺ユ暟鏈€灏戙€?/p>

    • IP Hash

    缁戝畾澶勭悊璇锋眰鐨勬湇鍔″櫒銆傜涓€娆¤姹傛椂锛屾牴鎹瀹㈡埛绔殑IP绠楀嚭涓€涓狧ASH鍊硷紝灏嗚姹傚垎閰嶅埌闆嗙兢涓殑鏌愪竴鍙版湇鍔″櫒涓娿€傚悗闈㈣瀹㈡埛绔殑鎵€鏈夎姹傦紝閮藉皢閫氳繃HASH绠楁硶锛屾壘鍒颁箣鍓嶅鐞嗚繖鍙板鎴风璇锋眰鐨勬湇鍔″櫒锛岀劧鍚庡皢璇锋眰浜ょ粰瀹冩潵澶勭悊銆?/p>

    浠ヨ疆璇㈣礋杞界瓥鐣ヤ负瀹炰緥

    1. 濡備笅涓恒€岃疆璇€嶉厤缃枃浠?Nginx.conf:
    # For more information on configuration, see:
    #   * Official English Documentation: http://nginx.org/en/docs/
    #   * Official Russian Documentation: http://nginx.org/ru/docs/
    
    user nginx;
    worker_processes auto;
    error_log /var/log/nginx/error.log;
    pid /run/nginx.pid;
    
    # Load dynamic modules. See /usr/share/nginx/README.dynamic.
    include /usr/share/nginx/modules/*.conf;
    
    events {
        worker_connections 65535;
    }
    
    stream {
    
        log_format basic 鈥?remote_addr [$time_local] 鈥?                     鈥?protocol $status $bytes_sent $bytes_received 鈥?                     鈥?session_time鈥?
    
        upstream test_cluster {
             server 192.168.1.100:4010 weight=2 max_fails=3 fail_timeout=15;;
             server 192.168.1.101:4011 weight=3;
             server 192.168.1.102:4012 weight=1;
             server 192.168.1.103:4013 weight=4;
        }
       server {
          listen 50052;
          proxy_connect_timeout 1s;
          proxy_pass test_cluster;
          access_log  /var/log/nginx/test_cluster.log basic;
          error_log  /var/log/nginx/ptest_cluster-error.log debug;
        }
    
    }
    1. 閰嶇疆鏂囦欢涓弬鏁拌鏄庯細
    • proxy_pass test_cluster锛氳〃绀哄皢鎵€鏈夎姹傝浆鍙戝埌 test_cluster 鏈嶅姟鍣ㄧ粍涓厤缃殑鏌愪竴鍙版湇鍔″櫒涓?/li>
    • upstream妯″潡锛氶厤缃弽鍚戜唬鐞嗘湇鍔″櫒缁勶紝Nginx浼氭牴鎹厤缃紝灏嗚姹傚垎鍙戠粰缁勯噷鐨勬煇涓€鍙版湇鍔″櫒銆倀est_cluster 鏄湇鍔″櫒缁勭殑鍚嶇О銆?/li>
    • upstream妯″潡涓嬬殑server鎸囦护锛氶厤缃鐞嗚姹傜殑鏈嶅姟鍣↖P鎴栧煙鍚嶏紝绔彛鍙€夛紝涓嶉厤缃粯璁や娇鐢?0绔彛銆傞€氳繃涓婇潰鐨勯厤缃紝Nginx榛樿灏嗚姹備緷娆″垎閰嶇粰100锛?01锛?02鏉ュ鐞嗭紝鍙互閫氳繃淇敼涓嬮潰杩欎簺鍙傛暟鏉ユ敼鍙橀粯璁ょ殑鍒嗛厤绛栫暐锛?
      • weight

        榛樿涓?锛屽皢璇锋眰骞冲潎鍒嗛厤缁欐瘡鍙皊erver锛岄厤缃?weight 鍊硷紝鍗抽厤缃垎閰嶈姹傛潈閲?/p>

      • max_fails

        榛樿涓?銆傛煇鍙癝erver鍏佽璇锋眰澶辫触鐨勬鏁帮紝瓒呰繃鏈€澶ф鏁板悗锛屽湪fail_timeout鏃堕棿鍐咃紝鏂扮殑璇锋眰灏嗕笉浼氬垎閰嶇粰杩欏彴鏈哄櫒銆傚鏋滆缃负0锛孨ginx浼氬皢杩欏彴Server缃负姘镐箙鏃犳晥鐘舵€侊紝鐒跺悗灏嗚姹傚彂缁欏畾涔変簡proxy_next_upstream, fastcgi_next_upstream, uwsgi_next_upstream, scgi_next_upstream, and memcached_next_upstream鎸囦护鏉ュ鐞嗚繖娆¢敊璇殑璇锋眰

      • fail_timeout

        榛樿涓?0绉掋€傛煇鍙癝erver杈惧埌max_fails娆″け璐ヨ姹傚悗锛屽湪fail_timeout鏈熼棿鍐咃紝nginx浼氳涓鸿繖鍙癝erver鏆傛椂涓嶅彲 鐢紝涓嶄細灏嗚姹傚垎閰嶇粰瀹冦€傦紙192.168.0.100杩欏彴鏈哄櫒锛屽鏋滄湁3娆¤姹傚け璐ワ紝nginx鍦?5绉掑唴锛屼笉浼氬皢鏂扮殑璇锋眰鍒嗛厤缁欏畠銆傦級


    鍙傝€冭祫鏂欙細

    以上是关于璐熻浇鍧囪的主要内容,如果未能解决你的问题,请参考以下文章

    璐熻浇鍧囪 涔?LVS

    浜斿垎閽熺湅鎳?Nginx 璐熻浇鍧囪

    nginx瀹炵幇璐熻浇鍧囪

    鍩轰簬Haproxy鏋勫缓璐熻浇鍧囪 闆嗙兢

    nginx鍩轰簬HTTP瀹炵幇璐熻浇鍧囪 tomcat

    2019.9.21 Tomcat缃戦〉浣嶇疆鐨勪慨鏀瑰強璐熻浇鍧囪