1
1
How to use replication: An example
2
2
====================================
4
Simple replication setup (using a single master and a single slave) between two Drizzle servers is straightforward with the replication slave plugin. With Drizzle replication, you can also provision a new slave into an existing setup.
4
A simple replication setup (using a single master and a single slave) between two Drizzle servers is done with the replication slave plugin. With Drizzle replication, you can also provision a new slave into an existing setup.
6
6
Replication setup begins with making certain that both master and slave share the same version of Drizzle to avoid any potential incompatibility issues.
11
Setting up the master is the first step. An important requirement is to start the master Drizzle database server with the --innodb.replication-log option. For example:
13
master> sbin/drizzled --datadir=$PWD/var --innodb.replication-log &
16
For more complex setups, the --server-id option may be appropriate to use.
11
Setting up the master is the first step. An important requirement is to start the master Drizzle database server with the --innodb.replication-log option, and a few other options in most circumstances. More options can be found in the options documentation. These are the most common options needed for a replication master. For example:
13
master> usr/local/sbin/drizzled \
14
--innodb.replication-log \
15
--pid-file=/var/run/drizzled/drizzled.pid \
16
--drizzle-protocol.bind-address=0.0.0.0 \
17
--mysql-protocol.bind-address=0.0.0.0 \
21
Several options are required on most setups. They are set on Drizzle Startup with a --optionname. The most important ones are:
24
The InnoDB replication log must be running:
26
--innodb.replication-log
31
--pid-file=/var/run/drizzled/drizzled.pid
34
the address binding for Drizzle's default port (4427):
36
--drizzle-protocol.bind-address=0.0.0.0
39
The address binding for systems replicating through MySQL's default port (3306):
41
--mysql-protocol.bind-address=0.0.0.0
44
Data Directory can be set other than default:
49
For more complex setups, the server id option may be appropriate to use:
54
To run Drizzle in the background, thereby keeping the database running if the user logs out:
18
60
With the master running, you can optionally now create a backup of any databases to be imported on the new slave by using :doc:`../../clients/drizzledump`. This example, however, assumes that we are starting with a fresh database with no data.
23
Starting the slave is almost as simple as starting the master. There are two Drizzle database server options required for the slave: --plugin-add=slave and --slave.config-file. For example: ::
25
slave> sbin/drizzled --datadir=$PWD/var \
27
--slave.config-file=/tmp/slave.cfg &
65
Starting the slave is very similar to starting the master. There are two Drizzle database server options required for the slave: --plugin-add=slave and --slave.config-file. For example: ::
67
slave> /usr/local/sbin/drizzled \
69
--slave.config-file=/usr/local/etc//slave.cfg
71
A more typical startup will need more options:
73
slave> /usr/local/sbin/drizzled \
75
--slave.config-file=/usr/local/etc//slave.cfg \
76
--pid-file=/var/run/drizzled/drizzled.pid \
77
--drizzle-protocol.bind-address=0.0.0.0 \
78
--mysql-protocol.bind-address=0.0.0.0 \
81
Similar to the Master setup, there are a number of options that can be selected. Please see the Plugin Documentation for the relevent options.
30
83
These options tell the server to load the slave plugin, and then tell the slave plugin where to find the slave host configuration file. This configuration file has options to specify the master host and a few options to control how the slave operates. You can read more about the available configuration options in the replication slave plugin documentation. Below is a simple example: ::
85
master-host = master.location.com
88
Some options that can be set other than default, but are otherwise not necessary, are:
34
90
master-user = dino_slave
35
91
master-pass = my_password
36
92
io-thread-sleep = 10