溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

MySQL中怎么實(shí)現(xiàn)主主復(fù)制

發(fā)布時(shí)間:2021-08-07 16:35:41 來(lái)源:億速云 閱讀:140 作者:Leah 欄目:MySQL數(shù)據(jù)庫(kù)

今天就跟大家聊聊有關(guān)MySQL中怎么實(shí)現(xiàn)主主復(fù)制 ,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

1 機(jī)器規(guī)劃

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

    192.168.6.66 VIP
    192.168.6.114 真實(shí)機(jī)(測(cè)試httpd負(fù)載均衡),lvs客戶端
    192.168.6.115 真實(shí)機(jī)(測(cè)試httpd負(fù)載均衡),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. 啟動(dòng)客戶端腳本

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

4 服務(wù)端keepalive配置文件如下

  1. 119 121機(jī)器(主備修改關(guān)鍵點(diǎn)即可)

  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. 啟動(dòng)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 


看完上述內(nèi)容,你們對(duì)MySQL中怎么實(shí)現(xiàn)主主復(fù)制 有進(jìn)一步的了解嗎?如果還想了解更多知識(shí)或者相關(guān)內(nèi)容,請(qǐng)關(guān)注億速云行業(yè)資訊頻道,感謝大家的支持。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI