For many years, MySQL replication used to be based on binary log events. It was considered that all a slave knew was the exact event and the exact position it just read from the master. Any single transaction from a master could have ended in different binary logs, and also, in different positions in these logs. GTID (Global Transaction ID) was introduced along with MySQL 5.6. It has brought, along, some major changes in the way MySQL operates. Every transaction has a unique identifier which identifies it in a same way on every server. It’s not important, anymore, in which binary log position a transaction was recorded, all you need to know is the GTID.
Database replication is used to handle multiple copies of data, automatically, from the master database server to slave database servers. If we have changed data or schema in the master database, it will, automatically, update the slave database. The main advantage of replication is that it prevents the data loss. If the master database server is crashed, the exact copy of data will be there in the slave server. In MySQL, you can use MySQL Utility for implementing database replication between master and slave. MySQL Utility is a package that is used for maintenance and administration of MySQL servers. You can install MySQL utility, along with MySQL Workbench, or install it as a stand-alone package.
This article explains how MySQL replication is implemented using GTID, with an example. In this example, two servers have been used – one master and one slave. Both servers are configured in the same manner with MySQL server and MySQL Utility.
Following are the steps used to implement replication:
- Enable GTID mode on both servers.
- Grant remote access to both servers by executing following commands.
- Establish Replication between master and slave using mysqlreplicate command.
Click here to Download the full document to understand the implementation stages in MySQL replication using GTID.
By Aneesha K. A.
.Net Developer, RapidValue Solutions