MySQL半同步安装以及参数
生活随笔
收集整理的這篇文章主要介紹了
MySQL半同步安装以及参数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
MySQL半同步安裝以及參數
基于MySQL5.5
官檔地址:
Semisynchronous Replication Administrative Interface
https://dev.mysql.com/doc/refman/5.5/en/replication-semisync-interface.html 控制半同步復制的系統參數
rpl_semi_sync_master_enabled
Controls whether semisynchronous replication is enabled on the master. To enable or disable the plugin, set this variable to 1 or 0, respectively. The default is 0 (off).
控制是否啟用半同步復制rpl_semi_sync_master_timeout
A value in milliseconds that controls how long the master waits on a commit for acknowledgment from a slave before timing out and reverting to asynchronous replication. The default value is 10000 (10 seconds).
等待從庫提交并反饋的超時時間,超時則轉向異步同步rpl_semi_sync_slave_enabled
Similar to rpl_semi_sync_master_enabled, but controls the slave plugin.
類似于 rpl_semi_sync_master_enabled,但是用于控制 slave 的插件。 啟用半同步復制監視的狀態變量
Rpl_semi_sync_master_clients
The number of semisynchronous slaves.
半同步復制的 slave 的數量Rpl_semi_sync_master_status
Whether semisynchronous replication currently is operational on the master. The value is 1 if the plugin has been enabled and a commit acknowledgment has occurred. It is 0 if the plugin is not enabled or the master has fallen back to asynchronous replication due to commit acknowledgment timeout.
半同步復制目前是否運行在主機上。如果已啟用該插件,提交確認發生,值為 1。如果未啟用該插件或 master 已經回落到異步復制導致提交確認超時,為 0。Rpl_semi_sync_master_no_tx
The number of commits that were not acknowledged successfully by a slave.
提交但是沒有反饋成功的slave的數量。Rpl_semi_sync_master_yes_tx
The number of commits that were acknowledged successfully by a slave.
提交后反饋成功的slave的數量。Rpl_semi_sync_slave_status
Whether semisynchronous replication currently is operational on the slave. This is 1 if the plugin has been enabled and the slave I/O thread is running, 0 otherwise.
是否同步復制目前是業務上的slave。如果已啟用該插件,slave的 I/O 線程正在運行,是1 ,否則 0。 安裝和配置
前提條件
1. MySQL 5.5 or higher must be installed.
2. The capability of installing plugins requires a MySQL server that supports dynamic loading. To verify this, check that the value of the have_dynamic_loading system variable is YES. Binary distributions should support dynamic loading.
3. Replication must already be working. 安裝
1.設置主從庫參數文件
[mysqld]
plugin_dir=/path/to/plugin/directory
主庫:
INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so';
從庫:
INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave.so';
查詢安裝情況
mysql> SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME LIKE '%semi%';
+----------------------+---------------+
| PLUGIN_NAME | PLUGIN_STATUS |
+----------------------+---------------+
| rpl_semi_sync_master | ACTIVE |
+----------------------+---------------+
安裝完成后,半同步默認是關閉的,需要在主從庫上面都開啟,才能使用,只開啟主或者從,都無法使用mysql運行時,可以使用以下參數
主庫:
SET GLOBAL rpl_semi_sync_master_enabled = {0|1}; #默認是0,1是啟用,0是關閉
SET GLOBAL rpl_semi_sync_master_timeout = N; #單位milliseconds(毫秒),10000毫秒=10秒
從庫:
SET GLOBAL rpl_semi_sync_slave_enabled = {0|1};
如果要在mysql運行時啟用半同步,必須重啟IO_THREAD,slave會重新連上master并且被注冊為 semisynchronous slave
STOP SLAVE IO_THREAD;
START SLAVE IO_THREAD;
如果不重啟的話,slave將會繼續使用 異步復制可以重啟mysql時
配置my.cof參數
主庫:
[mysqld]
rpl_semi_sync_master_enabled=1
rpl_semi_sync_master_timeout=1000 # 1 second
從庫:
[mysqld]
rpl_semi_sync_slave_enabled=1 監控
mysql> SHOW VARIABLES LIKE 'rpl_semi_sync%';
mysql> SHOW STATUS LIKE 'Rpl_semi_sync%'; 卸載
主庫:
UNINSTALL PLUGIN rpl_semi_sync_master;
從庫:
UNINSTALL PLUGIN rpl_semi_sync_slave;
轉載于:https://www.cnblogs.com/Coye/p/7256068.html
總結
以上是生活随笔為你收集整理的MySQL半同步安装以及参数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 我有凯撒,格雷夫,卧龙,白虎,天宇圣龙,
- 下一篇: 师开头成语有哪些啊?