Chinaunix首页 | 论坛 | 博客
  • 博客访问: 642758
  • 博文数量: 198
  • 博客积分: 4256
  • 博客等级: 上校
  • 技术积分: 1725
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-15 13:12
文章分类

全部博文(198)

文章存档

2012年(12)

2011年(39)

2010年(135)

2009年(12)

我的朋友

分类: LINUX

2010-08-11 17:13:28

sudo apt-get install keepalived (ipvsadm)

#master server
cat > /etc/keepalived/keepalived.conf <
vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
#    mcast_src_ip 192.168.39.80
    priority 100 
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 123456
    }
    virtual_ipaddress {
       192.168.39.88
    }
}
EOF

#slave_server
cat > /etc/keepalived/keepalived.conf <
vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
#    mcast_src_ip 192.168.39.81
    priority 50
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 123456
    }
    virtual_ipaddress {
       192.168.39.88
    }
}
EOF


nginx配置列子(master、backup配置相同)

    upstream admin.backend {
        server 127.0.0.1:81;
        server 192.168.39.81:81;
        fair;
        }

    server {
        listen       80;
        server_name  admin.365s.com.cn;

        location / {
        proxy_pass
        proxy_set_header   Host             $host;  
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        }
        access_log  /var/log/nginx/admin_up.log  main;
    }

    server {
        listen       81;
        server_name  admin.backend.com;

        set $www_root /home/web/mgt/htdocs;

        location / {
            root   $www_root;
            index  index.html index.htm index.php;
            autoindex on;
        }

        location ~ \.php$ {
            root           $www_root;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $www_root$fastcgi_script_name;
            include        fastcgi_params;
        }
        access_log  /var/log/nginx/admin_bk.log  main;
#       access_log off;
    }

阅读(1061) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~