fc2ブログ

RAID-Z の resilver を試してありがたみを知る

ざるそば

せっかく ZFS ストレージプールを RAID-Z で作ったので、resilver (再同期処理) を試してみます。

作成した ZFS の下に、1.2GB くらいのファイルを置いて、MD5 ハッシュ値を計算します。
$ ls -lh
total 2433036
-rw-r--r-- 1 hoge staff 1.2G 1月 15日 01:35 001.dat
$ md5sum 001.dat
27981a5960ae53fc10d8cdc5c9a0093f 001.dat

ここで、3 本の HDD のうち 1 本を外すことで障害を発生させます。が、電源を入れながら抜くと本当に壊れるかもしれないと怯え、電源を落としてから抜くことにしました。


電源が落ちていることを確認し、3 本並んでいる HDD の 一番左 (ここでは 1 番とします) を抜いて起動します。


zpool status を叩くと、degrade していることがわかります。

$ zpool status tank
  pool: tank
 state: DEGRADED
status: One or more devices are unavailable in response to persistent errors.
  Sufficient replicas exist for the pool to continue functioning in a
  degraded state.
action: Determine if the device needs to be replaced, and clear the errors
  using 'zpool clear' or 'fmadm repaired', or replace the device
  with 'zpool replace'.
  Run 'zpool status -v' to see device specific details.
  scan: scrub repaired 0 in 1s with 0 errors on Mon Feb 27 00:53:41 2017
config:
  NAME STATE READ WRITE CKSUM
  tank DEGRADED 0 0 0
  raidz1-0 DEGRADED 0 0 0
  c1t0d0 UNAVAIL 0 0 0
  c1t1d0 ONLINE 0 0 0
  c1t2d0 ONLINE 0 0 0

errors: No known data errors

ですが、ファイルには問題ありません。

$ ls -lh
total 2433036
-rw-r--r-- 1 hoge staff 1.2G 1月 15日 01:35 001.dat
$ md5sum 001.dat
27981a5960ae53fc10d8cdc5c9a0093f 001.dat

この状態 (2 番と 3 番しか HDD がない) 状態で、730MB くらいのファイルを置きます。

$ ls -lh
total 3940662
-rw-r--r-- 1 hoge staff 1.2G 1月 15日 01:35 001.dat
-rw-r--r-- 1 hoge staff 736M 2月 21日 23:58 002.dat
$ md5sum 002.dat
a61f027eb51d997d6daa51712179cb4a 002.dat

そして外した 1 番の HDD を挿します。cfgadm を叩くと、unconfigure になっているので、構成します。

$ sudo cfgadm -c configure sata0/0
$ cfgadm | grep sata0/0
sata0/0::dsk/c1t0d0 disk connected configured ok

すると、特に何もしなくても resilver が完了していました。

$ zpool status tank
  pool: tank
 state: ONLINE
  scan: resilvered 368M in 5s with 0 errors on Wed Mar 1 22:36:02 2017

config:

  NAME STATE READ WRITE CKSUM
  tank ONLINE 0 0 0
  raidz1-0 ONLINE 0 0 0
  c1t0d0 ONLINE 0 0 0
  c1t1d0 ONLINE 0 0 0
  c1t2d0 ONLINE 0 0 0

もう一度 shutdown して、今度は一番右の HDD (3 番) を抜いて起動します。

当然 degrade しますが、先ほど追加した 002.dat が問題なければ、ちゃんと resilver されていることがわかります。

$ zpool status -v tank
  pool: tank
 state: DEGRADED
status: One or more devices are unavailable in response to persistent errors.
  Sufficient replicas exist for the pool to continue functioning in a
  degraded state.
action: Determine if the device needs to be replaced, and clear the errors
  using 'zpool clear' or 'fmadm repaired', or replace the device
  with 'zpool replace'.
  scan: resilvered 368M in 5s with 0 errors on Wed Mar 1 22:36:02 2017

config:

  NAME STATE READ WRITE CKSUM
  tank DEGRADED 0 0 0
  raidz1-0 DEGRADED 0 0 0
  c1t0d0 ONLINE 0 0 0
  c1t1d0 ONLINE 0 0 0
  c1t2d0 UNAVAIL 0 0 0

device details:

  c1t2d0 UNAVAIL cannot open
  status: ZFS detected errors on this device.
  The device was missing.

errors: No known data errors

degrade していますが、ファイルは問題ありません。

$ls -lh
total 3940662
-rw-r--r-- 1 hoge staff 1.2G 1月 15日 01:35 001.dat
-rw-r--r-- 1 hoge staff 736M 2月 21日 23:58 002.dat
$md5sum *
27981a5960ae53fc10d8cdc5c9a0093f 001.dat
a61f027eb51d997d6daa51712179cb4a 002.dat
これで HDD が (1 本なら) 壊れても安心ですね!同時に 2 本以上壊れたら泣きますね!
最後に外した HDD を挿し、cfgadm コマンドで構成、resilver されたのを見届けて完了です。俺はやったぜ。
Posted byざるそば

Comments 0

There are no comments yet.

Leave a reply