阿里云配置 keepalived

广大6个月前技术文章213

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  # 启动服务



相关文章

bucket跨域问题处理

bucket跨域问题处理

问题描述OSS bucket 访问存在跨域问题问题处理查看oss 能否针对整个bucket设置no-cache吗核实目前阿里云后台只支持单个文件的HTTP头设置,不支持批量设置,如果有多个文件或者后续...

Kubernetes节点与令牌管理

令牌管理查看令牌```Plain Text [root@master ~]# kubeadm token list## **删除令牌**Plain Text [root@master ~]# ku...

PG体系结构(二)

PG体系结构(二)

二、逻辑架构graph TD     A[database] -->B(schema)     B -->C[表]     B -->D[视图]     B -->E[...

Linux Firewall规则配置

Linux Firewall规则配置

1、Firewalld是否启动成功systemctl start firewalld && systemctl enable firewalld2、开启规则需求:客户由于网络审查问题。...

oracle安装gi执行root.sh报错:PRCR-1079 : Failed to start resource ora.cvu

1、具体报错如下:安装gi执行root.sh报错:PRCC-1014 : LISTENER_SCAN1 was already runningPRCR-1004 : Resource ora.LIST...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。