Keepalived Basic
Loadbalancing & High-Availability 를 위한 Keepalived 설정 및 테스트 Keepalived https://www.keepalived.org/{:target="_blank"} VRRP 를 활용 가상IP (VIP) 기반 서버 다중화 도구 VRRP 는 여러 대의 라우터를 그룹으로 묶어 하나의 가상 IP 어드레스를 부여, 마스터로 지정된 라우터 장애시 VRRP 그룹 내의 백업 라우터가 마스터로 자동 전환되는 프로토콜입니다. Install # install $ sudo yum install keepalived # service start $ sudo systemctl start keepalived $ sudo systemctl status keepalived ● keepalived.service - LVS and VRRP High Availability Monitor Loaded: loaded (/usr/lib/systemd/system/keepalived.service; disabled; vendor preset: disabled) Active: active (running) since 화 2021-10-26 11:37:04 KST; 4s ago Process: 18356 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS) Main PID: 18357 (keepalived) Tasks: 3 Memory: 1.6M CGroup: /system.slice/keepalived.service ├─18357 /usr/sbin/keepalived -D ├─18358 /usr/sbin/keepalived -D └─18359 /usr/sbin/keepalived -D 10월 26 11:37:05 node1 Keepalived_vrrp[18359]: VRRP_Instance(VI_1) forcing a new MASTER ...on 10월 26 11:37:06 node1 Keepalived_vrrp[18359]: VRRP_Instance(VI_1) Transition to MASTER STATE 10월 26 11:37:07 node1 Keepalived_vrrp[18359]: VRRP_Instance(VI_1) Entering MASTER STATE 10월 26 11:37:07 node1 Keepalived_vrrp[18359]: VRRP_Instance(VI_1) setting pro 10월 26 11:37:07 node1 Keepalived_vrrp[18359]: Sending gratuitous ARP on eth0 for 192.16...00 10월 26 11:37:07 node1 Keepalived_vrrp[18359]: VRRP_Instance(VI_1) Sending/queueing grat...00 10월 26 11:37:07 node1 Keepalived_vrrp[18359]: Sending gratuitous ARP on eth0 for 192.16...00 10월 26 11:37:07 node1 Keepalived_vrrp[18359]: Sending gratuitous ARP on eth0 for 192.16...00 10월 26 11:37:07 node1 Keepalived_vrrp[18359]: Sending gratuitous ARP on eth0 for 192.16...00 10월 26 11:37:07 node1 Keepalived_vrrp[18359]: Sending gratuitous ARP on eth0 for 192.16...00 Hint: Some lines were ellipsized, use -l to show in full. 기본 설정 https://www.redhat.com/sysadmin/keepalived-basics{:target="_blank"} https://www.redhat.com/sysadmin/advanced-keepalived{:target="_blank"} 테스트 환경 CentOS 7 (Hyper-v) node1 (MASTER) : 192.168.137.201 node2 (BACKUP) : 192.168.137.202 VIP : 192.168.137.200 /etc/keepalived/keepalived.conf vrrp_instance : 인터페이스에서 실행되는 프로토콜의 개별 인스턴스 정의 state : 인스턴스에서 시작해야 하는 초기 상태 interface : 네트워크 인터페이스 virtual_router_id : 네트워크 가상 ID priority : 우선 순위 advert_int : VRRP 패킷 송신 간격 (sec) authentication : 서로 서버간, 인증 계정 정보 virtual_ipaddress : 가상 IP vip MASTER 설정 : 192.168.137.201 vrrp_instance VI_1 { state MASTER interface eth0 virtual_router_id 51 priority 210 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.137.200 } } BACKUP 설정 : 192.168.137.202 vrrp_instance VI_1 { state BACKUP interface eth0 virtual_router_id 51 priority 200 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.137.200 } } MASTER 노드에 우선순위 priority 210 를 높게 줌 ...