Spec-Zone .ru
спецификации, руководства, описания, API
|
Semisynchronous replication is implemented using plugins, so the plugins must be installed into the server to make them available. After a plugin has been installed, you control it by means of the system variables associated with it. These system variables are unavailable until the associated plugin has been installed.
To use semisynchronous replication, the following requirements must be satisfied:
MySQL 5.5 or higher must be installed.
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.
Replication must already be working. For information on creating a master/slave relationship, see Section 16.1.1, "How to Set Up Replication".
To set up semisynchronous replication, use the following instructions. The INSTALL PLUGIN
, SET
GLOBAL
, STOP SLAVE
, and START
SLAVE
statements mentioned here require the SUPER
privilege.
The semisynchronous replication plugins are included with MySQL distributions.
Unpack the component distribution, which contains files for the master side and the slave side.
Install the component files in the plugin directory of the appropriate server. Install the semisync_master*
files in the plugin directory of the master server. Install the
semisync_slave*
files in the plugin directory of each slave server. The location
of the plugin directory is available as the value of the server's plugin_dir
system variable.
To load the plugins, use the INSTALL
PLUGIN
statement on the master and on each slave that is to be semisynchronous.
On the master:
mysql> INSTALL PLUGIN rpl_semi_sync_master SONAME
'semisync_master.so';
On each slave:
mysql> INSTALL PLUGIN rpl_semi_sync_slave SONAME
'semisync_slave.so';
The preceding commands use a plugin file name suffix of .so
. A different suffix
might apply on your system. If you are not sure about the plugin file name, look for the plugins in the server's
plugin directory.
If an attempt to install a plugin results in an error on Linux similar to that shown here, you will need to
install libimf
:
mysql> INSTALL PLUGIN rpl_semi_sync_master SONAME
'semisync_master.so';
ERROR 1126 (HY000): Can't open shared library'/usr/local/mysql/lib/plugin/semisync_master.so' (errno: 22 libimf.so: cannot openshared object file: No such file or directory)
You can obtain libimf
from
To see which plugins are installed, use the SHOW
PLUGINS
statement, or query the INFORMATION_SCHEMA.PLUGINS
table.
After a semisynchronous replication plugin has been installed, it is disabled by default. The plugins must be enabled both on the master side and the slave side to enable semisynchronous replication. If only one side is enabled, replication will be asynchronous.
To control whether an installed plugin is enabled, set the appropriate system variables. You can set these
variables at runtime using SET GLOBAL
, or at server startup on the command line or in an option file.
At runtime, these master-side system variables are available:
mysql>SET GLOBAL rpl_semi_sync_master_enabled = {0|1};
mysql>SET GLOBAL rpl_semi_sync_master_timeout =
N
;
On the slave side, this system variable is available:
mysql> SET GLOBAL rpl_semi_sync_slave_enabled =
{0|1};
For rpl_semi_sync_master_enabled
or rpl_semi_sync_slave_enabled
,
the value should be 1 to enable semisynchronous replication or 0 to disable it. By default, these variables are
set to 1.
For rpl_semi_sync_master_timeout
,
the value N
is given in milliseconds. The default value is 10000 (10
seconds).
If you enable semisynchronous replication on a slave at runtime, you must also start the slave I/O thread (stopping it first if it is already running) to cause the slave to connect to the master and register as a semisynchronous slave:
mysql> STOP SLAVE IO_THREAD; START SLAVE
IO_THREAD;
If the I/O thread is already running and you do not restart it, the slave continues to use asynchronous replication.
At server startup, the variables that control semisynchronous replication can be set as command-line options or
in an option file. A setting listed in an option file takes effect each time the server starts. For example, you
can set the variables in my.cnf
files on the master and slave sides as follows.
On the master:
[mysqld]rpl_semi_sync_master_enabled=1rpl_semi_sync_master_timeout=1000 # 1 second
On each slave:
[mysqld]rpl_semi_sync_slave_enabled=1