根盘镜像方法(中文版)
发表于:2007-06-09来源:作者:点击数:
标签:
可靠且实用的根盘镜像方法(第二部分) 原文:http://www.samag.com/solaris/column/0106.htm 作者:PeterBaerGalvin 内容级别:高级 内容读者:Solaris管理员 译者: windows nt@www.china unix .net 摘要 在Solaris机器上可以采用好几种方法来镜像根盘(系统
可靠且实用的根盘镜像方法(第二部分)
原文:http://www.samag.com/solaris/column/0106.htm
作者: Peter Baer Galvin
内容级别:高级
内容读者:Solaris管理员
译者:
windowsnt@www.china
unix.net摘要
在Solaris机器上可以采用好几种方法来镜像根盘(系统盘)。在上个月的专栏中,我介绍了几种主要方法及其优缺点。这一次我将介绍一种“最优”
解决方案来结束该主题,解决上一期中所指出的问题,并证明这种方案在生产中是可行的、可靠的。
问题
如上期中所述,最好的磁盘镜像方案应该具有如下功能:
*它必须能够自动从单盘失效中恢复。
*它必须易于移除以便进行系统升级。
*它不会对性能造成太大影响。
*它必须允许安装并使用其他磁盘管理方案。
上一期中所提出解决方案包括手工地定期进行磁盘复制,使用Veritas Volume Manager,和使用Solstice Disk Suite。这些方案中的任何一种都不具备想要的全部功能,并且通常有一定
缺陷。在下个月的专栏中,我将介绍一个用于手工进行根盘镜像的脚本。
全世界最优
现在我将介绍“最优”解决方案。这种方案最早是由我所在公司“Corporate Technologies”的Manny Korkodilos和Kyle Oliver所提出的。
这种方法使用DiskSuite来镜像所有根盘分区。另外,它创建一个小分区,用于Veritas Volume Manager的rootdg分区。VXVM要求有一个rootdg磁盘组,并不允许将该磁盘组共享给任何其他系统(例如,当集群系统中的主系统发生故障时切换到其他系统)。因而,不应该将外部磁盘添加到rootdg中,但是rootdg是必需的。在这里我们不让VXVM使用它自己的方式来管理内部根盘,而是给它几兆空间以满足它的需要。
这种方法需要几个步骤,但是这些努力是值得的,因为这种解决方案满足了我们所要求的四条准则:
*当镜像磁盘对中的一块磁盘发生故障时,它通常会自动恢复。但是,这种磁盘故障必须被检测到并被修复,以防止另一块磁盘又发生故障,导致整个系统当机,尤其是在缺乏足够重视的地方容易发生这种问题。
*当升级这种配置中的系统时,必须移除DiskSuite,但是可以保持VXVM不动,它不受系统升级的影响。
*性能与单独使用Disksuite镜像时的性能相同,其性能是相当不错的。
*DiskSuite可以用于它所擅长的地方--管理少量磁盘,而VXVM可以管理其余磁盘,也正是它的优势所在。
我们已经在许多地方的许多系统上使用了这种方法,并且至今没有产生任何负面影响。希望它将会对你有用,并成为你进行系统管理的一种有力手段。这种方法假定你已经了解了Solaris安装,补丁安装,Solstice DiskSuite,Veritas Volume Manager,Open Boot Prom中的devalias命令,如何确定引导设备,以及如何动态修改这些指令以适应你的系统配置。
例如,假设你有二块磁盘:
引导盘:
c0t0d0s0: /pci@1f,0/pci@1,1/scsi@2/disk@0,0
和将要用作镜像的磁盘:
c0t1d0s0: /pci@1f,0/pci@1,1/scsi@2/disk@1,0
Assuming that the disclaimer did not send you running for cover, (假设免责声明没有让你停止使用)(这句我不会,谁会?),请按照如下步骤:
*安装Solaris(Solaris 2.6之后的版本应该都可以)。在安装期间,预留二个10MB磁盘空间的分区(假定为s6和s7),分别用于DiskSuite状态
数据库和Veritas VXVM rootdg。
*安装推荐补丁,Y2K补丁,以及其他想要安装的任何补丁。
*重新启动。
*安装Veritas VXVM,或Foundation Suite(VXVM和Veritas File System)。
*配置Veritas Foundation Suite:
*运行vxinstall,并只添加以后想要让DiskSuite用作根盘镜像的那块磁盘(在这里为c0t0d0s0)。
*当vxinstall提示重新启动时,重新启动机器。
*为rootdg创建简单分区。
vcdctl add disk c0t0d0s7 type=simple
vxdisk -f init c0t0d0s7 type=simple
vxdg adddisk c0t0d0s7
*用vxdg -g rootdg rmdisk c0t1d0将镜像盘从rootdg中删除。
*使用format命令,将引导镜像盘的分区配置成与引导盘分区相同。可以采用如下“技巧”来进行一次分区复制:
# format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c0t0d0
/pci@1f,0/pci@1,1/scsi@2/sd@0,0
1. c0t1d0
/pci@1f,0/pci@1,1/scsi@2/sd@1,0
Specify disk (enter its number): 0
selecting c0t0d0
[disk formatted]
Warning: Current Disk has mounted partitions.
FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
repair - repair a
defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
! - execute , then return
quit
format> partition
PARTITION MENU:
0 - change `0' partition
1 - change `1' partition
2 - change `2' partition
3 - change `3' partition
4 - change `4' partition
5 - change `5' partition
6 - change `6' partition
7 - change `7' partition
select - select a predefined table
modify - modify a predefined partition table
name - name the current table
print - display the current table
label - write partition map and label to the disk
! - execute , then return
quit
partition> print
Current partition table (original):
Total disk cylinders available: 4924 + 2 (reserved cylinders)
Part Tag Flag Cylinders Size Blocks
0 root wm 0 - 4324 7.41GB (4325/0/0) 15531075
1 swap wu 4325 - 4909 1.00GB (585/0/0) 2100735
2 backup wm 0 - 4923 8.43GB (4924/0/0) 17682084
3 unassigned wm 0 0 (0/0/0) 0
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 unassigned wm 4910 - 4916 12.27MB (7/0/0) 25137
7 unassigned wm 4917 - 4923 12.27MB (7/0/0) 25137
partition> name
Enter table name (remember quotes): temp
partition> quit
FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
! - execute , then return
quit
format> disk
AVAILABLE DISK SELECTIONS:
0. c0t0d0
/pci@1f,0/pci@1,1/scsi@2/sd@0,0
1. c0t1d0
/pci@1f,0/pci@1,1/scsi@2/sd@1,0
Specify disk (enter its number)[0]: 1
selecting c0t1d0
[disk formatted]
format> partition
PARTITION MENU:
0 - change `0' partition
1 - change `1' partition
2 - change `2' partition
3 - change `3' partition
4 - change `4' partition
5 - change `5' partition
6 - change `6' partition
7 - change `7' partition
select - select a predefined table
modify - modify a predefined partition table
name - name the current table
print - display the current table
label - write partition map and label to the disk
! - execute , then return
quit
partition> select
0. temp
1. original
Specify table (enter its number)[1]: 0
partition> label
Ready to label disk, continue? Y
partition> quit
FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
! - execute , then return
quit
format> quit
*添加第二块磁盘上的简单分区,以用于Veritas并完成Veritas安装:
*创建简单分区和卷:
vxdctl add disk c0t1d0s7 type=simple
vxdisk -f init c0t1d0s7 type=simple
vxdg adddisk c0t1d0s7
*在简单分区上创建一个“不用”卷:
vxassist make vol_dont_use 15m
*使用命令行或vxdiskadm添加所有非rootdg磁盘。例如,下面的命令将把磁盘c0t3d0添加到oradg磁盘组中:
vxdg init oradg c0t3d0=c0t3d0
*通过Veritas图形界面或命令行,在非rootdg磁盘组(即oradg)中创建卷。例如,下面显示了如何将c0t3d0磁盘加入到oradg磁盘组中。首先,获得c0t3d0上卷的最大尺寸(maxsize):
/usr/sbin/vxassist -g oradg -p maxsize layout=nostripe alloc="c0t3d0"
接下来在c0t3d0上创建卷"testvol":
/usr/sbin/vxassist -g oradg make testvol 2050048 layout=nostripe alloc="c0t3d0"
最后,在"testvol"上创建文件系统:
/usr/sbin/mkfs -F vxfs /dev/vx/rdsk/oradg/testvol 2050048
并将"testvol"安装到/testvol:
/sbin/mount -F vxfs /dev/vx/dsk/oradg/testvol /testvol
*确认用卷安装点更新/etc/vfstab文件。
*安装Sun Solstice DiskSuite补丁。
*安装Sun Solstice DiskSuite包SUNWmd和SUNWmdg。不需要安装Log Daemon包(SUNWmdn)。
*按如下过程配置DiskSuite:
在每块镜像盘的分区6上创建多个状态数据库副本。在这里,我们在第个6号分区上创建四个状态数据库。
cd /usr/opt/SUNWmd/sbin
./metadb -af -c 4 /dev/dsk/c0t0d0s6
./metadb -af -c 4 /dev/dsk/c0t1d0s6
./metadb
(该命令将显示状态数据库信息)
将如下内容添加到/etc/opt/SUNWmd/md.tab文件中。确认根据你的环境做相应修改。
# Root Mirror MetaDevices
# MetaDevice for c0t0d0s0 (boot disk root slice)
/dev/md/dsk/d11 1 1 /dev/dsk/c0t0d0s0
# MetaDevice for c0t1d0s0 (bootmirror disk root slice)
/dev/md/dsk/d12 1 1 /dev/dsk/c0t1d0s0
# MetaDevice for a mirror using boot disk to start with
/dev/md/dsk/d10 -m /dev/md/dsk/d11
#
# Swap Mirror Metadevices
# MetaDevice for c0t0d0s1 (boot disk swap)
/dev/md/dsk/d21 1 1 /dev/dsk/c0t0d0s1
# MetaDevice for c0t1d0s1 (bootmirror disk swap)
/dev/md/dsk/d22 1 1 /dev/dsk/c0t1d0s1
# MetaDevice for mirror using boot disk to start with.
/dev/md/dsk/d20 -m /dev/md/dsk/d21
初始化卷设备:
cd /usr/opt/SUNWmd/sbin
./metainit -f /dev/md/dsk/d11
./metainit /dev/md/dsk/d12
./metainit /dev/md/dsk/d10
./metainit -f /dev/md/dsk/d21
./metainit /dev/md/dsk/d22
./metainit /dev/md/dsk/d20
设置根卷文件系统:
cd /usr/opt/SUNWmd/sbin
./metaroot d10
编辑 /etc/vfstab,并将swap设备更改成使用/dev/md/dsk/d2
重新启动。
添加镜像:
.cd /usr/opt/SUNWmd/sbin
./metattach d10 d12
./metattach d20 d22
等待同步过程完成。可以通过如下命令检查同步状态:
/usr/opt/SUNWMd/sbin/metastat | more
*重新启动,确保一切正常。
*在Open Boot Prompt NVRAM中添加一个设备别名。系统可能已经建立了适当的磁盘别名(即“disk”和“disk1”)。但是,添加如下设备别名将是有益的,因为他们的名称更加直观,而且不会影响原来的别名,你也可以使用原来的别名。
{0} ok nvedit
0: devalias rootmirror0 /pci@1f,0/pci@1,1/scsi@2/disk@0,0
1: devalias rootmirror1 /pci@1f,0/pci@1,1/scsi@2/disk@1,0
{0} ok nvstore
{0} ok setenv use-nvramrc? true
{0} ok setenv boot-device rootmirror0 rootmirror1
{0} ok setenv diag-device rootmirror0 rootmirror1
*重新启动每个别名,确认一切可以正常启动。
必须承认,这些步骤相当复杂。最后的结果是一个DiskSuite镜像根盘,其上一个小分区用于Veritas VXVM的rootdg磁盘组。Veritas VXVM安装在系统中,用于管理系统中的其他磁盘,而不需要使用VXVM的根盘封装技巧。
unix菜鸟 回复于:2002-12-12 20:24:48
|
谢谢! 建议版主加为精华。
|
x3y4z5 回复于:2002-12-12 21:27:43
|
有空一定读,先下载了。谢谢。
|
phoenixli 回复于:2002-12-13 00:23:58
|
应该不错吧,8知道..
|
race 回复于:2002-12-13 08:03:07
|
你说的没错。
|
wzy9681 回复于:2002-12-13 08:06:00
|
好文!
|
zpdpd 回复于:2002-12-13 09:37:55
|
感觉是好东东,先下了再说,以后肯定有用,还有个问题,你的题目后面为什么还有个第二部分,难道还有第一部分你没贴出来吗
|
windowsnt 回复于:2002-12-14 23:19:00
|
第一部分没有翻译,前面有英文的
|
race 回复于:2002-12-15 00:20:30
|
http://www.samag.com/solaris/column/0106.htm 怎么上不去?
|
phoenixli 回复于:2002-12-15 00:48:03
|
上去干嘛?RACE老大,看看偶给你的回答啊先..
|
race 回复于:2002-12-15 00:53:18
|
你回答什么了,哪有啊? 俺想看WINDWOSNT的资料原件参考,你有这些?
|
phoenixli 回复于:2002-12-15 01:06:32
|
就是那个钥匙的回答啊..
|
race 回复于:2002-12-15 01:14:10
|
知道了,写完了,睡觉去了。
|
sprite 回复于:2002-12-15 17:33:08
|
好东西阿
|
clearcase/" target="_blank" >cchmail 回复于:2003-04-05 23:03:46
|
good
|
原文转自:http://www.ltesting.net