AIX系統(tǒng)學(xué)習(xí)之-ODM管理
成都創(chuàng)新互聯(lián)公司長(zhǎng)期為數(shù)千家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺(tái),與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為松嶺企業(yè)提供專業(yè)的成都網(wǎng)站建設(shè)、網(wǎng)站制作,松嶺網(wǎng)站改版等技術(shù)服務(wù)。擁有10多年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。
AIX ODM(Object Database Manager)是由一組對(duì)象類和對(duì)象所組成的數(shù)據(jù)庫。對(duì)象類相當(dāng)于Oracle數(shù)據(jù)庫中的object,由ODM create創(chuàng)建,刪除可以使用ODM drop,對(duì)象就相當(dāng)于object下的數(shù)據(jù)(比如磁盤、Adapter等),可以使用ODM add命令加入對(duì)象,使用ODM delete命令刪除,使用ODM change命令修改指定記錄。查詢的命令可以使用odmget。
一、使用 ODM 命令
當(dāng)使用 odmcreate 或者 odmdrop 命令來創(chuàng)建或者刪除對(duì)象類時(shí),請(qǐng)使用以下方法之一指定將從中訪問類定義文件的目錄:
將文件存儲(chǔ)在 $ODMDIR 指示的缺省目錄下,即:/usr/lib/objrepos 目錄。
[root@aix211 /]#echo $ODMDIR /etc/objrepos
比較常用的命令是odmget與odmadd命令:
1、odmget:
odmget [ -q Criteria ] ObjectClass ...
描述
odmget 命令以搜索規(guī)則和對(duì)象類列表為輸入,從指定的對(duì)象類中檢索選定的對(duì)象,并寫 ASCII odmadd 輸入文件到標(biāo)準(zhǔn)輸出。
標(biāo)志
-q Criteria 指定用于從對(duì)象類中選擇對(duì)象的搜索條件。如果沒有指定標(biāo)準(zhǔn)(沒有 -q 標(biāo)志),檢索對(duì)象類中的所有對(duì)象。
#odmget -q name=hdisk1 CuAt |more CuAt: name = "hdisk1" attribute = "unique_id" value = "2308AJ27R0820cdnES-309170W03IBMscsi" type = "R" generic = "" rep = "sl" nls_index = 0
2、odmadd :
添加對(duì)象到創(chuàng)建的對(duì)象類。
語法
odmadd [ InputFile ... ]
描述
odmadd 命令以一個(gè)或多個(gè)InputFile 文件為輸入,并且添加對(duì)象到帶有節(jié)文件數(shù)據(jù)的對(duì)象類中。每個(gè) InputFile 文件是 ASCII 文件,包含有描述要添加到對(duì)象類中的對(duì)象的數(shù)據(jù)。如果沒有指定文件,從標(biāo)準(zhǔn)輸入中獲取輸入。
在使用odmadd命令之前,最好使用odmget 查詢并生成樣本文件,然后修改一下,再使用odmadd命令加入指定的對(duì)象類。
注意:odmadd 將把對(duì)象添加到$ODMDIR變量指定的目錄所對(duì)應(yīng)的對(duì)象類中去。
比如:
取一份odm樣板;
# odmget -q name=hdisk2 CuAt > hdisk3odm.add
編輯樣本文件,最重要的是修改pvid屬性回原有硬盤的pvid,另外一項(xiàng)屬性u(píng)nique_id名字也一起修改了。當(dāng)然還有name要更正為hdisk3。插入修改過的文件到CuAt
# odmadd hdisk3odm.add
3、odmshow命令:
odmshow 命令以對(duì)象類名稱(ObjectClass)為輸入并在屏幕上顯示類描述。 類描述的格式采用 odmcreate 命令的輸入格式。
#odmshow CuDv |more class CuDv { char name[16]; /* offset: 0xc ( 12) */ short status; /* offset: 0x1c ( 28) */ short chgstatus; /* offset: 0x1e ( 30) */ char ddins[16]; /* offset: 0x20 ( 32) */ char location[16]; /* offset: 0x30 ( 48) */ char parent[16]; /* offset: 0x40 ( 64) */ char connwhere[16]; /* offset: 0x50 ( 80) */ link PdDv PdDv uniquetype PdDvLn[48]; /* offset: 0x60 ( 96) */ }; /* descriptors: 8 structure size: 0x98 (152) bytes data offset: 0x200030e8 population: 55 objects (55 active, 0 deleted) */
需要了解的幾個(gè)對(duì)象類:
PdDv 預(yù)定義設(shè)備庫
PdDv: type = "scsd" class = "pdisk" subclass = "ssar" prefix = "pdisk" devid = ""
以上三個(gè)參數(shù) 再使用mkdev的時(shí)候需要用到,需要特別關(guān)注,如果查找起來不方便的話,可以使用lsdev –P –H 產(chǎn)看預(yù)配置數(shù)據(jù)庫中的這三個(gè)選項(xiàng)。此項(xiàng)對(duì)于使用mkdev生成虛設(shè)備也非常方便。
PdAt 預(yù)定義屬性庫
PdAt: uniquetype = "tape/scsi/8mm" attribute = "block_size" deflt = "1024" values = "0-245760,1"
CuDv 用戶自定義設(shè)備庫
CuDv: name = "rmt0" status = 1 chgstatus = 2 ddins = "tape" location = "04-C0-00-1,0" parent = "scsi0" connwhere = "1,0" PdDvLn = "tape/scsi/8mm"
CuDv:
name = "hdisk1" status = 1 chgstatus = 2 ddins = "scdisk" location = "10-60-00-1,0" parent = "scsi0" connwhere = "1,0" PdDvLn = "disk/scsi/scsd"
CuAt:用戶自定義屬性庫
CuAt: name = "hdisk1" attribute = "unique_id" value = "2308AJ27R0820CDNES-309170W03IBMscsi" type = "R" generic = "" rep = "sl" nls_index = 0
由以上輸出可以看出,在使用odmget命令查找odm用戶數(shù)據(jù)庫信息時(shí),可以使用 name=×作為查詢key。
二、Additional Device Object Classes:
CuDep:
name = "rootvg" dependency = "hd6"
CuDep:
name = "datavg" dependency = "lv01"
CuDvDr: 設(shè)備驅(qū)動(dòng)
resource = "devno" value1 = "22" value2 = "0" value3 = "rmt0"
CuVPD: 設(shè)備vpd信息 vital product data
name = "rmt0" vpd = "*MFEXABYTE PN21F8842"
PdCn: 預(yù)定義配置信息
uniquetype = "adapter/pci/sym875" connkey = "scsi" connwhere = "1,0"
三、ODM 管理的系統(tǒng)數(shù)據(jù)包括:
設(shè)備配置信息
SMIT(菜單、選擇器和對(duì)話框)的顯示信息
安裝和更新過程的重要產(chǎn)品數(shù)據(jù)
通信配置信息
系統(tǒng)資源信息
注意:ODM中不包含設(shè)備驅(qū)動(dòng)程序,只能從設(shè)備驅(qū)動(dòng)文件往CuDvDr中寫驅(qū)動(dòng)記錄
設(shè)備狀態(tài):
Define:沒有加載驅(qū)動(dòng),但odm中有定義
Available:已加載驅(qū)動(dòng),并將驅(qū)動(dòng)記錄進(jìn)CuDvDr.
Stopped:停止?fàn)顟B(tài),有些設(shè)備支持此狀態(tài)
四、案例:
搜索對(duì)象所屬的對(duì)象類別:
Usage:
for i in `ls $ODMDIR`; do (odmget $i 2>/dev/null |grep -p 特定字符串); done
1、搜索hdisk0所屬的對(duì)象類別
[root@aix211 /]#for i in `ls $ODMDIR`; do (odmget $i 2>/dev/null |grep -p hdisk0);done
CuAt: name = "hdisk0" attribute = "unique_id" value = "21080005E93A0AST373307LC03IBMscsi" type = "R" generic = "" rep = "nl" nls_index = 79 CuAt: name = "hdisk0" attribute = "pvid" value = "00040f8aaa29d28e0000000000000000" type = "R" generic = "D" rep = "s" nls_index = 2 CuAt: name = "hdisk0" attribute = "size_in_mb" value = "73400" type = "R" generic = "D" rep = "nr" nls_index = 60 CuAt: name = "hdisk0" attribute = "led" value = "0x57D" type = "Z" generic = "" rep = "nr" nls_index = 0 CuAt: name = "hdisk0" attribute = "message_no" value = "87" type = "T" generic = "" rep = "nl" nls_index = 0 CuAt: name = "hdisk0" attribute = "diag_scsd" value = "a500000107000507000c0d" type = "R" generic = "" rep = "s" nls_index = 0 CuDv: name = "hdisk0" status = 1 chgstatus = 2 ddins = "scdisk" location = "1S-08-00-8,0" parent = "scsi0" connwhere = "8,0" PdDvLn = "disk/scsi/scsd" CuDvDr: resource = "devno" value1 = "24" value2 = "0" value3 = "hdisk0" CuPath: name = "hdisk0" parent = "scsi0" connection = "8,0" alias = "" path_status = 1 path_id = 0 CuVPD: name = "hdisk0" vpd_type = 0 vpd = "*MFIBM *TM\n\ ST373307LC *F00P3072 *RL4335304A*SN0005E93A*ECH12094 *P00P2672 *Z0\n\ 000003129F00013E*Z0812C512"
2、搜索網(wǎng)關(guān)地址所屬的對(duì)象類別:
[root@aix211 /]#for i in `ls $ODMDIR`; do (odmget $i 2>/dev/null |grep -p 192.168.8.1);done
CuAt: name = "inet0" attribute = "route" value = "net,-hopcount,0,,0,192.168.8.1" type = "R" generic = "DU" rep = "s" nls_index = 0
通過以上可以了解,每個(gè)對(duì)象所屬的對(duì)象類別,然后可以用odmdelete刪除對(duì)應(yīng)的對(duì)象即可
例如刪除hdisk0:
[root@aix211 /]#odmdelet -o CuDv -q "name=hdisk0"