天天看點

AIX 系統中 PVID 的含義與作用

Pvid是aix系統中的ODM LVM用于識别PV的序列号,作業系統通過pvid來識别pv,就好像我們每個人的ID card。

當pv被添加到系統中之後,可以通過兩種方式生成pvid

1,cfgmgr -v 2,lspv 如果沒有PVID的話,執行chdev -l hdiskn -a pv=yes

也就是說當系統可以識别硬碟 并将硬碟認可為pv(即lvm的元件)的時候。系統就配置設定了pvid給硬碟,系統的odm庫中儲存有pvid。

Pvid的生成原則是 主機闆序列号+形成pv時候的時間戳,pvid除了寫入odm庫,在硬碟頭資訊裡(0扇區的頭幾個位元組)以及VGDA 也将寫入pvid

To make a disk into a physical volume, the PVID is placed onto the disk. ThePVID is an combination of the machine's serial number (from the systems EPROMs) and the date the PVID was generated. This combination ensures the extremely low chance of PVIDs being duplicated. When the system is booted, the disk configurator looks at the PVID residing on the disk and compares it with an entry in the ODM. If an entry is found, then the disk is given the hdiskx number in the ODM that is associated with the PVID. If there is no matching entry, then the next name in the pool of 'free' hdisk names is allocated to the physical volume.

可以通過 lquerypv -H hdisk0檢視pv上的pvid

ibm150:[/]#lquerypv -H /dev/hdisk0 000af70de396426b0000000000000000 ibm150:[/]#lspv hdisk0 000af70de396426b datavg hdisk1 000af70d5c816fc2 rootvg hdisk2 000af70d4d50358c rootvg

可以看到三個pv的pvid前幾位數字是相同的(即主機闆序列号),後幾位數字是不同的。

可以通過以下方法修改pvid

chdev -l hdisk1 -a pv=clear 清除pv 磁盤頭的pvid

chdev -l hdisk1 -a pv=yes 重新定義pvid

如果pv已經加入卷組,首先還得先varyoffvg ,exportvg

執行以上步驟,pv的pvid将會改變。這裡修改的隻是磁盤頭的pvid,并沒有修改vgda中的pvid

當pv已經是一個卷組的成員時,切記不要随便修改pvid

因為當pv加入一個卷組的時候,pvid将被寫入vgda,如果你擅自修改卷組的pvid,然後新生成的pvid将不能和卷組vgda中的pvid相比對,這樣就無法importvg,就無法varyonvg,很有可能就會丢失資料!

當importvg的時候,odm将讀取pv上的vgda,如果vgda上pvid與自身磁盤上的pvid不符合的話,将出現錯誤!

注意:當pv加入卷組以後,pvid在硬碟上存在于至少兩個地方,一個是在硬碟頭,一個是在vgda中。這兩個地方的pvid一般是相同的,但是由于pvid的修改,可能造成不一緻,這樣就有可能丢失資料。

你可以通過

#lqueryvg -Atp hdisk0 檢視pv vgda中的pvid

ibm150:[/]#lqueryvg -Atp hdisk0 Max LVs: 256 PP Size: 25 Free PPs: 85 LV count: 3 PV count: 1 Total VGDAs: 2 Conc Allowed 0 MAX PPs per 1016 MAX PVs: 32 Conc Autovar 0 Varied on Co 0 Logical: 000af70d00004c0000000106e3964781.1 loglv00 1 000af70d00004c0000000106e3964781.2 lv00 1 000af70d00004c0000000106e3964781.3 lv02 1 Physical: 000af70de396426b 2 0 Total PPs: 542 LTG size: 128 HOT SPARE: 0 AUTO SYNC: 0 VG PERMISSIO 0

當然萬一修改了,還是有辦法恢複資料的!

1, 修複卷組(推薦)

1.首先将原卷組的定義從系統的ODM庫中删除:

# exportvg vgname

2.檢查硬碟上VGDA 區的資訊,從中得到有關邏輯卷的名稱及定義:

如:

#lqueryvg -Atp hdisk2 Max LVs: ------256 PP Size: ------26 Free PPs: -----538 LV count: -----2 PV count: -----1 Total VGDAs: --2 Conc Allowed --0 MAX PPs per ---1016 MAX PVs: ------32 Conc Autovar --0 Varied on Co --0 Logical: ------0003f62a00004c00000000f52f1737c5.1 --datalv1 1 ---------------0003f62a00004c00000000f52f1737c5.2 --datalv2 1 Physical: -----0003f62a2f135f0e --------------2 ----0 Total PPs: ----542 LTG size: -----128 HOT SPARE: ----0 AUTO SYNC: ----0 VG PERMISSIO --0

3.建立邏輯卷名對應表檔案。 第一字段為VGDA區中的邏輯卷的名,第二字段為在新卷組中新的邏輯卷名,可相同也可不同;為了修複原有卷組的内容,通常邏輯卷名保持不變。

#vi /tmp/lvname

datalv1:datalv1

datalv2:datalv2

4. 在硬碟上重新建立卷組,保留原有卷組的資料結構。

#recreatevg -y vgname -l lv_file hdisk_name...

#recreatevg -y testvg -l /tmp/lvname hdisk2

5. 如果卷組上有檔案系統,還需修改 /etc/filesystems ,使對應的檔案系統的加載點與原來的一緻。首先修改/etc/filesystems檔案,不行的話就執行下面的步驟

或者:

如果在重新import後,發現mountpoint不同,可以通過smitty chlv修改lv屬性,即修改Logical volume LABEL,使之與mount point相同。

為什麼要修改/etc/filesystem呢?

recreatevg 後,系統自動建立了目錄/fs,所有的檔案系統加載到了/fs下,原來的mountpoint是以/為基準的.

來源連結:

http://blog.chinaunix.net/u1/39140/showart_304297.html

本文轉自 pk2008 51CTO部落格,原文連結:http://blog.51cto.com/837244/1057495