Menu Close

Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

5.5. 在​​​​​​​叢​​​​​​​集​​​​​​​中​​​​​​​建​​​​​​​立​​​​​​​鏡​​​​​​​像​​​​​​​ LVM 邏​​​​​​​輯​​​​​​​卷​​​​​​​冊​​​​​​​

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 節 3.1, “在​​​​​​​叢​​​​​​​集​​​​​​​中​​​​​​​建​​​​​​​立​​​​​​​ LVM 卷​​​​​​​冊​​​​​​​”.
下​​​​​​​列​​​​​​​程​​​​​​​序​​​​​​​將​​​​​​​會​​​​​​​在​​​​​​​叢​​​​​​​集​​​​​​​中​​​​​​​建​​​​​​​立​​​​​​​一​​​​​​​個​​​​​​​鏡​​​​​​​像​​​​​​​ LVM 卷​​​​​​​冊​​​​​​​。​​​​​​​首​​​​​​​先​​​​​​​,程​​​​​​​序​​​​​​​會​​​​​​​查​​​​​​​看​​​​​​​叢​​​​​​​集​​​​​​​服​​​​​​​務​​​​​​​是​​​​​​​否​​​​​​​已​​​​​​​安​​​​​​​裝​​​​​​​並​​​​​​​運​​​​​​​作​​​​​​​中​​​​​​​,然​​​​​​​後​​​​​​​該​​​​​​​程​​​​​​​序​​​​​​​便​​​​​​​會​​​​​​​建​​​​​​​立​​​​​​​鏡​​​​​​​像​​​​​​​卷​​​​​​​冊​​​​​​​。​​​​​​​
  1. 若​​​​​​​要​​​​​​​建​​​​​​​立​​​​​​​一​​​​​​​個​​​​​​​會​​​​​​​被​​​​​​​叢​​​​​​​集​​​​​​​中​​​​​​​所​​​​​​​有​​​​​​​節​​​​​​​點​​​​​​​共​​​​​​​享​​​​​​​的​​​​​​​鏡​​​​​​​像​​​​​​​邏​​​​​​​輯​​​​​​​卷​​​​​​​冊​​​​​​​,叢​​​​​​​集​​​​​​​中​​​​​​​所​​​​​​​有​​​​​​​節​​​​​​​點​​​​​​​的​​​​​​​ lvm.conf 檔​​​​​​​案​​​​​​​裡​​​​​​​的​​​​​​​鎖​​​​​​​定​​​​​​​類​​​​​​​型​​​​​​​皆​​​​​​​必​​​​​​​須​​​​​​​經​​​​​​​過​​​​​​​正​​​​​​​確​​​​​​​設​​​​​​​置​​​​​​​。​​​​​​​就​​​​​​​預​​​​​​​設​​​​​​​值​​​​​​​,鎖​​​​​​​定​​​​​​​類​​​​​​​型​​​​​​​會​​​​​​​被​​​​​​​設​​​​​​​為​​​​​​​ local。​​​​​​​若​​​​​​​要​​​​​​​進​​​​​​​行​​​​​​​修​​​​​​​改​​​​​​​,請​​​​​​​在​​​​​​​叢​​​​​​​集​​​​​​​的​​​​​​​各​​​​​​​個​​​​​​​節​​​​​​​點​​​​​​​中​​​​​​​執​​​​​​​行​​​​​​​下​​​​​​​列​​​​​​​指​​​​​​​令​​​​​​​,以​​​​​​​啟​​​​​​​用​​​​​​​叢​​​​​​​集​​​​​​​鎖​​​​​​​定​​​​​​​:
    # /usr/sbin/lvmconf --enable-cluster
  2. 若​​​​​​​要​​​​​​​建​​​​​​​立​​​​​​​叢​​​​​​​集​​​​​​​邏​​​​​​​輯​​​​​​​卷​​​​​​​冊​​​​​​​,叢​​​​​​​集​​​​​​​架​​​​​​​構​​​​​​​必​​​​​​​須​​​​​​​經​​​​​​​過​​​​​​​設​​​​​​​定​​​​​​​並​​​​​​​執​​​​​​​行​​​​​​​於​​​​​​​叢​​​​​​​集​​​​​​​中​​​​​​​的​​​​​​​所​​​​​​​有​​​​​​​節​​​​​​​點​​​​​​​上​​​​​​​。​​​​​​​以​​​​​​​下​​​​​​​範​​​​​​​例​​​​​​​驗​​​​​​​證​​​​​​​了​​​​​​​ clvmd daemon 正​​​​​​​在​​​​​​​節​​​​​​​點​​​​​​​上​​​​​​​運​​​​​​​作​​​​​​​:
    [root@doc-07 ~]# ps auxw | grep clvmd
    root     17642  0.0  0.1 32164 1072 ?        Ssl  Apr06   0:00 clvmd -T20 -t 90
    
    下​​​​​​​列​​​​​​​指​​​​​​​令​​​​​​​顯​​​​​​​示​​​​​​​了​​​​​​​叢​​​​​​​集​​​​​​​狀​​​​​​​態​​​​​​​的​​​​​​​本​​​​​​​機​​​​​​​視​​​​​​​點​​​​​​​:
    [root@doc-07 ~]# cman_tool services
    Service          Name                              GID LID State     Code
    ...
    DLM Lock Space:  "clvmd"                             7   3 run       -
    [1 2 3]
    ...
    
  3. 請​​​​​​​確​​​​​​​認​​​​​​​ cmirror 與​​​​​​​ cmirror-kmod 套​​​​​​​件​​​​​​​已​​​​​​​被​​​​​​​安​​​​​​​裝​​​​​​​。​​​​​​​cmirror-kmod 套​​​​​​​件​​​​​​​需​​​​​​​根​​​​​​​據​​​​​​​運​​​​​​​作​​​​​​​中​​​​​​​的​​​​​​​ kernel 來​​​​​​​進​​​​​​​行​​​​​​​安​​​​​​​裝​​​​​​​。​​​​​​​比​​​​​​​方​​​​​​​說​​​​​​​,若​​​​​​​運​​​​​​​作​​​​​​​中​​​​​​​的​​​​​​​ kernel 為​​​​​​​ kernel-largesmp 的​​​​​​​話​​​​​​​,您​​​​​​​便​​​​​​​需​​​​​​​要​​​​​​​安​​​​​​​裝​​​​​​​ cmirror-kmod-largesmp 來​​​​​​​相​​​​​​​應​​​​​​​ kernel 版​​​​​​​本​​​​​​​。​​​​​​​
  4. 啟​​​​​​​用​​​​​​​ cmirror 服​​​​​​​務​​​​​​​。​​​​​​​
    [root@doc-07 ~]# service cmirror start
    Loading clustered mirror log:                              [  OK  ]
    
  5. 建​​​​​​​立​​​​​​​鏡​​​​​​​像​​​​​​​。​​​​​​​第​​​​​​​一​​​​​​​個​​​​​​​步​​​​​​​驟​​​​​​​就​​​​​​​是​​​​​​​建​​​​​​​立​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​。​​​​​​​下​​​​​​​列​​​​​​​指​​​​​​​令​​​​​​​會​​​​​​​建​​​​​​​立​​​​​​​三​​​​​​​個​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​。​​​​​​​其​​​​​​​中​​​​​​​兩​​​​​​​個​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​將​​​​​​​會​​​​​​​被​​​​​​​用​​​​​​​來​​​​​​​作​​​​​​​為​​​​​​​鏡​​​​​​​像​​​​​​​的​​​​​​​ leg,並​​​​​​​且​​​​​​​第​​​​​​​三​​​​​​​個​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​將​​​​​​​會​​​​​​​包​​​​​​​含​​​​​​​鏡​​​​​​​像​​​​​​​的​​​​​​​ 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. 建​​​​​​​立​​​​​​​卷​​​​​​​冊​​​​​​​群​​​​​​​組​​​​​​​。​​​​​​​此​​​​​​​範​​​​​​​例​​​​​​​將​​​​​​​會​​​​​​​建​​​​​​​立​​​​​​​一​​​​​​​個​​​​​​​卷​​​​​​​冊​​​​​​​群​​​​​​​組​​​​​​​ vg001,它​​​​​​​將​​​​​​​會​​​​​​​包​​​​​​​含​​​​​​​著​​​​​​​先​​​​​​​前​​​​​​​步​​​​​​​驟​​​​​​​中​​​​​​​所​​​​​​​建​​​​​​​立​​​​​​​的​​​​​​​三​​​​​​​個​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​。​​​​​​​
    [root@doc-07 ~]# vgcreate vg001 /dev/xvdb1 /dev/xvdb2 /dev/xvdc1
      Clustered volume group "vg001" 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 vg001
      VG       #PV #LV #SN Attr   VSize  VFree
      vg001      3   0   0 wz--nc 68.97G 68.97G
    
  7. 建​​​​​​​立​​​​​​​鏡​​​​​​​像​​​​​​​邏​​​​​​​輯​​​​​​​卷​​​​​​​冊​​​​​​​。​​​​​​​此​​​​​​​範​​​​​​​例​​​​​​​將​​​​​​​會​​​​​​​由​​​​​​​卷​​​​​​​冊​​​​​​​群​​​​​​​組​​​​​​​ vg001 建​​​​​​​立​​​​​​​邏​​​​​​​輯​​​​​​​卷​​​​​​​冊​​​​​​​ mirrorlv。​​​​​​​此​​​​​​​卷​​​​​​​冊​​​​​​​含​​​​​​​有​​​​​​​一​​​​​​​個​​​​​​​鏡​​​​​​​像​​​​​​​ leg。​​​​​​​此​​​​​​​範​​​​​​​例​​​​​​​會​​​​​​​指​​​​​​​定​​​​​​​實​​​​​​​體​​​​​​​卷​​​​​​​冊​​​​​​​的​​​​​​​哪​​​​​​​個​​​​​​​扇​​​​​​​區​​​​​​​會​​​​​​​被​​​​​​​用​​​​​​​來​​​​​​​作​​​​​​​為​​​​​​​邏​​​​​​​輯​​​​​​​卷​​​​​​​冊​​​​​​​。​​​​​​​
    [root@doc-07 ~]# lvcreate -l 1000 -m1 vg001 -n mirrorlv /dev/xvdb1:1-1000 /dev/xvdb2:1-1000 /dev/xvdc1:0
      Logical volume "mirrorlv" created
    
    您​​​​​​​可​​​​​​​使​​​​​​​用​​​​​​​ lvs 指​​​​​​​令​​​​​​​來​​​​​​​顯​​​​​​​示​​​​​​​鏡​​​​​​​像​​​​​​​建​​​​​​​立​​​​​​​的​​​​​​​完​​​​​​​成​​​​​​​度​​​​​​​。​​​​​​​下​​​​​​​列​​​​​​​範​​​​​​​例​​​​​​​顯​​​​​​​示​​​​​​​了​​​​​​​鏡​​​​​​​像​​​​​​​已​​​​​​​完​​​​​​​成​​​​​​​了​​​​​​​ 47% 的​​​​​​​同​​​​​​​步​​​​​​​、​​​​​​​接​​​​​​​著​​​​​​​ 91%,然​​​​​​​後​​​​​​​當​​​​​​​鏡​​​​​​​像​​​​​​​完​​​​​​​成​​​​​​​時​​​​​​​將​​​​​​​會​​​​​​​顯​​​​​​​示​​​​​​​ 100% 同​​​​​​​步​​​​​​​化​​​​​​​。​​​​​​​
    [root@doc-07 log]# lvs vg001/mirrorlv
      LV       VG       Attr   LSize Origin Snap%  Move Log           Copy%  Convert
      mirrorlv vg001    mwi-a- 3.91G                    vg001_mlog     47.00
    [root@doc-07 log]# lvs vg001/mirrorlv
      LV       VG       Attr   LSize Origin Snap%  Move Log           Copy%  Convert
      mirrorlv vg001    mwi-a- 3.91G                    vg001_mlog     91.00   
    [root@doc-07 ~]#  lvs vg001/mirrorlv
      LV       VG       Attr   LSize Origin Snap%  Move Log           Copy%  Convert
      mirrorlv vg001    mwi-a- 3.91G                    vg001_mlog    100.00
    
    鏡​​​​​​​像​​​​​​​完​​​​​​​成​​​​​​​後​​​​​​​將​​​​​​​會​​​​​​​被​​​​​​​紀​​​​​​​錄​​​​​​​在​​​​​​​系​​​​​​​統​​​​​​​日​​​​​​​誌​​​​​​​檔​​​​​​​中​​​​​​​:
    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
    
  8. 您​​​​​​​可​​​​​​​使​​​​​​​用​​​​​​​ lvs 指​​​​​​​令​​​​​​​以​​​​​​​及​​​​​​​ -o +devices 選​​​​​​​項​​​​​​​來​​​​​​​顯​​​​​​​示​​​​​​​鏡​​​​​​​像​​​​​​​的​​​​​​​配​​​​​​​置​​​​​​​,包​​​​​​​括​​​​​​​鏡​​​​​​​像​​​​​​​ leg 是​​​​​​​由​​​​​​​哪​​​​​​​些​​​​​​​裝​​​​​​​置​​​​​​​所​​​​​​​組​​​​​​​成​​​​​​​的​​​​​​​。​​​​​​​在​​​​​​​此​​​​​​​範​​​​​​​例​​​​​​​中​​​​​​​,您​​​​​​​可​​​​​​​發​​​​​​​現​​​​​​​邏​​​​​​​輯​​​​​​​卷​​​​​​​冊​​​​​​​是​​​​​​​由​​​​​​​兩​​​​​​​個​​​​​​​ linear image 和​​​​​​​一​​​​​​​個​​​​​​​ log 所​​​​​​​組​​​​​​​成​​​​​​​的​​​​​​​。​​​​​​​
    [root@doc-07 ~]# lvs -a -o +devices
      LV                  VG         Attr   LSize  Origin Snap%  Move Log           Copy%  Convert Devices                                  
      mirrorlv            vg001      mwi-a-  3.91G                    mirrorlv_mlog 100.00         mirrorlv_mimage_0(0),mirrorlv_mimage_1(0)
      [mirrorlv_mimage_0] vg001      iwi-ao  3.91G                                                 /dev/xvdb1(1)                            
      [mirrorlv_mimage_1] vg001      iwi-ao  3.91G                                                 /dev/xvdb2(1)                            
      [mirrorlv_mlog]     vg001      lwi-ao  4.00M                                                 /dev/xvdc1(0)
    
    在​​​​​​​ RHEL 5.2 或​​​​​​​更​​​​​​​新​​​​​​​版​​​​​​​本​​​​​​​上​​​​​​​,您​​​​​​​可​​​​​​​使​​​​​​​用​​​​​​​ lvs 的​​​​​​​ seg_pe_ranges 選​​​​​​​項​​​​​​​來​​​​​​​顯​​​​​​​示​​​​​​​資​​​​​​​料​​​​​​​格​​​​​​​式​​​​​​​。​​​​​​​您​​​​​​​可​​​​​​​使​​​​​​​用​​​​​​​此​​​​​​​選​​​​​​​項​​​​​​​來​​​​​​​驗​​​​​​​證​​​​​​​您​​​​​​​的​​​​​​​格​​​​​​​式​​​​​​​是​​​​​​​否​​​​​​​正​​​​​​​確​​​​​​​。​​​​​​​這​​​​​​​項​​​​​​​指​​​​​​​令​​​​​​​的​​​​​​​輸​​​​​​​出​​​​​​​會​​​​​​​將​​​​​​​ PE 範​​​​​​​圍​​​​​​​以​​​​​​​ lvcreate 與​​​​​​​ lvresize 指​​​​​​​令​​​​​​​所​​​​​​​接​​​​​​​受​​​​​​​的​​​​​​​輸​​​​​​​入​​​​​​​格​​​​​​​式​​​​​​​來​​​​​​​顯​​​​​​​示​​​​​​​。​​​​​​​
    [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
    
    當​​​​​​​您​​​​​​​建​​​​​​​立​​​​​​​鏡​​​​​​​像​​​​​​​卷​​​​​​​冊​​​​​​​時​​​​​​​,您​​​​​​​將​​​​​​​會​​​​​​​建​​​​​​​立​​​​​​​ clustered_log dlm 空​​​​​​​間​​​​​​​,它​​​​​​​將​​​​​​​會​​​​​​​包​​​​​​​含​​​​​​​著​​​​​​​所​​​​​​​有​​​​​​​鏡​​​​​​​像​​​​​​​的​​​​​​​ dlm lock。​​​​​​​
    [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]