Do not need to manually lock the table to synchronize mysql database

Source: Internet
Author: User
Tags install perl percona

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.