How to Set Up Replication
1434
Note
Note that certain steps within the setup process require the
SUPER
[578]
privilege. If you do not have this privilege, it might not be possible to enable
replication.
16.1.1.1. Setting the Replication Master Configuration
On a replication master, you must enable binary logging and establish a unique server ID. If this has
not already been done, this part of master setup requires a server restart.
Binary logging must be enabled on the master because the binary log is the basis for sending data
changes from the master to its slaves. If binary logging is not enabled, replication will not be possible.
Each server within a replication group must be configured with a unique server ID. This ID is used to
identify individual servers within the group, and must be a positive integer between 1 and (2
32
)–1. How
you organize and select the numbers is entirely up to you.
To configure the binary log and server ID options, you will need to shut down your MySQL server and
edit the
my.cnf
or
my.ini
file. Add the following options to the configuration file within the
[mysqld]
section. If these options already exist, but are commented out, uncomment the options and alter them
according to your needs. For example, to enable binary logging using a log file name prefix of
mysql-
bin
, and configure a server ID of 1, use these lines:
[mysqld]
log-bin=mysql-bin
server-id=1
After making the changes, restart the server.
Note
If you omit
server-id
[1442]
(or set it explicitly to its default value of 0), a
master refuses connections from all slaves.
Note
For the greatest possible durability and consistency in a
replication setup using
InnoDB
with transactions, you should use
innodb_flush_log_at_trx_commit=1
and
sync_binlog=1
in the master
my.cnf
file.
Note
Ensure that the
skip-networking
[421]
option is not enabled on your
replication master. If networking has been disabled, your slave will not able to
communicate with the master and replication will fail.
16.1.1.2. Setting the Replication Slave Configuration
On a replication slave, you must establish a unique server ID. If this has not already been done, this
part of slave setup requires a server restart.
If the slave server ID is not already set, or the current value conflicts with the value that you have
chosen for the master server, you should shut down your slave server and edit the configuration to
specify a unique server ID. For example:
[mysqld]
server-id=2
After making the changes, restart the server.
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...