Solaris 中的根盘镜像方法
发表于:2007-06-09来源:作者:点击数:
标签:
昨天看到了一篇文章,讲的是关于根盘镜像的,试了一下,绝对好用,所以就顺便推荐给大家。:) 先是DiskSuite的安装,这里我就不说了。 以下是镜像的方法: PreparethedrivesforSDS SDSusesmetadevicestatedatabasestostoreinformationondiskaboutthestate o
昨天看到了一篇文章,讲的是关于根盘镜像的,试了一下,绝对好用,所以就顺便推荐给大家。:)
先是DiskSuite的安装,这里我就不说了。
以下是镜像的方法:
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
| 车干子 回复于:2003-03-03 09:32:56
|
up up up up up up up up up up up up up up up up up up up up up up up
|
| x3y4z5 回复于:2003-03-03 11:12:05
|
好文章,收藏。
|
| 小羽毛 回复于:2003-03-10 13:56:33
|
我原来用installition盘装过,也是在v880上,就不是这样的提示.我是在想v880的swap怎么不让修改了,而且怎么成了cly了?
|
| coolfoxjinan 回复于:2003-03-18 18:32:01
|
现在有个问题,最后使用ok状态下:boot mirror以后如果想再改为从以前那个第一个硬盘启动怎么改啊,谢谢了。
|
| Philmoon 回复于:2003-03-18 18:41:02
|
[quote:51847bb242="coolfoxjinan"]现在有个问题,最后使用ok状态下:boot mirror以后如果想再改为从以前那个第一个硬盘启动怎么改啊,谢谢了。[/quote:51847bb242]
boot或boot disk
但实际使用中还是要小心,本人碰到过这情况:一个盘启不动了,换另一个盘也不行。估计是软故障而不是硬盘的故障,第一个盘上的错误同时镜象到了另一边。
|
| coolfoxjinan 回复于:2003-03-18 18:56:27
|
现在所有的程序都已经做完,但是切换到BOOT MIRROR的时候,不能正常启动,提示不能打开设备为什么?
|
| race 回复于:2003-03-18 20:01:55
|
你的是什么机器?
|
| x3y4z5 回复于:2003-03-18 20:04:28
|
search for my post.Someday before i have gotten the help from others.
|
| Hom 回复于:2003-03-18 21:39:50
|
不错,好文章,讲的很清楚。我今天刚刚做了四台机器的MIRROR。
不过/etc/vfstab里应该不需要手动添加的,lockfs -af以后就会自动有了的。
不过如果是根卷的话还要加上metaroot d10。
|
| coolfoxjinan 回复于:2003-03-22 16:02:49
|
经过测试,如果想用第二个硬盘单独启动,还需要改第二个硬盘的VFSTAB文件。
mount /dev/dsk/c1t2d0s3 /mnt
cd /mnt/etc
vi vfstab
改为相应的第二个盘的配置。
然后重启。
不过我还有一个问题:如果第一个硬盘坏了,第二个硬盘是不是有可能也把第一个硬盘上的坏数据也一并镜像到第二个硬盘啊?那样的话就是用第二个硬盘也没用了啊?
请各位大虾回复~!THX
|
| johnyou 回复于:2003-03-22 16:22:08
|
up / up
|
原文转自:http://www.ltesting.net