What is master-slave replication in database?
Master-slave replication enables data from one database server (the master) to be replicated to one or more other database servers (the slaves). The master logs the updates, which then ripple through to the slaves. Master-slave replication can be either synchronous or asynchronous.
How does master-slave work in MySQL?
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.
How does MySQL copy user accounts from master to slave?
A note on user accounts: each database has its own directory in /var/lib/mysql – including a database called “mysql”. This is MySQL’s own database in which it stores users and their privileges. Hence, when you import all your previous databases into the slave, you’ll automatically copy all user accounts from the master too.
Is it possible to replicate an existing MySQL server?
This is a step-by-step guide on how to replicate an existing MySQL server. The server is live and contains data and needs a constant backup companion. Many tutorials focus on how to setup replication when no data is present on the system.
How do I change MySQL ID for my Slave?
Open a new SSH session and edit /etc/my.cnf, then give your slave a unique ID: It doesn’t have to be just 1 or 2, you can go crazy and use a 10 digit number if you like. Just make sure the master and slave to not have the same ID. Just as before, restart MySQL on the Slave for the change to take effect:
What happens when a slave reads a Master log?
This log is read later by the slave and contains a collection of statements of what has been executed by the master. Therefore the slave just remembers the position of where he last read the log, and from then onwards just does what the master does. Hence the slave ends up being in sync.