适用范围:
主机本地至少有两个磁盘,其中操作系统已经进行镜像。
当vg00中某个镜像的磁盘坏时,可以使用下面的方法进行更换
操作步骤:
一,拆镜像:
1, 查看vg00卷组信息:
#vgdisplay –v vg00
--- Volume groups ---
VG Name /dev/vg00
VG Write Access read/write
VG Status available
Max LV 255
Cur LV 11
Open LV 11
Max PV 16
Cur PV 2
Act PV 1
Max PE per PV 4384
VGDA 2
PE Size (Mbytes) 16
Total PE 4374
Alloc PE 1878
Free PE 2496
Total PVG 0
Total Spare PVs 0
Total Spare PVs in use 0
--- Logical volumes ---
LV Name /dev/vg00/lvol1
LV Status available/stale
LV Size (Mbytes) 512
Current LE 32
Allocated PE 64
Used PV 1
LV Name /dev/vg00/lvol2
LV Status available/stale
LV Size (Mbytes) 4096
Current LE 256
Allocated PE 512
Used PV 1
LV Name /dev/vg00/lvol3
LV Status available/stale
LV Size (Mbytes) 512
Current LE 32
Allocated PE 64
Used PV 1
LV Name /dev/vg00/lvol4
LV Status available/stale
LV Size (Mbytes) 512
Current LE 32
Allocated PE 64
Used PV 1
LV Name /dev/vg00/lvol5
LV Status available/stale
LV Size (Mbytes) 4096
Current LE 256
Allocated PE 512
Used PV 1
LV Name /dev/vg00/lvol6
LV Status available/stale
LV Size (Mbytes) 2048
Current LE 128
Allocated PE 256
Used PV 1
LV Name /dev/vg00/lvol7
LV Status available/stale
LV Size (Mbytes) 2048
Current LE 128
Allocated PE 256
Used PV 1
LV Name /dev/vg00/lvol8
LV Status available/stale
LV Size (Mbytes) 2048
Current LE 128
Allocated PE 256
Used PV 1
LV Name /dev/vg00/lvora
LV Status available/stale
LV Size (Mbytes) 6000
Current LE 375
Allocated PE 750
Used PV 1
LV Name /dev/vg00/oradata
LV Status available/stale
LV Size (Mbytes) 5104
Current LE 319
Allocated PE 638
Used PV 1
LV Name /dev/vg00/lvtsmdata
LV Status available/stale
LV Size (Mbytes) 3072
Current LE 192
Allocated PE 384
Used PV 1
--- Physical volumes ---
PV Name /dev/dsk/c2t1d0
PV Status available
Total PE 4374
Free PE 2496
Autoswitch On
#strings /etc/lvmtab
/dev/vg00
/dev/dsk/c2t0d0
/dev/dsk/c2t1d0
/dev/vglock
/dev/dsk/c12t3d2
/dev/vg301
/dev/dsk/c12t3d5
/dev/vg101
/dev/dsk/c12t2d1
/dev/dsk/c12t2d4
/dev/vg201
/dev/dsk/c12t2d5
/dev/dsk/c12t3d3
/dev/dsk/c12t3d4
从上面信息可以知道,vg00中有两块磁盘分别是c2t0d0,c2t1d0,目前vg00只可以识别到c2t1d0这块磁盘,c2t0d0这块磁盘有问题了,需要更换。
从上面的输出中得知:vg00包含以下lv,分别是lvol1、lvol2、lvol3、lvol4、lvol5、lvol6、lvol7、lvol8、lvora、oradata、lvtsmdata。因此在镜像时,这些lv都需要拆镜像。
2, 拆除c2t0d0这块磁盘上面的镜像
法1》一个一个拆
#lvreduce –m 0 /dev/vg00/lvol1 /dev/dsk/c2t0d0
#lvreduce –m 0 /dev/vg00/lvol2 /dev/dsk/c2t0d0
#lvreduce –m 0 /dev/vg00/lvol3 /dev/dsk/c2t0d0
#lvreduce –m 0 /dev/vg00/lvol4 /dev/dsk/c2t0d0
#lvreduce –m 0 /dev/vg00/lvol5 /dev/dsk/c2t0d0
#lvreduce –m 0 /dev/vg00/lvol6 /dev/dsk/c2t0d0
#lvreduce –m 0 /dev/vg00/lvol7 /dev/dsk/c2t0d0
#lvreduce –m 0 /dev/vg00/lvol8 /dev/dsk/c2t0d0
#lvreduce –m 0 /dev/vg00/lvora /dev/dsk/c2t0d0
#lvreduce –m 0 /dev/vg00/oradata /dev/dsk/c2t0d0
#lvreduce –m 0 /dev/vg00/lvtsmdata /dev/dsk/c2t0d0
法2》使用循环(一次性执行完毕)
#for lvol in lvol1 lvol2 lvol3 lvol4 lvol5 lvol6 lvol7 lvol8 lvora oradata lvtsmdata
>do
>lvreduce –m 0 /dev/vg00/$lvol /dev/dsk/c2t0d0
>done
注意上面的”>”不需要输入,上面一行输入完后,回车会自动出现
3, 从vg00卷组中去除c2t0d0磁盘
#vgreduce vg00 /dev/dsk/c2t0d0
二,物理更换故障磁盘
1,更换故障磁盘
#ioscan –knfCdisk
disk 1 0/1/1/0.0.0 sdisk CLAIMED DEVICE HP 73.4GST373454LC
/dev/dsk/c2t0d0 /dev/rdsk/c2t0d0
disk 8 0/1/1/0.1.0 sdisk CLAIMED DEVICE HP 73.4GST373454LC
/dev/dsk/c2t1d0 /dev/rdsk/c2t1d0
查看hp rp3440小型机的硬件手册,可以知道物理路径0/1/1/0.0.0的磁盘对应rp3440的最下面一块磁盘,如下面图示的hdd1:
拆除hdd1,装入新磁盘并插好。
2,在主机中扫描新硬盘
#ioscan –nfCdisk
disk 1 0/1/1/0.0.0 sdisk CLAIMED DEVICE HP 73.4GST373454LC
/dev/dsk/c2t0d0 /dev/rdsk/c2t0d0
disk 8 0/1/1/0.1.0 sdisk CLAIMED DEVICE HP 73.4GST373454LC
/dev/dsk/c2t1d0 /dev/rdsk/c2t1d0
正常为CLAIMED,如果没有/dev/dsk/c2t0d0,/dev/rdsk/c2t0d0设备文件,可以执行下面命令生成:
#insf –eCdisk
确保新磁盘状态正常
三,做镜像:
1, 查看主机的本地磁盘
#ioscan –knfCdisk
disk 1 0/1/1/0.0.0 sdisk CLAIMED DEVICE HP 73.4GST373454LC
/dev/dsk/c2t0d0 /dev/rdsk/c2t0d0
disk 8 0/1/1/0.1.0 sdisk CLAIMED DEVICE HP 73.4GST373454LC
/dev/dsk/c2t1d0 /dev/rdsk/c2t1d0
2, 格式化新磁盘
#pvcreate -fB /dev/rdsk/c2t0d0
参数-B的作用是将该磁盘格式化为可启动磁盘
参数-f的作用是强行,有时需要加次参数
注意:此处必须使用块设备
3, 将第二块磁盘加入vg00
#vgextend vg00 /dev/dsk/c2t0d0
4, 给新磁盘写入LIF header和LIF文件(ISL,AUTO,HPUX,LABEL)
#mkboot –l /dev/rdsk/c2t0d0
5, 查看给新磁盘写入的LIF header和LIF文件,确保写入正确(有下面的输出就行)
#lifls –l /dev/rdsk/c2t0d0
volume c2t6d0 data size 7984 directory size 8 07/08/08 12:44:39
filename type start size implement created
===============================================================
ISL -12800 584 306 0 02/05/10 16:25:44
AUTO -12289 896 1 0 02/05/10 16:25:44
HPUX -12928 904 848 0 02/05/10 16:25:44
PAD -12290 1752 1580 0 02/05/10 16:25:45
LABEL BIN 3336 8 0 07/08/10 17:19:04
6, 将vg00中的所有lv复制到一份到第二块磁盘上
法1》一个一个做
#lvextend –m 1 /dev/vg00/lvol1 /dev/dsk/c2t0d0
#lvextend –m 1 /dev/vg00/lvol2 /dev/dsk/c2t0d0
#lvextend –m 1 /dev/vg00/lvol3 /dev/dsk/c2t0d0
#lvextend –m 1 /dev/vg00/lvol4 /dev/dsk/c2t0d0
#lvextend –m 1 /dev/vg00/lvol5 /dev/dsk/c2t0d0
#lvextend –m 1 /dev/vg00/lvol6 /dev/dsk/c2t0d0
#lvextend –m 1 /dev/vg00/lvol7 /dev/dsk/c2t0d0
#lvextend –m 1 /dev/vg00/lvol8 /dev/dsk/c2t0d0
#lvextend –m 1 /dev/vg00/lvora /dev/dsk/c2t0d0
#lvextend –m 1 /dev/vg00/oradata /dev/dsk/c2t0d0
#lvextend –m 1 /dev/vg00/lvtsmdata /dev/dsk/c2t0d0
法2》使用循环(一次性执行完毕)
#for lvol in lvol1 lvol2 lvol3 lvol4 lvol5 lvol6 lvol7 lvol8 lvora oradata lvtsmdata
>do
>lvextend –m 1 /dev/vg00/$lvol /dev/dsk/c2t0d0
>done
注意上面的”>”不需要输入,上面一行输入完后,回车会自动出现
此过程需要一段时间完成,需要耐心等待完成后再操作下一步
7, 给两个磁盘的AUTO文件写入新的内容
#mkboot –a ‘hpux –lq’ /dev/rdsk/c2t0d0
#mkboot –a ‘hpux –lq’ /dev/rdsk/c2t1d0
hpux –lq意为:autoboot without qurom enforced
8, 查看给两个磁盘的AUTO文件写入新的内容是否正确
#lifcp /dev/rdsk/c2t0d0:AUTO –
hpux -lq
#lifcp /dev/rdsk/c2t1d0:AUTO –
hpux –lq
9, 给LABEL文件写入内容
#lvlnboot –r /dev/vg00/lvol3
#lvlnboot –b /dev/vg00/lvol1
#lvlnboot –s /dev/vg00/lvol2
#lvlnboot –d /dev/vg00/lvol2
10, 查看给LABEL文件写入内容是否正确
#lvlnboot -v
Boot Definitions for Volume Group /dev/vg00:
Physical Volumes belonging in Root Volume Group:
/dev/dsk/c2t0d0 (0/0/2/0.6.0) -- Boot Disk
/dev/dsk/c2t1d0 (0/0/2/1.6.0) -- Boot Disk
Boot: lvol1 on: /dev/dsk/c2t0d0
/dev/dsk/c2t1d0
Root: lvol3 on: /dev/dsk/c2t0d0
/dev/dsk/c2t1d0
Swap: lvol2 on: /dev/dsk/c2t0d0
/dev/dsk/c2t1d0
Dump: lvol2 on: /dev/dsk/c2t0d0, 0
11, 设置为启动路径
主启动路径:
#setboot –p 0/1/1/0.0.0
从启动路径:
#setboot –a 0/1/1/0.1.0
12, 查看启动路径设置是否正确
#setboot
Primary bootpath : 0/1/1/0.0.0
Alternate bootpath : 0/1/1/0.1.0
Autoboot is ON (enabled)
Autosearch is ON (enabled)
13, 重新启动机器
#shutdown –ry 0
14, 进入机器的bch,亦即10秒终端(需要通过串口console 登陆)
出现To discontinue, press any key within 10 seconds.提示后按任意键
15, 从第一块硬盘(新盘)启动,看机器是否可以启动正常
Boot terminated.
---- Main Menu ---------------------------------------------------------------
Command Description
------- -----------
BOot [PRI|ALT|<path>] Boot from specified path
PAth [PRI|ALT] [<path>] Display or modify a path
SEArch [DIsplay|IPL] [<path>] Search for boot devices
COnfiguration menu Displays or sets boot values
INformation menu Displays hardware information
SERvice menu Displays service commands
DIsplay Redisplay the current menu
HElp [<menu>|<command>] Display help for menu or command
RESET Restart the system
----
Main Menu: Enter command or menu > bo pri
Interact with IPL (Y, N, or Cancel)?> n
Booting...
Boot IO Dependent Code (IODC) revision 1
HARD Booted.
。。。。。。。。。。。。。。。。。。。。
18, 检查vg00的所有lv是否都是synced,即同步,确保都是synced,并且vg00中可以看到两块磁盘(c2t0d0,c2t1c0,仿照下面的)
--- Volume groups ---
VG Name /dev/vg00
VG Write Access read/write
VG Status available
Max LV 255
Cur LV 10
Open LV 10
Max PV 16
Cur PV 2
Act PV 2
Max PE per PV 4384
VGDA 4
PE Size (Mbytes) 16
Total PE 4340
Alloc PE 4046
Free PE 294
Total PVG 0
Total Spare PVs 0
Total Spare PVs in use 0
--- Logical volumes ---
LV Name /dev/vg00/lvol1
LV Status available/syncd
LV Size (Mbytes) 512
Current LE 32
Allocated PE 64
Used PV 2
LV Name /dev/vg00/lvol2
LV Status available/syncd
LV Size (Mbytes) 2048
Current LE 128
Allocated PE 256
Used PV 2
LV Name /dev/vg00/lvol3
LV Status available/syncd
LV Size (Mbytes) 1024
Current LE 64
Allocated PE 128
Used PV 2
LV Name /dev/vg00/lvol4
LV Status available/syncd
LV Size (Mbytes) 512
Current LE 32
Allocated PE 64
Used PV 2
LV Name /dev/vg00/lvol5
LV Status available/syncd
LV Size (Mbytes) 1024
Current LE 64
Allocated PE 128
Used PV 2
LV Name /dev/vg00/lvol6
LV Status available/syncd
LV Size (Mbytes) 4096
Current LE 256
Allocated PE 512
Used PV 2
LV Name /dev/vg00/lvol7
LV Status available/syncd
LV Size (Mbytes) 2048
Current LE 128
Allocated PE 256
Used PV 2
LV Name /dev/vg00/lvol8
LV Status available/syncd
LV Size (Mbytes) 4096
Current LE 256
Allocated PE 512
Used PV 2
LV Name /dev/vg00/oracle
LV Status available/syncd
LV Size (Mbytes) 8000
Current LE 500
Allocated PE 1000
Used PV 2
LV Name /dev/vg00/sybase
LV Status available/syncd
LV Size (Mbytes) 9008
Current LE 563
Allocated PE 1126
Used PV 2
--- Physical volumes ---
PV Name /dev/dsk/c1t6d0
PV Status available
Total PE 2170
Free PE 147
Autoswitch On
PV Name /dev/dsk/c2t6d0
PV Status available
Total PE 2170
Free PE 147
Autoswitch On