검색

이 콘텐츠는 선택한 언어로 제공되지 않습니다.

5.5. Creating a Mirrored LVM Logical Volume in a Cluster

download PDF
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 Section 3.1, “Creating LVM Volumes in a Cluster”.
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.
  1. 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 the lvm.conf file 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:
    # /usr/sbin/lvmconf --enable-cluster
  2. 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 the clvmd daemon is running on the node from which it was issued:
    [root@doc-07 ~]# ps auxw | grep clvmd
    root     17642  0.0  0.1 32164 1072 ?        Ssl  Apr06   0:00 clvmd -T20 -t 90
    
    The following command shows the local view of the cluster status:
    [root@doc-07 ~]# cman_tool services
    Service          Name                              GID LID State     Code
    ...
    DLM Lock Space:  "clvmd"                             7   3 run       -
    [1 2 3]
    ...
    
  3. Ensure that the cmirror and cmirror-kernel packages are installed. The cmirror-kernel package that must be installed depends on the kernel that is running. For example, if the running kernel is kernel-largesmp, it is necessary to have cmirror-kernel-largesmp for the corresponding kernel version.
  4. Start the cmirror service.
    [root@doc-07 ~]# service cmirror start
    Loading clustered mirror log:                              [  OK  ]
    
  5. 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.
    [root@doc-07 ~]# pvcreate /dev/xvdb1
      Physical volume "/dev/xvdb1" successfully created
    [root@doc-07 ~]# pvcreate /dev/xvdb2
      Physical volume "/dev/xvdb2" successfully created
    [root@doc-07 ~]# pvcreate /dev/xvdc1
      Physical volume "/dev/xvdc1" successfully created
    
  6. Create the volume group. This example creates a volume group mirrorvg that consists of the three physical volumes that were created in the previous step.
    [root@doc-07 ~]# vgcreate mirrorvg /dev/xvdb1 /dev/xvdb2 /dev/xvdc1
      Clustered volume group "mirrorvg" successfully created
    
    Note that the output of the vgcreate command indicates that the volume group is clustered. You can verify that a volume group is clustered with the vgs command, which will show the volume group's attributes. If a volume group is clustered, it will show a c attribute.
    [root@doc-07 ~]# vgs mirrorvg
      VG       #PV #LV #SN Attr   VSize  VFree
      mirrorvg   3   0   0 wz--nc 68.97G 68.97G
    
  7. Create the mirrored logical volume. This example creates the logical volume mirrorlv from the volume group mirrorvg. This volume has one mirror leg. This example specifies which extents of the physical volume will be used for the logical volume.
    [root@doc-07 ~]# lvcreate -l 1000 -m1 mirrorvg -n mirrorlv /dev/xvdb1:1-1000 /dev/xvdb2:1-1000 /dev/xvdc1:0
      Logical volume "mirrorlv" created
    
    You can use the lvs command 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.
    [root@doc-07 log]# lvs mirrorvg/mirrorlv
      LV       VG       Attr   LSize Origin Snap%  Move Log           Copy%  Convert
      mirrorlv mirrorvg mwi-a- 3.91G                    mirrorlv_mlog  47.00
    [root@doc-07 log]# lvs mirrorvg/mirrorlv
      LV       VG       Attr   LSize Origin Snap%  Move Log           Copy%  Convert
      mirrorlv mirrorvg mwi-a- 3.91G                    mirrorlv_mlog  91.00   
    [root@doc-07 ~]#  lvs mirrorvg/mirrorlv
      LV       VG       Attr   LSize Origin Snap%  Move Log           Copy%  Convert
      mirrorlv mirrorvg mwi-a- 3.91G                    mirrorlv_mlog 100.00
    
    The completion of the mirror is noted in the system log:
    May 10 14:52:52 doc-07 [19402]: Monitoring mirror device mirrorvg-mirrorlv for events
    May 10 14:55:00 doc-07 lvm[19402]: mirrorvg-mirrorlv is now in-sync
    
  8. You can use the lvs with the -o +devices options 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.
    [root@doc-07 ~]# lvs -a -o +devices
      LV                  VG         Attr   LSize  Origin Snap%  Move Log           Copy%  Convert Devices                                  
      mirrorlv            mirrorvg   mwi-a-  3.91G                    mirrorlv_mlog 100.00         mirrorlv_mimage_0(0),mirrorlv_mimage_1(0)
      [mirrorlv_mimage_0] mirrorvg   iwi-ao  3.91G                                                 /dev/xvdb1(1)                            
      [mirrorlv_mimage_1] mirrorvg   iwi-ao  3.91G                                                 /dev/xvdb2(1)                            
      [mirrorlv_mlog]     mirrorvg   lwi-ao  4.00M                                                 /dev/xvdc1(0)
    
    For release RHEL 4.8 and later, you can use the seg_pe_ranges option of the lvs to display the data layout. You can use this option to verify that your layout is properly redundant. The output of this command dispays PE ranges in the same format that the lvcreate and lvresize commands take as input.
    [root@doc-07 ~]# lvs -a -o seg_pe_ranges --segments
      PE Ranges                                      
      mirrorlv_mimage_0:0-999 mirrorlv_mimage_1:0-999
      /dev/xvdb1:1-1000                              
      /dev/xvdb2:1-1000                              
      /dev/xvdc1:0-0
    
    When you create the mirrored volume, you create the clustered_log dlm space, which will contain the dlm logs for all mirrors.
    [root@doc-07 log]# cman_tool services
    Service          Name                              GID LID State     Code
    Fence Domain:    "default"                           4   2 run       -
    [1 2 3]
    
    DLM Lock Space:  "clvmd"                            12   7 run       -
    [1 2 3]
    
    DLM Lock Space:  "clustered_log"                    14   9 run       -
    [1 2 3]
    
    User:            "usrm::manager"                    10   4 run       -
    [1 2 3]
    

Note

For information on recovering from the failure of one of the legs of an LVM mirrored volume, see Section 6.3, “Recovering from LVM Mirror Failure”.
Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.