-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
43 lines (27 loc) · 1.96 KB
/
Copy pathREADME
File metadata and controls
43 lines (27 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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/