$ zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
zroot 228G 16.8G 211G - - 12% 7% 1.00x ONLINE -
zvol0 1.81T 1.49T 333G - - 5% 82% 1.00x DEGRADED -
$
$ zpool status zvol0
pool: zvol0
state: DEGRADED
status: One or more devices could not be opened. Sufficient replicas exist for
the pool to continue functioning in a degraded state.
action: Attach the missing device and online it using 'zpool online'.
see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-2Q
scan: scrub repaired 0B in 05:36:58 with 0 errors on Tue Jan 17 08:40:57 2023
config:
NAME STATE READ WRITE CKSUM
zvol0 DEGRADED 0 0 0
mirror-0 DEGRADED 0 0 0
12897545936258916783 UNAVAIL 0 0 0 was /dev/gpt/ndisk2
gpt/ndisk1 ONLINE 0 0 0
errors: No known data errors
两个硬盘应该构成镜像,但其中一个 gpt / ndisk2 不见了,只剩下一个,因此在 HEALTH 或 STATE 方面显示为 DEGRADED。另外,在 zpool status 中,显示了 gpt / ndisk2 所在位置的 config:部分中不见了,而是显示为“12897545936258916783”,并以“was /dev/gpt/ndisk2”结尾。稍后将使用此 ID。
创建备用分区
为备用硬盘准备工作,要进行 GPT 初始化,并准备用于 ZFS 的分区。
首先,使用 GPT 初始化硬盘。
$ gpart show ada1
gpart: No such geom: ada1.
$ gpart create -s gpt ada1
ada1 created
$ gpart show ada1
=> 40 11721045088 ada1 GPT (5.5T)
40 11721045088 - free - (5.5T)
$
同期在后台进行,如前所述,在此期间通常可以正常使用服务器。由于数据量大约为 1.5TB,因此同步需要相当长的时间,而在此期间如果无法了解进展情况,可能会感到有些不安。在 ZFS 中可以通过 zpool status 确认同步进度,从而获得结束时间的大致参考。
$ zpool status zvol0
pool: zvol0
state: DEGRADED
status: One or more devices is currently being resilvered. The pool will
continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
scan: resilver in progress since Sat Jan 28 14:25:44 2023
12.8G scanned at 596M/s, 600K issued at 27.3K/s, 1.49T total
0B resilvered, 0.00% done, no estimated completion time
config:
NAME STATE READ WRITE CKSUM
zvol0 DEGRADED 0 0 0
mirror-0 DEGRADED 0 0 0
replacing-0 DEGRADED 0 0 0
12897545936258916783 UNAVAIL 0 0 0 was /dev/gpt/ndisk2
gpt/sdisk1 ONLINE 0 0 0
gpt/ndisk1 ONLINE 0 0 0
errors: No known data errors
$
在 status: 下显示 One or more devices is currently being resilvered 和 resilver^ 3^ 中(同步中)的状态。在 action: 下显示指示等待 resilver 完成。而在 scan: 中显示处理量和预计时间,但正如 no estimated completion time 所示,同步刚开始时由于无法预知时间,因此不会显示。
过一段时间,将会显示预计完成时间,但根据经验,在这个阶段这些时间通常不可靠。
$ zpool status zvol0
===== <省略> =====
scan: resilver in progress since Sat Jan 28 14:25:44 2023
265G scanned at 664M/s, 6.51G issued at 16.3M/s, 1.49T total
6.51G resilvered, 0.43% done, 1 days 02:27:43 to go
===== <省略> =====
$
进一步确认后,显示需要大约 14 小时才能完成。
$ zpool status zvol0
===== <省略> =====
scan: resilver in progress since Sat Jan 28 14:25:44 2023
289G scanned at 488M/s, 18.6G issued at 31.4M/s, 1.49T total
18.6G resilvered, 1.22% done, 13:38:30 to go
===== <省略> =====
$
一小时后再次确认时,显示时间已减少到约 6 小时,但第一台镜像的同步最终花了约 15 个半小时。以下是第一台同步完成时检查到的 zpool list 和 zpool status 的结果。
$ zpool status zvol0
pool: zvol0
state: ONLINE
scan: resilvered 1.49T in 15:34:45 with 0 errors on Sun Jan 29 06:00:29 2023
config:
NAME STATE READ WRITE CKSUM
zvol0 ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
gpt/sdisk1 ONLINE 0 0 0
gpt/ndisk1 ONLINE 0 0 0
errors: No known data errors
$
HEALTH 和 STATE 均为 ONLINE,无错误发生,第一台同步顺利完成。
第二个硬盘的同步
由于第二个硬盘的更换和同步步骤与第一个完全相同,因此只记录命令的执行和结果。
更换第二个硬盘并启动。
$ zpool status zvol0
pool: zvol0
state: DEGRADED
status: One or more devices could not be opened. Sufficient replicas exist for
the pool to continue functioning in a degraded state.
action: Attach the missing device and online it using 'zpool online'.
see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-2Q
scan: resilvered 1.49T in 15:34:45 with 0 errors on Sun Jan 29 06:00:29 2023
config:
NAME STATE READ WRITE CKSUM
zvol0 DEGRADED 0 0 0
mirror-0 DEGRADED 0 0 0
gpt/sdisk1 ONLINE 0 0 0
13953654332474917058 UNAVAIL 0 0 0 was /dev/gpt/ndisk1
errors: No known data errors
$
$ zpool replace zvol0 13953654332474917058 gpt/sdisk2
$ zpool status zvol0
pool: zvol0
state: DEGRADED
status: One or more devices is currently being resilvered. The pool will
continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
scan: resilver in progress since Sun Jan 29 13:38:15 2023
12.8G scanned at 692M/s, 492K issued at 25.9K/s, 1.49T total
0B resilvered, 0.00% done, no estimated completion time
config:
NAME STATE READ WRITE CKSUM
zvol0 DEGRADED 0 0 0
mirror-0 DEGRADED 0 0 0
gpt/sdisk1 ONLINE 0 0 0
replacing-1 DEGRADED 0 0 0
13953654332474917058 UNAVAIL 0 0 0 was /dev/gpt/ndisk1
gpt/sdisk2 ONLINE 0 0 0
errors: No known data errors
第二台同步大约需要 14 小时。
$ zpool status zvol0
pool: zvol0
state: ONLINE
scan: resilvered 1.49T in 14:11:00 with 0 errors on Mon Jan 30 03:49:15 2023
config:
NAME STATE READ WRITE CKSUM
zvol0 ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
gpt/sdisk1 ONLINE 0 0 0
gpt/sdisk2 ONLINE 0 0 0
errors: No known data errors
$