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 卷冊。首先,程序會查看叢集服務是否已安裝並運作中,然後該程序便會建立鏡像卷冊。
- 若要建立一個會被叢集中所有節點共享的鏡像邏輯卷冊,叢集中所有節點的
lvm.conf
檔案裡的鎖定類型皆必須經過正確設置。就預設值,鎖定類型會被設為 local。若要進行修改,請在叢集的各個節點中執行下列指令,以啟用叢集鎖定:#
/usr/sbin/lvmconf --enable-cluster
- 若要建立叢集邏輯卷冊,叢集架構必須經過設定並執行於叢集中的所有節點上。以下範例驗證了
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] ... - 請確認
cmirror
與cmirror-kmod
套件已被安裝。cmirror-kmod
套件需根據運作中的 kernel 來進行安裝。比方說,若運作中的 kernel 為kernel-largesmp
的話,您便需要安裝cmirror-kmod-largesmp
來相應 kernel 版本。 - 啟用
cmirror
服務。[root@doc-07 ~]#
service cmirror start
Loading clustered mirror log: [ OK ] - 建立鏡像。第一個步驟就是建立實體卷冊。下列指令會建立三個實體卷冊。其中兩個實體卷冊將會被用來作為鏡像的 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 - 建立卷冊群組。此範例將會建立一個卷冊群組
vg001
,它將會包含著先前步驟中所建立的三個實體卷冊。[root@doc-07 ~]#
vgcreate vg001 /dev/xvdb1 /dev/xvdb2 /dev/xvdc1
Clustered volume group "vg001" successfully createdNote that the output of thevgcreate
command indicates that the volume group is clustered. You can verify that a volume group is clustered with thevgs
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 - 建立鏡像邏輯卷冊。此範例將會由卷冊群組
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
- 您可使用
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]
注意
For information on recovering from the failure of one of the legs of an LVM mirrored volume, see 節 6.3, “由 LVM 鏡像錯誤中復原”.