zoukankan      html  css  js  c++  java
  • keepalived双机热备(nginx+mysql)

    1、安装
    系统:ubuntu1804
    两个节点(us248,us249)都安装了nginx代理mysql(us251,us252,us253,us254)

    sudo apt install keepalived
    查看版本:keepalived -v
    查看服务状态:sudo systemctl status keepalived

    2、配置
    参考/usr/share/doc/keepalived/keepalived.conf.说明

    配置文件/etc/keepalived/keepalived.conf
    global_defs {
        router_id node1 #node2 备节点
    }
    vrrp_script chk_nginx {
           script "killall -0 nginx"
           interval 1
    }
    vrrp_instance vrrp1 {
        state MASTER #BACKUP  备节点
        interface ens33
        virtual_router_id 51
        priority 100 #90  备节点
        advert_int 1
        authentication { 
            auth_type PASS
            auth_pass 1111
        }
        virtual_ipaddress {
            192.168.1.240
        }
        track_script {
           chk_nginx
        } 
    }


    3、测试
    1)主从节点启动:
    sudo systemctl restart keepalived

    2)主节点检查是否有虚拟IP:192.168.1.240
    ip a(VIP在主节点)

    3)关闭主节点,从节点检查虚拟IP
    ip a(VIP在从节点)

    4)重启主节点,检查VIP
    VIP回到了主节点

    4、脑裂问题
    TODO

  • 相关阅读:
    事务
    排序算法
    二维数组中的查找
    在Linux中安装Matlab
    null和“”的区别
    【学习笔记】〖九度OJ〗题目1433:FatMouse
    【学习笔记】〖九度OJ〗题目1464:Hello World for U
    year:2017 month:8 day:1
    year:2017 month:07 day:31
    year:2017 month:7 day:27
  • 原文地址:https://www.cnblogs.com/xiaomacs/p/11697148.html
Copyright © 2011-2022 走看看