Nginx负载均衡+keepalived双机热备

环境:
web服务器:
web1:192.168.1.51
web2:192.168.1.52
负载均衡:
LB主:192.168.1.41
LB从;192.168.1.42
VIP:192.168.1.44



安装配置nginx负载均衡(主从都一样)
#tar zxf nginx-1.1.2.tar.gz
# ./configure --user=www --group=www --prefix=/usr/local/nginx--with-http_stub_status_module --with-http_gzip_static_module--with-http_ssl_module
#make && make install
# vim /usr/local/nginx/conf/nginx.conf
#iptables -A INPUT -p vrrp -jACCEPT    //开防火墙需要添加规则,否则备用机检测不到主机会认为主机  死掉而强制切换为主机
user  www;
worker_processes  1;
#pid       /data/www/logs/nginx.pid;


events {
    useepoll;
   worker_connections  65535;
}


http {
   include      mime.types;
   default_type  application/octet-stream;


   connection_pool_size   256;
   client_max_body_size   20m;
   client_header_buffer_size   32k;
   large_client_header_buffers   4 32k;


   sendfile       on;
   tcp_nopush   on;
   tcp_nodelay   on;



   keepalive_timeout   60;
   client_header_timeout   10;
   client_body_timeout   10;
   send_timeout       10;



   gzip  on;
   gzip_min_length   1k;
   gzip_buffers   4 16k;
   gzip_http_version   1.1;
   gzip_comp_level   2;
   gzip_types   text/plain application/x-javascript text/css aplication/xml;
   gzip_vary   on;


   fastcgi_cache_path   /usr/local/nginx/fastcgi_cachelevels=1:2   keys_zone=TEST:10m   inactive=5m;
   fastcgi_connect_timeout   300;
   fastcgi_send_timeout   300;
   fastcgi_read_timeout   300;
   fastcgi_buffer_size   64k;
   fastcgi_buffers      4    64k;
   fastcgi_busy_buffers_size   128k;
   fastcgi_cache_valid   200   302    1h;
   fastcgi_cache_valid   301    1d;
   fastcgi_cache_valid   any    1m;





    upstreamlb.os.com {
#   ip_hash;
       server 192.168.1.51;
       server 192.168.1.52;
#   
posted @ 2013-10-29 14:03  消磨_时间  阅读(90)  评论(0)    收藏  举报