Home Database Mysql Tutorial Linux-6.5下MariaDB-10基于LVM快照的备份数据详解

Linux-6.5下MariaDB-10基于LVM快照的备份数据详解

Jun 07, 2016 pm 03:56 PM
lvm based on Snapshot

理解部分: LVM是逻辑盘卷管理(Logical Volume Manager)的简称,它是Linux环境下对磁盘分区进行管理的一种机制,LVM是建立在硬盘和分区之上的一个逻辑层,来提高磁盘分区管理的灵活性。LVM可以对分区在线扩容,快照,镜像和条带化,功能非常强大。这篇文章

理解部分:

LVM是逻辑盘卷管理(Logical Volume Manager)的简称,它是Linux环境下对磁盘分区进行管理的一种机制,LVM是建立在硬盘和分区之上的一个逻辑层,来提高磁盘分区管理的灵活性。LVM可以对分区在线扩容,快照,镜像和条带化,功能非常强大。这篇文章的主题就是其中一个功能——快照。

快照(Snapshot)就是关于指定数据集合的一个完全可用拷贝,该拷贝包括相应数据在某个时间点(拷贝开始的时间点)的映像。快照可以是其所表示的数据的一个副本,也可以是数据的一个复制品;

其实快照就相当于一张照片,照的某个时刻都应的lv的数据。如果在快照以后,lv的数据发生变化,快照就会将变化的数据拷贝到snap中,这样你通过快照去访问lv时,数据还是原来的数据。当然,在你创建snap的时候,肯定给这个快照指定了一个大小,如果变化的数据量超过了的指定的大小,那么快照将会损坏。


下面是简单的配置步骤:

一、事先准备好LVM的环境. 1、查看是否创建LVM(是否挂载):

wKiom1NriSOTwY9MAAKcUSdyFb8073.jpg

2、当前lvs、vgs 的使用信息: wKiom1NriSTRwpSzAAJC7DJvhyc741.jpg


二、请求全解锁及二进制日志. 1、导入测试环境的库: wKioL1NriPrA0XHSAAFMP3IMlDY788.jpg
2、请求全局锁,并滚动日志: wKiom1NriSbD_dflAAILETzSlOo015.jpg 3、查看滚动日志的状态: wKioL1NriPyh5yNBAAFIlQGpnLY028.jpg


三、做好二进制日志的标记. 1、创建用于备份的目录
wKioL1NriPzgBiBvAACnqW9hprw804.jpg
2、做二进制日志文件及位置标记(手动进行); wKiom1NriSfwZCUrAAGTwDKVy8M388.jpg


四、创建LVM快照及释放全局锁. 1、创建快照卷 wKioL1NriP3ByacLAAD_taBXh94902.jpg
2、释放全局锁 wKiom1NriSeTRUKOAACOty9Sfy8388.jpg


五、备份数据及删除快照. 1、挂载快照卷并查看是否成功挂载: wKioL1NriP7xi36-AAH04PR4AYw428.jpg
2、在备份之前往表中插入数据以便测试:查看表及表中数据: wKiom1NriSnAYsywAAJNJ2s9eU8389.jpg
3、查看表及表中数据: wKioL1NriP-DaT-eAAF3eLZuKPE777.jpg
4、备份/mnt/mydata/目录下hellodb和test目录: wKiom1NriSrhXVPUAAF2J_SAx4k829.jpg
5、备份完成之后,卸载及删除快照卷: wKiom1NriSrwDBMVAAD5EQpRXmw669.jpg

六、模拟数据丢失.
1、不小心停止了MySQL服务: wKioL1NriQDRVMK8AACm27bjWPg163.jpg
2、不小心将/data/mydata/目录下(hellodb和test)删除的数据: wKiom1NriSugTzuLAAJ5ASNkRqw887.jpg

七、模拟恢复数据. 1、将之前备份的数据还原: wKioL1NriQGhms1PAAIC_D4g9Rk307.jpg
2、启动MySQL服务: wKiom1NriSzw-9ogAABfj2fGgdI661.jpg
3、连入MySQL查看表数据: wKioL1NriQHRQodQAACzPkwY92E682.jpg
4、查看/backups/binlog.pos文件: wKiom1NriSygCRgsAAEYJlz2Fm8757.jpg 5、执行mysqlbinlog命令查看: wKioL1NriQPif_MIAAJUPXUEhIk599.jpg
6、将其导入至MySQL中: wKioL1NriQORu707AAB4FUgUt4M335.jpg
7、最后在连入MySQL并且查看是否恢复: wKiom1NriS-CTm5kAACV6yAEeu8195.jpg 8、最后给一个建议: wKiom1NritrTGwfxAACoV78nH6I788.jpg

OK!!!
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed explanation of CentOS cloning and snapshot functions in virtual machines Detailed explanation of CentOS cloning and snapshot functions in virtual machines Jan 15, 2024 pm 04:09 PM

For beginners, it is best to take a snapshot or clone after installing the system! 1. How to use snapshots 1. Open the snapshot manager, 2. Start: take a snapshot, 3. Complete the snapshot. 4. Snapshot recovery: Just choose to go to a snapshot. The snapshot function is very simple to use and is suitable for beginners! 2. Use of cloning 1. Cloning function: For test users, it saves a lot of steps to install a new virtual machine; it does not need to occupy a lot of hard disk space, it is not a complete virtual machine, it may only be tens of megabytes; The clone machine depends on the original virtual machine; 2. Start cloning. Note: To clone a virtual machine, you need to shut down the host! 3. Select the cloning source, 4. Select the linked clone, 5. Select the storage location of the cloned virtual machine, 6. Cloning is completed.

How to use LVM disk operation commands in Linux disk management How to use LVM disk operation commands in Linux disk management May 23, 2023 pm 01:58 PM

LVM, LogicalVolumeManger, is a logical volume management function provided by the Linux kernel. It is composed of kernel drivers and application layer tools. It creates a logical layer based on the hard disk partitions, which can be very flexible and very convenient to manage storage devices. . LVM uses the device-mapper function of the Linux kernel to virtualize the storage system (system partitions are independent of the underlying hardware). Through LVM, the storage space can be abstracted and virtual partitions can be established on it. Partitions can be expanded and reduced more easily. When adding or deleting partitions, there is no need to worry about not having enough contiguous space on a certain hard disk to avoid losing space for the one being used. disk

Does linux use lvm? Does linux use lvm? Mar 13, 2023 am 11:25 AM

Linux uses lvm. LVM refers to logical volume management, which is a mechanism for managing disk partitions in the Linux environment. LVM is a logical layer built on the hard disk and partitions to improve the flexibility of disk partition management. The biggest feature of LVM is that it can dynamically manage disks. Because the size of the logical volume can be dynamically adjusted without losing existing data; if a new hard disk is added, it will not change the existing upper logical volume. As a dynamic disk management mechanism, logical volume technology greatly improves the flexibility of disk management.

How to expand the default LVM space of Linux How to expand the default LVM space of Linux Feb 19, 2024 pm 07:30 PM

1. Introduction to LinuxLVM LinuxLogicalVolumeManager (LVM) is a tool for managing disks and storage space. It provides flexible storage management through volume groups and logical volumes. The core concepts of LVM include physical volumes, volume groups and logical volumes. Physical volume (PhysicalVolume, PV): A physical volume is a physical hard disk or partition, which is used by LVM to store data. LVM combines one or more physical volumes into volume groups. Volume Group (VG): A volume group is a logical storage unit composed of one or more physical volumes. Logical volumes are created on volume groups, and they can dynamically allocate and reclaim storage space. A system can contain multiple volume groups. logical volume (

What is the lvm partition of linux? What is the lvm partition of linux? Mar 24, 2023 am 09:48 AM

The lvm partition of Linux refers to "logical volume management". The full English name of lvm is "Logical Volume Manager", which is a mechanism for managing disk partitions in the Linux environment; LVM is a logic built on the hard disk and partitions. layer to improve the flexibility of disk partition management.

Do you need lvm in linux? Do you need lvm in linux? May 14, 2023 pm 08:49 PM

Linux uses lvm. LVM refers to logical volume management, which is a mechanism for managing disk partitions in the Linux environment. LVM is a logical layer built on the hard disk and partitions to improve the flexibility of disk partition management. The biggest feature of LVM is that it can dynamically manage disks. Because the size of the logical volume can be dynamically adjusted without losing existing data; if a new hard disk is added, it will not change the existing upper logical volume. As a dynamic disk management mechanism, logical volume technology greatly improves the flexibility of disk management. Introduction to LVM LVM is the abbreviation of Logical Volume Manager (LogicalVolumeManager). It is a method for managing disk partitions in the Linux environment.

Anomaly detection problem based on time series Anomaly detection problem based on time series Oct 09, 2023 pm 04:33 PM

The problem of anomaly detection based on time series requires specific code examples. Time series data is data recorded in a certain order over time, such as stock prices, temperature changes, traffic flow, etc. In practical applications, anomaly detection of time series data is of great significance. An outlier can be an extreme value that is inconsistent with normal data, noise, erroneous data, or an unexpected event in a specific situation. Anomaly detection can help us discover these anomalies and take appropriate measures. For time series anomaly detection problems, commonly used

How to add a hard disk and adjust the LVM size on CentOS7? How to add a hard disk and adjust the LVM size on CentOS7? Jan 02, 2024 pm 12:00 PM

LVM is the abbreviation of LogicalVolumeManager (Logical Volume Management), which is a mechanism for managing disk partitions in the Linux environment. LVM virtualizes one or more disk partitions (PV) into a volume group (VG), which is equivalent to a large hard disk, on which we can divide some logical volumes (LV). When the space in the volume group is insufficient, new disk partitions can be added. We can also allocate some space from the remaining space of the volume group for use by logical volumes that do not have enough space. The LVM model is as shown below: There is no need to restart to refresh the new hard disk file. First, use the cat command cat/proc/scsi/scsi to browse the Id:??What is the largest one? Then echo "scsiadd-

See all articles