美文网首页
【keepalived】MySQL virtual_serve

【keepalived】MySQL virtual_serve

作者: Bogon | 来源:发表于2023-12-10 16:17 被阅读0次

    # cat /etc/keepalived/keepalived.conf

    ! Configuration File for keepalived
    
    global_defs {
    #   notification_email {
    #     123456789@qq.com
    #   }
    #   notification_email_from Alexandre.Cassen@firewall.loc
    #   smtp_server 127.0.0.1
    #   smtp_connect_timeout 30
       router_id LVS_DEVEL
       vrrp_skip_check_adv_addr
    #   vrrp_strict
       vrrp_garp_interval 0
       vrrp_gna_interval 0
    }
        vrrp_script check_mysqld {
        script "/usr/local/keepalived/mysqlcheck.sh" #检查MYSQL 复制状态脚本
        interval 2
        weight 21
    }
    vrrp_instance VI_1 {
        state MASTER  #指定主服务器节点为主节点,备用节点上设置需一致
        interface ens192 #指定虚拟IP的网络接口
        virtual_router_id 59 #VRRP组名,两个节点的设置必须一样,以指明各个节点属于同一VRRP组
        priority 99  #主节点的优先级(1-254之间),备用节点必须比主节点优先级低
        advert_int 1 #检测服务器状态间隔时间
        nopreempt
        authentication {
            auth_type PASS
            auth_pass 1111
        }
        virtual_ipaddress {
            192.168.1.227 #虚拟ip
        }
        track_script {
         check_mysqld
        }
    }
    
    virtual_server 192.168.1.227 3306 {
        delay_loop 6  #每个2秒检查一次real_server状态
        lb_algo rr    #
        lb_kind NAT
        persistence_timeout 60
        protocol TCP
    
       #sorry_server 192.168.200.200 1358
    
        real_server 192.168.1.10 3306 {
        weight 3
            notify_down "/usr/local/keepalived/keepalived.sh"
            TCP_CHECK {  
                 connect_timeout 10    #连接超时时间  
                 nb_get_retry 3       #重连次数  
                 delay_before_retry 3   #重连间隔时间  
                 connect_port 3306   #健康检查端口
                 delay_before_retry 3
             }
        }
    }
    
    

    # cat /etc/keepalived/keepalived.conf

    ! Configuration File for keepalived
    
    global_defs {
    #   notification_email {
    #     1121809867@qq.com
    #   }
    #   notification_email_from Alexandre.Cassen@firewall.loc
    #   smtp_server 127.0.0.1
    #   smtp_connect_timeout 30
       router_id LVS_DEVEL
       vrrp_skip_check_adv_addr
    #   vrrp_strict
       vrrp_garp_interval 0
       vrrp_gna_interval 0
    }
        vrrp_script check_mysqld {
        script "/usr/local/keepalived/mysqlcheck.sh" #检查MYSQL 复制状态脚本
        interval 2
        weight 21
    }
    vrrp_instance VI_1 {
        state MASTER  #指定主服务器节点为主节点,备用节点上设置需一致
        interface ens192 #指定虚拟IP的网络接口
        virtual_router_id 59 #VRRP组名,两个节点的设置必须一样,以指明各个节点属于同一VRRP组
        priority 100  #主节点的优先级(1-254之间),备用节点必须比主节点优先级低
        advert_int 1 #检测服务器状态间隔时间
        nopreempt
        authentication {
            auth_type PASS
            auth_pass 1111
        }
        virtual_ipaddress {
            192.168.1.227 #虚拟ip
        }
        track_script {
         check_mysqld
        }
    }
    
    virtual_server 192.168.1.227 3306 {
        delay_loop 6  #每个2秒检查一次real_server状态
        lb_algo rr    #
        lb_kind NAT
        persistence_timeout 60
        protocol TCP
    
       #sorry_server 192.168.200.200 1358
    
        real_server 192.168.1.11 3306 {
        weight 3
            notify_down "/usr/local/keepalived/keepalived.sh"
            TCP_CHECK {  
                 connect_timeout 10    #连接超时时间  
                 nb_get_retry 3       #重连次数  
                 delay_before_retry 3   #重连间隔时间  
                 connect_port 3306   #健康检查端口
                 delay_before_retry 3
             }
        }
    }
    

    相关文章

      网友评论

          本文标题:【keepalived】MySQL virtual_serve

          本文链接:https://www.haomeiwen.com/subject/qikpgdtx.html