网站建设资讯

NEWS

网站建设资讯

MySQL中怎么实现主主复制

今天就跟大家聊聊有关MySQL中怎么实现主主复制 ,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

成都创新互联公司是一家专注于做网站、网站设计与策划设计,太白网站建设哪家好?成都创新互联公司做网站,专注于网站建设10年,网设计领域的专业建站公司;建站业务涵盖:太白等地区。太白做网站价格咨询:13518219792

1 机器规划

  1. 192.168.6.119 keepalive+ipvsadm(Lvs)
    192.168.6.121 keepalive+ipvsadm(Lvs)

    192.168.6.66 VIP
    192.168.6.114 真实机(测试httpd负载均衡),lvs客户端
    192.168.6.115 真实机(测试httpd负载均衡),lvs客户端

  1. 114.115上都需要

  2. [root@node1 ~]# more /usr/local/bin/lvs_real
    #!/bin/bash
    #description : start realserver
    VIP=192.168.6.66
    /etc/rc.d/init.d/functions
    case "$1" in
    start)
    echo " start LVS of REALServer"
    /sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up
    echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
    echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
    echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
    echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
    ;;
    stop) 
    /sbin/ifconfig lo:0 down
    echo "close LVS Directorserver"
    echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore
    echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce
    echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore
    echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce
    ;;
    *)
    echo "Usage: $0 {start|stop}"
    exit 1
    esac 

  3. 启动客户端脚本

  4. [root@node1 ~]# sh /usr/local/bin/lvs_real start

4 服务端keepalive配置文件如下

  1. 119 121机器(主备修改关键点即可)

  2. [root@localhost keepalived]# more keepalived.conf
    #writed by sery , contact sery@163.com
    #guration File for keepalived
    #global define
    global_defs {
     router_id LVS_CNC_1

    vrrp_sync_group VGM {
     group {
     VI_CACHE
     }
    }
    ################################################################
    # vvrp_instance define #
    ################################################################
    vrrp_instance VI_CACHE {
     state MASTER
     interface eth0
     lvs_sync_daemon_inteface eth0
     virtual_router_id 51
     priority 180
     advert_int 5
     authentication {
     auth_type PASS
     auth_pass 1111
     }
     virtual_ipaddress {
     192.168.6.66
     }
    }
    ##############################################################
    # virtual machine setting #
    ##############################################################
    # setting port 80 forward


  3. virtual_server 192.168.6.66 80 {
     delay_loop 6
     lb_algo wlc
     lb_kind DR
    # persistence_timeout 20

     protocol TCP
     real_server 192.168.6.114 80{
     weight 100
     TCP_CHECK {
     connect_timeout 3
     nb_get_retry 3
     delay_before_retry 3
     connect_port 80
     }
     }
     real_server 192.168.6.115 80{
     weight 100
     TCP_CHECK {
     connect_timeout 3
     nb_get_retry 3
     delay_before_retry 3
     connect_port 80
     }
     }
    }

  4. 启动keepalive

  5. [root@localhost ~]# /etc/init.d/keepalived start

  6. 查看ipvsadm情况

  7. [root@localhost keepalived]# ipvsadm -ln
    IP Virtual Server version 1.2.1 (size=4096)
    Prot LocalAddress:Port Scheduler Flags
      -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
    TCP  192.168.6.66:80 wlc
      -> 192.168.6.115:80             Route   100    0          0         
      -> 192.168.6.114:80             Route   100    0          0 

看完上述内容,你们对MySQL中怎么实现主主复制 有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注创新互联行业资讯频道,感谢大家的支持。


当前题目:MySQL中怎么实现主主复制
文章路径:http://njwzjz.com/article/gsjjdh.html