오픈소스/nginx

nginx mysql load balancing

세모데 2018. 10. 5. 11:56

tcp load balancing임으로 steam를 사용하여 조정 (client ip로 hash로 지정)

( http load balancing 은 upstream으로 )


stream { 

  upstream MyGroup { 

    # use IP address-based distribution 

    hash $remote_addr; 

    server 10.0.0.201 weight=2; 

    server 10.0.0.202; 

    server 10.0.0.203 backup; # use as backup only 

  } 

  server { 

    # listen on the default MySQL port 

    listen 3306;  

    proxy_pass MyGroup; # forward requests to upstream 

  } 

}