Archive for the ‘binary logs’ Category

Setting up Master-Slave Replication with MySQL

Март 12th, 2011
Replication enables data from one MySQL server to be replicated on one or more other MySQL servers. Replication is mostly used as scale-out solution. In such a solution, all writes and updates take place on the master server, while reads take place on one or more slaves. This model is actually known as master-slave replication and this is the kind of replication that I will be setting up in this post.
PlanetMySQL Voting: Vote UP / Vote DOWN

Purging binary logs.

Январь 13th, 2010
Being a MySQL DBA , one faces a common issue in replication environment -> Disk space issue on master, since the number of binary logs have increased.
Now, one of the solution to this would be using expire_logs_days parameter in your mysql config file.
But what if, the slave is lagging by few hours or if the slave is broken since few days and the binary logs are removed due to the parameter set. Whenever the salve comes up, it will go bonkers, knowing that the binary log where it last stopped no more exists.

I faced this issue a couple of times until I decided to automate it using a script. Herewith I am attaching the URL to my python script which can run regularly in cron.
Features :
  • Checks the slaves connected to the master (I have limit it to 3 for now.)
  • Checks the last binary log file which is being used by the slave.
  • All the binary logs until the last bin log used by slave are purged.
  • If a slave is not connected, purging is aborted, so that important bin logs are not purged.
You can download this script from here .

Tips and Warnings to use this script
  • Test a couple of times, different test cases, before using this script on critical or production databases.
  • It is advisable to take backup of data before running this script.
  • You can send the output of this script to syslog or to different mail addresses.
  • You can embed into you alerting system, so that whenever there is a disk space warning on the machine, this scrip is fired.

PlanetMySQL Voting: Vote UP / Vote DOWN