|
楼主 |
发表于 2008-7-31 08:45:57
|
显示全部楼层
用ZFS存储池管理设备
- Z" V# v8 l% a& X2 Y% D 1、增加设备到存储池
2 ]# Q l2 ^+ ] 用户可以通过增加一个新的顶级虚拟设备的方法动态给存储池增加空间,这个空间立即对空间中的所有数据集(dataset)有效。要增加一个虚拟设备到池中,用“zpool add”命令,例如:
. U1 X- ]6 ~' J # zpool add zeepool mirror c2t1d0 c2t2d0% o( F1 t: U- O+ b" {5 o
该命令也可以用 -n选项进行预览,例如:
* w" F# e% W; M. T: ~! G' s # zpool add -n zeepool mirror c3t1d0 c3t2d0
5 @: S' O. C- l" V" H would update ’zeepool’ to the following configuration:
+ T0 w0 c2 k3 P& o" k zeepool
+ P8 M* w5 C( Z+ n& H mirror6 e4 g$ b ]* j8 N+ V
c1t0d0/ t4 h) C% V. Y) ~
c1t1d0+ j4 W! }5 m$ X" `7 B
mirror
1 Y0 H. u: V8 O4 ]3 F* P( C c2t1d0, H u: f, F$ T7 @: b
c2t2d0
- i: @% B8 ^/ U mirror0 X8 A3 w% I% }% d
c3t1d0
6 }" B7 w+ Q6 o' c- X J c3t2d0
% U7 r- u& G( r8 ^6 ] - ^' {$ ^3 S8 { ^% _1 J
2、增加和减少一路镜像
# |9 @+ o7 [% e* m: V 用“zpool attach”命令增加一路镜像,例如:. ?& e. | I. b/ m# P# c# n
# zpool attach zeepool c1t1d0 c2t1d0* Q) y! P* |' v) C" W& W. K n8 |/ f# q
在这个例子中,假设 zeepool 是第一点里的那个zeepool(已经是两路镜像),那么这个命令将把zeepool升级成三路镜像。, U5 X4 J1 K4 E! b, C7 n/ ^7 H
用“zpool detach”命令来分离一路镜像
8 I! w3 T1 I: C6 r5 s1 v- o/ U # zpool detach zeepool c2t1d0 4 e( j# j6 Y$ e/ V% X6 d
如果池中不存在镜像,这个才操作将被拒绝。错误提示如下边这个例子:
% ~! j& O) z& b( V # zpool detach newpool c1t2d0 cannot detach c1t2d0: onlyapplicable to mirror and replacing vdevs
. a3 X5 |9 H& I B! |9 K/ i' A 8 p) N4 k5 @( ]# e
3、管理设备的“上线”和“下线”
$ c& F3 G* t- } ZFS允许个别的设备处于offline或者online状态。当硬件不可靠或者还没有完全不能用的时候,ZFS会继续向设备读写数据,但不过是临时这么做,因为设备还能将就使用。一旦设备不能使用,就要指示ZFS忽略该设备,并让这个坏掉的设备下线。ZFS不会向offline的设备发送任何请求。) a4 g+ n W7 J) G
注意:如果只是为了更换设备(被换设备并没有出问题),不需要把他们offline。如果offline设备,然后换了一个新设备上去,再把新设备online,这么做会出错!+ k6 \7 K: F) d" V7 R4 m
用“zpool offline”命令让设备下线。例如:
7 o7 C# o6 f3 c" m3 _( } # zpool offline tank c1t0d01 u5 X2 _- }$ F8 ?' F+ U
bringing device c1t0d0 offline
. n2 ~: I4 C! u; s1 o' k5 a 下边这句话没怎么看懂:
5 e" ]" I/ j+ \, t @ You cannot take a pool offline to the point where it becomes faulted. For example, you cannot take offline two devices out of a RAID-Z configuration, nor can you take offline a top-level virtual device.5 @# P: N# {1 J
# zpool offline tank c1t0d08 s1 l6 A( v7 C
cannot offline c1t0d0: no valid replicas4 Y, K5 e! e$ d8 ?, @
默认情况下,offline设备将永久保持offline状态,直到系统重新启动。
) i6 C% q' X# Y% r p* N( f* L 要临时offline一个设备,用-t选项,例如:% }# {2 }: d$ E
# zpool offline -t tank c1t0d0
9 ?7 d1 `" m2 N6 n! F bringing device ’c1t0d0’ offline8 `% {& F) R+ n& Z% L, F
用“zpool onine”命令使设备上线8 w" P6 ^: o! [( l( |5 G0 E
# zpool online tank c1t0d0
3 i) G2 j$ ?. \# R9 L8 q! t8 x7 y bringing device c1t0d0 online9 _$ x. L7 h7 i
注意:如果只是为了更换设备(被换设备并没有出问题),不需要把他们offline。如果offline设备,然后换了一个新设备上去,再把新设备online,这么做会出错!在这个问题上文档是这么说的:(但愿我没理解错)
/ Q& H7 V1 R# ]/ b+ b% q' K Note that you cannot use device onlining to replace a disk. If you offline a
^2 Q/ q% V! B' wdevice, replace the drive, and try to bring it online, it remains in the faulted state.# P7 z" {1 c7 I: D4 |4 _: L" N% B
2 W4 P4 a2 q8 Z& o5 ]! l
4、清扫存储池设备' P6 l) M. w& L; e' `+ Z
如果设备因为出现错误,被offline了,可以用“zpool clear”命令清扫错误。$ c7 ]' G$ B3 L3 L. l
如果没有特别指定,zpool clear命令清扫池里所有设备。例如:. b5 `) l: ]* c" Y
# zpool clear tank( B6 F3 ?/ n1 C* j% h/ S+ Z
如果要清扫指定设备,例如:
a: o) E, w$ h! c& H # zpool clear tank c1t0d0, r) N- [4 w" X$ x
* J9 u6 c1 V! V; V8 ?/ M% g
5、替换存储池里的设备
4 x4 T( e+ y) j/ Y: @2 W5 l7 } 用“zpool replace”命令替换池中设备,例如: ! a" x" k; J. f$ j7 ]& h& N
# zpool replace tank c1t1d0 c1t2d0) m. B( [1 G5 s: y7 {( n0 S
c1t1d0 被 c1t2d0 替换
7 W: K1 {/ o1 g; p 注意:如果是mirror或者RAID-Z,替换设备的容量必须大于或等于所有设备最小容量!; s \0 Q+ _' n9 S& q: ? d
9 J* R r3 c* ^7 ?; j5 E
查询ZFS存储池的状态
& [$ r0 ] H& E2 n& {9 H( u. x 1、ZFS存储池的基本信息
0 r2 Y' ^8 s+ g H) g 用“zpool list”命令查看存储池的基本信息,例如:9 H ^& j0 ^9 |* @" K' v4 @
# zpool list
7 I$ Z2 }6 D. d3 T NAME SIZE USED AVAIL CAP HEALTH ALTROOT
3 z u, \0 U; S: N. i4 {, P tank 80.0G 22.3G 47.7G 28% ONLINE -3 }2 ^$ x U0 ?. m+ a* g) |% Y- {$ H0 C
dozer 1.2T 384G 816G 32% ONLINE -1 T, g B2 c, f# ?+ k/ D/ u3 K ~
NAME: The name of the pool. V6 a, Z8 n. R/ ]1 d6 G, ]
SIZE: The total size of the pool, equal to the sum of the size of all top-level virtual
; Z. x- ^! @6 u# c$ }" Idevices.. h |2 V! q6 ~% T
USED: The amount of space allocated by all datasets and internal metadata. Note that; S, t1 ~ W7 }6 [6 L
this amount is different from the amount of space as reported at the file system level. 9 U8 G$ {4 c# N* w" n4 p
AVAILABLE: The amount of unallocated space in the pool.+ h# B% Q" P! n5 p( x$ j
CAPACITY (CAP): The amount of space used, expressed as a percentage of total space.
' Q' v! l% ~6 n HEALTH: The current health status of the pool.
8 i8 }' Q" ?$ v9 n. {4 _ ALTROOT: The alternate root of the pool, if any.# z) S, H! s* J: A C$ O+ J
可以通过指定名字来查看某一个池的状态,例如:
; F8 i- r( w Z1 Q5 x # zpool list tank# Q d4 E" U1 U! u7 Z# v
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
1 w$ z2 B: m8 g S2 A1 y tank 80.0G 22.3G 47.7G 28% ONLINE -9 Z( p6 ~4 y8 O) N$ M
. ] O$ r5 i& j5 n2 b
如果要有选择看状态列表,可以用-o选项4 {0 G. E k0 z1 e$ u, {# J, D4 ^
# zpool list -o name,size, O F# ], P' @9 w: y6 Q6 C
NAME SIZE ) a5 [2 U" x" X
tank 80.0G
* L) C" F" x2 o dozer 1.2T
7 c6 ?- f( ^: C
& W' {. P3 a6 ]8 [! e2 c1 E) G Scripting ZFS Storage Pool Output9 z5 B2 b, i9 o5 E+ U5 W9 x9 t7 G
The default output for the zpool list command is designed for readability, and is not easy to use as art of a shell script. To aid programmatic uses of the command, the -H option can be used to uppress the column headings and separate fields by tabs, rather than by spaces. For example, to request a simple list of all pool names on the system:8 J3 M D* ~& ~' ]* B& D% k: W
上边这段话简单说就是为了方便编程,用-H选项,这样输出列表的域之间用tab相隔,而不是空格。2 p! F1 T- R/ t9 C. c) ]. i
# zpool list -Ho name
3 [/ K3 Z2 V7 G6 g4 `8 n/ @; } tank5 G6 H. q' s& z/ x2 Y# h
dozer
& @( f$ B1 f3 Q! S# V Here is another example:9 U# C$ S+ `6 n
# zpool list -H -o name,size- w2 K1 g; n8 Z9 |6 Q+ d
tank 80.0G
- B0 O! o. ?4 Q% b' z dozer 1.2T5 q E* M, T8 c. o% k; F: |
0 r6 O0 z+ j% p9 Y
2、查看存储池的I/O状态& S" Z4 o: ?* U& `
用“zpool iostat”命令查看存储池的I/O状态,例如:
& a. Q( P3 a7 E( \& I # zpool iostat
7 y: E6 r% z$ \" ]% k capacity operations bandwidth% h5 ?* I2 j$ p8 o
pool used avail read write read write
$ A% M! ]& }/ F; j- G ---------- ----- ----- ----- ----- ----- -----
2 L& d" @* b" e0 b1 F tank 100G 20.0G 1.2M 102K 1.2M 3.45K
# V- }: M$ O; i6 N5 m' b dozer 12.3G 67.7G 132K 15.2K 32.1K 1.20K
6 }/ c( v1 q! _3 K# ?6 `! \0 ?
0 O# }( g( ~# B5 _ [' N4 J7 M 3、ZFS存储池的健康状态
# b# H- y: b& I' l; n x 用“zpool status”查看健康状态 |
|