AIX LVM底层数据结构剖析.docx
《AIX LVM底层数据结构剖析.docx》由会员分享,可在线阅读,更多相关《AIX LVM底层数据结构剖析.docx(23页珍藏版)》请在冰豆网上搜索。
AIXLVM底层数据结构剖析
AIXLVM底层数据结构剖析(根据qintl讲稿整理)
背景:
一个关于数据丢失后的恢复问题,在LU中引起热烈的讨论,在相关的讨论帖中,qintl对LVM底层数据结构做了详细而精彩的演讲,受益匪浅。
现将qintl主要讲稿内容整理如下,以便大家阅读。
相关讨论帖地址:
一个硬盘在AIX系统下系统保留区数据结构,AIX下的Block其实就是512Byte,编号从0开始,跟我们所说的扇区是一样的。
以下是我机器上某块盘的信息
想了解更多的东西,请阅读:
硬盘物理位置,用扇区标记(sec)
Readvgda结果(readvgda-shdisk10)
0sec(开始)
bootrecord
bad-blockdirectory
LVMrecord(7sec和70sec)
Readvgda会调用LVMrecord中的数据
mirrorwriteconsistency(MWC)record
LVMrecord记录着lvmarea最基本的参数
127sec(结束)
lvmid:
1598838349
vgid:
0037521400004c00000000dc6ffba362
lvmarea_len:
4212 -->(vgda_len+vgsa_len)*2
vgda_len:
2098
vgda_psn[0]:
136
vgda_psn[1]:
2242
reloc_psn:
286749223
pv_num:
1
pp_size:
28
vgsa_len:
8
vgsa_psn[0]:
128
vgsa_psn[1]:
2234
version:
8
vg_type:
-8739
图片是7sec的十六进制视图,可以通过十六进制转换成上面某些参数的十进制数值。
128sec(开始)
VGSA数据区
135sec(结束)
*****************************************
VGSAatblock128
*****************************************
*****************************************
vgsabeg:
timestamp946773107(386e9c73),314919315(12c54993)
vgsabeg:
timestampSatJan 118:
31:
47CST:
2000
vgsa.pv_missing:
0
vgsa.stalepp[0]:
0000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000
vgsa.stalepp[1]:
0000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000
vgsa.stalepp[2]:
ff3f0ffffffffff70000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000
vgsa.factor:
1
vgsa.pad2:
000
vgsaend:
timestamp946773107(386e9c73),314919315(12c54993)
vgsaend:
timestampSatJan 118:
31:
47CST:
2000
*****************************************
136sec(开始)
VGDA数据区
LP/PPMAP
2233sec(结束)
*****************************************
VGDAatblock136
*****************************************
*****************************************
vgh.vg_id:
0037521400004c00000000dc6ffba362
vgh.numlvs:
1
vgh.maxlvs:
256
vgh.pp_size:
28
vgh.numpvs:
3
vgh.total_vgdas:
3
vgh.vgda_size:
2098
vgh.quorum:
1
vgh.auto_varyon:
1
vgh.check_sum:
0
vgdahdr:
timestamp946773107(386e9c73),352680539(15057a5b)
vgdahdr:
timestampSatJan 118:
31:
47CST:
2000
以上是从136扇区读取的
********** LogicalVolume:
datalv4 ***********
lve.lvname:
0
lve.maxsize:
512
lve.lv_state:
1
lve.mirror:
3
lve.mirror_policy:
2
lve.num_lps:
10
lve.permissions:
1
lve.bb_relocation:
1
lve.write_verify:
2
lve.mirwrt_consist:
1
lve.stripe_exp:
0
lve.striping_width:
0
lve.lv_avoid:
0
lve.child_minor_num:
0
********** PhysicalVolume:
1 ***********
pvh.pv_num:
1
pvh.pv_id:
003752146ff9501b
pvh.pp_count:
546
pvh.pv_state:
1
pvh.pvnum_vgdas:
1
pvh.psn_part1:
4352
* pv_num:
pp_num:
pp_state lv_name:
lp_num:
pp_copy_val:
pv_fst_mir:
part_fst_mir:
p
v_snd_mir:
part_snd_mir
* pv1:
111:
1 datalv4:
1:
1:
3:
15:
2:
4
* pv1:
112:
1 datalv4:
2:
1:
3:
16:
2:
5
* pv1:
113:
1 datalv4:
3:
1:
3:
17:
2:
6
* pv1:
114:
1 datalv4:
4:
1:
3:
18:
2:
7
* pv1:
115:
1 datalv4:
5:
1:
3:
19:
2:
8
* pv1:
116:
1 datalv4:
6:
1:
3:
20:
2:
9
* pv1:
117:
1 datalv4:
7:
1:
3:
21:
2:
10
* pv1:
118:
1 datalv4:
8:
1:
3:
22:
2:
11
* pv1:
119:
1 datalv4:
9:
1:
3:
23:
2:
12
* pv1:
120:
1 datalv4:
10:
1:
3:
24:
2:
13
第一个PV的Map表,MAP表的开头是某个PV的pvh.pv_id
********** PhysicalVolume:
2 ***********
pvh.pv_num:
2
pvh.pv_id:
003752146ff979f4
pvh.pp_count:
15
pvh.pv_state:
1
pvh.pvnum_vgdas:
1
pvh.psn_part1:
4352
* pv_num:
pp_num:
pp_state lv_name:
lp_num:
pp_copy_val:
pv_fst_mir:
part_fst_mir:
p
v_snd_mir:
part_snd_mir
* pv2:
4:
1 datalv4:
1:
3:
1:
111:
3:
15
* pv2:
5:
1 datalv4:
2:
3:
1:
112:
3:
16
* pv2:
6:
1 datalv4:
3:
3:
1:
113:
3:
17
* pv2:
7:
1 datalv4:
4:
3:
1:
114:
3:
18
* pv2:
8:
1 datalv4:
5:
3:
1:
115:
3:
19
* pv2:
9:
1 datalv4:
6:
3:
1:
116:
3:
20
* pv2:
10:
1 datalv4:
7:
3:
1:
117:
3:
21
* pv2:
11:
1 datalv4:
8:
3:
1:
118:
3:
22
* pv2:
12:
1 datalv4:
9:
3:
1:
119:
3:
23
* pv2:
13:
1 datalv4:
10:
3:
1:
120:
3:
24
********** PhysicalVolume:
3 ***********
pvh.pv_num:
3
pvh.pv_id:
003752146ff9a31b
pvh.pp_count:
67
pvh.pv_state:
1
pvh.pvnum_vgdas:
1
pvh.psn_part1:
4352
* pv_num:
pp_num:
pp_state lv_name:
lp_num:
pp_copy_val:
pv_fst_mir:
part_fst_mir:
p
v_snd_mir:
part_snd_mir
* pv3:
15:
1 datalv4:
1:
2:
1:
111:
2:
4
* pv3:
16:
1 datalv4:
2:
2:
1:
112:
2:
5
* pv3:
17:
1 datalv4:
3:
2:
1:
113:
2:
6
* pv3:
18:
1 datalv4:
4:
2:
1:
114:
2:
7
* pv3:
19:
1 datalv4:
5:
2:
1:
115:
2:
8
* pv3:
20:
1 datalv4:
6:
2:
1:
116:
2:
9
* pv3:
21:
1 datalv4:
7:
2:
1:
117:
2:
10
* pv3:
22:
1 datalv4:
8:
2:
1:
118:
2:
11
* pv3:
23:
1 datalv4:
9:
2:
1:
119:
2:
12
* pv3:
24:
1 datalv4:
10:
2:
1:
120:
2:
13
*****************************************
vgt.concurrency:
0
vgdatrl:
timestamp946773107(386e9c73),352680539(15057a5b)
vgdatrl:
timestampSatJan 118:
31:
47CST:
2000
2234sec(开始)
VGSA数据区(备份)
2241sec(结束)
2242sec(开始)
VGDA数据区(备份)
LP/PPMAP
4339sec(结束)
4340sec(开始)
4351sec
4352sec(物理硬盘第1PP开始)
LV开始
Nsec(结束)(硬盘总扇区数)
硬盘的PVID
一个硬盘要被操作系统正常使用,必须先分配PVID,硬盘的PVID在以后加入某个VG、LV都是要用到的。
分配PVID的过程就像windows下的初始化硬盘操作,就是把硬盘0扇区改写成符合操作系统使用的格式,只改写0扇区,别的地方没有任何改变。
用lspv命令就可以知道哪些硬盘还没有分配PVID,用#chdev-lhdiskX-apv=yes就可以给硬盘分配PVID,当一个硬盘在操作系统中已经有了PVID,#chdev-lhdiskX-apv=yes命令不会改变原来的PVID。
如果要修改某块盘的PVID,我们要先清除掉原先的PVID,然后再生成,可以用以下命令:
#chdev-lhdiskX-apv=clear
#chdev-lhdiskX-apv=yes
chinadns的Blog有对PVID的详细介绍:
我们从底层观察chdev-lhdiskX-apv=yes对硬盘0扇区的改动:
#lspv
hdisk0 003752149a0b2b91 rootvg
hdisk10 none None
hdisk11 003752146ff979f4 None
hdisk12 003752146ff9a31b None
hdisk10没有分配PVID,我们看看0扇区的十六进制代码:
#lquerypv-h/dev/hdisk100200(结果:
第一列是序号,后4列是十六进制数据)
00000000 C9C2D4C1000000000000000000000000 |................|
00000010 00000000000000000000000000000000 |................|
00000020 00000000000000000000000000000000 |................|
00000030 00000000000000000000000000000000 |................|
00000040 00000000000000000000000000000000 |................|
00000050 00000000000000000000000000000000 |................|
00000060 00000000000000000000000000000000 |................|
00000070 00000000000000000000000000000000 |................|
00000080 00000000000000000000000000000000 |................|
00000090 00000000000000000000000000000000 |................|
000000A0 00000000000000000000000000000000 |................|
000000B0 00000000000000000000000000000000 |................|
000000C0 00000000000000000000000000000000 |................|
000000D0 00000000000000000000000000000000 |................|
000000E0 00000000000000000000000000000000 |................|
000000F0 00000000000000000000000000000000 |................|
00000100 00000000000000000000000000000000 |................|
00000110 00000000000000000000000000000000 |................|
00000120 00000000000000000000000000000000 |................|
00000130 00000000000000000000000000000000 |................|
00000140 00000000000000000000000000000000 |................|
00000150 00000000000000000000000000000000 |................|
00000160 00000000000000000000000000000000 |................|
00000170 00000000000000000000000000000000 |................|
00000180 00000000000000000000000000000000 |................|
00000190 00000000000000000000000000000000 |................|
000001A0 00000000000000000000000000000000 |................|
000001B0 00000000000000000000000000000000 |................|
000001C0 00000000000000000000000000000000 |................|
000001D0 00000000000000000000000000000000 |................|
000001E0 00000000000000000000000000000000 |................|
000001F0 00000000000000000000000000000000 |................|
#chdev-lhdisk10-apv=yes
hdisk10changed
#lspv
hdisk0 003752149a0b2b91 rootvg
hdisk10 0037521474170251 None
hdisk11 003752146ff979f4 None
hdisk12 003752146ff9a31b None
#lquerypv-h/dev/hdisk100200
00000000 C9C2D4C1000000000000000000000000 |................|
00000010 00000000000000000000000000000000 |................|
00000020 00000000000000000000000000000000 |................|
00000030 00000000000000000000000000000000 |................|
00000040 00000000000000000000000000000000 |................|
00000050 00000000000000000000000000000000 |................|
00000060 00000000000000000000000000000000 |................|
00000070 00000000000000000000000000000000 |................|
00000080 00375214741702510000000000000000 |.7R.t..Q........|
00000090 00000000000000000000000000000000 |.............