This tutorial describes how to manually create a multi-master replication system using the multi-source replication functions in MySQL. MySQL Console
The examples in this article will be based on 3 MySQL server machines as shown below:
...
Before we start the configuration process, stop the DualShield service on all machines. If we're going to make changes to an existing replication cluster, such as adding a new master/slave server, then stop the slave process on all MySQL servers in the replication cluster.
We will carry out the tasks below on server 1:
- Creating a user for replication
- Setting up the replication Master
- Taking a database snapshot (optional)
1.1 Creating a user for replication
We need to create a pseudo-user on this server (master) that will be used by other servers (slaves) to pull replication data from this server.
Expand |
---|
Include Page |
---|
| Creating a user for MySQL replication |
---|
| Creating a user for MySQL replication |
---|
|
|
1.2 Setting up the replication Master
We will now enable this server as a replication master. This involves making changes in the MySQL configuration file.
Expand |
---|
Include Page |
---|
| Setting up a MySQL Replication Master |
---|
| Setting up a MySQL Replication Master |
---|
|
|
1.3 Taking a database snapshot
If the DualShield database has already been running for some times, then we need to take a snapshot of the database which will be copied and imported into the save servers.
Expand |
---|
Include Page |
---|
| Taking a MySQL database snapshot |
---|
| Taking a MySQL database snapshot |
---|
|
|
We will carry out the tasks below on server 2:
- Importing the database snapshot (optional)
- Creating a user for replication
- Setting up the replication Master
2.1 Importing the database snapshot
Expand |
---|
Include Page |
---|
| Importing a MySQL database snapshot |
---|
| Importing a MySQL database snapshot |
---|
|
|
2.2 Creating a user for replication
We need to create a pseudo-user on this server (master) that will be used by other servers (slaves) to pull replication data from this server.
Expand |
---|
Include Page |
---|
| Creating a user for MySQL replication |
---|
| Creating a user for MySQL replication |
---|
|
|
2.3 Setting up the replication Master
We will now enable this server as a replication master. This involves making changes in the MySQL configuration file.
Expand |
---|
Include Page |
---|
| Setting up a MySQL Replication Master |
---|
| Setting up a MySQL Replication Master |
---|
|
|
Follow the same procedure in Step 2 to to configure Server 3 as a Master
Step 4: Record the Master Binary Log Info on all Servers
We need to obtain and record the master binary log file and position on all servers
Expand |
---|
Include Page |
---|
| Obtaining the Replication Master Binary Log Info |
---|
| Obtaining the Replication Master Binary Log Info |
---|
|
|
Now, we will set up the replication slave on Server 3, connecting to Server 1 & 2 as the master.
Expand |
---|
Include Page |
---|
| Setting up a MySQL Replication Slave |
---|
| Setting up a MySQL Replication Slave |
---|
|
|
Now, we will set up the replication slave on Server 2, connecting to Server 1 & 3 as the master.
Expand |
---|
Include Page |
---|
| Setting up a MySQL Replication Slave |
---|
| Setting up a MySQL Replication Slave |
---|
|
|
Now, we will set up the replication slave on Server 1, connecting to Server 2 & 3 as the master.
...