How to create RAID-5 and mirror in LVM in Redhat ?

I have tested the RAID5 and RAID1 configuration in my test lab.

My test lab :

RHEL 6.2 64 bit

Volume Group : demo_vg consist of /dev/sdc1 /dev/sdd1 /dev/sde1

Logical Volume : demo_lv1

==================================RAID5================================

Step 1 : We will create demo_lv1 raid5 volume using two stripes and stripesize of 64kiB.

[root@Node2 ~]# lvcreate –type raid5 -L 100M -i 2 -I 64 -n demo_lv1 demo_vg
WARNING: RAID segment types are considered Tech Preview
For more information on Tech Preview features, visit:
https://access.redhat.com/support/offerings/techpreview/
Rounding size (25 extents) up to stripe boundary size (26 extents)
Logical volume “demo_lv1” created
[root@Node2 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg_node2 lvm2 a– 11.51g 0
/dev/sdc1 demo_vg lvm2 a– 1016.00m 960.00m
/dev/sdd1 demo_vg lvm2 a– 1016.00m 960.00m
/dev/sde1 demo_vg lvm2 a– 1016.00m 960.00m

Step 2 : I have create ext4 file system on top of volume mounted it on /mnt.

[root@Node2 ~]# df -h /mnt
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/demo_vg-demo_lv1
101M 5.6M 90M 6% /mnt

[root@Node2 ~]# time dd if=/dev/zero of=/mnt/test1 bs=512 count=1000 oflag=dsync
1000+0 records in
1000+0 records out
512000 bytes (512 kB) copied, 3.56304 s, 144 kB/s

real 0m3.567s
user 0m0.001s
sys 0m0.005s

==========================MIRROR========================

Step 1 : I have destroyed the previous setup and created new mirror volume with name demo_lv1. I have created only single mirror.

[root@Node2 ~]# lvcreate -m 1 –size 100M –nosync -n demo_lv1 demo_vg
WARNING: New mirror won’t be synchronised. Don’t read what you didn’t write!
Logical volume “demo_lv1” created

[root@Node2 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
demo_lv1 demo_vg Mwi-a- 100.00m demo_lv1_mlog 100.00
lv_root vg_node2 -wi-ao 9.57g
lv_swap vg_node2 -wi-ao 1.94g

Step 2 :  I have create ext4 file system on volume and mounted that file system on /mnt/

[root@Node2 ~]# cd /mnt
[root@Node2 mnt]# time dd if=/dev/zero of=/mnt/test1 bs=512 count=1000 oflag=dsync
1000+0 records in
1000+0 records out
512000 bytes (512 kB) copied, 3.04246 s, 168 kB/s

real 0m3.045s
user 0m0.000s
sys 0m0.005s

I can see that 100MB space has been consumed from two physical volumes.

[root@Node2 mnt]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg_node2 lvm2 a– 11.51g 0
/dev/sdc1 demo_vg lvm2 a– 1016.00m 916.00m
/dev/sdd1 demo_vg lvm2 a– 1016.00m 916.00m
/dev/sde1 demo_vg lvm2 a– 1016.00m 1012.00m

Step 3 : I tried to convert volume from mirror 1 to mirror 0 but end up with mess.

[root@Node2 ~]# lvconvert -m0 demo_vg/demo_lv1

[root@Node2 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg_node2 lvm2 a– 11.51g 0
/dev/sdc1 demo_vg lvm2 a– 1016.00m 916.00m
/dev/sdd1 demo_vg lvm2 a– 1016.00m 1016.00m
/dev/sde1 demo_vg lvm2 a– 1016.00m 1016.00m

Step 4 : Then again convert the volume into mirror volume.

[root@Node2 ~]# lvconvert -m1 demo_vg/demo_lv1
demo_vg/demo_lv1: Converted: 0.0%
demo_vg/demo_lv1: Converted: 100.0%

[root@Node2 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg_node2 lvm2 a– 11.51g 0
/dev/sdc1 demo_vg lvm2 a– 1016.00m 916.00m
/dev/sdd1 demo_vg lvm2 a– 1016.00m 916.00m
/dev/sde1 demo_vg lvm2 a– 1016.00m 1012.00m
Step 5 : Below is the Correct way of splitting mirror. Here I have converted the existing mirrored volume demo_lv1 into demo_lv2 

[root@Node2 ~]# lvconvert –splitmirrors 1 –name demo_lv2 demo_vg/demo_lv1 /dev/sdd1
Logical volume demo_lv1 converted.
[root@Node2 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
demo_lv1 demo_vg -wi-ao 100.00m
demo_lv2 demo_vg -wi-a- 100.00m
lv_root vg_node2 -wi-ao 9.57g
lv_swap vg_node2 -wi-ao 1.94g

Step 6 : I mounted the demo_lv2 file system on new mount point to see whether my data is present or not.

[root@Node2 ~]# mount -t ext4 /dev/demo_vg/demo_lv2 /mirrot

[root@Node2 ~]# df -h /mirrot/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/demo_vg-demo_lv2
97M 6.1M 86M 7% /mirrot

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s