Nginx+Keepalived 做负载均衡器

gamezouni 2013-07-28

1.安装 keepalived 
tar zxvf keepalived-XXXX.tar.gz
./configure --prefix=/usr/local/keepalived --with-kernel-dir=/usr/src/kernels/2.6.XXXXXXXX/
make && make install
cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
mkdir /etc/keepalived
cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
service keepalived start

2.Master与Backup 的配置文件

Master:

! Configuration File for keepalived
global_defs {
  notification_email {
      [email protected]
  }
  notification_email_from [email protected]
  smtp_server smtp.163.com
  smtp_connect_timeout 30
  router_id LVS_DEVEL
}
# VIP1
vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    mcast_src_ip 192.168.18.211
    priority 100
    advert_int 5
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.18.200
    }
}

 

BackUP:
! Configuration File for keepalived
global_defs {
  notification_email {
      [email protected]
  }
  notification_email_from [email protected]
  smtp_server smtp.163.com
  smtp_connect_timeout 30
  router_id LVS_DEVEL
}
# VIP1
vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    mcast_src_ip 192.168.18.212
    priority 90
    advert_int 5
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.18.200
    }
}

推荐阅读:

相关推荐