<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      Mysql 主從復制搭建-極簡版

      前言

      自己在百度、Google一番踩坑搭建成功后,記錄一下,也希望后來人不再被這些坑到。

      這里為了方便使用 docker,不會的同學請移步相關 Docker 教程。

      正文

      1. 啟動 mysql

      #啟動 master
      docker run --name master -e MYSQL_ROOT_PASSWORD=123456 -d mysql
      #啟動 slave
      docker run --name slave -e MYSQL_ROOT_PASSWORD=123456 -d mysql
      

      備注:--name 是指定容器名稱;-e MYSQL_ROOT_PASSWORD 是指定mysql密碼

      2. 修改 mysql 配置

      docker 的正確用法應該是基于mysql鏡像,創建兩個新的鏡像,這里為了簡單,直接進入容器修改

      修改 master 的 mysql 配置

      docker exec -it [master容器id] bash
      
      echo '[mysqld]
      pid-file        = /var/run/mysqld/mysqld.pid
      socket          = /var/run/mysqld/mysqld.sock
      datadir         = /var/lib/mysql
      secure-file-priv= NULL
      symbolic-links=0
      #啟用二進制日志
      log-bin=mysql-bin
      #設置服務器唯一Id,這里省事直接寫1
      server-id=1
      !includedir /etc/mysql/conf.d/' > /etc/mysql/my.cnf
      

      備注:第二段請一口氣復制,它們是一句..
      這里因為容器內沒有裝vim所以使用這種方式,其實就是加上log-bin=mysql-binserver-id=1這兩個配置

      修改 slave 的 mysql 配置

      其實一樣,只是改個server-id

      docker exec -it [slave容器id] bash
      
      echo '[mysqld]
      pid-file        = /var/run/mysqld/mysqld.pid
      socket          = /var/run/mysqld/mysqld.sock
      datadir         = /var/lib/mysql
      secure-file-priv= NULL
      symbolic-links=0
      #啟用二進制日志
      log-bin=mysql-bin
      #設置服務器唯一Id
      server-id=2
      !includedir /etc/mysql/conf.d/' > /etc/mysql/my.cnf
      

      重啟容器

      docker restart [master容器id] [slave容器id]
      

      3. 配置同步

      登錄 master 獲取信息

      docker exec -it [master容器id] mysql -uroot -p123456
      mysql> show master status;
      +------------------+----------+--------------+------------------+-------------------+
      | File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
      +------------------+----------+--------------+------------------+-------------------+
      | mysql-bin.000001 |      155 |              |                  |                   |
      +------------------+----------+--------------+------------------+-------------------+
      1 row in set (0.00 sec)
      

      主要記住 mysql-bin.000001 和 155 這兩個值,一個是文件,一個是偏移量

      登錄 slave 設置同步

      docker exec -it [slave容器id] mysql -uroot -p123456
      mysql> change master to master_host='172.17.0.2',master_user='root',master_log_file='mysql-bin.000001',master_log_pos=155,master_port=3306,master_password='123456';
      msql> start slave;
      

      備注:這里的 ip 是 master 的 ip,可以通過 docker inspect [容器id]|grep IPA 查看 IP

      4. 檢驗成功

      通過 show slave status\G; 看到

      失敗了..

      Last_IO_Error: error connecting to master 'root@172.17.0.2:3306' - retry-time: 60 retries: 1 message: Authentication plugin 'caching_sha2_password' reported error: Authentication requires secure connection.

      不安全的連接?

      最后在 Mysql 官網發現端倪,需要先在 slave 上連接 master 獲取 public-key,如下

      mysql --ssl-mode=DISABLED -h [masterIP] -uroot -p123456 --get-server-public-key

      然后重啟下 slave 線程

      stop slave;

      start slave;

      查看狀態

      show slave status\G;

      可以看到下面兩個yes就說明成功了

      Slave_IO_Running: Yes
      Slave_SQL_Running: Yes

      后記

      關于最后那個連接不安全的錯誤,應該是 mysql8 才有的,不過具體原因還沒空去研究

      附上操作日志

      ################【啟動mysql】################
      deepin@DeepinBook:~$ docker run --name master -e MYSQL_ROOT_PASSWORD=123456 -d mysql
      6f0d597fda22325f35eef4d00356238e4058d3dc2122177fe1bdc2a9cca554b2
      deepin@DeepinBook:~$ docker run --name slave -e MYSQL_ROOT_PASSWORD=123456 -d mysql
      5dca640e2ceb4744a1e85402c50a0134ad981a9cc658f91058bd739c80fb22b4
      
      ################【修改mysql配置】#############
      deepin@DeepinBook:~$ docker exec -it 6f bash
      root@6f0d597fda22:/# cat /etc/mysql/my.cnf
      # Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
      #
      # This program is free software; you can redistribute it and/or modify
      # it under the terms of the GNU General Public License as published by
      # the Free Software Foundation; version 2 of the License.
      #
      # This program is distributed in the hope that it will be useful,
      # but WITHOUT ANY WARRANTY; without even the implied warranty of
      # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      # GNU General Public License for more details.
      #
      # You should have received a copy of the GNU General Public License
      # along with this program; if not, write to the Free Software
      # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
      
      #
      # The MySQL  Server configuration file.
      #
      # For explanations see
      # http://dev.mysql.com/doc/mysql/en/server-system-variables.html
      
      [mysqld]
      pid-file        = /var/run/mysqld/mysqld.pid
      socket          = /var/run/mysqld/mysqld.sock
      datadir         = /var/lib/mysql
      secure-file-priv= NULL
      # Disabling symbolic-links is recommended to prevent assorted security risks
      symbolic-links=0
      
      # Custom config should go here
      !includedir /etc/mysql/conf.d/
      root@6f0d597fda22:/# echo '[mysqld]
      > pid-file        = /var/run/mysqld/mysqld.pid
      > socket          = /var/run/mysqld/mysqld.sock
      > datadir         = /var/lib/mysql
      > secure-file-priv= NULL
      > symbolic-links=0
      > log-bin=mysql-bin
      > server-id=1
      > !includedir /etc/mysql/conf.d/' > /etc/mysql/my.cnf
      root@6f0d597fda22:/# cat /etc/mysql/my.cnf
      [mysqld]
      pid-file        = /var/run/mysqld/mysqld.pid
      socket          = /var/run/mysqld/mysqld.sock
      datadir         = /var/lib/mysql
      secure-file-priv= NULL
      symbolic-links=0
      log-bin=mysql-bin
      server-id=1
      !includedir /etc/mysql/conf.d/
      root@6f0d597fda22:/# exit
      
      deepin@DeepinBook:~$ docker exec -it 5d bash
      root@5dca640e2ceb:/# echo '[mysqld]
      > pid-file        = /var/run/mysqld/mysqld.pid
      > socket          = /var/run/mysqld/mysqld.sock
      > datadir         = /var/lib/mysql
      > secure-file-priv= NULL
      > symbolic-links=0
      > #啟用二進制日志
      > log-bin=mysql-bin
      > #設置服務器唯一Id
      > server-id=2
      > !includedir /etc/mysql/conf.d/' > /etc/mysql/my.cnf
      root@5dca640e2ceb:/# 
      root@5dca640e2ceb:/# 
      root@5dca640e2ceb:/# exit
      exit
      deepin@DeepinBook:~$ docker restart 6f 5d
      6f
      5d
      
      ################【配置主從】#############
      deepin@DeepinBook:~$ docker exec -it 6f mysql -uroot -p123456
      mysql: [Warning] Using a password on the command line interface can be insecure.
      Welcome to the MySQL monitor.  Commands end with ; or \g.
      Your MySQL connection id is 8
      Server version: 8.0.17 MySQL Community Server - GPL
      
      Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
      
      Oracle is a registered trademark of Oracle Corporation and/or its
      affiliates. Other names may be trademarks of their respective
      owners.
      
      Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
      
      mysql> show master status;
      +------------------+----------+--------------+------------------+-------------------+
      | File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
      +------------------+----------+--------------+------------------+-------------------+
      | mysql-bin.000001 |      155 |              |                  |                   |
      +------------------+----------+--------------+------------------+-------------------+
      1 row in set (0.00 sec)
      
      mysql> exit
      Bye
      deepin@DeepinBook:~$ docker exec -it 5d mysql -uroot -p123456
      mysql: [Warning] Using a password on the command line interface can be insecure.
      Welcome to the MySQL monitor.  Commands end with ; or \g.
      Your MySQL connection id is 8
      Server version: 8.0.17 MySQL Community Server - GPL
      
      Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
      
      Oracle is a registered trademark of Oracle Corporation and/or its
      affiliates. Other names may be trademarks of their respective
      owners.
      
      Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
      
      mysql> change master to master_host='172.17.0.2',master_user='root',master_log_file='mysql-bin.000001',master_log_pos=155,master_port=3306,master_password='123456';
      Query OK, 0 rows affected, 2 warnings (0.04 sec)
      
      mysql> start slave;
      Query OK, 0 rows affected (0.01 sec)
      
      mysql> show slave status\G;
      *************************** 1. row ***************************
                     Slave_IO_State: Connecting to master
                        Master_Host: 172.17.0.2
                        Master_User: root
                        Master_Port: 3306
                      Connect_Retry: 60
                    Master_Log_File: mysql-bin.000001
                Read_Master_Log_Pos: 155
                     Relay_Log_File: 5dca640e2ceb-relay-bin.000001
                      Relay_Log_Pos: 4
              Relay_Master_Log_File: mysql-bin.000001
                   Slave_IO_Running: Connecting
                  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: 155
                    Relay_Log_Space: 155
                    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: NULL
      Master_SSL_Verify_Server_Cert: No
                      Last_IO_Errno: 2061
                      Last_IO_Error: error connecting to master 'root@172.17.0.2:3306' - retry-time: 60 retries: 8 message: Authentication plugin 'caching_sha2_password' reported error: Authentication requires secure connection.
                     Last_SQL_Errno: 0
                     Last_SQL_Error: 
        Replicate_Ignore_Server_Ids: 
                   Master_Server_Id: 0
                        Master_UUID: 
                   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: 191008 10:43:52
           Last_SQL_Error_Timestamp: 
                     Master_SSL_Crl: 
                 Master_SSL_Crlpath: 
                 Retrieved_Gtid_Set: 
                  Executed_Gtid_Set: 
                      Auto_Position: 0
               Replicate_Rewrite_DB: 
                       Channel_Name: 
                 Master_TLS_Version: 
             Master_public_key_path: 
              Get_master_public_key: 0
                  Network_Namespace: 
      1 row in set (0.00 sec)
      
      ERROR: 
      No query specified
      
      mysql> exit
      Bye
      deepin@DeepinBook:~$ docker exec -it 5d bash
      root@5dca640e2ceb:/# mysql --ssl-mode=DISABLED -h172.17.0.2 -uroot -p123456 --get-server-public-key
      mysql: [Warning] Using a password on the command line interface can be insecure.
      Welcome to the MySQL monitor.  Commands end with ; or \g.
      Your MySQL connection id is 20
      Server version: 8.0.17 MySQL Community Server - GPL
      
      Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
      
      Oracle is a registered trademark of Oracle Corporation and/or its
      affiliates. Other names may be trademarks of their respective
      owners.
      
      Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
      
      mysql> exit
      Bye
      root@5dca640e2ceb:/# mysql -uroot -p123456
      mysql: [Warning] Using a password on the command line interface can be insecure.
      Welcome to the MySQL monitor.  Commands end with ; or \g.
      Your MySQL connection id is 11
      Server version: 8.0.17 MySQL Community Server - GPL
      
      Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
      
      Oracle is a registered trademark of Oracle Corporation and/or its
      affiliates. Other names may be trademarks of their respective
      owners.
      
      Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
      
      mysql> show slave status\G;
      *************************** 1. row ***************************
                     Slave_IO_State: Connecting to master
                        Master_Host: 172.17.0.2
                        Master_User: root
                        Master_Port: 3306
                      Connect_Retry: 60
                    Master_Log_File: mysql-bin.000001
                Read_Master_Log_Pos: 155
                     Relay_Log_File: 5dca640e2ceb-relay-bin.000001
                      Relay_Log_Pos: 4
              Relay_Master_Log_File: mysql-bin.000001
                   Slave_IO_Running: Connecting
                  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: 155
                    Relay_Log_Space: 155
                    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: NULL
      Master_SSL_Verify_Server_Cert: No
                      Last_IO_Errno: 2061
                      Last_IO_Error: error connecting to master 'root@172.17.0.2:3306' - retry-time: 60 retries: 11 message: Authentication plugin 'caching_sha2_password' reported error: Authentication requires secure connection.
                     Last_SQL_Errno: 0
                     Last_SQL_Error: 
        Replicate_Ignore_Server_Ids: 
                   Master_Server_Id: 0
                        Master_UUID: 
                   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: 191008 10:46:52
           Last_SQL_Error_Timestamp: 
                     Master_SSL_Crl: 
                 Master_SSL_Crlpath: 
                 Retrieved_Gtid_Set: 
                  Executed_Gtid_Set: 
                      Auto_Position: 0
               Replicate_Rewrite_DB: 
                       Channel_Name: 
                 Master_TLS_Version: 
             Master_public_key_path: 
              Get_master_public_key: 0
                  Network_Namespace: 
      1 row in set (0.00 sec)
      
      ERROR: 
      No query specified
      
      mysql> stop slave;
      Query OK, 0 rows affected (0.01 sec)
      
      mysql> start slave;
      Query OK, 0 rows affected (0.00 sec)
      
      mysql> show slave status\G;
      *************************** 1. row ***************************
                     Slave_IO_State: Waiting for master to send event
                        Master_Host: 172.17.0.2
                        Master_User: root
                        Master_Port: 3306
                      Connect_Retry: 60
                    Master_Log_File: mysql-bin.000001
                Read_Master_Log_Pos: 155
                     Relay_Log_File: 5dca640e2ceb-relay-bin.000002
                      Relay_Log_Pos: 322
              Relay_Master_Log_File: mysql-bin.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: 155
                    Relay_Log_Space: 537
                    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: 1
                        Master_UUID: 48507a05-e9b2-11e9-ae20-0242ac110002
                   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: 0
               Replicate_Rewrite_DB: 
                       Channel_Name: 
                 Master_TLS_Version: 
             Master_public_key_path: 
              Get_master_public_key: 0
                  Network_Namespace: 
      1 row in set (0.00 sec)
      
      ERROR: 
      No query specified
      
      posted @ 2019-10-08 19:47  夏日淺笑、  閱讀(2581)  評論(1)    收藏  舉報
      主站蜘蛛池模板: 亚洲区色欧美另类图片| 深夜免费av在线观看| 日韩av天堂综合网久久| 久久精产国品一二三产品| 久久青草国产精品一区| 亚洲高清国产拍精品熟女| 午夜色无码大片在线观看免费| 国产成人无码免费视频在线| 丰满人妻一区二区三区色| 精品中文人妻中文字幕| 国产丝袜视频一区二区三区 | 亚洲一级特黄大片在线观看| 日本中文字幕在线播放| 一区二区三区av天堂| 九九热视频在线观看精品| 隔壁老王国产在线精品| 国产精品亚洲一区二区在| 性色欲情网站iwww九文堂| 丰腴饱满的极品熟妇| 久久亚洲精品成人av秋霞| 东京热一精品无码av| 国产午夜精品一区二区三区不卡| 中文国产人精品久久蜜桃| 亚洲成年轻人电影网站WWW| 日本熟妇XXXX潮喷视频| 亚洲精品中文字幕二区| 91精品国产吴梦梦在线观看永久| 免费看欧美全黄成人片| 性男女做视频观看网站| 日韩精品一区二区三区中文| 国产亚洲精品成人aa片新蒲金| 国产男女猛烈无遮挡免费视频| 国产成人午夜福利在线播放 | 亚洲国模精品一区二区| 亚洲一区二区约美女探花| 久久影院九九被窝爽爽| 亚洲av永久无码精品网站| 亚洲国产色婷婷久久99精品91| 噜噜噜亚洲色成人网站∨| 无码国产偷倩在线播放| 亚洲av色香蕉一区二区三|