Centos 7 LVM raid

Source: Internet
Author: User

Centos 7How to create an LVM Image

1. Create a disk partition

First, partition the SDB and SDC, and create four PVS (sdb1, sdb2, sdc1, and sdc2). Then create vg0 and add sd1 and sdc1 to it. Run the following commands in sequence:

Fdisk/dev/SDB-create three extended partitions:/dev/sdb1 and/dev/sdb2
Partprobe-re-read the Partition Table

Pvcreate/dev/sdb1
Pvcreate/dev/sdb2
Pvdisplay
Fdisk/dev/SDC-create partition/dev/SDC
Partprobe
Pvcreate/dev/sdc1

Pvcreate/dev/sdc2

Pvdisplay
Vgcreate vg0/dev/sdb1/dev/sdc1-create vg0

2. Create an LVM image/dev/vg0/Mirror

Use the-ml parameter flag to create an image. Use the-l parameter to set the image volume size to 1000 MB. Use the-n parameter to specify the image name as mirror. This image consists of two parts: sdb1 and sdc1 as the data volume and replica volume partitions.

Lvcreate-l 1000 m-M1-N mirror vg0/dev/sdb1/dev/sdc1

View the status of/dev/vg0/Mirror:

Lvdisplay/dev/vg0/Mirror

View the status of devices in the current LVM:

LVS-a-O + Devices

3. Format and mount the new image LV.

Mkfs. ext3/dev/vg0/Mirror
Mkdir/Mirror
Mount/dev/vg0/mirror/

4. damage the image LVM

Damage a piece of PV to see if it works properly

Dd If =/dev/Zero of =/dev/sdb5 COUNT = 10

After the image is damaged, the/dev/sdb5 in the image LV becomes unknown:

LVS-a-O + Devices
Lvscan

Attach the image LV again and find that it is still usable.

Umount/mirror/
Mount/dev/vg0/mirror/
CD/mirror/

Remove the faulty device from vg0:

Vgreduce -- removemissing -- force vg0

Removed and found vg0 InformationMirrored volumesOption Missing

Vgdisplay/dev/vg0

5. Image Data Recovery

Add a new PV in vg0 to restore the data:

Vgextend vg0/dev/sdb2

Lvconvert-M1/dev/vg0/mirror/dev/sdb2/dev/SDC

Check the device status again and we will find that sdb2 has replaced the position of sdb1.

LVS-a-O + Devices


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.