mysql 5.6 半同步主從安裝

raysuen發表於2017-02-24
一 配置完成主從
二 安裝和配置外掛
     1 master:
        命令幫助:
        mysql> help install
        Name: 'INSTALL PLUGIN'
        Description:
        Syntax:
        INSTALL PLUGIN plugin_name SONAME 'shared_library_name'
        1) 外掛安裝:
        mysql> install plugin rpl_semi_sync_master SONAME 'semisync_master.so';
        Query OK, 0 rows affected (0.88 sec)

        mysql> show variables like '%semi%';
        +------------------------------------+-------+
        | Variable_name                      | Value |
        +------------------------------------+-------+
        | rpl_semi_sync_master_enabled       | OFF   |
        | rpl_semi_sync_master_timeout       | 10000 |     單位:毫秒,預設為10秒
        | rpl_semi_sync_master_trace_level   | 32    |
        | rpl_semi_sync_master_wait_no_slave | ON    |
        +------------------------------------+-------+
        4 rows in set (0.01 sec)

        2) 啟動外掛和設定引數
        mysql> set global rpl_semi_sync_master_enabled=1;
        Query OK, 0 rows affected (0.00 sec)

        mysql> set global rpl_semi_sync_master_timeout=2000;
        Query OK, 0 rows affected (0.00 sec)

        mysql> show variables like '%semi%';
        +------------------------------------+-------+
        | Variable_name                      | Value |
        +------------------------------------+-------+
        | rpl_semi_sync_master_enabled       | ON    |
        | rpl_semi_sync_master_timeout       | 2000  |
        | rpl_semi_sync_master_trace_level   | 32    |
        | rpl_semi_sync_master_wait_no_slave | ON    |
        +------------------------------------+-------+
          4 rows in set (0.00 sec)

     2 slave:
          1) 安裝外掛
          mysql> install plugin rpl_semi_sync_slave soname 'semisync_slave.so';
          Query OK, 0 rows affected (0.30 sec)

          mysql> show variables like '%semi%';
          +---------------------------------+-------+
          | Variable_name                   | Value |
          +---------------------------------+-------+
          | rpl_semi_sync_slave_enabled     | OFF   |
          | rpl_semi_sync_slave_trace_level | 32    |
          +---------------------------------+-------+
          2 rows in set (0.00 sec)

          2) 啟動外掛
          mysql> set global rpl_semi_sync_slave_enabled=1;
          Query OK, 0 rows affected (0.00 sec)

          mysql> stop slave IO_thread;
          Query OK, 0 rows affected (0.82 sec)

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

三 檢查配置和驗證
     mysql> show global status like '%semi%';
     +--------------------------------------------+-------+
     | Variable_name                              | Value |
     +--------------------------------------------+-------+
     | Rpl_semi_sync_master_clients               | 1     |         顯示半同步的slave的數量
     | Rpl_semi_sync_master_net_avg_wait_time     | 0     |
     | Rpl_semi_sync_master_net_wait_time         | 0     |
     | Rpl_semi_sync_master_net_waits             | 0     |
     | Rpl_semi_sync_master_no_times              | 0     |
     | Rpl_semi_sync_master_no_tx                 | 0     |
     | Rpl_semi_sync_master_status                | ON    |
     | Rpl_semi_sync_master_timefunc_failures     | 0     |
     | Rpl_semi_sync_master_tx_avg_wait_time      | 0     |
     | Rpl_semi_sync_master_tx_wait_time          | 0     |
     | Rpl_semi_sync_master_tx_waits              | 0     |
     | Rpl_semi_sync_master_wait_pos_backtraverse | 0     |
     | Rpl_semi_sync_master_wait_sessions         | 0     |
     | Rpl_semi_sync_master_yes_tx                | 0     |
     +--------------------------------------------+-------+
     14 rows in set (0.01 sec)

四 解除安裝外掛
mysql> help uninstall
Name: 'UNINSTALL PLUGIN'
Description:
Syntax:
UNINSTALL PLUGIN plugin_name

注意:
一旦某次等待超時,會自動降級為非同步;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28572479/viewspace-2134195/,如需轉載,請註明出處,否則將追究法律責任。

相關文章