Slave Configuration¶
Configuring a Drizzle replication stream using the Slave Applier requires:
Load a replicator plugin on the masters
Enabling
--innodb.replication-logon the mastersCreating user accounts for the slaves on the masters
Writing a Slave Config File for
--slave.config-fileon the slaveLoading and configure the
slaveplugin on the slave
The first three steps are performed on a master, and the last two steps are performed on a slave.
Configuring a Master¶
A single slave can apply replication events from up to ten masters at once. There are three requirements for each master:
A replicator plugin must be loaded on each master. The Default Replicator is loaded by default. To verify that it is loaded on a master, execute:
drizzle> SELECT * FROM DATA_DICTIONARY.PLUGINS WHERE PLUGIN_NAME = 'default_replicator';
+--------------------+-----------------------+-----------+--------------------+
| PLUGIN_NAME | PLUGIN_TYPE | IS_ACTIVE | MODULE_NAME |
+--------------------+-----------------------+-----------+--------------------+
| default_replicator | TransactionReplicator | 1 | default_replicator |
+--------------------+-----------------------+-----------+--------------------+
If the plugin is not loaded, verify that the server was not started with
--plugin-remove default_replicator. If it was, remove that option and
restart the server.
To use a different replicator, configure Drizzle to load the replicator plugin on startup, and specify the replicator name with --innodb.use-replicator.
Each master must also be started with --innodb.replication-log
to enable the InnoDB Replicaiton Log which is not enabled by default.
Therefore, Drizzle must be configured with this option at startup.
See Configuring Drizzle for more information. To verify that the
InnoDB replication log is active, execute:
drizzle> SELECT * FROM DATA_DICTIONARY.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'innodb_replication_log';
+------------------------+----------------+
| VARIABLE_NAME | VARIABLE_VALUE |
+------------------------+----------------+
| innodb_replication_log | ON |
+------------------------+----------------+
drizzle> SELECT * FROM DATA_DICTIONARY.INNODB_REPLICATION_LOG LIMIT 1;
-- The query should return one row showing a replication event.
Slave User Account¶
A user account is required on the master for slave connections, unless no Authentication is used (which is highly inadvisable). One user account can be used for all slaves, or individual user accounts can be used for each slave. In either case, the user account credentials (username and password) for a master are specified in the Slave Config File.
Authorization must be configured on the master to allow slave user accounts to access the DATA_DICTIONARY schema, else the slave IO thread will fail to start on the slave:
drizzle> SELECT * FROM sys_replication.io_state\G
*************************** 1. row ***************************
master_id: 1
status: STOPPED
error_msg: Replication slave: Access denied for user 'slave' to schema 'data_dictionary'
The sys_replication Tables are discussed in Slave Administration.
Authorization cannot be used to filter which schemas or tables are replicated because slave connections do no access individual schemas and tables, they only access the InnoDB Replicaiton Log. To filter which schemas or tables are replicated, configure the master to use a filtering replicator like Filtered Replicator, as described above.
Configuring a Slave¶
After Configuring a Master, configuring a slave requires only:
Slave Config File¶
A slave config file is a plain text file that contains connection and configuration options for each master. At least one master must be specifed, and masters must be numbered sequentially from 1 to 10. The general syntax of a slave config file is:
# comment
common-option=value
[masterN]
master-specific-option=value
There are two types of options: common options which apply to all masters, and master-specific options which only apply to the preceding [masterN] header where N is the sequentially numbered master, starting with 1. Whitespace
before and after lines and around = (equal signs) is ignored.
The simplest possible slave config file is:
[master1]
master-host=<master hostname>
master-user=slave1
See Slave Applier for complete, working examples.
Common Options¶
These options must be specified first, before any [masterN] headers.
- applier-thread-sleep¶
- Default:
5
The number of seconds the applier (consumer) thread sleeps between applying replication events from the local queue.
- ignore-errors¶
Ignore errors and continue applying replication events. It is generally a bad idea to use this option!
- io-thread-sleep¶
- Default:
5
The number of seconds the IO (producer) thread sleeps between queries to the master for more replication events.
- seconds-between-reconnects¶
- Default:
30
The number of seconds to wait between reconnect attempts when the master server becomes unreachable.
Master-specific Options¶
These options must be specified after a [masterN] header.
- master-host¶
Hostname/IP address of the master server.
- master-port¶
- Default:
3306
Drizzle port used by the master server.
- master-user¶
Username to use for connecting to the master server. See Slave User Account.
- master-pass¶
Password associated with the username given by
master-user. See Slave User Account.
- max-commit-id¶
Maximum commit ID the slave is assumed to have applied from the master. This value will be used by the slave to determine where to begin retrieving replication events from the master transaction log. This option can be used to provision a new slave by setting it to the value output from the drizzledump Backup Tool when used with the
--single-transactionoption.
- max-reconnects¶
- Default:
10
The number of reconnection attempts the slave plugin will try if the master server becomes unreachable.
slave Plugin¶
A slave must load the slave plugin which is not loaded by default.
This plugin has only one option:
- --slave.config-file FILE¶
- Default:
BASEDIR/etc/slave.cfg- Variable:
Full path to a Slave Config File. By default, the plugin looks for a file named
slave.cfginBASEDIR/etc/whereBASEDIRis determined by--basedir.
Since a slave can connect to multiple masters, all other options are set
in the Slave Config File. Once a slave config file has been written, start Drizzle with the slave plugin like:
$ drizzled --plugin-add slave --slave.config-file /etc/drizzled/slave.conf
If the masters are configured properly, and the slave config file is correct, and the slave plugin loads successfully, the sys_replication Tables will be accessible on the slave as described in the next topic, Slave Administration.