MySQL主從複製非同步半同步執行個體

來源:互聯網
上載者:User

MySQL主從複製非同步半同步執行個體

MySQL主從複製非同步半同步執行個體

  1. 建立mysql的複製

    node1:

    mysql> show master status;
    +------------------+----------+--------------+------------------+-------------------+
    | File            | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
    +------------------+----------+--------------+------------------+-------------------+
    | mysql-bin.000003 |      120 |              |                  |                  |
    +------------------+----------+--------------+------------------+-------------------+
    1 row in set (0.00 sec)

    mysql>

     

    node2:

    mysql> change master to master_host='192.168.56.102',master_user='qwer',master_password='system',master_log_file='mysql-bin.000003',master_log_pos=120,master_port=3306;
    Query OK, 0 rows affected, 2 warnings (0.04 sec)

    mysql> start slave;
    Query OK, 0 rows affected (0.03 sec)

    mysql> show slave status\G
    *************************** 1. row ***************************
                  Slave_IO_State: Waiting for master to send event
                      Master_Host: 192.168.56.102
                      Master_User: qwer
                      Master_Port: 3306
                    Connect_Retry: 60
                  Master_Log_File: mysql-bin.000003
              Read_Master_Log_Pos: 120
                  Relay_Log_File: node2-relay-bin.000002
                    Relay_Log_Pos: 283
            Relay_Master_Log_File: mysql-bin.000003
                Slave_IO_Running: Yes
                Slave_SQL_Running: Yes
                Replicate_Do_DB: tongs

2.載入外掛程式

    node1:

     mysql> install plugin rpl_semi_sync_master soname 'semisync_master.so';           

    mysql> set global rpl_semi_sync_master_enabled=1;        --開啟半同步
    mysql> set global rpl_semi_sync_master_timeout=1000;      --半同步1000毫秒

 

    node2:

     mysql> install plugin rpl_semi_sync_slave soname 'semisync_slave.so';
    mysql> set  global rpl_semi_sync_slave_enabled=1;

3.查看狀態

    node1: 

    mysql> show variables like '%rpl_%';
    +-------------------------------------------+------------+
    | Variable_name                            | Value      |
    +-------------------------------------------+------------+
    | rpl_semi_sync_master_enabled              | ON        |
    | rpl_semi_sync_master_timeout              | 1000      |
    | rpl_semi_sync_master_trace_level          | 32        |
    | rpl_semi_sync_master_wait_for_slave_count | 1          |
    | rpl_semi_sync_master_wait_no_slave        | ON        |
    | rpl_semi_sync_master_wait_point          | AFTER_SYNC |
    | rpl_stop_slave_timeout                    | 31536000  | 
      +-------------------------------------------+------------+
    7 rows in set (0.00 sec)

    mysql>

   

    node2:

    mysql> show variables like '%rpl_%';
    +---------------------------------+----------+
    | Variable_name                  | Value    |
    +---------------------------------+----------+
    | rpl_semi_sync_slave_enabled    | ON      |
    | rpl_semi_sync_slave_trace_level | 32      |
    | rpl_stop_slave_timeout          | 31536000 |
      +---------------------------------+----------+
    3 rows in set (0.00 sec)

    mysql>

Ubuntu下Nginx做負載實現高效能WEB伺服器5---MySQL主主同步

生產環境MySQL主主同步主鍵衝突處理

MySQL主從失敗 錯誤Got fatal error 1236

MySQL主從複製,單台伺服器上實施

搭建MySQLProxy 伺服器實現讀寫分離+主從同步

MySQL 5.5 主從雙向同步

MySQL 5.5主從同步排錯

本文永久更新連結地址:

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.