keepalivedè¬ç¿ä¼
- 2007.08.13
- ã¤ã³ãã©, åå¼·ä¼è³æ
ã´ã¼ã«
- VRRPã«ããä»®æ³IPæã¡åãã®ä»çµã¿ãç解ãã
- keepalivedãå©ç¨ããHAã¯ã©ã¹ã¿ãæ§ç¯ã§ãã
LVSå¨ãã¯ãã·ã§ã
åºç¤ç¥èç·¨
åºæ¬çãªè³æ
ãã¨ã¯æã¾ã¨ãã社å¤ç§ã®è³æ
keepalivedã£ã¦ä½ã¹ã
Linuxã«ãããVRRPã®å®è£ ã®ã²ã¨ã¤ãHAã¯ã©ã¹ã¿ãå®ç¾ãããã¼ã¢ã³ã
HAã¯ã©ã¹ã¿ã®ãã¹ã¿æ©ã¨ããã¯ã¢ããæ©ã®ä¸¡æ¹ã§åä½ããããã¨ã§ç°¡åã«HAã¯ã©ã¹ã¿ãã§ããã
ã¾ãLVSãå©ç¨ããè² è·åæ£ã¯ã©ã¹ã¿ã®ç¨¼åããµãã¼ãããæ©è½ãããã
VRRP
ä»®æ³IPãè¤æ°æ©å¨ã§å ±æããä¸çªãã©ã¤ãªãªãã£ã®é«ãæ©å¨ããã®IPãæã¤ä»çµã¿ã
æ¬æ¥ã¯ã«ã¼ã¿åé·åã®ããã®ãããã³ã«ã ãããµã¼ãã®åé·åã«ã使ç¨ã§ããã
ã¤ã¾ãHAã¯ã©ã¹ã¿ãä½æå¯è½ã
åè : Virtual Router Redundancy Protocol - Wikipedia
è¨å®ãã¡ã¤ã«ã®æ¸ãæ¹
è¨å®ãã¡ã¤ã«ã¯/etc/keepalived/keepalived.confã
è¨å®ã®åæ
- ã¯ã©ã¹ã¿ã®ä»®æ³IPã¯192.168.1.10
- MASTERã®å®IPã¯192.168.1.11
- BACKUPã®å®IPã¯192.168.1.12
- ãã¨ã§ããããã®ä»®æ³IPãæããã
MASTERå´
MASTERã§ãã192.168.1.11ã®ãµã¼ãã«ã¯ä»¥ä¸ã®å 容ã®ãã¡ã¤ã«ãç½®ãã
# Configuration File for keepalived
global_defs {
notification_email {
[email protected]
}
notification_email_from [email protected]
smtp_server localhost
smtp_connect_timeout 30
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.1.10
}
}
BACKUPå´
BACKUPã§ãã192.168.1.12ã®ãµã¼ãã«ã¯ä»¥ä¸ã®å 容ã®ãã¡ã¤ã«ãç½®ãã
# Configuration File for keepalived
global_defs {
notification_email {
[email protected]
}
notification_email_from [email protected]
smtp_server localhost
smtp_connect_timeout 30
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.1.10
}
}
è¨å®å¤ã®æå³
以ä¸å°ãã ã説æã¨ãè¨å®ä¸ã®æ³¨æç¹ã¨ãã
global_defs
keepalivedã®åä½å ¨è¬ã«é¢ä¿ããã¯ã©ã¹ã¿å ã®ãµã¼ãã«ç°å¸¸ãçããéã«ã¡ã¼ã«ãé£ã°ãè¨å®ãªã©ãè¡ãã»ã¯ã·ã§ã³ã
vrrp_instance
ä»®æ³ã«ã¼ã¿ãå®ç¾©ããã»ã¯ã·ã§ã³ã
ä»®æ³ã«ã¼ã¿ã¯ããã¤ã§ãå®ç¾©ã§ããã¾ãã²ã¨ã¤ã®ä»®æ³ã«ã¼ã¿ãè¤æ°ã®ä»®æ³IPãæã¤ãã¨ãåºæ¥ãã
advert_int
æ»æ´»ç¢ºèªã®ã¤ã³ã¿ã¼ãã«ã
virtual_router_id
å±ãã¦ãä»®æ³ã«ã¼ã¿ã®èå¥IDã
åä¸ãããã¯ã¼ã¯å ã«vrrpã§åä½ãã¦ããä»®æ³ã«ã¼ã¿ãããå ´åãvirtual_router_idã¯ä»ã®ä»®æ³ã«ã¼ã¿ã¨ãã¶ããªãå¤ã§ããå¿ è¦ãããã
state, priority
MASTERã®priorityã«ã¯BACKUPã®priorityã®å¤ãã大ããªãã®ãè¨å®ããã
å®è·µç·¨ - åºæ¬ -
è¨å®ãã¡ã¤ã«ãç·¨éãã¦ä»®æ³IPãå¢ããããæ¸ãããããã¦ã¿ãã
- è¨å®ãã¡ã¤ã«ã®ç·¨é
vrrp_instance VI_1 {
...
virtual_ipaddress {
192.168.1.10
192.168.1.101
192.168.1.102
192.168.1.103
192.168.1.104
}
...
}
ãã§ã¤ã«ãªã¼ãã¼ - ãã¹ã¿ããããã¯ã¢ããã¸ã®åãæ¿ã
- çæ¹ã±ã¼ãã«ãæã
- 両æ©ã®IPã確èªãã
$ /sbin/ip address list
ãã§ã¤ã«ãã㯠- ããã¯ã¢ãããããã¹ã¿ã¸ã®åãæ¿ã
- æããã±ã¼ãã«ãæ»ã
- 両æ©ã®IPã確èªãã
$ /sbin/ip address list
ãã¹ã¿ã¨ããã¯ã¢ããã®è¨å®ãå ¥ãæ¿ãã¦åãæ¿ãä½æ¥ããã¦ã¿ã
- è¨å®ãã¡ã¤ã«ã®ç·¨é
- æåã®ç¶æ ã§ãã¹ã¿ãå ¥ãæ¿ãã£ã¦ãããã¨ã確èªãã
- ãã§ã¤ã«ãªã¼ãã¼ã¨ãã§ã¤ã«ããã¯ã確èªãã
å®è·µç·¨ - å¿ç¨ -
ãã§ã¤ã«ãªã¼ãã¼æã¨ãã§ã¤ã«ããã¯æã«ã¹ã¯ãªãããå®è¡ãã
- èªåããã¹ã¿ã«ãªã£ãå ´åï¼ä¸»ã«ãã¹ã¿ã®èµ·åæããã§ã¤ã«ãªã¼ãã¼æï¼ã«hoge.shãå®è¡
vrrp_instance VI_1 {
...
notify_master /etc/keepalived/hoge.sh
...
}
- èªåãããã¯ã¢ããã«ãªã£ãå ´åï¼ä¸»ã«ãã§ã¤ã«ããã¯æï¼ã«hage.shãå®è¡
vrrp_instance VI_1 {
...
notify_backup /etc/keepalived/hage.sh
...
}
21å以ä¸ã®ä»®æ³IP
- virtual_ipaddressã«21å以ä¸è¿½å ãã¦ã©ããªãã試ã
vrrp_instance VI_1 {
...
virtual_ipaddress {
192.168.1.10
...(18åç¥)
192.168.1.119
192.168.1.120
192.168.1.121
192.168.1.122
}
...
}
- 21åç®ä»¥ä¸ã¯virtual_ipaddress_excludedã«è¿½å ãã
vrrp_instance VI_1 {
...
virtual_ipaddress {
192.168.1.10
...(18åç¥)
192.168.1.119
}
virtual_ipaddress_excluded {
192.168.1.120
192.168.1.121
192.168.1.122
}
...
}
åè
vrrpã¯ãããã¯ã¼ã¯ãªæ»æ´»ç¢ºèªããè¡ããªãã
ãªã®ã§ãµã¼ãã¹ã®æ»æ´»ç¢ºèªãè¡ãããå ´åã¯å¥éãªãããã®ä»çµã¿ãå¿
è¦ã
ããã«é¢ãã¦ã¯ã¯ã©ã¹ã¿ä¸ã®åãµã¼ããèªå·±ã®ãµã¼ãã¹ç£è¦ãè¡ã£ã¦ããµã¼ãã¹ããã¦ã³ãããkeepalivedãåæ¢ããããã¨ãã£ãäºãè¡ãã°ããµã¼ãã¹ãåæ¢ãããµã¼ããã¯ã©ã¹ã¿ããåãé¢ããã¨ãã§ããã