日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

MySQL半同步安装以及参数

發(fā)布時間:2023/11/27 生活经验 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MySQL半同步安装以及参数 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

MySQL半同步安裝以及參數(shù)

基于MySQL5.5

官檔地址:

Semisynchronous Replication Administrative Interface
https://dev.mysql.com/doc/refman/5.5/en/replication-semisync-interface.html

控制半同步復制的系統(tǒng)參數(shù)

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 的插件。

啟用半同步復制監(jiān)視的狀態(tài)變量

Rpl_semi_sync_master_clients
The number of semisynchronous slaves.
半同步復制的 slave 的數(shù)量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.
半同步復制目前是否運行在主機上。如果已啟用該插件,提交確認發(fā)生,值為 1。如果未啟用該插件或 master 已經(jīng)回落到異步復制導致提交確認超時,為 0。Rpl_semi_sync_master_no_tx
The number of commits that were not acknowledged successfully by a slave.
提交但是沒有反饋成功的slave的數(shù)量。Rpl_semi_sync_master_yes_tx
The number of commits that were acknowledged successfully by a slave.
提交后反饋成功的slave的數(shù)量。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.
是否同步復制目前是業(yè)務上的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.設置主從庫參數(shù)文件
[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運行時,可以使用以下參數(shù)
主庫:
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將會繼續(xù)使用 異步復制可以重啟mysql時
配置my.cof參數(shù)
主庫:
[mysqld]
rpl_semi_sync_master_enabled=1
rpl_semi_sync_master_timeout=1000 # 1 second
從庫:
[mysqld]
rpl_semi_sync_slave_enabled=1

監(jiān)控

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半同步安装以及参数的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。