免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1091 | 回复: 0
打印 上一主题 下一主题

solaris下使用Disksuite 生成镜像磁盘 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-04-14 12:48 |只看该作者 |倒序浏览
solaris下使用Disksuite 生成镜像磁盘
说明:
该镜像所使用的是两块18G的硬盘。
该安装过程分为三大步骤:
第一步、安装Disksuite 4.2.1
1、
插入Solaris 8 Software CD 2 of 2并改变到下列目录:
2、
# cd /cdrom/sol_8_401_sparc_2/Solaris_8/EA/products/DiskSuite_4.2.1/sparc/Packages
使用pkgadd 命令安装Solstice Disksuite:
3、
# pkgadd -d .
The following packages are available:
1 SUNWmdg Solstice DiskSuite Tool
(sparc) 4.2.1,REV=1999.11.04.18.29
2 SUNWmdja Solstice DiskSuite Japanese localization
(sparc) 4.2.1,REV=1999.12.09.15.37
3 SUNWmdnr Solstice DiskSuite Log Daemon Configuration Files
(sparc) 4.2.1,REV=1999.11.04.18.29
4 SUNWmdnu Solstice DiskSuite Log Daemon
(sparc) 4.2.1,REV=1999.11.04.18.29
5 SUNWmdr Solstice DiskSuite Drivers
(sparc) 4.2.1,REV=1999.12.03.10.00
6 SUNWmdu Solstice DiskSuite Commands
(sparc) 4.2.1,REV=1999.11.04.18.29
7 SUNWmdx Solstice DiskSuite Drivers(64-bit)
(sparc) 4.2.1,REV=1999.11.04.18.29
选择1、3、4、5、6、7,在安装过程中出现的全部提问都回答"y" 。
在成功安装之后重新引导服务器。
4、
# init 6
第二步、为Solstice Disksuite准备硬盘
Solstice Disksuite 使用metadevice 状态数据库在硬盘上存储有关DiskSuite的配置状态信息。
这些数据库必须驻留在一个引导磁盘的专用分区上。可以创建两个大约50M的磁盘分区。
如我们在主引导磁盘上创建的两个分区是:c0t0d0s3、c0t0d0s4
那么被镜像的磁盘相对应的分区就应该是:c0t1d0s3、c0t1d0s4
比如我们镜像两个磁盘:c0t0d0、c0t1d0
使用format 命令并选择引导磁盘并且创建两个大约50M大小的分区来保存状态数据库。
1、
# format
被镜像的磁盘分区表必须是与引导磁盘相同。把引导磁盘的分区表复制到镜像磁盘。使用下列命令:
# prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t1d0s2
fmthard: New volume table of contents now in place
第三步、使用Disksuite进行配置
首先要创建状态数据库复本。最少要创建两个或两个以上的数据库复本。在上面我们已经创建了两个用来保存数据库复本的磁盘分区,后把引导磁盘的分区表复制到被镜像磁盘,这样就有四个相同的大约50M的磁盘分区。现在我们将在四个分区中分别为每个分区创建两个数据库复本,总计是八个复本。状态数据库复本存储着DiskSuite的配置和状态信息。我们可以使用下列命令去创建这个数据库复本。
1、
# metadb -a -f -c2 /dev/dsk/c0t0d0s3 /dev/dsk/c0t1d0s3
# metadb -a -f -c2 /dev/dsk/c0t0d0s4 /dev/dsk/c0t1d0s4
2、创建一个文件系统的镜像
首先我们先对一个磁盘做一个单向的镜像,稍候我们追加第二个磁盘去镜像。设备编号(d##) 是任意的。现在我们先做个约定:
d10 – 1st表示第一块磁盘的镜像设备
d20 – 2nd表示第二块磁盘的镜像设备
d30 – 镜像中所包含的镜像设备。
metainit 命令被用来创建磁盘0号分区的镜像:
1、
# metainit -f d10 1 1 c0t0d0s0
d10: Concat/Stripe is setup
2、
# metainit -f d20 1 1 c0t1d0s0
d20: Concat/Stripe is setup
3、
# metainit d30 -m d10
d30: Mirror is setup
l 在上列命令中的“-f”参数表示强迫metainit 命令继续,即使是这些分区之一包含了一个被挂载的文件系 统或正在被使用的交换分区。
l 命令“# metainit -f d10 1 1 c0t0d0s0”表示为root分区创建一个一对一的级联。
l 最后一条命令表示创建metadevice 镜像并且把镜像设备d10 附加到d30。
下一步是要更新/etc/vfstab 文件和/etc/system file.不能手工的编辑 /etc/vfstab或/etc/system文件。可以使用metaroot 命令:
4、
# metaroot d30
查看/etc/vfstab,并且你能看到“/”文件系统将被挂载到/dev/md/dsk上而不是挂载到/dev/dsk.
5、创建其它文件系统的镜像
swap 文件系统:
# metainit -f d11 1 1 c0t0d0s1
# metainit -f d21 1 1 c0t1d0s1
# metainit d31 -m d11
/var文件系统:
# metainit -f d12 1 1 c0t0d0s5
# metainit -f d22 1 1 c0t1d0s5
# metainit d32 -m d12
/opt文件系统:
# metainit -f d13 1 1 c0t0d0s6
# metainit -f d23 1 1 c0t1d0s6
# metainit d33 -m d13
/export/home 文件系统:
# metainit -f d14 1 1 c0t0d0s7
# metainit -f d24 1 1 c0t1d0s7
# metainit d34 -m d14
6、编辑/etc/vfstab文件,编辑之后这个新的/etc/vfstab文件应该类似于这样:
# vi /etc/vfstab
#device#to mount Deviceto fsck Mountpoint FStype Fsckpass Mountat boot mount options
#
#/dev/dsk/c1d0s2 /dev/rdsk/c1d0s2 /usr ufs 1 yes -
FD - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/md/dsk/d31 - - swap - no -
/dev/md/dsk/d30 /dev/md/rdsk/d30 / ufs 1 no -
/dev/md/dsk/d32 /dev/md/rdsk/d32 /var ufs 1 no -
/dev/md/dsk/d34 /dev/md/rdsk/d34 /export/home ufs 2 yes -
/dev/md/dsk/d33 /dev/md/rdsk/d33 /opt ufs 2 yes -
swap - /tmp tmpfs - yes -
7、禁止无害的消息(可选)被禁止掉的这条信息是:"WARNING: forceload of misc/md_hotspares failed".
# metainit hsp001
8、重新引导允许系统去重新挂载镜像
# lockfs -fa
# init 6
下列的警告住处是无害的,可以忽略不记:
WARNING: forceload of misc/md_trans failed
WARNING: forceload of misc/md_raid failed
WARNING: forceload of misc/md_hotspares failed
追加第二个镜像设备到镜像。这样磁盘上的数据就会从引导磁盘上与已经镜像的磁盘进行同步
9、
# metattach d30 d20
运行metastat检查这个同步的进程
10、
# metastat d30
现在可以追加其它的镜像设备了。
11、
# metattach d31 d21
# metattach d32 d22
# metattach d33 d23
# metattach d34 d24
运行metastat检查这些进程
12、生成可自切换的能启动的镜像磁盘
13、生成引导块
# installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t1d0s0
为被镜像磁盘创建一个nvram 别名如:“backup”,允许从备份磁盘进行引导
13、确定被镜像磁盘的设备路径
# ls -l /dev/rdsk/c0t1d0s0
lrwxrwxrwx 1 root root 54 Aug 5 20:35 /dev/rdsk/c0t1d0s0 ->
../../devices/sbus@3,0/SUNW,fas@3,8800000/sd@b,0:a,raw
这个设备路径被用来为今后第一块儿磁盘出现故障时可以自动切换到第二块备份磁盘。
这个路径就是:/sbus@3,0/SUNW,fas@3,8800000/sd@b,0:a(注意:这个路径需要跟据自己的服务器所输出的内容相同。)
14、Shut down 机器停留在ok提示符下,并键入:
ok nvalias backup /sbus@3,0/SUNW,fas@3,8800000/sd@b,0:a
14、或是在操作系统环境中使用eeprom命令,如:
# eeprom nvramrc="devalias backup /sbus@3,0/SUNW,fas@3,8800000/sd@b,0:a"
15、在ok提示符下修改启动值,把被镜像磁盘列入备用启动中:
ok setenv boot-device disk backup
ok reset-all
** 最好还加上
# dumpadm -d /dev/md/dsk/d32
系统crash时dump到/var/crash/$HOSTNAME目录下面
以下是英文版:
Prepare the drives for SDS
SDS uses metadevice state databases to store information on disk about the state
of your DiskSuite configuration. The metadevice state database records and
tracks changes made to your configuration. These databases must reside on a
dedicated slice(in the case of a boot drive). I typically leave a small amount
of unused space on the boot drive when installing Solaris for these databases.
That is, I leave at least one unused slice with approximately 6 MB of free space
available for SDS when installing Solaris. If you do not have any unused space
and you have an unused slice, then you may borrow space from swap. See
documentation from Sun to perform this step.
Use format command to select the boot disk and create the slice that will hold
the state database.
The output from format of my boot disk looks like the following. I have the
following filesystems carved: /, swap, /var, /opt, and /export/home
Part Tag Flag Cylinders Size Blocks
0 root wm 0 - 1392 3.13GB (1393/0/0) 6563816
1 swap wu 1393 - 3131 3.91GB (1739/0/0) 8194168
2 backup wm 0 - 7505 16.86GB (7506/0/0) 35368272
3 var wm 3132 - 4870 3.91GB (1739/0/0) 8194168
4 unassigned wm 4871 - 5740 1.95GB (870/0/0) 4099440
5 home wm 5741 - 7479 3.91GB (1739/0/0) 8194168
6 unassigned wm 0 0 (0/0/0) 0
7 unassigned wm 0 0 (0/0/0) 0
Notice that slice 6 and 7 are unassigned and also there are 26 unused
cylinders (7480 to 7505).
Create the dedicated slice for the state databases:
partition> 6
Part Tag Flag Cylinders Size Blocks
6 unassigned wm 7480 - 7504 57.52MB (25/0/0) 117800
Enter partition id tag[unassigned]:
Enter partition permission flags[wm]:
Enter new starting cyl[0]: 7480
Enter partition size[117800b, 25c, 57.52mb, 0.06gb]: 26c
partition> p
Current partition table (unnamed):
Total disk cylinders available: 7506 + 2 (reserved cylinders)
Part Tag Flag Cylinders Size Blocks
0 root wm 0 - 1392 3.13GB (1393/0/0) 6563816
1 swap wu 1393 - 3131 3.91GB (1739/0/0) 8194168
2 backup wm 0 - 7505 16.86GB (7506/0/0) 35368272
3 var wm 3132 - 4870 3.91GB (1739/0/0) 8194168
4 unassigned wm 4871 - 5740 1.95GB (870/0/0) 4099440
5 home wm 5741 - 7479 3.91GB (1739/0/0) 8194168
6 unassigned wm 7480 - 7505 59.82MB (26/0/0) 122512
7 unassigned wm 0 0 (0/0/0) 0
partition> label
Ready to label disk, continue? y
Note: in this example the slice is 60 MB. I made this slice bigger than what
is needed. This is because I intend on adding other features to this
configuration at a later time and need more space. However, you should be fine
with approx. 6 Mb.
The partition table of the mirrored drive should be identical to the boot drive.
Simply copy the partition table of the boot drive to its mirror
# prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t8d0s2
fmthard: New volume table of contents now in place
In this case c0t0d0s2 is the boot drive and c0t8d0s2 is the mirror. Notice
that it is on the same controller. You should try to mirror drives across
different controllers if at all possible. Basically, the fmthard command takes
the partition table of the boot disk and replicates it to the mirror drive.
Use the format command to verify that the partitions are exactly identical.
Configure Solstice Disksuite
Create at least 2 state database replicas on each disk. A state database replica
stores DiskSuite configuration and state information. Before you can use
DiskSuite, you must create state database replicas.
# metadb -a -f -c2 /dev/dsk/c0t0d0s6 /dev/dsk/c0t8d0s6
Where -a means adding; -f means force because this is the first time creating
databases; and -c 2 means create 2 databases in each slice.
Create the mirror for / filesystem
Here we are creating a one-way mirror which for the time being is composed of
1 drive. Later we will attach the second drive to the mirror. The metainit
command defines the metadevices that the mirror will use. The device numbers
(d##) are arbitrary. I typically use 10's(1st set of submirrors), 20's(2nd set
of submirrors), and 30's(mirror containing the submirrors).
# metainit -f d10 1 1 c0t0d0s0
# metainit d20 1 1 c0t8d0s0
# metainit d30 -m d10
The -f means force the creation. The "1 1" means we are creating a 1 way 1
slice metadevice. "metainit d30 -m d10" creates the metadevice mirror and
attaches the submirror "d10" to it.
Update the /etc/vfstab for / filesystem and /etc/system. Do not try to edit
/etc/vfstab or /etc/system manually - Use the metaroot command!
# metaroot d30
Take a look at your /etc/vfstab and notice that the / filesystem will be
mounted on /dev/md/dsk rather than /dev/dsk.
Create the mirror for all other filesystems
Swap filesystem:
# metainit -f d11 1 1 c0t0d0s1
# metainit d21 1 1 c0t8d0s1
# metainit d31 -m d11
/var filesystem:
# metainit -f d12 1 1 c0t0d0s3
# metainit d22 1 1 c0t8d0s3
# metainit d32 -m d12
/opt filesystem:
# metainit -f d13 1 1 c0t0d0s4
# metainit d23 1 1 c0t8d0s4
# metainit d33 -m d13
/export/home filesystem:
# metainit -f d14 1 1 c0t0d0s5
# metainit d24 1 1 c0t8d0s5
# metainit d34 -m d14
Edit the /etc/vfstab to mount the new mirrors on boot.
The /etc/vfstab prior to updating it:
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
#/dev/dsk/c1d0s2 /dev/rdsk/c1d0s2 /usr ufs 1 yes -
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/dsk/c0t0d0s1 - - swap - no -
/dev/md/dsk/d30 /dev/md/rdsk/d30 / ufs 1 no -
/dev/dsk/c0t0d0s3 /dev/rdsk/c0t0d0s3 /var ufs 1 no -
/dev/dsk/c0t0d0s5 /dev/rdsk/c0t0d0s5 /export/home ufs 2 yes -
/dev/dsk/c0t0d0s4 /dev/rdsk/c0t0d0s4 /opt ufs 2 yes -
swap - /tmp tmpfs - yes -
The /etc/vfstab after updating it:
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
#/dev/dsk/c1d0s2 /dev/rdsk/c1d0s2 /usr ufs 1 yes -
FD - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/md/dsk/d31 - - swap - no -
/dev/md/dsk/d30 /dev/md/rdsk/d30 / ufs 1 no -
/dev/md/dsk/d32 /dev/md/rdsk/d32 /var ufs 1 no -
/dev/md/dsk/d34 /dev/md/rdsk/d34 /export/home ufs 2 yes
-
/dev/md/dsk/d33 /dev/md/rdsk/d33 /opt ufs 2 yes -
swap - /tmp tmpfs - yes -
Be very careful when editing this file. It is very easy to mistype something
and not be able to mount that filesystem when you reboot. I suggest carefully
reviewing this file before proceeding.
Suppress harmless warning messages (optional)
Typically, after a SDS install, you will receive the harmless but annoying
messages on boot-up: "WARNING: forceload of misc/md_hotspares failed". This is a
nuisance, so I typically suppress them by creating an empty hot spare pool:
# metainit hsp001
Reboot and allow the system to mount the mirrors.
# lockfs -fa
# init 6
Ignore the following errors on boot. Suns reason for these errors: "These
warnings are harmless, and may be ignored. They are an artifact of the way
drivers are loaded during the boot process when you have a mirrored root or
/usr file system.":
WARNING: forceload of misc/md_trans failed
WARNING: forceload of misc/md_raid failed
WARNING: forceload of misc/md_hotspares failed
Attach the second submirror to the mirror. This will cause the data from the
boot disk to be synchronized with the mirrored drive.
# metattach d30 d20
# metattach d31 d21
# metattach d32 d22
# metattach d33 d23
# metattach d34 d24
Use metastat to track progress
# metastat
d30: Mirror
Submirror 0: d10
State: Okay
Submirror 1: d20
State: Resyncing
Resync in progress: 21 % done
Pass: 1
Read option: roundrobin (default)
Write option: parallel (default)
Size: 6563816 blocks...
Enable the mirror disk to be bootable:
# installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t8d0s0
# ls -l /dev/rdsk/c0t8d0s0
lrwxrwxrwx 1 root root 50 Aug 1 10:48 /dev/rdsk/c0t8d0s0 ->
../../devices/pci@1f,0/pci@1,1/ide@3/dad@1,0:a,raw
Notice the red font. This is the device path that you will use to define the
alternate boot path at the ok prompt.
ok nvalias mirror /pci@1f,0/pci@1,1/ide@3/dad@1,0:a,raw
NOTE: You may have to replace the "dad" with "disk" depending on the boot
prom. Issue a "show-disks" at the ok prompt to verify the correct path to the
disk. Use "devalias" at the ok prompt to also give clues as to which device
path to use.
In case of primary boot disk failure, boot from the alternate disk
ok boot mirror


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/15649/showart_99757.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP