Do not need to manually lock the table to synchronize mysql database
Ensure that the system is installedPerl-DBD-mysql
Yum install perl-DBD-mysql
InstallXtrabackup
Versions later than Xtrabackup 2.1 do not support the innodb engine. Therefore, you need to download versions 2. 0.
Wget http://www.percona.com/downloads/XtraBackup/XtraBackup-2.0.7/RPM/rhel5/x86_64/percona-xtrabackup-2.0.7-552.rhel5.x86_64.rpm
Run the rpm-ivh percona-xtrabackup-2.0.7-552.rhel5.x86_64.rpm to easily install the required package.
Execute backup
1. Make sure that the source database is in the starting state.
2. execute commands
Innobackupex -- user = yourDBuser -- password = MaGiCdB1 -- defaults-file =/etc/my. cnf <Backup directory>
The backup directory is any partition that is large enough.
3. Check whether the Backup Directory generates data.
4. Run innobackupex -- apply-log <Backup directory>
Compressing and transferring files
1. tarczvf backdir.gz backup
2、scpbackdir.gz ip:/dir
Restore data in the target database)
1. cd dir
2. tar xvzf backdir.gz
3. Make sure that the/etc/my. cnf file has rows datadir = dir
4. Make sure that the database directory is empty.
5. Run innobackupex -- copy-back -- defaults-file =/etc/my. cnf <Backup directory>
Data Synchronization
1. Start mysql
2. Execute mysql master-slave Synchronization
This article is from the sery blog, please be sure to keep this source http://sery.blog.51cto.com/10037/1271112