6.5. Creating a Mirrored LVM Logical Volume in a Cluster
			Creating a mirrored LVM logical volume in a cluster requires the same commands and procedures as creating a mirrored LVM logical volume on a single node. However, in order to create a mirrored LVM volume in a cluster the cluster and cluster mirror infrastructure must be running, the cluster must be quorate, and the locking type in the 
lvm.conf file must be set correctly to enable cluster locking, either directly or by means of the lvmconf command as described in 第 4.1 节 “在群集中创建 LVM 卷”.
		
			The following procedure creates a mirrored LVM volume in a cluster. First the procedure checks to see whether the cluster services are installed and running, then the procedure creates the mirrored volume.
		
- In order to create a mirrored logical volume that is shared by all of the nodes in a cluster, the locking type must be set correctly in thelvm.conffile in every node of the cluster. By default, the locking type is set to local. To change this, execute the following command in each node of the cluster to enable clustered locking:/sbin/lvmconf --enable-cluster # /sbin/lvmconf --enable-clusterCopy to Clipboard Copied! Toggle word wrap Toggle overflow 注意 As of Red Hat Enterprise Linux 6.7, thelvmconfcommand provides a--servicesoption that will also enable the services required for LVM in a cluster, a--mirrorserviceoption that enables thecmirrordservice, and a--startstopservicesoption that immediately starts or stops the services that have been enabled. For information on thelvmconfcommand, see thelvmconfman page.
- To create a clustered logical volume, the cluster infrastructure must be up and running on every node in the cluster. The following example verifies that theclvmddaemon is running on the node from which it was issued:ps auxw | grep clvmd root 17642 0.0 0.1 32164 1072 ? Ssl Apr06 0:00 clvmd -T20 -t 90 ps auxw | grep clvmd root 17642 0.0 0.1 32164 1072 ? Ssl Apr06 0:00 clvmd -T20 -t 90Copy to Clipboard Copied! Toggle word wrap Toggle overflow The following command shows the local view of the cluster status:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 
- Ensure that thecmirrorpackage is installed.
- Start thecmirrordservice.service cmirrord start # service cmirrord start Starting cmirrord: [ OK ]Copy to Clipboard Copied! Toggle word wrap Toggle overflow 
- Create the mirror. The first step is creating the physical volumes. The following commands create three physical volumes. Two of the physical volumes will be used for the legs of the mirror, and the third physical volume will contain the mirror log.Copy to Clipboard Copied! Toggle word wrap Toggle overflow 
- Create the volume group. This example creates a volume groupvg001that consists of the three physical volumes that were created in the previous step.vgcreate vg001 /dev/sdb1 /dev/sdc1 /dev/sdd1 # vgcreate vg001 /dev/sdb1 /dev/sdc1 /dev/sdd1 Clustered volume group "vg001" successfully createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Note that the output of thevgcreatecommand indicates that the volume group is clustered. You can verify that a volume group is clustered with thevgscommand, which will show the volume group's attributes. If a volume group is clustered, it will show a c attribute.vgs vg001 VG #PV #LV #SN Attr VSize VFree vg001 3 0 0 wz--nc 68.97G 68.97G vgs vg001 VG #PV #LV #SN Attr VSize VFree vg001 3 0 0 wz--nc 68.97G 68.97GCopy to Clipboard Copied! Toggle word wrap Toggle overflow 
- Create the mirrored logical volume. This example creates the logical volumemirrorlvfrom the volume groupvg001. This volume has one mirror leg. This example specifies which extents of the physical volume will be used for the logical volume.lvcreate -l 1000 -m1 vg001 -n mirrorlv /dev/sdb1:1-1000 /dev/sdc1:1-1000 /dev/sdd1:0 # lvcreate -l 1000 -m1 vg001 -n mirrorlv /dev/sdb1:1-1000 /dev/sdc1:1-1000 /dev/sdd1:0 Logical volume "mirrorlv" createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow You can use thelvscommand to display the progress of the mirror creation. The following example shows that the mirror is 47% synced, then 91% synced, then 100% synced when the mirror is complete.Copy to Clipboard Copied! Toggle word wrap Toggle overflow The completion of the mirror is noted in the system log:May 10 14:52:52 doc-07 [19402]: Monitoring mirror device vg001-mirrorlv for events May 10 14:55:00 doc-07 lvm[19402]: vg001-mirrorlv is now in-sync May 10 14:52:52 doc-07 [19402]: Monitoring mirror device vg001-mirrorlv for events May 10 14:55:00 doc-07 lvm[19402]: vg001-mirrorlv is now in-syncCopy to Clipboard Copied! Toggle word wrap Toggle overflow 
- You can use thelvswith the-o +devicesoptions to display the configuration of the mirror, including which devices make up the mirror legs. You can see that the logical volume in this example is composed of two linear images and one log.Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can use theseg_pe_rangesoption of thelvsto display the data layout. You can use this option to verify that your layout is properly redundant. The output of this command displays PE ranges in the same format that thelvcreateandlvresizecommands take as input.Copy to Clipboard Copied! Toggle word wrap Toggle overflow 
注意
				For information on recovering from the failure of one of the legs of an LVM mirrored volume, see 第 7.3 节 “修复 LVM 镜像错误”.