Linux 시스템 설정 nginx 의 부하 균형

2443 단어
Linux 시스템 설정 nginx 의 부하 균형
부하 균형 의 몇 가지 방식:
1. 폴 링: 기본적으로 시간 순서에 따라 모든 서버 에 한 번 씩 접근 합 니 다. 서버 가 다운 되면 자동 으로 삭 제 됩 니 다.
2. weight: 서버 의 방위 확률 은 weight 와 정비례 합 니 다. 이것 은 서버 설정 이 고 르 지 않 을 때 설정 할 수 있 습 니 다.
3.ip_hash: 모든 요청 한 ip 에 대해 hash 계산 을 하고 일정한 규칙 에 따라 해당 하 는 서버 를 분배 합 니 다 (session 공 유 를 해결 할 수 있 습 니 다).
4. fair: 각 서버 의 응답 시간 (rt) 에 따라 요청 을 분배 합 니 다. rt 는 우선 분 배 를 알 고 있 습 니 다.
5.url_hash: url 에 접근 한 hash 값 에 따라 요청 을 분배 합 니 다.
NGINX 프로필:

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
  worker_connections 1024;
}

http {
  log_format main '$remote_addr - $remote_user [$time_local] "$request" '
           '$status $body_bytes_sent "$http_referer" '
           '"$http_user_agent" "$http_x_forwarded_for"';

  access_log /var/log/nginx/access.log main;

  sendfile      on;
  tcp_nopush     on;
  tcp_nodelay     on;
  keepalive_timeout  65;
  types_hash_max_size 2048;
  
  
  include       blockip.conf;    #  IP
  include       /etc/nginx/mime.types;
  default_type    application/octet-stream;

  # Load modular configuration files from the /etc/nginx/conf.d directory.
  # See http://nginx.org/en/docs/ngx_core_module.html#include
  # for more information.
  include /etc/nginx/conf.d/*.conf;

  upstream www.  .com {
  server IP1:  ;            #   1
  server IP2:  ;            #   2
  ip_hash;               #       
  }

  server {
    listen    80 default_server;   #NGINX        
    listen    [::]:80 default_server;
    server_name IP;           #NGINX        IP
    root     /usr/share/nginx/html; #NGINX HTML   

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
      proxy_pass  http://www.  .com; #nginx     
   }

    error_page 404 /404.html;
      location = /40x.html {      #404  
    }

    error_page 500 502 503 504 /500.html;
      location = /500.html {      #500  
    }
  }
}


읽 어 주 셔 서 감사합니다. 여러분 에 게 도움 이 되 기 를 바 랍 니 다. 본 사이트 에 대한 여러분 의 지지 에 감 사 드 립 니 다!

좋은 웹페이지 즐겨찾기