请查看自上而下创建卷的先决条件。
标识要在其上创建卷的可用存储器。
如果没有明确指定存储器,Solaris Volume Manager 会标识系统上未使用的存储器并使用它(如果适用的话)。如果您选择指定存储器-可以广泛地指定存储器(例如,控制器 1 上的所有存储器),也可以明确地指定存储器(例如,使用 c1t4d2,而不使用 c1t4d1),则 Solaris Volume Manager 会使用您指定的存储器。
使用 metassist 命令和适用于所执行任务的选项。
使用 -c 选项指定不应实际创建卷。
# metassist create -s diskset-name -f -r redundancy -a device1, device2... \ -S size -v verbosity [-c] |
用于创建卷的子命令。
指定要用于卷的磁盘集的名称。
指定该卷要与热备件相关联。
指定要创建的冗余级别(数据副本的数量)。
指定要用于创建卷的设备。
指定要创建的卷所采用的单位:KB(表示千字节)、MB(表示兆字节)、GB(表示千兆字节)或 TB(兆兆字节)。
指定输出的详细程度。允许值介于 0(几乎无提示的输出)和 2(详细输出)之间。缺省详细程度是 1(中等详细程度的输出)。
指定不应实际创建卷,而应将可用来创建指定配置的 shell 脚本发送到标准输出中。
-c 参数所需的 shell 脚本将发送到标准输出中,metassist 命令的其余输出将转至标准错误中。您可以在进行选择时重定向输出流。
有关更多信息,请参见以下示例和 metassist(1M) 手册页。
以下示例说明如何使用 metassist 命令来创建大小为 10 MB 且具有热备件的双向镜像,热备件可提供额外的容错功能。-f 选项指定容错功能。最后一个参数 (-c) 指定不应实际创建卷,而应将可用来创建指定配置的 shell 脚本发送到标准输出中。
# metassist create -s myset -f -r 2 -S 10mb -c
(output truncated)
.
.
.
Volume request completed successfully.
#!/bin/sh
#
# Environment
#
# Amend PATH
PATH="/usr/sbin:/usr/bin:$PATH"
export PATH
# Disk set name
diskset='myset'
#
# Functions
#
# Echo (verbose) and exec given command, exit on error
execho () {
test -n "$verbose" && echo "$@"
"$@" || exit
}
# Get full /dev/rdsk path of given slice
fullpath () {
case "$1" in
/dev/dsk/*|/dev/did/dsk/*) echo "$1" | sed 's/dsk/rdsk/' ;;
/*) echo "$1" ;;
*) echo /dev/rdsk/"$1" ;;
esac
}
# Run fmthard, ignore partboot error, error if output
fmthard_special () {
ignore='Error writing partboot'
out=`fmthard "$@" 2>&1`
result=$?
echo "$out" |
case "$out" in
*"$ignore"*) grep -v "$ignore"; return 0 ;;
'') return "$result" ;;
*) cat; return 1 ;;
esac >&2
}
#
# Main
#
# Verify root
if [ "`id | sed 's/^[^(]*(\([^)]*\).*/\1/'`" != root ]
then
echo "This script must be run as root." >&2
exit 1;
fi
# Check for verbose option
case "$1" in
-v) verbose=1 ;;
*) verbose= ;;
esac
# Does the disk set exist?
if metaset -s "$diskset" >/dev/null 2>&1
then
# Take control of disk set
execho metaset -s "$diskset" -t
else
# Create the disk set
autotakeargs=
/usr/sbin/clinfo || autotakeargs='-A enable'
execho metaset -s "$diskset" $autotakeargs -a -h `uname -n | cut -f1 -d.`
fi
# Format slices
execho fmthard_special -d 7:0:0:0:0 `fullpath c1t3d0s7`
execho fmthard_special -d 7:0:0:0:0 `fullpath c1t6d0s7`
execho fmthard_special -d 7:0:0:0:0 `fullpath c1t4d0s7`
# Add disks to set
execho metaset -s "$diskset" -a c1t3d0
execho metaset -s "$diskset" -a c1t6d0
execho metaset -s "$diskset" -a c1t4d0
# Format slices
execho fmthard_special -d 0:4:0:10773:17649765 `fullpath c1t3d0s0`
execho fmthard_special -d 0:4:0:10773:17649765 `fullpath c1t6d0s0`
execho fmthard_special -d 0:4:0:10773:17649765 `fullpath c1t4d0s0`
execho fmthard_special -d 1:4:0:17660538:21546 `fullpath c1t3d0s1`
execho fmthard_special -d 1:4:0:17660538:21546 `fullpath c1t4d0s1`
execho fmthard_special -d 1:4:0:17660538:21546 `fullpath c1t6d0s1`
# Does hsp000 exist?
metahs -s "$diskset" -i hsp000 >/dev/null 2>&1 || {
# Create hsp hsp000
execho metainit -s "$diskset" hsp000
}
# Add slices to hsp000
execho metahs -s "$diskset" -a hsp000 c1t3d0s1
# Create concat d2
execho metainit -s "$diskset" d2 1 1 c1t4d0s1
# Associate concat d2 with hot spare pool hsp000
execho metaparam -s "$diskset" -h hsp000 d2
# Create concat d1
execho metainit -s "$diskset" d1 1 1 c1t6d0s1
# Associate concat d1 with hot spare pool hsp000
execho metaparam -s "$diskset" -h hsp000 d1
# Create mirror d0
execho metainit -s "$diskset" d0 -m d2 1
execho metattach -s "$diskset" d0 d1
#
|
以下示例说明如何使用 metassist 命令来创建大小为 10 MB 且具有热备件的双向镜像,热备件可提供额外的容错功能。-f 选项指定容错功能。最后一个参数 (-c) 指定不应实际创建卷,而应将可用来创建指定配置的 shell 脚本发送到标准输出中。该命令最后会重定向标准输出,以便创建 /tmp/metassist-shell-script.sh shell 脚本,该脚本以后可用来创建指定的卷。
# metassist create -s myset -f -r 2 -S 10mb -c > \ /tmp/metassist-shell-script.sh |