FrontPage

ZFS

Sunが開発したファイルシステム。Solaris, OpenSolaris?, FreeBSD (7.x or later?)で使用可能らしい。ditto block, storage poolといった考え方が斬新で、ディスク構成を柔軟に変更することが可能。

練習、基礎編

VMware上にインストールしたFreeBSDで練習。

ディスクイメージ作成

mkdir ~/images
cd ~/images
dd if=/dev/zero of=./disk1 bs=1m count=100
dd if=/dev/zero of=./disk2 bs=1m count=100
dd if=/dev/zero of=./disk3 bs=1m count=100

イメージを作ったら仮想デバイスとして割り当てる。

mdconfig -a -t vnode -f disk1
mdconfig -a -t vnode -f disk2
mdconfig -a -t vnode -f disk3

プールつくる

zpool createコマンドでzfstestというプールを作成する。

zpool create zfstest /dev/md0

プールいちらん

zpool listコマンドでプールの一覧を見る。

zpool list
NAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT
zfstest                95.5M    111K   95.4M     0%  ONLINE     -

プールどうなってるのか

zpool statusコマンドで状態をみる。

  pool: zfstest
 state: ONLINE
 scrub: none requested
config:

	NAME        STATE     READ WRITE CKSUM
	zfstest     ONLINE       0     0     0
	  md0       ONLINE       0     0     0

errors: No known data errors

プールにディスクを追加する

プールにディスクを追加する。いったんステータスを確認。

zpool status
  pool: zfstest
 state: ONLINE
 scrub: none requested
config:

	NAME        STATE     READ WRITE CKSUM
	zfstest     ONLINE       0     0     0
	  md0       ONLINE       0     0     0

errors: No known data errors

ついでに容量を確認する。

df -h zfstest
Filesystem    Size    Used   Avail Capacity  Mounted on
zfstest        63M      0B     63M     0%    /zfstest

zfstestプールにmd1を追加する。

zpool add zfstest md1

ステータスをみると追加されている。

  pool: zfstest
 state: ONLINE
 scrub: none requested
config:

	NAME        STATE     READ WRITE CKSUM
	zfstest     ONLINE       0     0     0
	  md0       ONLINE       0     0     0
	  md1       ONLINE       0     0     0

errors: No known data errors

容量も増える。かっこいい。

df -h zfstest
Filesystem    Size    Used   Avail Capacity  Mounted on
zfstest       151M      0B    151M     0%    /zfstest

プール消す

zpool destroyコマンドで削除する。警告メッセージは出ないので注意。

zpool destroy zfstest

練習、ミラー編

ミラーつくる

プール名のあとにmirrorと書いてデバイスを列挙する。デバイスは2個以上必要。

zpool create zfstest mirror md0 md1

ミラーにディスクを追加する

mirrorにはディスクを追加することができる。

ディスク容量はミラーなので変わらないが一応確認する。

zpool list
NAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT
zfstest                87.5M    112K   87.4M     0%  ONLINE     -

zpool attachコマンドでディスクを追加する。md2をmd0のコピーとして作る、という理解でいいのかな…。

zpool attach zfstest md0 md2

ミラーなので容量は変わらない。

zpool list
NAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT
zfstest                87.5M    114K   87.4M     0%  ONLINE     -

ディスクをオフラインにしてミラーをこわす

ディスク交換などのためにミラーからディスクを外す。

zpool offline zfstest md0

ステータスをみるとミラーが壊れて縮退運転(DEGRADE)に入ったことがわかる。

zpool status
  pool: zfstest
 state: DEGRADED
status: One or more devices has been taken offline by the administrator.
	Sufficient replicas exist for the pool to continue functioning in a
	degraded state.
action: Online the device using 'zpool online' or replace the device with
	'zpool replace'.
 scrub: resilver completed with 0 errors on Tue May 12 19:47:01 2009
config:

	NAME        STATE     READ WRITE CKSUM
	zfstest     DEGRADED     0     0     0
	  mirror    DEGRADED     0     0     0
	    md0     OFFLINE      0     0     0
	    md1     ONLINE       0     0     0

ディスクのこうかん

オフラインにしたmd0の代わりにmd2を追加してミラーを再構成する。

zpool replace zfstest md0 md2

scrubの部分をみるとresilver(これなに?)されたことがわかる。かっこいい。

zpool status
  pool: zfstest
 state: ONLINE
 scrub: resilver completed with 0 errors on Tue May 12 19:49:28 2009
config:

	NAME        STATE     READ WRITE CKSUM
	zfstest     ONLINE       0     0     0
	  mirror    ONLINE       0     0     0
	    md2     ONLINE       0     0     0
	    md1     ONLINE       0     0     0

スペアのついか

プールにスペアディスクを追加する。

zpool add zfstest spare md0

sparesにディスクが追加されていることがわかる。

zpool status
  pool: zfstest
 state: ONLINE
 scrub: resilver completed with 0 errors on Tue May 12 19:49:28 2009
config:

	NAME        STATE     READ WRITE CKSUM
	zfstest     ONLINE       0     0     0
	  mirror    ONLINE       0     0     0
	    md2     ONLINE       0     0     0
	    md1     ONLINE       0     0     0
	spares
	  md0       AVAIL   

そのほか

hot spareの動作を試そうと思いミラーディスクの片方をオフラインにしたが、リカバリ動作が開始されなかった。 障害ディスクをリプレイスするように指示しないと動作してくれなかった。実装状況について少し調べる必要がある。


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2009-05-12 (火) 21:09:11 (305d)