Jump to: navigation, search

Reddwarf-MySQL-Replication-and-Clustering

Revision as of 21:08, 1 May 2013 by Imsplitbit (talk | contribs) (Created page with "'''How master-slave replication works:''' * Replication in mysql works basically via log shipping. * The mysql master logs all data manipulation events in the mysql binary l...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

How master-slave replication works:

  • Replication in mysql works basically via log shipping.
  • The mysql master logs all data manipulation events in the mysql binary log.
  • While this is happening the slave instances are connected to the master via TCP and receive the same events and write them to their relay log.
  • Binary logging should be turned *on* on the master and *off* on the slaves.
  • If binary logging is turned on on the slave you will suffer massive IO hits as each log entry writes to the relay log, then the table, then the binary log.
  • there are 2 internal mysql threads that exist on the slave, the SQL thread and the IO thread
  • the IO thread is responsible for getting binary events from the master and the SQL thread is responsible for applying them locally.
  • slaves should be read-only, allowing data manipulation statements on slaves will result in corrupt or out of sync slaves

How to know that replication broke:

  • parse the output of "SHOW SLAVE STATUS" on the replicated slave.
  • the IO thread is set to No
  • the SQL thread is set to No
  • the seconds_behind_master is > a set number and isn't reducing over time (this is a conditional case that we need to define).
  • This case is a failure because it means that for whatever reason the slave will never be in sync with the master.
  • This can be due to the slave not having enough resources to keep up or that the master has too many slaves.
  • If ever any of these 3 things are true it is assumed that replication is broken and the slave is to be destroyed and recreated.

Steps to setup replicaiton: No point in rewriting known steps, follow instructions here: MySQL Replication Documentation