欧美阿v视频在线大全_亚洲欧美中文日韩V在线观看_www性欧美日韩欧美91_亚洲欧美日韩久久精品

主頁 > 知識庫 > mariadb的主從復制、主主復制、半同步復制配置詳解

mariadb的主從復制、主主復制、半同步復制配置詳解

熱門標簽:安陽手機自動外呼系統原理是什么 地圖標注專員入駐 如何辦理400客服電話 外呼系統怎樣才能不封號 外呼系統線路經常出問題嗎 西藏地圖標注改進點 地圖標注什么軟件好用 地圖標注百度競價 神行者百貨商場地圖標注

主從服務器的時間要同步,數據庫版本最好是一致的,以免造成函數處理、日志讀取、日志解析等發生異常。

以下三個主從復制的設置是獨立的。

注意防火墻和selinux的影響。

1、簡單主從復制的實現

(1)主服務器的配置

1)安裝mariadb-server

[root@localhost ~]# yum -y install mariadb-server

2)編輯/etc/my.cnf文件

[root@localhost ~]# vim /etc/my.cnf

    在[mysqld]段的最后添加以下內容

    skip_name_resolve = ON
    innodb_file_per_table = ON
    server-id = 1 (id號不能跟從服務器相同)
    log-bin = master-log (自定義二進制日志文件名)

3)授權可以復制本地數據庫信息的主機

[root@localhost ~]# systemctl start mariadb.service (啟動mariadb server)

[root@localhost ~]# mysql
 MariaDB [(none)]> grant replication slave,replication client on *.* to 'repluser'@'10.1.51.%' identified by 'replpasswd';
 MariaDB [(none)]> flush privileges;

MariaDB [(none)]> show master status\G (查看主服務器的狀態信息,在從服務器中要用到)
*************************** 1. row ***************************
   File: master-log.000003 (正在使用的二進制日志文件)
  Position: 497 (所處的位置)
 Binlog_Do_DB: 
Binlog_Ignore_DB:

(2)從服務器的配置

1)安裝mariadb-server

[root@localhost ~]# yum -y install mariadb-server

2)編輯/etc/my.cnf文件

[root@localhost ~]# vim /etc/my.cnf

    在[mysqld]段的最后添加以下內容

    skip_name_resolve = ON
    innodb_file_per_table = ON
    server-id = 2 (id號不能跟主服務器相同)
    relay-log = slave-log (自定義二進制日志文件名)

3)設置要從哪個主服務器的那個位置開始同步

[root@localhost ~]# systemctl start mariadb.service

[root@localhost ~]# mysql
 MariaDB [(none)]> change master to master_host='10.1.51.60',master_user='repluser',master_password='replpasswd',master_log_file='master-log.000003',master_log_pos=497;

MariaDB [(none)]> start slave; (啟動復制功能)
MariaDB [(none)]> show slave status\G (查看從服務器的狀態,下面顯示的是部分內容)
 Master_Host: 10.1.51.60
 Master_User: repluser
 Master_Port: 3306
 Connect_Retry: 60
 Master_Log_File: master-log.000003
 Read_Master_Log_Pos: 497
 Relay_Log_File: slave-log.000002
 Relay_Log_Pos: 530
 Relay_Master_Log_File: master-log.000003
 Slave_IO_Running: Yes 
 Slave_SQL_Running: Yes
 Master_Server_Id: 1

(3)測試

1)在主服務器導入事先準備好的數據庫

[root@localhost ~]# mysql hellodb.sql

2)在從服務器查看是否同步

MariaDB [(none)]> show databases;
+--------------------+
| Database   |
+--------------------+
| information_schema |
| hellodb   |(數據庫已經同步)
| mysql    |
| performance_schema |
| test    |
+--------------------+
MariaDB [(none)]> use hellodb;
MariaDB [hellodb]> show tables; (hellodb數據庫的表也是同步的)
+-------------------+
| Tables_in_hellodb |
+-------------------+
| classes   |
| coc    |
| courses   |
| scores   |
| students   |
| teachers   |
| toc    |
+-------------------+

2、雙主復制的實現

(1)服務器1的配置

1)安裝mariadb-server

[root@localhost ~]# yum -y install mariadb-server

2)編輯/etc/my.cnf文件

[root@localhost ~]# vim /etc/my.cnf

    在[mysqld]段的最后添加以下內容

    skip_name_resolve = ON
    innodb_file_per_table = ON
    server-id = 1 (id號不能跟從服務器相同)
    log-bin = master-log (自定義主服務器的二進制日志文件名)
    relay-log = slave-log (自定義從服務器的二進制日志文件名)
    auto_increment_offset = 1
    auto_increment_increment = 2

3)在服務器2上查看的master狀態

MariaDB [(none)]> show master status\G
*************************** 1. row ***************************
   File: master-log.000003
  Position: 422
 Binlog_Do_DB: 
Binlog_Ignore_DB:

4)啟動mariadb server并進行如下配置

[root@localhost ~]# systemctl start mariadb.service

[root@localhost ~]# mysql

 MariaDB [(none)]> grant replication slave,replication client on *.* to 'repluser'@'10.1.51.%' identified by 'replpasswd';

 MariaDB [(none)]> change master to master_host='10.1.51.50',master_user='repluser',master_password='replpasswd',master_log_file='master-log.000003',master_log_pos=422;

 MariaDB [(none)]> start slave;

 MariaDB [(none)]> SHOW SLAVE STATUS\G (僅是部分內容)
  Master_Host: 10.1.51.50
  Master_User: repluser
  Master_Port: 3306
  Connect_Retry: 60
  Master_Log_File: master-log.000003
  Read_Master_Log_Pos: 422
  Relay_Log_File: slave-log.000002
  Relay_Log_Pos: 530
  Relay_Master_Log_File: master-log.000003
  Slave_IO_Running: Yes
  Slave_SQL_Running: Yes
  Master_Server_Id: 2

(2)服務器2的配置

1)安裝mariadb-server

[root@localhost ~]# yum -y install mariadb-server

2)編輯/etc/my.cnf文件

[root@localhost ~]# vim /etc/my.cnf
    skip_name_resolve = ON
    innodb_file_per_table = ON
    server-id = 2
    relay-log = slave-log
    lob-bin = master-log
    auto_increment_offset = 2
    auto_increment_increment = 2

3)在服務器1查看master狀態

MariaDB [(none)]> show master status\G
*************************** 1. row ***************************
            File: master-log.000003
        Position: 245
    Binlog_Do_DB:
Binlog_Ignore_DB:

4)啟動mariadb server并配置

[root@localhost ~]# systemctl start mariadb.service

[root@localhost ~]# mysql

 MariaDB [(none)]> grant replication slave,replication client on *.* to 'repluser'@'10.1.51.%' identified by 'replpasswd';

 MariaDB [(none)]> change master to master_host='10.1.51.60',master_user='repluser',master_password='replpasswd',master_log_file='master-log.000003',master_log_pos=245;

 MariaDB [(none)]> start slave;

 MariaDB [(none)]> show slave status\G (僅是部分內容) 
  Master_Host: 10.1.51.60
  Master_User: repluser
  Master_Port: 3306
  Connect_Retry: 60
  Master_Log_File: master-log.000003
  Read_Master_Log_Pos: 422
  Relay_Log_File: slave-log.000003
  Relay_Log_Pos: 530
  Relay_Master_Log_File: master-log.000003
  Slave_IO_Running: Yes
  Slave_SQL_Running: Yes
  Master_Server_Id: 1

(3)測試

1)在任意一臺服務器上創建mydb數據庫

MariaDB [(none)]> create database mydb;

2)在另一臺服務器上查看

MariaDB [(none)]> show databases;
+--------------------+
| Database   |
+--------------------+
| information_schema |
| mydb    |
| mysql    |
| performance_schema |
| test    |
+--------------------+

3、半同步復制的實現

(1)在主服務器上的配置

1)安裝mariadb-server

[root@localhost ~]# yum -y install mariadb-server

2)編輯/etc/my.cnf

[root@localhost ~]# vim /etc/my.cnf
    skip_name_resolve = ON
    innodb_file_per_table = ON
    server-id = 1
    log-bin = master-log

3)授權可以復制本地數據庫信息的主機

[root@localhost ~]# systemctl start mariadb.service (啟動mariadb server)

[root@localhost ~]# mysql
 MariaDB [(none)]> grant replication slave,replication client on *.* to 'repluser'@'10.1.51.%' identified by 'replpasswd';
 MariaDB [(none)]> flush privileges;

MariaDB [(none)]> show master status\G (查看主服務器的狀態信息,在從服務器中要用到)
*************************** 1. row ***************************
   File: master-log.000003 (正在使用的二進制日志文件)
  Position: 245 (所處的位置)
 Binlog_Do_DB: 
Binlog_Ignore_DB:

4)安裝rpl semi sync_master插件,并啟用

[root@localhost ~]# mysql

MariaDB [(none)]> install plugin rpl_semi_sync_master soname 'semisync_master.so';
MariaDB [(none)]> set global rpl_semi_sync_master_enabled = ON;

補充:

MariaDB [(none)]> show plugins;(可查看插件是否激活)
MariaDB [(none)]> show global variables like 'rpl_semi%';(可查看安裝的插件是否啟用)
MariaDB [(none)]> show global status like '%semi%';(可查看從服務器的個數,此時是0個)

(2)從服務器的配置

1)安裝mariadb-server

[root@localhost ~]# yum -y install mariadb-server

2)編輯/etc/my.cnf文件

[root@localhost ~]# vim /etc/my.cnf

    在[mysqld]段的最后添加以下內容

    skip_name_resolve = ON
    innodb_file_per_table = ON
    server-id = 2 (id號不能跟主服務器相同)
    relay-log = slave-log (自定義二進制日志文件名)

3)設置要從哪個主服務器的那個位置開始同步

[root@localhost ~]# systemctl start mariadb.service

[root@localhost ~]# mysql

 MariaDB [(none)]> change master to master_host='10.1.51.60',master_user='repluser',master_password='replpasswd',master_log_file='master-log.000003',master_log_pos=245;

4)安裝rpl semi sync_slave插件并啟用

[root@localhost ~]# mysql 

 MariaDB [(none)]> install plugin rpl_semi_sync_slave soname 'semisync_slave.so';
 MariaDB [(none)]> set global rpl_semi_sync_slave_enabled = ON;
 MariaDB [(none)]> start slave;

完成上面配置后,可以在主服務器上查看半同步復制的相關信息,命令如下:

MariaDB [(none)]> show global status like '%semi%';
 Rpl_semi_sync_master_clients 1 (從服務器有一臺)

(3)測試

測試以個人實際情況而定
1)在主服務器上導入事先準備好的數據庫hellodb.sql

MariaDB [hellodb]> source /root/hellodb.sql;

2)在主服務器上查看半同步復制的狀態

MariaDB [hellodb]> show master status;
+-------------------+----------+--------------+------------------+
| File    | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-------------------+----------+--------------+------------------+
| master-log.000003 |  8102 |    |     |
+-------------------+----------+--------------+------------------+

MariaDB [hellodb]> show global status like '%semi%';
+--------------------------------------------+-------+
| Variable_name        | Value |
+--------------------------------------------+-------+
| Rpl_semi_sync_master_clients    | 1  |
| Rpl_semi_sync_master_net_avg_wait_time  | 1684 |
| Rpl_semi_sync_master_net_wait_time   | 60630 |
| Rpl_semi_sync_master_net_waits    | 36 |
| Rpl_semi_sync_master_no_times    | 1  |
| Rpl_semi_sync_master_no_tx     | 1  |
| Rpl_semi_sync_master_status    | ON |
| Rpl_semi_sync_master_timefunc_failures  | 0  |
| Rpl_semi_sync_master_tx_avg_wait_time  | 1884 |
| Rpl_semi_sync_master_tx_wait_time   | 65965 |
| Rpl_semi_sync_master_tx_waits    | 35 |
| Rpl_semi_sync_master_wait_pos_backtraverse | 0  |
| Rpl_semi_sync_master_wait_sessions   | 0  |
| Rpl_semi_sync_master_yes_tx    | 35 |
+--------------------------------------------+-------+

3)在從服務器上查看是否同步

MariaDB [(none)]> show databases;
MariaDB [(none)]> use hellodb;
MariaDB [hellodb]> select * from students;

補充:基于上面的半同步復制配置復制的過濾器,復制過濾最好在從服務器上設置,步驟如下

(1)從服務器的配置

1)關閉mariadb server

[root@localhost ~]# systemctl stop mariadb.service

2)編輯/etc/my.cnf文件

[root@localhost ~]# vim /etc/my.cnf
 skip_name_resolve = ON
 innodb_file_per_table = ON
 server-id = 2
 relay-log = slave-log
 replicate-do-db = mydb (只復制mydb數據庫的內容)

補充:常用的過濾選項如下

    Replicate_Do_DB=
    Replicate_Ignore_DB=
    Replicate_Do_Table=
    Replicate_Ignore_Table=
    Replicate_Wild_Do_Table=
    Replicate_Wild_Ignore_Table=

3)重啟mariadb server

[root@localhost ~]# systemctl start mariadb.service

4)重啟mariadb server后,半同步復制功能將被關閉,因此要重新啟動

MariaDB [(none)]> show global variables like '%semi%';
+---------------------------------+-------+
| Variable_name     | Value |
+---------------------------------+-------+
| rpl_semi_sync_slave_enabled  | OFF |
| rpl_semi_sync_slave_trace_level | 32 |
+---------------------------------+-------+

MariaDB [(none)]> set global rpl_semi_sync_slave_enabled = ON;
MariaDB [(none)]> stop slave;(需先關閉從服務器復制功能再重啟)
MariaDB [(none)]> start slave;

(2)測試

1)主服務器上的hellodb數據庫創建一個新表semitable

MariaDB [hellodb]> create table semitable (id int);

2)在從服務器上查看hellodb數據庫是否有semitable

MariaDB [(none)]> use hellodb
MariaDB [hellodb]> show tables;(并沒有)
+-------------------+
| Tables_in_hellodb |
+-------------------+
| classes   |
| coc    |
| courses   |
| scores   |
| students   |
| teachers   |
| toc    |
+-------------------+

3)在主服務器上創建mydb數據庫,并為其創建一個tbl1表

MariaDB [hellodb]> create database mydb;

4)在從服務器上查看mydb數據庫的是否有tbl1表

MariaDB [hellodb]> use mydb;
MariaDB [mydb]> show tables; (可以查看到)
+----------------+
| Tables_in_mydb |
+----------------+
| tbl1   |
+----------------+

您可能感興趣的文章:
  • 淺談MySQL和mariadb區別
  • centos 7安裝mysql5.5和安裝 mariadb使用的命令
  • Centos7 下mysql重新啟動MariaDB篇
  • Mac中MariaDB數據庫的安裝步驟
  • CentOS安裝和設置MariaDB的教程
  • 關于MariaDB安裝問題小記(CMake Error at)
  • 記一次mariadb數據庫無法連接
  • CentOS 7中成功安裝MariaDB的方法教程
  • MariaDB性能調優工具mytop的使用詳解
  • MariaDB數據庫的外鍵約束實例詳解

標簽:AXB 張掖 貴港 萍鄉 雞西 阜陽 酒泉 衡水

巨人網絡通訊聲明:本文標題《mariadb的主從復制、主主復制、半同步復制配置詳解》,本文關鍵詞  mariadb,的,主從,復制,主主,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《mariadb的主從復制、主主復制、半同步復制配置詳解》相關的同類信息!
  • 本頁收集關于mariadb的主從復制、主主復制、半同步復制配置詳解的相關信息資訊供網民參考!
  • 推薦文章
    欧美阿v视频在线大全_亚洲欧美中文日韩V在线观看_www性欧美日韩欧美91_亚洲欧美日韩久久精品
  • <rt id="w000q"><acronym id="w000q"></acronym></rt>
  • <abbr id="w000q"></abbr>
    <rt id="w000q"></rt>
    aaaaa级少妇高潮大片免费看| 欧洲一区二区三区在线| 欧美一级在线免费| 亚洲一区二区三区国产| av中文字幕不卡| 性欧美疯狂猛交69hd| 久久久www免费人成精品| 女同久久另类69精品国产 | 杨幂一区二区国产精品| 色一区在线观看| 日韩毛片在线免费观看| 成人性生交大片| 色偷偷久久人人79超碰人人澡| 国产精品久久午夜| 波多野结衣在线aⅴ中文字幕不卡| 杨钰莹一级淫片aaaaaa播放| 中文字幕va一区二区三区| 国产精品主播直播| 日本黄色免费片| 中文字幕综合网| 日本少妇一区二区三区| 欧美久久久久久蜜桃| 日韩二区三区四区| 受虐m奴xxx在线观看| 久久久噜噜噜久久中文字幕色伊伊 | 亚洲综合激情小说| 性农村xxxxx小树林| 91精品婷婷国产综合久久竹菊| 日本最新不卡在线| 亚洲女优在线观看| 国产精品欧美一级免费| 91一区二区三区在线播放| 欧美日本韩国一区二区三区视频| 五月天久久比比资源色| 国产女主播喷水高潮网红在线| 久久精品综合网| 不卡的av在线播放| 欧美久久久一区| 九九久久精品视频| www.超碰在线观看| 亚洲伊人色欲综合网| 欧美性xxxx图片| 国产欧美一区二区在线| 99久久精品情趣| 777奇米四色成人影色区| 久久精品99国产精品| 日韩在线不卡av| 亚洲国产中文字幕在线视频综合| 中文人妻一区二区三区| 日本一区二区三区高清不卡| 久久综合桃花网| 精品久久人人做人人爰| 粉嫩蜜臀av国产精品网站| 欧美性猛交一区二区三区精品| 日韩精品欧美精品| frxxee中国xxx麻豆hd| 亚洲综合在线免费观看| xxxxx在线观看| 亚洲人成精品久久久久久| 久久久久国产精品无码免费看| 久久久久99精品一区| 日本一区二区三区在线免费观看| 精品国产一区二区三区不卡| 成人avav影音| 精品区一区二区| 99精品视频在线免费观看| 日韩免费一区二区| 97久久人人超碰| 精品国产一区二区三区四区四| 国产午夜亚洲精品不卡| 99精品一区二区| 久久久久久久久久看片| 91浏览器在线视频| 久久精品一区二区| 久久久久无码国产精品一区李宗瑞| 久久亚洲春色中文字幕久久久| 91麻豆国产福利精品| 欧美国产禁国产网站cc| a级一a一级在线观看| 国产精品全国免费观看高清 | 亚洲免费伊人电影| 亚洲理论片在线观看| 亚洲精选一二三| 婷婷国产成人精品视频| 午夜精品久久一牛影视| 黄色一级片中国| 精品一区二区在线看| 欧美日韩二区三区| 成人h版在线观看| 久久人人超碰精品| 欧类av怡春院| 一区二区成人在线| 黄色录像一级片| 精品一区二区三区久久| 欧美老女人在线| av一区二区久久| 中文字幕欧美日韩一区| 亚洲综合网在线观看| 亚洲成人自拍偷拍| 色婷婷一区二区三区四区| 国产精品一区二区久激情瑜伽| 精品日韩一区二区三区| xxxx黄色片| 天天av天天翘天天综合网色鬼国产| 在线视频欧美区| 成人美女视频在线观看18| 国产日韩欧美高清在线| 国产毛片久久久久久久| 日韩和欧美一区二区三区| 欧美视频在线观看一区二区| 成年人午夜久久久| 国产精品色婷婷| 日本美女黄色一级片| 精品亚洲免费视频| 欧美成人女星排名| 一本色道综合久久欧美日韩精品| 亚洲国产美女搞黄色| 欧美亚洲国产一卡| 99久久777色| 亚洲男人天堂一区| 色天使久久综合网天天| 成人av电影在线| 亚洲免费在线视频一区 二区| 91aaa在线观看| 成人的网站免费观看| 国产精品成人网| 国产精品成人免费观看| 成人免费观看视频| 国产精品国产精品国产专区不片 | 老司机福利在线观看| 韩国女主播成人在线| 久久久午夜精品理论片中文字幕| 永久免费av无码网站性色av| 久久丁香综合五月国产三级网站| 精品精品欲导航| 无码少妇精品一区二区免费动态| 国内精品伊人久久久久av影院| 久久久不卡网国产精品一区| 蜜桃视频最新网址| 成人av在线影院| 亚洲乱码国产乱码精品精98午夜| 欧美性受xxxx| xxxxxx黄色| 久久97超碰国产精品超碰| 久久久精品综合| 538任你躁在线精品视频网站| 99在线精品一区二区三区| 亚洲精品免费在线观看| 欧美日韩情趣电影| 国产精品一级黄片| 精品一区二区在线免费观看| 国产精品无圣光一区二区| 一本色道久久综合狠狠躁的推荐| 91一区在线观看| 日韩和的一区二区| 久久毛片高清国产| www.超碰在线观看| 日本天堂在线播放| 开心九九激情九九欧美日韩精美视频电影 | 911国产在线| 99久久久精品免费观看国产蜜| 午夜一区二区三区在线观看| 欧美成人vps| 国产精品三区在线观看| 波多野结衣三级视频| 日韩成人精品在线观看| 久久久精品国产99久久精品芒果| 国产在线一卡二卡| 亚洲精品无码一区二区| 久久99精品国产91久久来源| 国产精品乱码一区二三区小蝌蚪| 欧美视频你懂的| 色哟哟精品观看| av电影天堂一区二区在线观看| 亚洲午夜激情av| 久久久久久毛片| 在线免费不卡电影| 新91视频在线观看| www..com久久爱| 日本va欧美va瓶| 中文字幕亚洲欧美在线不卡| 欧美精品亚洲一区二区在线播放| 欧美一区二区三区粗大| 91在线一区二区三区| 蜜臀久久99精品久久久画质超高清 | 欧美男女性生活在线直播观看| 欧美黄色一级生活片| 99在线视频精品| 久久69国产一区二区蜜臀| 专区另类欧美日韩| 精品国产露脸精彩对白| 色婷婷国产精品久久包臀| 国产 欧美 在线| av电影中文字幕| 国产成人精品亚洲午夜麻豆| 天堂成人免费av电影一区| 国产精品理伦片| 2024国产精品| 欧美日韩精品是欧美日韩精品| 少妇高潮在线观看|