Skip to content

olc/auto_repl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Create a rMySQL eplica is not a complex operation but as I prefer watching Puppet do it for me, I made some piece of scripts in order to automate this.

It is based to the great xtrabackup tools of Percona (works with any MySQL version> = 5), which allows to hot backup a MySQL server (MyISAM and InnoDB are supported).

The works like this: when deploying the replicate, puppet starts a script that does the following:

- stop mysql
- rm /var/lib/mysql (I do not backup)
- get hot backup on the master via xinetd/netcat
- perform some treatments (mainly apply binlog), CHANGE MASTER ...
- restart mysql

The -m option can be used to also make a CHANGE MASTER on the master after the creation of the replica: it is helpful if both servers are in circular replication (aka master / master).

I have only tested on debian/squeeze but other distro should need not need more than some path fixes.

Master side:
xinetd.conf 
xinet_mysql_repl_srv.sh (/opt/puppet/bin/xinet_mysql_repl_srv.sh in my case)

Slave side:
mysql_repl_init.sh

(In case of circular replication, please drops eveything on each server)

On slave server (here's a percona 5.5), the following command will populate mysql data, then set CHANGE MASTER also on the master (master-master, or circular replication):

# mysql_repl_init.sh -f -m -x xtrabackup

Launch "mysql_repl_init.sh -h" to get a short help.

The script allows you to use SSH (-s option) instead of xinetd but I have not so much tested it (especially because it's faster via netcat/xinetd).

Attention, I'm not very hostile environment, the security mechanisms are quite light (a common secret to authenticate) and a simple allow_from in the xinetd conf.

That's it. Nothing complicated in and puppet is absolutely not mandatory.

HTH.

Usefull links:
http://www.percona.com/doc/percona-xtrabackup/
http://vitobotta.com/painless-hot-backups-mysql-live-databases-percona-xtrabackup/
http://www.dctrwatson.com/2010/07/taking-a-hot-backup-of-a-mysql-database-with-xtrabackup/

About

Populate a MySQL replica on line

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published