亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

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

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

mysql5.6 —>mysql5.7 GTID模式下多源復制之實戰案例

發布時間:2020-08-11 22:44:37 來源:ITPUB博客 閱讀:153 作者:西湖看海 欄目:MySQL數據庫
背景說明:公司有多個mysql實例,單實例多個數據庫,而且版本還是5.6,這給數據查詢分析增加了不少繁瑣的事情。所以推薦使用mysql5.6的實例多源復制到mysql5.7實例下方便數據的查詢、分析以及權限的管理


mysql5.6 —>mysql5.7 GTID模式下多源復制之實戰案例


環境說明:10.89.3.224  mysql5.6.39  master1
        10.89.3.225  mysql5.6.39  master2
        10.89.3.222  mysql5.7.21  slave
        OS:centos 7.4    mysql_port:3309

操作步驟
1、安裝mysql5.6 mysql5.7
    詳細過程不再重復、如有疑問歡迎參考我的博客
    http://blog.itpub.net/29987453/viewspace-2149405/


2、配置mysql master01配置
    1)配置10.89.3.224  mysql5.6.39  master1
    ##在一個復制組內的serverid必須不一樣
    server-id = 123
    ##gtid 開啟gtid mysql5.6支持
    gtid_mode=on
    ##強制事務一致性,保證事務的安全
    enforce-gtid-consistency=on
    ##在從庫上記錄從主庫傳過來的日志數據
    log-slave-updates=1
    ##開啟binlog 必須的
    log_bin = master01-binlog      ##強烈建議設置row模式
    binlog_format = row
    ##binlog保存的日期
    expire_logs_days = 30
    #relay log在從服務器中記錄從主服務器傳過來的日志數據
    skip_slave_start=1
    ###設置master-info和relay-log 存放在table中
    master-info-repository = TABLE
    relay-log-info-repository = TABLE
    
    #指定復制的數據庫
    replicate-do-db=roket1,roket2
    ##指定忽略的數據庫(不需要復制的庫)
    replicate-ignore-               db=mysql,information_schema,performance_schema,test

    2)配置完之后重啟mysql server
    service mysqld restart
    3)登錄數據庫,創建主從同步賬號
    grant replication slave on *.* to 'repl'@'10.89.3.222' identified by '123456';
      flush privileges;
    4)重置binlog日志
    reset master;
    Query OK, 0 rows affected (0.01 sec)

    (root@localhost:mysql.sock) [(none)]>show binary logs;
    +------------------------+-----------+
    | Log_name               | File_size |
    +------------------------+-----------+
    | master01-binlog.000001 |       151 |
    +------------------------+-----------+

3、配置mysql master03配置
    1)配置10.89.3.225  mysql5.6.39  master2
    ##在一個復制組內的serverid必須不一樣
    server-id = 234
    ##gtid 開啟gtid mysql5.6支持
    gtid_mode=on
    ##強制事務一致性,保證事務的安全
    enforce-gtid-consistency=on
    ##在從庫上記錄從主庫傳過來的日志數據
    log-slave-updates=1
    ##開啟binlog 必須的
    log_bin = master01-binlog      ##強烈建議設置row模式
    binlog_format = row
    ##binlog保存的日期
    expire_logs_days = 30
    #relay log在從服務器中記錄從主服務器傳過來的日志數據
    skip_slave_start=1
    ###設置master-info和relay-log 存放在table中
    master-info-repository = TABLE
    relay-log-info-repository = TABLE
    
    #指定復制的數據庫
    replicate-do-db=maya1,maya2
    ##指定忽略的數據庫(不需要復制的庫)
    replicate-ignore-               db=mysql,information_schema,performance_schema,test

    2)配置完之后重啟mysql server
    service mysqld restart
    3)登錄數據庫,創建主從同步賬號
    grant replication slave on *.* to 'repl'@'10.89.3.222' identified by '123456';
      flush privileges;
    4)重置binlog日志
    reset master;
    Query OK, 0 rows affected (0.01 sec)

    (root@localhost:mysql.sock) [(none)]>show binary logs;
    +------------------------+-----------+
    | Log_name               | File_size |
    +------------------------+-----------+
    | master01-binlog.000001 |       151 |
    +————————————+-----------+

4、配置slave數據庫
    1)配置配置10.89.3.222  mysql5.7.21  slave
    ##在一個復制組內的serverid必須不一樣
    server-id = 234
    gtid_mode=on
    ##強制事務一致性,保證事務的安全
    enforce-gtid-consistency=on
    ##在從庫上記錄從主庫傳過來的日志數據
    log-slave-updates=1
    ##開啟binlog 必須的
    log_bin = master01-binlog      ##強烈建議設置row模式
    binlog_format = row
    ##binlog保存的日期
    expire_logs_days = 30
    #relay log在從服務器中記錄從主服務器傳過來的日志數據
    skip_slave_start=1
    ###設置master-info和relay-log 存放在table中
    master-info-repository = TABLE
    relay-log-info-repository = TABLE
    #配置只讀數據庫
    read_only=on

    4)重置binlog日志
    (root@localhost:mysql.sock) [(none)]>reset master;
    Query OK, 0 rows affected (0.02 sec)

    (root@localhost:mysql.sock) [(none)]>show binary logs;
    +---------------------+-----------+
    | Log_name            | File_size |
    +---------------------+-----------+
    | slave-binlog.000001 |       154 |
    +---------------------+-----------+
    1 row in set (0.00 sec)

    (root@localhost:mysql.sock) [(none)]>reset slave;
    Query OK, 0 rows affected (0.00 sec)
5、開啟主從復制
    1)關閉master1 和master2的防火墻
    2)開啟主從復制
    (root@localhost:mysql.sock) [(none)]>  CHANGE MASTER TO      MASTER_HOST = '10.89.3.225',  MASTER_PORT = 3309,   MASTER_USER = 'repl',   MASTER_PASSWORD = '123456',  MASTER_AUTO_POSITION = 1 FOR CHANNEL 'master2';
    Query OK, 0 rows affected, 2 warnings (0.02 sec)

    (root@localhost:mysql.sock) [(none)]>  CHANGE MASTER TO  MASTER_HOST = '10.89.3.224',  MASTER_PORT = 3309,   MASTER_USER = 'repl',   MASTER_PASSWORD = '123456',  MASTER_AUTO_POSITION = 1 FOR CHANNEL 'master1';
    Query OK, 0 rows affected, 2 warnings (0.02 sec)
    (root@localhost:mysql.sock) [(none)]>start slave;
    3)查看主從復制狀態
    (root@localhost:mysql.sock) [(none)]>show slave status for channel 'master1'\G
    *************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.89.3.224
                  Master_User: repl
                  Master_Port: 3309
                Connect_Retry: 60
              Master_Log_File: master01-binlog.000001
          Read_Master_Log_Pos: 151
               Relay_Log_File: mysql-relay-bin-master1.000002
                Relay_Log_Pos: 376
        Relay_Master_Log_File: master01-binlog.000001
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 151
              Relay_Log_Space: 591
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 123
                  Master_UUID: 3809e1da-25c0-11e8-93b1-080027857522
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp:
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set:
            Executed_Gtid_Set:
                Auto_Position: 1
         Replicate_Rewrite_DB:
                 Channel_Name: master1
           Master_TLS_Version:
1 row in set (0.00 sec)

(root@localhost:mysql.sock) [(none)]>show slave status for channel 'master2'\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.89.3.225
                  Master_User: repl
                  Master_Port: 3309
                Connect_Retry: 60
              Master_Log_File: master02-binlog.000001
          Read_Master_Log_Pos: 151
               Relay_Log_File: mysql-relay-bin-master2.000002
                Relay_Log_Pos: 376
        Relay_Master_Log_File: master02-binlog.000001
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 151
              Relay_Log_Space: 591
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 234
                  Master_UUID: ab8c56e0-25c0-11e8-93b4-0800278c8292
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp:
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set:
            Executed_Gtid_Set:
                Auto_Position: 1
         Replicate_Rewrite_DB:
                 Channel_Name: master2
           Master_TLS_Version:
1 row in set (0.00 sec)
    顯示 主從復制正常    
     Slave_IO_Running: Yes
           Slave_SQL_Running: Yes

6、測試核對數據
    1)登錄master1數據庫
    create database roket1;
    Query OK, 1 row affected (0.00 sec)

    (root@localhost:mysql.sock) [(none)]>create database roket2;
    Query OK, 1 row affected (0.01 sec)

    (root@localhost:mysql.sock) [(none)]>use roket1;
    Database changed
    (root@localhost:mysql.sock) [roket1]>create table t1(
        ->  id bigint not null auto_increment,
        ->  name varchar(20),
        ->  primary key(id)
        -> )engine=innodb;
    Query OK, 0 rows affected (0.02 sec)

    (root@localhost:mysql.sock) [roket1]>insert into t1 (name) values     (‘master1'),('master1'),('master1');
    Query OK, 3 rows affected (0.00 sec)
    Records: 3  Duplicates: 0  Warnings: 0
    (root@localhost:mysql.sock) [roket1]>select * from t1;
    +----+---------+
    | id | name    |
    +----+---------+
    |  1 | master1 |
    |  2 | master1 |
    |  3 | master1 |
+----+---------+

    2)登錄master2數據庫
    (root@localhost:mysql.sock) [(none)]>create database maya1;
    Query OK, 1 row affected (0.00 sec)

    (root@localhost:mysql.sock) [(none)]>create database maya2;
    Query OK, 1 row affected (0.00 sec)

    (root@localhost:mysql.sock) [(none)]>use maya1;
    Database changed
    (root@localhost:mysql.sock) [maya1]>create table t2(
        ->  id bigint not null auto_increment,
        ->  name varchar(20),
        ->  primary key(id)
        -> )engine=innodb;
    Query OK, 0 rows affected (0.02 sec)

        (root@localhost:mysql.sock) [maya1]>insert into t2 (name) values     ('master2'),('master2'),('master2') ;
    Query OK, 3 rows affected (0.00 sec)
    Records: 3  Duplicates: 0  Warnings: 0
    (root@localhost:mysql.sock) [maya1]>select * from t2;
    +----+---------+
    | id | name    |
    +----+---------+
    |  1 | master2 |
    |  2 | master2 |
    |  3 | master2 |
    +----+---------+
    3 rows in set (0.00 sec)

    3)登錄主庫
    (root@localhost:mysql.sock) [(none)]>show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | maya1               |
    | maya2              |
    | mysql              |
    | performance_schema |
    | roket1             |
    | roket2             |
    | sys                |

    (root@localhost:mysql.sock) [(none)]>
(root@localhost:mysql.sock) [(none)]>use roket1
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
(root@localhost:mysql.sock) [roket1]>show tables;
+------------------+
| Tables_in_roket1 |
+------------------+
| t1               |
+------------------+
1 row in set (0.00 sec)

(root@localhost:mysql.sock) [roket1]>select * from t1;
+----+---------+
| id | name    |
+----+---------+
|  1 | master1 |
|  2 | master1 |
|  3 | master1 |
+----+---------+
3 rows in set (0.00 sec)
(root@localhost:mysql.sock) [maya1]>use maya1
Database changed
(root@localhost:mysql.sock) [maya1]>select * from t2;
+----+---------+
| id | name    |
+----+---------+
|  1 | master2 |
|  2 | master2 |
|  3 | master2 |
+----+---------+
3 rows in set (0.00 sec)

經核對、master1、master2的實例的數據已經正常同步到slave,多源復制搞定
    
    總結:1、首先為mysql5.7多源復制點歌贊
         2、解決了公司業務的需要多實例的情況下,統一分析數據、查詢權限控制等眾多問題
        3、解決了多實例備份麻煩的問題
        


    

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

五河县| 民和| 邳州市| 和龙市| 凤阳县| 奉贤区| 桦南县| 于田县| 诏安县| 台山市| 长海县| 夏邑县| 浦北县| 且末县| 清徐县| 阜南县| 金溪县| 松滋市| 阿坝县| 宜君县| 紫阳县| 军事| 滦南县| 五台县| 灯塔市| 奉贤区| 巍山| 西安市| 怀宁县| 昭苏县| 温泉县| 赤壁市| 乌海市| 望谟县| 土默特右旗| 甘肃省| 伊吾县| 济宁市| 庄河市| 鄱阳县| 德昌县|