To configure a master to use binary log file position based replication, you must enable binary logging and establish a unique server ID. If this has not already been done, a server restart is required.
Binary logging must be enabled on the
master because the binary log is the basis for replicating
changes from the master to its slaves. If binary logging is not
enabled on the master using the
option, replication is not 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 (232)−1. How you organize and select the numbers is your choice.
To configure the binary log and server ID options, shut down the
MySQL server and edit the
my.ini file. Within the
[mysqld] section of the configuration file,
server-id options. 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.
The following options have an impact on this procedure:
If you do not set
server_id(or set it explicitly to its default value of 0), the master refuses any connections from slaves.
For the greatest possible durability and consistency in a replication setup using
InnoDBwith transactions, you should use
sync_binlog=1in the master
Ensure that the
skip_networkingsystem variable is not enabled on your replication master. If networking has been disabled, the slave cannot communicate with the master and replication fails.