六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 126|回复: 0

ZFS Pool 里增加硬盘做镜像

[复制链接]

升级  0%

156

主题

156

主题

156

主题

进士

Rank: 4

积分
500
 楼主| 发表于 2013-1-16 16:43:15 | 显示全部楼层 |阅读模式
 
<div class="entry">ZFS第一次出现在 OpenSolaris 上是在2005年11月发布的 build 27 版本,因为稳定性、可靠性等原因直到最近 VPSee才有考虑把它用在生产环境里,现在 VPSee 所有的 Solaris 服务器还是在用很古老的 UFS,UFS 仍是 Solaris 10的默认文件系统。昨天简单玩了一下 ZFS,用6个文件模拟6个硬盘在 ZFS 上进行了一系列添加、删除、镜像的操作,立刻体会到了 ZFS 的强大,但这与实际操作物理硬盘还是有点差别。VPSee 当时安装 OpenSolaris 的时候只用了一块 250GB 的硬盘,现在可以增加一块 250GB 的硬盘做镜像,试验一下 ZFS 强大的 mirror,相当于做 RAID1.
检查 pool

要在服务器上增加一块实际硬盘,先要看看系统原来的 pool 有什么:
# zpool status  pool: rpool state: ONLINE scrub: none requestedconfig:        NAME        STATE     READ WRITE CKSUM        rpool       ONLINE       0     0     0          c8t0d0s0  ONLINE       0     0     0errors: No known data errors上面显示 c8t0d0s0 是里面唯一的一块硬盘。现在插上一块新硬盘后(必要时需要重启)运行 format 工具:
# formatSearching for disks...The device does not support mode page 3 or page 4,or the reported geometry info is invalid.WARNING: Disk geometry is based on capacity data.The current rpm value 0 is invalid, adjusting it to 3600donec8t1d0: configured with capacity of 232.87GBAVAILABLE DISK SELECTIONS:       0. c8t0d0           /pci@0,0/pci108e,534c@5/disk@0,0       1. c8t1d0           /pci@0,0/pci108e,534c@5/disk@1,0Specify disk (enter its number):按 “Ctrl + C” 退出。c8t0d0 是原来的硬盘,c8t1d0 是后来加上去的新硬盘。
分区和 label

现在用 -e 参数再次运行 format,然后选择 partition,创建一个 Solaris 分区后打印出分区表看看,只有 s0,s2, s8 有内容。完成分区后退到 format 菜单,接着选择 label,因为大多数的 PC BIOS 都不支持 EFIlabels,所以要选择 SMI:
# format -e c8t1d0format> partitionSELECT ONE OF THE FOLLOWING:   1. Create a partition...partition> printCurrent partition table (original):Total disk cylinders available: 30398 + 2 (reserved cylinders)Part      Tag    Flag     Cylinders         Size            Blocks  0       root    wm       1 - 30396      232.85GB    (30396/0/0) 488311740  1 unassigned    wu       0                0         (0/0/0)             0  2     backup    wu       0 - 30396      232.85GB    (30397/0/0) 488327805  3 unassigned    wu       0                0         (0/0/0)             0  4 unassigned    wu       0                0         (0/0/0)             0  5 unassigned    wu       0                0         (0/0/0)             0  6 unassigned    wu       0                0         (0/0/0)             0  7 unassigned    wu       0                0         (0/0/0)             0  8       boot    wu       0 -     0        7.84MB    (1/0/0)         16065  9 unassigned    wu       0                0         (0/0/0)             0partition>quitformat> label[0] SMI Label[1] EFI LabelSpecify Label type[0]: 0Ready to label disk, continue? y做镜像

退出 format,在 rpool 里增加新硬盘作为第1一块硬盘 mirror,会出现以下报错:
# zpool attach -f rpool c8t0d0 c8t1d0cannot label 'c8t1d0': EFI labeled devices are not supported on root pools.我们必须把 VTOC 从第1块硬盘拷贝到第2块硬盘,注意这里 s2 是 slice(分区),c8t0d0s2 是 c8t0d0 的 s2分区,注意上面打印的分区显示 s2 代表整个硬盘,看 Blocks 发现 s2 = s0 + s8,s0 是 root 分区,s8 是boot 分区:
# prtvtoc /dev/rdsk/c8t0d0s2 | fmthard -s - /dev/rdsk/c8t1d0s2fmthard: Partition 2 specifies the full disk and is not equalfull size of disk.  The full disk capacity is 488343870 sectors.fmthard:  New volume table of contents now in place.新硬盘的 c8t1d0s0 分区做成 c8t0d0s0 的镜像,注意上面打印的分区显示 s0 是 root 分区,有 232.85GB 空间,也是我们想 mirror 的分区:
# zpool attach -f rpool c8t0d0s0 c8t1d0s0Please be sure to invoke installgrub(1M) to make 'c8t1d0s0' bootable.安装 grub

这一步非常重要,需要把 grub 安装在第二块硬盘上:
# installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c8t1d0s0Updating master boot sector destroys existing boot managers (if any).continue (y/n)?y校验 pool

校验 pool 后查看校验后状态:
# zpool scrub rpool# zpool status  pool: rpool state: ONLINE scrub: scrub in progress for 0h0m, 0.95% done, 0h26m to goconfig:        NAME        STATE     READ WRITE CKSUM        rpool       ONLINE       0     0     0          c8t0d0s0  ONLINE       0     0     0          c8t1d0s0  ONLINE       0     0     0errors: No known data errors
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表