1、AIX LVM底层数据结构剖析AIX LVM底层数据结构剖析(根据qintl讲稿整理)背景:一个关于数据丢失后的恢复问题,在LU中引起热烈的讨论,在相关的讨论帖中,qintl对LVM底层数据结构做了详细而精彩的演讲,受益匪浅。现将qintl主要讲稿内容整理如下,以便大家阅读。相关讨论帖地址:一个硬盘在AIX系统下系统保留区数据结构,AIX下的Block其实就是512Byte,编号从0开始,跟我们所说的扇区是一样的。以下是我机器上某块盘的信息想了解更多的东西,请阅读:硬盘物理位置,用扇区标记(sec)Readvgda结果(readvgda -s hdisk10)0 sec(开始)boot rec
2、ordbad-block directoryLVM record(7 sec和70 sec)Readvgda会调用LVM record中的数据mirror write consistency (MWC) recordLVM record记录着lvmarea最基本的参数127 sec(结束)lvmid: 1598838349vgid: 0037521400004c00000000dc6ffba362lvmarea_len: 4212 - (vgda_len + vgsa_len) * 2vgda_len: 2098vgda_psn0: 136vgda_psn1: 2242reloc_psn: 2
3、86749223pv_num: 1pp_size: 28vgsa_len: 8vgsa_psn0: 128vgsa_psn1: 2234version: 8vg_type: -8739图片是7sec的十六进制视图,可以通过十六进制转换成上面某些参数的十进制数值。128 sec(开始)VGSA数据区135 sec(结束)*VGSA at block 128*vgsa beg: timestamp 946773107 (386e9c73), 314919315 (12c54993)vgsa beg: timestamp Sat Jan1 18:31:47 CST:2000vgsa.pv_missi
4、ng: 0vgsa.stalepp0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0vgsa.stalepp1: 0 0 0 0 0 0 0 0
5、 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0vgsa.stalepp2: ff 3f 0 ff ff ff ff ff 7 0 0 0 0 0 0 0 0 0 0 0 0 0
6、 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0vgsa.factor: 1vgsa.pad2: 0 0 0vgsa end: timestamp 946773107 (386e9c73), 314919315 (12c54993)v
7、gsa end: timestamp Sat Jan1 18:31:47 CST:2000*136 sec(开始)VGDA数据区LP/PP MAP2233 sec(结束)*VGDA at block 136*vgh.vg_id: 0037521400004c00000000dc6ffba362vgh.numlvs: 1vgh.maxlvs: 256vgh.pp_size: 28vgh.numpvs: 3vgh.total_vgdas: 3vgh.vgda_size: 2098vgh.quorum: 1vgh.auto_varyon: 1vgh.check_sum: 0vgda hdr: tim
8、estamp 946773107 (386e9c73), 352680539 (15057a5b)vgda hdr: timestamp Sat Jan1 18:31:47 CST:2000以上是从136扇区读取的*Logical Volume: datalv4*lve.lvname: 0lve.maxsize: 512lve.lv_state: 1lve.mirror: 3lve.mirror_policy: 2lve.num_lps: 10lve.permissions: 1lve.bb_relocation: 1lve.write_verify: 2lve.mirwrt_consist:
9、 1lve.stripe_exp: 0lve.striping_width: 0lve.lv_avoid: 0lve.child_minor_num: 0*Physical Volume: 1*pvh.pv_num: 1pvh.pv_id: 003752146ff9501bpvh.pp_count: 546pvh.pv_state: 1pvh.pvnum_vgdas: 1pvh.psn_part1: 4352*pv_num:pp_num:pp_state lv_name:lp_num:pp_copy_val:pv_fst_mir:part_fst_mir:pv_snd_mir:part_snd
10、_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 dat
11、alv4:10:1:3:24:2:13第一个PV的Map表,MAP表的开头是某个PV的pvh.pv_id*Physical Volume: 2*pvh.pv_num: 2pvh.pv_id: 003752146ff979f4pvh.pp_count: 15pvh.pv_state: 1pvh.pvnum_vgdas: 1pvh.psn_part1: 4352*pv_num:pp_num:pp_state lv_name:lp_num:pp_copy_val:pv_fst_mir:part_fst_mir:pv_snd_mir:part_snd_mir*pv2:4:1 datalv4:1:3:1
12、: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*Ph
13、ysical Volume: 3*pvh.pv_num: 3pvh.pv_id: 003752146ff9a31bpvh.pp_count: 67pvh.pv_state: 1pvh.pvnum_vgdas: 1pvh.psn_part1: 4352*pv_num:pp_num:pp_state lv_name:lp_num:pp_copy_val:pv_fst_mir:part_fst_mir:pv_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 da
14、talv4: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: 0vgda trl: timestamp 946773107 (38
15、6e9c73), 352680539 (15057a5b)vgda trl: timestamp Sat Jan1 18:31:47 CST:20002234 sec(开始)VGSA数据区(备份)2241 sec(结束)2242 sec(开始)VGDA数据区(备份)LP/PP MAP4339 sec(结束)4340 sec(开始)4351 sec4352 sec (物理硬盘第1PP开始)LV开始N sec(结束)(硬盘总扇区数)硬盘的PVID一个硬盘要被操作系统正常使用,必须先分配PVID,硬盘的PVID在以后加入某个VG、LV都是要用到的。分配PVID的过程就像windows下的初始化硬盘操
16、作,就是把硬盘0扇区改写成符合操作系统使用的格式,只改写0扇区,别的地方没有任何改变。用lspv命令就可以知道哪些硬盘还没有分配PVID,用#chdev -l hdiskX -a pv=yes就可以给硬盘分配PVID,当一个硬盘在操作系统中已经有了PVID,#chdev -l hdiskX -a pv=yes命令不会改变原来的PVID。如果要修改某块盘的PVID,我们要先清除掉原先的PVID,然后再生成,可以用以下命令:#chdev -l hdiskX -a pv=clear#chdev -l hdiskX -a pv=yeschinadns的Blog有对PVID的详细介绍:我们从底层观察ch
17、dev -l hdiskX -a pv=yes对硬盘0扇区的改动:# lspvhdisk0 003752149a0b2b91 rootvghdisk10 none Nonehdisk11 003752146ff979f4 Nonehdisk12 003752146ff9a31b Nonehdisk10没有分配PVID,我们看看0扇区的十六进制代码:# lquerypv -h /dev/hdisk10 0 200 (结果:第一列是序号,后4列是十六进制数据)00000000 C9C2D4C1 00000000 00000000 00000000|.|00000010 00000000 00000
18、000 00000000 00000000|.|00000020 00000000 00000000 00000000 00000000|.|00000030 00000000 00000000 00000000 00000000|.|00000040 00000000 00000000 00000000 00000000|.|00000050 00000000 00000000 00000000 00000000|.|00000060 00000000 00000000 00000000 00000000|.|00000070 00000000 00000000 00000000 00000
19、000|.|00000080 00000000 00000000 00000000 00000000|.|00000090 00000000 00000000 00000000 00000000|.|000000A0 00000000 00000000 00000000 00000000|.|000000B0 00000000 00000000 00000000 00000000|.|000000C0 00000000 00000000 00000000 00000000|.|000000D0 00000000 00000000 00000000 00000000|.|000000E0 000
20、00000 00000000 00000000 00000000|.|000000F0 00000000 00000000 00000000 00000000|.|00000100 00000000 00000000 00000000 00000000|.|00000110 00000000 00000000 00000000 00000000|.|00000120 00000000 00000000 00000000 00000000|.|00000130 00000000 00000000 00000000 00000000|.|00000140 00000000 00000000 000
21、00000 00000000|.|00000150 00000000 00000000 00000000 00000000|.|00000160 00000000 00000000 00000000 00000000|.|00000170 00000000 00000000 00000000 00000000|.|00000180 00000000 00000000 00000000 00000000|.|00000190 00000000 00000000 00000000 00000000|.|000001A0 00000000 00000000 00000000 00000000|.|0
22、00001B0 00000000 00000000 00000000 00000000|.|000001C0 00000000 00000000 00000000 00000000|.|000001D0 00000000 00000000 00000000 00000000|.|000001E0 00000000 00000000 00000000 00000000|.|000001F0 00000000 00000000 00000000 00000000|.|# chdev -l hdisk10 -a pv=yeshdisk10 changed# lspvhdisk0 003752149a
23、0b2b91 rootvghdisk10 0037521474170251 Nonehdisk11 003752146ff979f4 Nonehdisk12 003752146ff9a31b None# lquerypv -h /dev/hdisk10 0 20000000000 C9C2D4C1 00000000 00000000 00000000|.|00000010 00000000 00000000 00000000 00000000|.|00000020 00000000 00000000 00000000 00000000|.|00000030 00000000 00000000
24、00000000 00000000|.|00000040 00000000 00000000 00000000 00000000|.|00000050 00000000 00000000 00000000 00000000|.|00000060 00000000 00000000 00000000 00000000|.|00000070 00000000 00000000 00000000 00000000|.|00000080 00375214 74170251 00000000 00000000|.7R.t.Q.|00000090 00000000 00000000 00000000 00000000|.
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1