MySQL non-stop short time lock table backup master standby sync new backup machine

Source: Internet
Author: User

Refresh Data
[[email protected] ~]# mysql-e ' flush tables with read lock; ' Lock table Refresh table data
[[email protected] ~]# mysql-e ' flush logs; ' Refresh log (redo log and binlog log)
[[email protected] ~]# mysql-e ' show master status; ' >/root/back.$ (date +%f+%t) Save Binlog log file name and position location

Create a snapshot of the LV
[Email protected] ~]# lvcreate-l 1g-n/dev/mydata/mysqlback-p r-s/dev/mydata/mydatalv
Release lock
[Email protected] ~]# mysql-e ' unlock tables; '

Backing Up snapshot files
[Email protected] ~]# Mkdir/myback
[Email protected] ~]# mount-r/dev/mydata/mysqlback/mnt
[Email protected] ~]# cp-a/mnt/mysql/myback

Add a standby machine
Copy the backup files to the MySQL data directory of the standby machine
[Email protected] ~]# cp-a/myback/*/data/
Start MySQL
[Email protected] ~]# service mysqld restart
Start the slave synchronization on the standby, using the Binlog file name and position location saved on the host computer
[Email protected] ~]# mysql-e ' Change master to master_host= ' 192.168.56.87 ', master_user= ' test ', master_password= ' 123 ' , master_log_file= ' mysql-bin.000005 ', master_log_pos=1370; '
[[email protected] ~]# mysql-e ' start slave '


Recovering data on the host
Copy data to MySQL data Catalog
[Email protected] ~]# cp-a/myback/*/data/
Start MySQL
[Email protected] ~]# service mysqld restart
Recover subsequent writes using the Binlog file
[Email protected] ~]# Mysqlbinlog--start-position=245/var/lib/mysql/mysql-bin.000014 > Binlog.sql
[[email protected] ~]# MySQL </root/binlog.sql

Reference http://www.jb51.net/article/96609.htm

MySQL non-stop short time lock table backup master standby sync new backup machine

Related Article

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.