우분투 keepalived 설치

우분투 keepalived 설치

1 패키지 설치[ | ]

apt-get install keepalived

2 설정 파일 작성[ | ]

vim /etc/keepalived/keepalived.conf
  • 서버 1
vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 50
    priority 100
    advert_int 1
    nopreempt
    authentication {
        auth_type PASS
        auth_pass $ place secure password here.
    }
    virtual_ipaddress {
        10.10.0.20
    }
}
  • 서버 2
vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 50
    priority 99
    advert_int 1
    nopreempt
    authentication {
        auth_type PASS
        auth_pass $ place secure password here.
    }
    virtual_ipaddress {
        10.10.0.20
    }
}
  • 서버 3
vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 50
    priority 98
    advert_int 1
    nopreempt
    authentication {
        auth_type PASS
        auth_pass $ place secure password here.
    }
    virtual_ipaddress {
        10.10.0.20
    }
}

3 서비스 시작[ | ]

  • 서버 1, 2, 3 모두 keepalived 시작
root@server1:~# /etc/init.d/keepalived start
 * Starting keepalived keepalived                                                   [ OK ]

4 확인 2[ | ]

root@server1:~# ps -ef | grep keepalived
root      2069     1  0 16:36 ?        00:00:00 /usr/sbin/keepalived
root      2070  2069  0 16:36 ?        00:00:00 /usr/sbin/keepalived
root      2071  2069  0 16:36 ?        00:00:00 /usr/sbin/keepalived
root      4338  4233  0 17:08 pts/0    00:00:00 grep --color=auto keepalived
root@server1:~# netstat -nlp | grep keepalived
raw   214656      0 0.0.0.0:112             0.0.0.0:*               7           2071/keepalived 
raw        0      0 0.0.0.0:112             0.0.0.0:*               7           2071/keepalived 
raw        0      0 0.0.0.0:255             0.0.0.0:*               7           2071/keepalived 
raw        0      0 0.0.0.0:255             0.0.0.0:*               7           2070/keepalived
root@server1:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 02:46:d8:13:57:9f brd ff:ff:ff:ff:ff:ff
    inet 10.10.0.11/23 brd 10.10.1.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 10.10.0.20/32 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fa80::402:d4fb:ea68:135c/64 scope link 
       valid_lft forever preferred_lft forever
root@workstation:~# ping 10.10.0.20 -c 2
PING 10.10.0.20 (10.10.0.20) 56(84) bytes of data.
64 bytes from 10.10.0.20: icmp_seq=1 ttl=64 time=0.249 ms
64 bytes from 10.10.0.20: icmp_seq=2 ttl=64 time=0.250 ms

--- 10.10.0.20 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.249/0.249/0.250/0.015 ms

5 같이 보기[ | ]

6 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}