阿里云配置 keepalived
1 安装 keepalived
yum install keepalived mv /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.bak |
2 配置
[root@rac1 ~]# vim /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } notification_email_from Alexandre.Cassen@firewall.loc smtp_server 192.168.200.1 smtp_connect_timeout 30 router_id LVS_DEVEL vrrp_skip_check_adv_addr vrrp_garp_interval 0 vrrp_gna_interval 0 } vrrp_instance VI_1 { state MASTER #设置ECS1实例为主实例 interface eth0 #设置网卡名,本示例配置为eth0 virtual_router_id 51 nopreempt priority 100 #设置优先级,数字越大,优先级越高,本示例配置主用实例优先级为100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } unicast_src_ip 192.168.10.1 #设置ECS实例的私网IP地址 unicast_peer { 192.168.10.2 #对端ECS实例的私网IP地址 } virtual_ipaddress { 192.168.10.3 #设置HaVip的IP地址 192.168.10.5 } notify_master "/etc/keepalived/notify_action.sh MASTER" notify_backup "/etc/keepalived/notify_action.sh BACKUP" notify_fault "/etc/keepalived/notify_action.sh FAULT" notify_stop "/etc/keepalived/notify_action.sh STOP" garp_master_delay 1 garp_master_refresh 5 track_interface { eth0 #设置ECS实例网卡名,本示例配置为eth0 } } vrrp_instance VI_2 { state BACKUP #设置ECS1实例为备用实例 interface eth0 #设置网卡名,本示例配置为eth0 virtual_router_id 52 nopreempt priority 10 #设置优先级,数字越大,优先级越高,本示例配置备用实例优先级为10 advert_int 1 authentication { auth_type PASS auth_pass 1111 } unicast_src_ip 192.168.10.1 #设置ECS实例的私网IP地址 unicast_peer { 192.168.10.2 #对端ECS实例的私网IP地址 } virtual_ipaddress { 192.168.10.4 #设置HaVip的IP地址 } notify_master "/etc/keepalived/notify_action.sh MASTER" notify_backup "/etc/keepalived/notify_action.sh BACKUP" notify_fault "/etc/keepalived/notify_action.sh FAULT" notify_stop "/etc/keepalived/notify_action.sh STOP" garp_master_delay 1 garp_master_refresh 5 track_interface { eth0 #设置ECS实例网卡名,本示例配置为eth0 } } service keepalived start # 启动服务 [root@rac2 ~]# vim /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } notification_email_from Alexandre.Cassen@firewall.loc smtp_server 192.168.200.1 smtp_connect_timeout 30 router_id LVS_DEVEL vrrp_skip_check_adv_addr vrrp_garp_interval 0 vrrp_gna_interval 0 } vrrp_instance VI_1 { state BACKUP #设置ECS2实例为备用实例 interface eth0 #设置网卡名,本示例配置为eth0 virtual_router_id 51 nopreempt priority 10 #设置优先级,数字越大,优先级越高,本示例配置备用实例优先级为10 advert_int 1 authentication { auth_type PASS auth_pass 1111 } unicast_src_ip 192.168.10.2 #设置ECS实例的私网IP地址 unicast_peer { 192.168.10.1 #对端ECS实例的私网IP地址 } virtual_ipaddress { 192.168.10.3 #设置HaVip的IP地址 192.168.10.5 } notify_master "/etc/keepalived/notify_action.sh MASTER" notify_backup "/etc/keepalived/notify_action.sh BACKUP" notify_fault "/etc/keepalived/notify_action.sh FAULT" notify_stop "/etc/keepalived/notify_action.sh STOP" garp_master_delay 1 garp_master_refresh 5 track_interface { eth0 #设置ECS实例网卡名,本示例配置为eth0 } } vrrp_instance VI_2 { state MASTER #设置ECS1实例为主实例 interface eth0 #设置网卡名,本示例配置为eth0 virtual_router_id 52 nopreempt priority 100 #设置优先级,数字越大,优先级越高,本示例配置主用实例优先级为100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } unicast_src_ip 192.168.10.2 #设置ECS实例的私网IP地址 unicast_peer { 192.168.10.1 #对端ECS实例的私网IP地址 } virtual_ipaddress { 192.168.10.4 #设置HaVip的IP地址 } notify_master "/etc/keepalived/notify_action.sh MASTER" notify_backup "/etc/keepalived/notify_action.sh BACKUP" notify_fault "/etc/keepalived/notify_action.sh FAULT" notify_stop "/etc/keepalived/notify_action.sh STOP" garp_master_delay 1 garp_master_refresh 5 track_interface { eth0 #设置ECS实例网卡名,本示例配置为eth0 } } service keepalived start # 启动服务 |