- 220.127.116.11 Setting the Replication Master Configuration
- 18.104.22.168 Setting the Replication Slave Configuration
- 22.214.171.124 Creating a User for Replication
- 126.96.36.199 Obtaining the Replication Master Binary Log Coordinates
- 188.8.131.52 Creating a Data Snapshot Using mysqldump
- 184.108.40.206 Creating a Data Snapshot Using Raw Data Files
- 220.127.116.11 Setting Up Replication with New Master and Slaves
- 18.104.22.168 Setting Up Replication with Existing Data
- 22.214.171.124 Introducing Additional Slaves to an Existing Replication Environment
- 126.96.36.199 Setting the Master Configuration on the Slave
This section describes how to set up complete replication of a MySQL server. There are a number of different methods for setting up replication, and the exact method to use depends on how you are setting up replication, and whether you already have data within your master database.
There are some generic tasks that are common to all replication setups:
On the master, you must enable binary logging and configure a unique server ID. This might require a server restart. See Section 188.8.131.52, “Setting the Replication Master Configuration”.
On each slave that you want to connect to the master, you must configure a unique server ID. This might require a server restart. See Section 184.108.40.206, “Setting the Replication Slave Configuration”.
You may want to create a separate user that will be used by your slaves to authenticate with the master to read the binary log for replication. The step is optional. See Section 220.127.116.11, “Creating a User for Replication”.
Before creating a data snapshot or starting the replication process, you should record the position of the binary log on the master. You will need this information when configuring the slave so that the slave knows where within the binary log to start executing events. See Section 18.104.22.168, “Obtaining the Replication Master Binary Log Coordinates”.
If you already have data on your master and you want to use it to synchronize your slave, you will need to create a data snapshot. You can create a snapshot using mysqldump (see Section 22.214.171.124, “Creating a Data Snapshot Using mysqldump”) or by copying the data files directly (see Section 126.96.36.199, “Creating a Data Snapshot Using Raw Data Files”).
You will need to configure the slave with settings for connecting to the master, such as the host name, login credentials, and binary log file name and position. See Section 188.8.131.52, “Setting the Master Configuration on the Slave”.
Once you have configured the basic options, you will need to follow the instructions for your replication setup. A number of alternatives are provided:
If you are establishing a new MySQL master and one or more slaves, you need only set up the configuration, as you have no data to exchange. For guidance on setting up replication in this situation, see Section 184.108.40.206, “Setting Up Replication with New Master and Slaves”.
If you are already running a MySQL server, and therefore already have data that must be transferred to your slaves before replication starts, have not previously configured the binary log and are able to shut down your MySQL server for a short period during the process, see Section 220.127.116.11, “Setting Up Replication with Existing Data”.
If you are adding slaves to an existing replication environment, you can set up the slaves without affecting the master. See Section 18.104.22.168, “Introducing Additional Slaves to an Existing Replication Environment”.
If you will be administering MySQL replication servers, we suggest that you read this entire chapter through and try all statements mentioned in Section 13.4.1, “SQL Statements for Controlling Master Servers”, and Section 13.4.2, “SQL Statements for Controlling Slave Servers”. You should also familiarize yourself with the replication startup options described in Section 16.1.3, “Replication and Binary Logging Options and Variables”.
Note that certain steps within the setup process require the
SUPER privilege. If you do not
have this privilege, it might not be possible to enable