I wrote myself a small script that produces the following shell command.
echo "CHANGE MASTER TO MASTER_USER='slave_user';" | mysql -uroot -pXXX --host=SLAVE &&
echo "CHANGE MASTER TO MASTER_PASSWORD='slave_password';" | mysql -uroot -pXXX --host=SLAVE &&
echo "STOP SLAVE;" | mysql -uroot -pXXX --host=SLAVE &&
mysqldump -uroot -pXXX --host=MASTER --add-drop-database --master-data=1 --databases database1 database2 | mysql -uroot -pXXX --host=SLAVE &&
echo "START SLAVE;" | mysql -C -uroot -pXXX --host=SLAVE
It should be possible to be run either on the slave or the master. However I am aware that the advantage of compression using the -C
switch is only given when run on the master.
My master server is configured with the following settings (only shown what differs fromthe default. I use mysql server version 5.1.41.
[mysqld]
bind-address = 0.0.0.0
max_connections = 600
server-id = 1
log_bin = /media/mysql-ebs/log_bin/mysql-bin.log
binlog_do_db = database1
binlog_do_db = database2
datadir = /media/mysql-ebs/datadir
My slave(s) are configured as follows:
server-id = UNIQUE-ID
replicate-do-db = database1
replicate-do-db = database2
The server runs MyIsam as well as InnoDB Tables.
My Questions are:
- Did I miss anything?
- Will data consistency be ensured even if clients try read/write during the backup?
- Are there any problesm/considerations/suggestions for this command?