xxxmenger 发表于 2018-9-27 11:10:04

MySQL主主互备结合keepalived实现高可用

! Configuration File for keepalived  

  
global_defs {
  
   notification_email {
  
   root@huangmingming.cn
  
   741616710@qq.com
  
   }
  
   notification_email_from keepalived@localhost
  
   smtp_server 127.0.0.1
  
   smtp_connect_timeout 30
  
   router_id LVS_DEVEL
  
}
  

  
vrrp_instance HA_1 {
  
    state BACKUP                #master和slave都配置为BACKUP
  
    interface eth0            #指定HA检测的网络接口
  
    virtual_router_id 80      #虚拟路由标识,主备相同
  
    priority 100                #定义优先级,slave设置90
  
    advert_int 1                #设定master和slave之间同步检查的时间间隔
  
    nopreempt                   #不抢占模式。只在优先级高的机器上设置即可
  
    authentication {
  
      auth_type PASS
  
      auth_pass 1111
  
    }
  

  
    virtual_ipaddress {               #设置虚拟IP,可以设置多个,每行一个
  
      192.168.1.208/24 dev eth0       #MySQL对外服务的IP,即VIP
  
    }
  
}
  

  
virtual_server 192.168.1.208 3306 {
  
    delay_loop 2                  #每隔2秒查询real server状态
  
    lb_algo wrr                     #lvs 算法
  
    lb_kinf DR                      #LVS模式(Direct Route)
  
    persistence_timeout 50
  
    protocol TCP
  

  
    real_server 192.168.1.210 3306 {    #监听本机的IP
  
      weight 1
  
      notify_down /usr/local/keepalived/bin/mysql.sh
  
      TCP_CHECK {
  
      connect_timeout 10         #10秒无响应超时
  
      bingto 192.168.1.208
  
      nb_get_retry 3
  
      delay_before_retry 3
  
      connect_port 3306
  
      }
  
    }
  

  
}


页: [1]
查看完整版本: MySQL主主互备结合keepalived实现高可用