mirrored volume lvm

A plurality of image copies can be allocated physical partitions, thereby improving the availability of data. When a disk fails and the physical partition becomes unavailable, you can still access the data on available disk mirroring. LVM mirroring is performed in the logical volume.

system version

# cat /etc/centos-release
CentOS Linux release 7.2.1511 (Core)

Disk

[root@host-192-168-100-19 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 10G 0 disk
├─vda1 252:1 0 500M 0 part /boot
└─vda2 252:2 0 9.5G 0 part
├─centos-root 253:0 0 8.5G 0 lvm /
└─centos-swap 253:1 0 1G 0 lvm [SWAP]
vdb 252:16 0 5G 0 disk
vdc 252:32 0 5G 0 disk
vdd 252:48 0 5G 0 disk

Create a physical volume

# pvcreate /dev/vdb /dev/vdc 

Create a volume group

# vgcreate wyl  /dev/vdb /dev/vdc

Create a mirrored volume

 lvcreate -L 3G -m1 -n mirror  wyl /dev/vdc /dev/vdb   

Description: 
Use -ml parameter flag to create mirrored; -L is used to set the size of the mirrored volume 3G; -n argument is used to specify the mirror name mirror. This image consists of two parts: vdb vdc and the copy volume is a data volume and partition 
view the status of logical 
view the current status of the devices lvm:

 

 # lvs -a -o +devices 

 

 Lv for new format and mirror mount

# mkfs.xfs /dev/wyl/mirror
# mkdir /mirror
# mount /dev/wyl/mirror /mirror/

Reading and writing test partition ok

# cd /mirror/
# echo "it's ok" >test
# cat test
it's ok

Lvm to destroy the mirror

# dd if=/dev/zero of=/dev/vdc count=10  

 

 You can see in the mirror lv / dev / vdc became unknown after destruction

 

 

 

 

The broken equipment is removed from the wyl in:

# vgreduce --removemissing --force wyl

View lvm devices in the current state:

# lvs -a -o +devices 

 

 Mirror data recovery (without unmounting process logical volumes) 
in adding a new wyl pv, the data recovery:

# vgextend wyl /dev/vdd

Unset mirrored volume

# lvconvert -m0 /dev/wyl/mirror

Data migration, data synchronization to the vdc vdd in

# lvconvert -m1 /dev/wyl/mirror /dev/vdd  /dev/vdc

test

# cd /mirror/
# echo 'it is ok 2' >test2
# cat test
it's ok

 

Guess you like

Origin www.cnblogs.com/ghl666/p/12376444.html