Contents
How does MySQL master-slave replication work?
Replication works as follows: Whenever the master’s database is modified, the change is written to a file, the so-called binary log, or binlog. The slave has another thread, called the SQL thread, that continuously reads the relay log and applies the changes to the slave server.
What is master-slave replication in MySQL?
MySQL replication is a process that enables data from one MySQL database server (the master) to be copied automatically to one or more MySQL database servers (the slaves). However, general principles of setting up the MySQL master-slave replication on the same machine are the same for all operating systems.
Can I delete MySQL bin log files?
Those are mysql bin logs. The server can get seriously irritated if you delete them with rm. Instead, use PURGE BINARY LOGS TO ‘mysql-bin. 010’; as the root mysql user to let it safely delete the files.
What is MySQL master-master replication?
Master-Master replication, also known as mirror, is by far the simplest technique you can use to increase the performance and the reliability of your MySQL server installation. If you don’t know what it is, just imagine two MySQL server instances continuosly updating each other in real-time while fullfilling their job.
Is it safe to delete Binlog files?
2 Answers. It’s all in the MySQL documentation that they are binary log files for data recovery and synchronizing. Look at the documentation on how to get rid of them. But make sure that you don’t need them in your current setup.
How to create a replication slave in MySQL?
Connect to the master instance using the MySQL client with the appropriate host and port: mysql> CREATE USER ‘replication’@’%’ IDENTIFIED BY ‘replication’; mysql> GRANT REPLICATION SLAVE ON *.* TO ‘replication’@’%’; Exit from the MySQL client.
How to setup a second MySQL instance as a slave?
To setup the second MySQL instance as a slave, set server-id to 2, as it must be different to the master’s server-id. Since both instances will run on the same machine, set port for the second instance to 3307 since it has to be different from the port used for the first instance, which is 3306 by default.
What’s the difference between master and slave replication?
As the master-slave replication is a one-way replication (from master to slave), only the master database is used for the write operations, while read operations may be spread on multiple slave databases.
How is data copied from one MySQL server to another?
MySQL replication is a process that enables data from one MySQL database server (the master) to be copied automatically to one or more MySQL database servers (the slaves).