LVM snapshot feature for almost hot-standby
The snapshot feature of LVM can log information from a moment to the snapshot area, so you can take advantage of this feature to make a full backup of the data. The newly submitted data can then be incrementally backed up and restored using a binary log file. Therefore, it is possible to make almost hot preparation of data in this way.
To use the snapshot capabilities of LVM for almost hot provisioning, the following conditions need to be met:
1. The data file must be on a logical volume
2. The volume group where this logical volume is located must have sufficient space to store the snapshot volume
3. Data files and transaction logs are to be on the same logical volume.
The implementation steps are as follows:
1. Open session, apply read lock, lock all tables, and perform log scrolling
Mysql> flush tables with read lock;
Mysql>flush logs;
2, by opening another terminal, save the binary log files and location and other related information
$mysql-uroot-p-e ' show Master Status\g ' >/path/to/master.info
3. Create a Snapshot volume
#lvcreate-L #-s-p R-n Lv_name/path/to/source_lv_name
4. Release the lock
Mysql>unlock tables;
5. Mount the snapshot volume and copy the data inside
#mount/path/to/lv_name/path/to/dir/
#cp-a/path/to/dir/*/path/to/otherdir/
6. Deleting a snapshot volume
#umount Lv_name
7. Incremental backup binary log files
8. When restoring using binary log files, turn off the binary logging feature
Mysql>set Global sql_log_bin=0;
This article is from the "Linux Learning path" blog, so be sure to keep this source http://xslwahaha.blog.51cto.com/4738972/1585054
Using the snapshot function of LVM to make the data almost hot prepared