bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

mysql雙主配置講義

下文內容主要給大家帶來MySQL雙主配置講義,這里所講到的知識,與書籍略有不同,都是創新互聯專業技術人員在與用戶接觸過程中,總結出來的,具有一定的經驗分享價值,希望給廣大讀者帶來幫助。

公司主營業務:成都做網站、網站制作、成都外貿網站建設、移動網站開發等業務。幫助企業客戶真正實現互聯網宣傳,提高企業的競爭能力。成都創新互聯是一支青春激揚、勤奮敬業、活力青春激揚、勤奮敬業、活力澎湃、和諧高效的團隊。公司秉承以“開放、自由、嚴謹、自律”為核心的企業文化,感謝他們對我們的高要求,感謝他們從不同領域給我們帶來的挑戰,讓我們激情的團隊有機會用頭腦與智慧不斷的給客戶帶來驚喜。成都創新互聯推出郴州免費做網站回饋大家。

結尾2

1.數據庫架構圖:
mysql雙主配置講義

2.安裝環境信息:
master1 172.16.90.13    CentOS 7.2  Keepalived讀  VIP:172.16.90.15
master2 172.16.90.14    CentOS 7.2  Keepalived讀  VIP:172.16.90.16

3.MySQL雙主配置

master1修改my.cnf,新增如下配置:

server-id=13
log-bin=mysql-bin
sync-binlog=1
binlog-checksum=none
binlog-format=mixed
auto-increment-increment=2
auto-increment-offset=1
log-slave-updates
slave-skip-errors=all

master2修改my.cnf,新增如下配置:

server-id=14
log-bin=mysql-bin
sync-binlog=1
binlog-checksum=none
binlog-format=mixed
auto-increment-increment=2
auto-increment-offset=1
log-slave-updates
slave-skip-errors=all

在master1中為mysql從庫賬戶授權:

grant replication slave on . to 'sync'@'%' identified by 'syncpwd';
flush privileges;
show master status; #當前主庫狀態,即master1
show master status;
+------------------+----------+--------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000004 |      599 |              |                  |                   |
+------------------+----------+--------------+------------------+-------------------+

在master2中為mysql從庫賬戶授權:

grant replication slave on . to 'sync'@'%' identified by 'syncpwd';
flush privileges;
show master status; #當前主庫狀態,即master2
show master status;
+------------------+----------+--------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000002 |      468 |              |                  |                   |
+------------------+----------+--------------+------------------+-------------------+

在maste1中指定master2為主庫:

stop slave;
change master to master_host='172.16.90.14',master_user='sync',master_password='syncpwd',master_log_file='mysql-bin.000002',master_log_pos=468;
flush privileges;
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE;
start slave;

在maste2中指定master1為主庫:

stop slave;
change master to master_host='172.16.90.13',master_user='sync',master_password='syncpwd',master_log_file='mysql-bin.000004',master_log_pos=599;
flush privileges;
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE;
start slave;

MySQL雙主配置完成,驗證配置成功:

show slave status\G #master1中顯示的信息
1. row
Slave_IO_State: Waiting for master to send event
Master_Host: 172.16.90.13
Master_User: sync
Master_Port: 3306
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
show slave status\G #master2中顯示的信息
1. row
Slave_IO_State: Waiting for master to send event
Master_Host: 172.16.90.14
Master_User: sync
Master_Port: 3306
Slave_IO_Running: Yes
Slave_SQL_Running: Yes

4.Keepalived高可用配置

安裝:yum install -y keepalived
啟動:systemctl stop keepalived
說明:
當兩臺云服務器都正常的時候
用戶寫數據默認訪問服務器A,如果A有異常則訪問B服務器。
用戶讀數據默認訪問服務器B,如果B有異常則訪問A服務器。

服務器A的寫數據初始權重為100,B為90
服務器A的讀數據初始權重為90,B為100
檢測進程檢測到異常時,會使得本機的權重下降20

服務器A

vrrp_script chk_master1 {
    script "/opt/context/keepalive_check/chk_mysql.sh"
    interval 2            
    weight -20 
}

vrrp_instance VI_MASTER1 {
    state MASTER
    interface eno16780032
    virtual_router_id 51
    priority 100
    mcast_src_ip 172.16.90.13
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 5678
    }
    virtual_ipaddress {
        172.16.90.15
    }

    track_script {
        chk_master1
    }
}

vrrp_instance VI_MASTER2 {
    state BACKUP
    interface eno16780032
    virtual_router_id 52
    priority 90
    mcast_src_ip 172.16.90.13
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 15678
    }
    virtual_ipaddress {
        172.16.90.16
    }
}

服務器B

vrrp_script chk_master2 {
    script "/opt/context/keepalive_check/chk_mysql.sh"
    interval 2
    weight -20
}

vrrp_instance VI_MASTER1 {
    state BACKUP
    interface eno16780032
    virtual_router_id 51
    priority 90
    mcast_src_ip 172.16.90.14
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 5678
    }
    virtual_ipaddress {
        172.16.90.15
    }
}

vrrp_instance VI_MASTER2 {
    state MASTER
    interface eno16780032
    virtual_router_id 52
    priority 100
    mcast_src_ip 172.16.90.14
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 15678
    }
    virtual_ipaddress {
        172.16.90.16
    }

    track_script {
        chk_master2
    }
}

檢測腳本

#!/bin/bash
counter=$(netstat -na|grep "LISTEN"|grep "3306"|wc -l)
if [ "${counter}" -eq 0 ]; then
    systemctl stop keepalived

fi

對于以上關于mysql雙主配置講義,如果大家還有更多需要了解的可以持續關注我們創新互聯的行業推新,如需獲取專業解答,可在官網聯系售前售后的,希望該文章可給大家帶來一定的知識更新。

當前名稱:mysql雙主配置講義
分享地址:http://vcdvsql.cn/article18/jhijdp.html

成都網站建設公司_創新互聯,為您提供全網營銷推廣微信小程序云服務器網站設計公司網站改版定制網站

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

網站優化排名