Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2616727
  • 博文数量: 323
  • 博客积分: 10211
  • 博客等级: 上将
  • 技术积分: 4934
  • 用 户 组: 普通用户
  • 注册时间: 2006-08-27 14:56
文章分类

全部博文(323)

文章存档

2012年(5)

2011年(3)

2010年(6)

2009年(140)

2008年(169)

分类: 系统运维

2009-04-11 14:35:57

有关LVCB的背景知识,请参考AIX的相关资料。我在这里就不啰嗦了。首先建立一个LV并在上面建立FS,建好后的情况如下:
 
/dev/sjhlv         0.08      0.08    1%        6     1% /lvcbtest
 
#lsvg -l sjhvg
sjhvg:
LV NAME             TYPE       LPs   PPs   PVs  LV STATE      MOUNT POINT
sjhlv               jfs2       10    10    1    open/syncd    /lvcbtest
loglv02             jfs2log    1     1     1    open/syncd    N/A
 
#cd /lvcbtest
#ls
config.xml        lost+found        webAppConfig.xml
man getlvcb
Manual entry for getlvcb not found or not installed.
#getlvcb -TA sjhlv
         AIX LVCB
         intrapolicy = m
         copies = 1
         interpolicy = m
         lvid = 00c2c87200004c00000001203c5bee8a.1
         lvname = sjhlv
         label = /lvcbtest
         machine id = 2C8724C00
         number lps = 10
         relocatable = y
         strict = y
         stripe width = 0
         stripe size in exponent = 0
         type = jfs2
         upperbound = 32
         fs = vfs=jfs2:log=/dev/loglv02:options=rw:account=false
         time created  = Wed Mar 25 14:03:55 2009
         time modified = Sat Apr 11 09:46:45 2009
 
--以上简单的列了一下FS中的文件,同时给出了lvcb的内容作为以下实验的参考。

dd if=/dev/zero of=/dev/sjhlv bs=512 count=1   --破坏lvcb的内容。
1+0 records in
1+0 records out
 
#getlvcb -TA sjhlv
        
         intrapolicy = 
         copies = 0
         interpolicy = 
         lvid = 
         lvname = 
         label = 
         machine id = 
         number lps = 0
         relocatable = 
         strict = 
         stripe width = 0
         stripe size in exponent = 0
         type = 
         upperbound = 0
         fs = 
         time created  =         time modified = 
 
--此时lvcb的内容被清空了。

#cd /lvcbtest
#ls
config.xml        lost+found        webAppConfig.xml
#more config.xml

 
    Provides the following main targets:
   
#umount /lvcbtest
#mount /lvcbtest
#cd /lvcbtest
#ls
config.xml        lost+found        webAppConfig.xml
 
--从上面的输出我们可以看到虽然lvcb被清空,但LV及其上的FS都没有问题,依然可以正常使用。
 
下面我们开始对LVCB的内容进行恢复:
 
#echo "AIX LVCB\0" | dd of=/dev/sjhlv bs=1 count=9
9+0 records in
9+0 records out
 
--这一步是必须的,否则会报这样的错:

#synclvodm -vP sjhvg sjhlv
synclvodm: Physical volume data updated.
0516-622 synclvodm: Warning, cannot write lv control block data.
synclvodm: Logical volume sjhlv updated.
#getlvcb -TA sjhlv
         AIX LVCB
         intrapolicy = 
         copies = 0
         interpolicy = 
         lvid = 
         lvname = 
         label = 
         machine id = 
         number lps = 0
         relocatable = 
         strict = 
         stripe width = 0
         stripe size in exponent = 0
         type = 
         upperbound = 0
         fs = 
         time created  =         time modified = 
 
--把逻辑卷标志写到从逻辑卷开始的9个字节中。
 
#synclvodm -vP sjhvg sjhlv
synclvodm: Physical volume data updated.
synclvodm: Logical volume sjhlv updated.
#getlvcb -TA sjhlv
         AIX LVCB
         intrapolicy = m
         copies = 1
         interpolicy = m
         lvid = 00c2c87200004c00000001203c5bee8a.1
         lvname = sjhlv
         label = 
         machine id = 
         number lps = 10
         relocatable = y
         strict = y
         stripe width = 0
         stripe size in exponent = 0
         type = jfs2
         upperbound = 32
         fs = 
         time created  =         time modified = Sat Apr 11 10:34:11 2009
 
--用VGDA的数据同步ODM,ODM多的VGDA不管,不更新。然后会把ODM库中关于这个LV的参数写入LV卷头4KB中。最后我们看到一些信息还是没有恢复,比如:label = ,machine id =  ,fs =等。LVCB的信息存在三份,分别在lv的头部,VGDA,ODM。我猜测VGDA,ODM只含有LVCB的部分信息。通过这个命令可以看到vgda的内容:#readvgda -v /dev/hdisk5 我们只看sjhlv的信息:
 
**********  Logical Volume: sjhlv  ***********
lve.lvname:             0
lve.maxsize:            512
lve.lv_state:           1
lve.mirror:             1
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
 

#chfs -a log=/dev/loglv02 /lvcbtest
#getlvcb -TA sjhlv
         AIX LVCB
         intrapolicy = m
         copies = 1
         interpolicy = m
         lvid = 00c2c87200004c00000001203c5bee8a.1
         lvname = sjhlv
         label = 
         machine id = 2C8724C00
         number lps = 10
         relocatable = y
         strict = y
         stripe width = 0
         stripe size in exponent = 0
         type = jfs2
         upperbound = 32
         fs = vfs=jfs2:log=/dev/loglv02:options=rw:account=false
         time created  =         time modified = Sat Apr 11 10:40:50 2009
 
--用chfs命令按照ODM数据库中的其它内容,进行恢复。到现在位置还有label,time created条目没有恢复。
 
#putlvcb -L /lvcbtest sjhlv
[test1:/]#getlvcb -TA sjhlv
         AIX LVCB
         intrapolicy = m
         copies = 1
         interpolicy = m
         lvid = 00c2c87200004c00000001203c5bee8a.1
         lvname = sjhlv
         label = /lvcbtest
         machine id = 2C8724C00
         number lps = 10
         relocatable = y
         strict = y
         stripe width = 0
         stripe size in exponent = 0
         type = jfs2
         upperbound = 32
         fs = vfs=jfs2:log=/dev/loglv02:options=rw:account=false
         time created  =         time modified = Sat Apr 11 10:58:16 2009
 
--The putlvcb command writes the control block information into block 0 of the
logical volume lvname. Only the fields specified are written. putlvcb can be
used to write a new control block or update an existing one.直接修改LVCB的条目。time created条目依然没有恢复,暂时不管它。
 
#varyoffvg sjhvg
#exportvg sjhvg
 
--OK,我们现在在其他机器上importvg试试看,这个LV有没有问题。
 
#importvg -y sjhvg hdisk7
sjhvg
 
#mount /lvcbtest
#cd /lvcbtest
#ls
config.xml        lost+found        webAppConfig.xml
#more config.xml

 
    Provides the following main targets:
   
      * installService: Installs Apache as service (on Windows only).  Input
        properties are:

#getlvcb -AT sjhlv
         AIX LVCB
         intrapolicy = m
         copies = 1
         interpolicy = m
         lvid = 00c2c87200004c00000001203c5bee8a.1
         lvname = sjhlv
         label = /lvcbtest
         machine id = 2C8724C00
         number lps = 10
         relocatable = y
         strict = y
         stripe width = 0
         stripe size in exponent = 0
         type = jfs2
         upperbound = 32
         fs = vfs=jfs2:log=/dev/loglv02:options=rw:account=false
         time created  =         time modified = Sat Apr 11 10:58:16 2009
 
#lslv sjhlv
LOGICAL VOLUME:     sjhlv                  VOLUME GROUP:   sjhvg
LV IDENTIFIER:      00c2c87200004c00000001203c5bee8a.1 PERMISSION:     read/write
VG STATE:           active/complete        LV STATE:       opened/syncd
TYPE:               jfs2                   WRITE VERIFY:   off
MAX LPs:            512                    PP SIZE:        8 megabyte(s)
COPIES:             1                      SCHED POLICY:   parallel
LPs:                10                     PPs:            10
STALE PPs:          0                      BB POLICY:      relocatable
INTER-POLICY:       minimum                RELOCATABLE:    yes
INTRA-POLICY:       middle                 UPPER BOUND:    32
MOUNT POINT:        /lvcbtest              LABEL:          /lvcbtest
MIRROR WRITE CONSISTENCY: on/ACTIVE                             
EACH LP COPY ON A SEPARATE PV ?: yes                                   
Serialize IO ?:     NO                                    
--经测试一切OK。 
 
我们继续搞破坏。
 
#dd if=/dev/zero of=/dev/sjhlv bs=512 count=1
1+0 records in
1+0 records out

#getlvcb -AT sjhlv
        
         intrapolicy = 
         copies = 0
         interpolicy = 
         lvid = 
         lvname = 
         label = 
         machine id = 
         number lps = 0
         relocatable = 
         strict = 
         stripe width = 0
         stripe size in exponent = 0
         type = 
         upperbound = 0
         fs = 
         time created  =         time modified = 
 
--上面这个过程是在本机上继续上次破坏的操作。

下面的操作是在异机恢复lvcb。注意异机的ODM库已经没有sjhvg的任何信息。
 
#importvg -y sjhvg hdisk7
0516-622 synclvodm: Warning, cannot write lv control block data.
sjhvg
 
--无法得到此LV的信息,因为信息在LVCB上。
 
#lsvg -l sjhvg
sjhvg:
LV NAME             TYPE       LPs   PPs   PVs  LV STATE      MOUNT POINT
sjhlv                          10    10    1    closed/syncd  N/A
loglv02             jfs2log    1     1     1    closed/syncd  N/A
 
--LV能看到。
 
#mount /lvcbtest
mount: /lvcbtest is not a known file system
 
--但无法mount FS
 
#getlvcb -AT sjhlv
        
         intrapolicy = 
         copies = 0
         interpolicy = 
         lvid = 
         lvname = 
         label = 
         machine id = 
         number lps = 0
         relocatable = 
         strict = 
         stripe width = 0
         stripe size in exponent = 0
         type = 
         upperbound = 0
         fs = 
         time created  =         time modified = 
 
--什么信息都没有。
 
开始按照本机的恢复方法在异机恢复lvcb的内容
 
#echo "AIX LVCB\0" | dd of=/dev/sjhlv bs=1 count=9
9+0 records in
9+0 records out
 
#getlvcb -AT sjhlv
         AIX LVCB
         intrapolicy = 
         copies = 0
         interpolicy = 
         lvid = 
         lvname = 
         label = 
         machine id = 
         number lps = 0
         relocatable = 
         strict = 
         stripe width = 0
         stripe size in exponent = 0
         type = 
         upperbound = 0
         fs = 
         time created  =         time modified = 
 
#synclvodm -vP sjhvg sjhlv
synclvodm: Physical volume data updated.
synclvodm: Logical volume sjhlv updated.

#getlvcb -AT sjhlv
         AIX LVCB
         intrapolicy = m
         copies = 1
         interpolicy = m
         lvid = 00c2c87200004c00000001203c5bee8a.1
         lvname = sjhlv
         label = 
         machine id = 
         number lps = 10
         relocatable = n
         strict = y
         stripe width = 0
         stripe size in exponent = 0
         type = 
         upperbound = 32
         fs = 
         time created  =         time modified = Sat Apr 11 11:53:09 2009

#chfs -a log=/dev/loglv02 /lvcbtest
chfs: No record matching '/lvcbtest' was found in /etc/filesystems.
 
--我把本机/etc/filesystems中关于lvcbtest的信息copy到异机。内容如下:

/lvcbtest:
        dev             = /dev/sjhlv
        vfs             = jfs2
        log             = /dev/loglv02
        mount           = false
        check           = false
        options         = rw
        account         = false
 
#chfs -a log=/dev/loglv02 /lvcbtest  --需要注意lv不要与异机的lv同名。
 
#getlvcb -AT sjhlv
         AIX LVCB
         intrapolicy = m
         copies = 1
         interpolicy = m
         lvid = 00c2c87200004c00000001203c5bee8a.1
         lvname = sjhlv
         label = 
         machine id = 2C8724C00
         number lps = 10
         relocatable = n
         strict = y
         stripe width = 0
         stripe size in exponent = 0
         type = 
         upperbound = 32
         fs = vfs=jfs2:log=/dev/loglv02:options=rw:account=false
         time created  =         time modified = Sat Apr 11 13:26:28 2009
 
#putlvcb -L /lvcbtest sjhlv
#getlvcb -AT sjhlv
         AIX LVCB
         intrapolicy = m
         copies = 1
         interpolicy = m
         lvid = 00c2c87200004c00000001203c5bee8a.1
         lvname = sjhlv
         label = /lvcbtest
         machine id = 2C8724C00
         number lps = 10
         relocatable = n
         strict = y
         stripe width = 0
         stripe size in exponent = 0
         type = 
         upperbound = 32
         fs = vfs=jfs2:log=/dev/loglv02:options=rw:account=false
         time created  =         time modified = Sat Apr 11 13:35:27 2009
 
--type的信息无法恢复。time created的信息也无法恢复。
 
#mount /lvcbtest
#cd /lvcbtest
ls
config.xml        lost+found        webAppConfig.xml
#more config.xml

 
    Provides the following main targets:
   
      * installService: Installs Apache as service (on Windows only).  Input
        properties are:
 
--在异机恢复完成。在本机恢复LVCB的type信息是可以恢复的,我猜测因为ODM库有LVCB的部分信息,而同时VGDA也没有LVCB关于type的条目信息。
 
由于本人水平有限,错误之处,还望大家多多指点。

 
阅读(6614) | 评论(3) | 转发(1) |
给主人留下些什么吧!~~

zhangdonglin2009-09-24 12:33:32

在本机测试时,当清空sjhlv的LVCB后,立即通过mount文件系统进行测试。但有没有测试一下: 此时,不是mount文件系统进行验证,而是varyoffvg,然后exportvg,再importvg,最后mount文件系统,会有什么现象? 我猜和在异机上的效果是一样的。 期待作者的答复!

chinaunix网友2009-09-24 12:24:58

very good! 我们需要这样的实践文章。

chinaunix网友2009-06-30 09:32:47

学到很多东西!