Use the snapshot feature of LVM to implement almost hot backup of data
The snapshot function of LVM can record information at a certain time point to the snapshot area. Therefore, you can use this feature to completely back up data. Then, the new data can be incrementally backed up and restored using the binary log file. Therefore, data can be almost hot-standby in this way.
Use LVM snapshot for Database Backup
To use the snapshot feature of LVM for almost hot backup, the following conditions must be met:
1. Data Files must be on logical volumes
2. The volume group of the logical volume must have enough space to store the snapshot volume.
3. data files and transaction logs must be on the same logical volume.
The implementation steps are as follows:
1. open the session, apply a read lock, lock all tables, and execute log scrolling.
Mysql> flush tables with read lock;
Mysql> flush logs;
2. Open another terminal to save binary log files, locations, and other 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 in it
# Mount/path/to/LV_NAME/path/to/dir/
# Cp-a/path/to/dir/*/path/to/otherdir/
6. delete a snapshot volume
# Umount LV_NAME
7. Incremental backup of binary log files
8. Disable the binary log function when restoring binary log files.
Mysql> set global SQL _log_bin = 0;
-------------------------------------- Split line --------------------------------------
Disk management-LVM
Linux Tutorial: Use LVM logical volume manager to manage flexible storage
Configure LVM (logical volume management) in CentOS 6.3)
Linux LVM (Logical Volume Manager) Study Notes
LVM-snapshot: LVM snapshot-based backup preparation
LVM-snapshot: LVM-based snapshot Backup
RHEL5.9 LVM usage
-------------------------------------- Split line --------------------------------------
This article permanently updates the link address: