Home | Mirror | Search

第 120 章 keepalived

目錄

1. 安裝
2. test

VRRP(Virtual Router Redundancy Protocol)協議

網站: http://www.keepalived.org/

http://www.lvwnet.com/vince/linux/Keepalived-LVS-NAT-Director-ProxyArp-Firewall-HOWTO.html

http://www.keepalived.org/LVS-NAT-Keepalived-HOWTO.html

http://archive.linuxvirtualserver.org/html/lvs-users/2002-12/msg00189.html

http://www.linuxvirtualserver.org/docs/ha/keepalived.html

1. 安裝

兩台已經安裝好Ubuntu的伺服器

分別安裝ssh以方便putty登錄

neo@master:~$ sudo apt-get install ssh
neo@slave:~$ sudo apt-get install ssh
		

install keepalived

neo@master:~$ apt-cache search lvs
keepalived - Failover and monitoring daemon for LVS clusters
neo@master:~$ sudo apt-get install keepalived
		

配置 keepalived.conf

neo@master:/etc/keepalived$ sudo touch keepalived.conf
neo@master:/etc/keepalived$ sudo vi keepalived.conf
		

例 120.1. keepalived.conf

			
vrrp_sync_group VG1 {
    group {
        VI_1
        VI_2
    }
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        172.16.0.1
    }
}

vrrp_instance VI_2 {
    state MASTER
    interface eth1
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        172.18.1.254
    }
}

virtual_server 172.16.0.1 80 {
    delay_loop 6
    lb_algo wlc
    lb_kind NAT
    persistence_timeout 600
    protocol TCP

    real_server 172.16.0.2 80 {
        weight 100
        TCP_CHECK {
            connect_timeout 3
        }
    }
    real_server 172.16.0.3 80 {
        weight 100
        TCP_CHECK {
            connect_timeout 3
        }
    }
    real_server 172.16.0.4 80 {
        weight 100
        TCP_CHECK {
            connect_timeout 3
        }
    }
}			
			
			

enable ip_forward

$ sudo sysctl -w net.ipv4.ip_forward=1

neo@master:~$ sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0		
		

Starting keepalived

neo@master:/etc/keepalived$ sudo /etc/init.d/keepalived start
Starting keepalived: keepalived.		
		

virtual_ipaddress

virtual_ipaddress { 172.16.0.1/16 } 正常直接寫IP即可.但在ubuntu中如果不寫子網掩碼,它會預設為172.16.0.1/32.

comments powered by Disqus