~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/slave/docs/index.rst

  • Committer: Mark Atwood
  • Date: 2011-08-11 03:05:03 UTC
  • mfrom: (2385.1.12 refactor4)
  • Revision ID: me@mark.atwood.name-20110811030503-rp9xjihc5x3y0x4q
merge lp:~olafvdspek/drizzle/refactor4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Replication Slave
 
2
==================
 
3
 
 
4
This page contains the configuration and implementation details for Drizzle replication.
 
5
 
 
6
See these pages for user-level information: 
 
7
 
 
8
.. toctree::
 
9
   :maxdepth: 2
 
10
 
 
11
   user_example
 
12
   admin
 
13
 
 
14
Description
 
15
-----------
 
16
 
 
17
Replication enables data from one Drizzle database server (the master) to be replicated to one or more Drizzle database servers (the slaves). It provides a native implementation of replication between two Drizzle processes. Depending on your configuration, you can replicate all databases, selected databases, or selected tables within a database.
 
18
 
 
19
Drizzle’s replication system is entirely new and different from MySQL. Replication events are stored using Google Protocol Buffer messages in an InnoDB table. These events are read by the slave, stored locally, and applied. The advantage of the Google Protocol Buffer messages is a script or program can be put together in pretty much any language in minutes, and read the replication log. In other words, replication plugins are easy to implement, which enable developers to entirely customize their replication system.
 
20
 
 
21
This plugin requires a master that is running with the InnoDB replication log enabled. The slave plugin allows a server to replicate from another server that is using the innodb-trx log. It is a very simple setup:

 
22
master options:  –innodb.replication-log=true
slave options: –plugin-add=slave –slave.config-file=XYZ
 
23
 
 
24
The config file may contain the following options in option=value format:

 
25
master-host – hostname/ip of the master host
master-port – port used by the master server
master-user – username
master-pass – password
max-reconnects – max # of reconnect attempts if the master disappears
seconds-between-reconnects – how long to wait between reconnect attempts
 
26
 
 
27
 
 
28
Configuration
 
29
-------------
 
30
 
 
31
Most of the options that can be used to control the replication slave plugin
 
32
can only be given in a configuration file. The only exceptions are the
 
33
:option:`--slave.config-file` and :option:`--slave.max-commit-id` options.
 
34
 
 
35
.. program:: drizzled
 
36
 
 
37
.. option:: --slave.config-file=arg
 
38
 
 
39
   Path to the replication slave configuration file. By default, the
 
40
   plugin will look for a file named `slave.cfg` in the `etc` directory
 
41
   of the Drizzle installation. If you want to specify a different path or
 
42
   configuration file name, it is best to specify a full path to the
 
43
   file. The relative path used by plugins is within the :option:`--datadir`
 
44
   directory, so a full path is recommended.
 
45
 
 
46
.. option:: --slave.max-commit-id=arg
 
47
 
 
48
   Manually set the maximum commit ID the slave is assumed to have retrieved
 
49
   from the master. This value will be used by the slave to determine where
 
50
   to begin retrieving replication messages from the master transaction log.
 
51
   This option can be used to provision a new slave machine by setting it to
 
52
   the value output from the drizzledump client when used with the
 
53
   --single-transaction option.
 
54
 
 
55
   This value is not allowed to be set via the configuration file since
 
56
   you would normally only set it once on initial slave startup. This
 
57
   eliminates the possibility of forgetting to delete it from the configuration
 
58
   file for subsequent slave restarts.
 
59
 
 
60
The options below are read from the configuration file.
 
61
 
 
62
.. confval:: master-host
 
63
 
 
64
   Hostname/IP address of the master server.
 
65
 
 
66
.. confval:: master-port
 
67
 
 
68
   Drizzle port used by the master server. Default is 3306.
 
69
 
 
70
.. confval:: master-user
 
71
 
 
72
   Username to use for connecting to the master server.
 
73
 
 
74
.. confval:: master-pass
 
75
 
 
76
   Password associated with the username given by :confval:`master-user`.
 
77
 
 
78
.. confval:: max-reconnects
 
79
 
 
80
   The number of reconnection attempts the slave plugin will try if the
 
81
   master server becomes unreachable. Default is 10.
 
82
 
 
83
.. confval:: seconds-between-reconnects
 
84
 
 
85
   The number of seconds to wait between reconnect attempts when the master
 
86
   server becomes unreachable. Default is 30.
 
87
 
 
88
.. confval:: io-thread-sleep
 
89
 
 
90
   The number of seconds the IO (producer) thread sleeps between queries to the
 
91
   master for more replication events. Default is 5.
 
92
 
 
93
.. confval:: applier-thread-sleep
 
94
 
 
95
   The number of seconds the applier (consumer) thread sleeps between applying
 
96
   replication events from the local queue. Default is 5.
 
97
 
 
98
Implementation Details
 
99
----------------------
 
100
 
 
101
The replication slave plugin creates two worker threads, each accessing a
 
102
work queue (implemented as an InnoDB table) that contains the replication
 
103
events. This is a producer/consumer paradigm where one thread populates the
 
104
queue (the producer), and the other thread (the consumer) reads events from
 
105
the queue.
 
106
 
 
107
The producer thread (or I/O thread) is in charge of connecting to the master
 
108
server and pulling down replication events from the master's transaction
 
109
log and storing them locally in the slave queue. It is required that the
 
110
master use the InnoDB replication log (:option:`--innodb.replication-log <drizzled --innodb.replication-log>`).
 
111
 
 
112
The consumer thread (or applier thread) reads the replication events from
 
113
the local slave queue, applies them locally, and then deletes successfully
 
114
applied events from the queue.
 
115
 
 
116
Schemas and Tables
 
117
------------------
 
118
 
 
119
The slave plugin creates its own schema and set of tables to store its
 
120
metadata. It stores everything in the **sys_replication** schema. The
 
121
following are the tables that it will create:
 
122
 
 
123
.. dbtable:: sys_replication.io_state
 
124
 
 
125
   Stores metadata about the IO/producer thread.
 
126
 
 
127
.. dbtable:: sys_replication.applier_state
 
128
 
 
129
   Stores metadata about the applier/consumer thread.
 
130
 
 
131
.. dbtable:: sys_replication.queue
 
132
 
 
133
   The replication event queue.
 
134