|

楼主 |
发表于 2008-7-31 08:45:57
|
显示全部楼层
用ZFS存储池管理设备
0 V9 d1 ^. R. l 1、增加设备到存储池# J! ~3 N& k6 |( N* Q" r
用户可以通过增加一个新的顶级虚拟设备的方法动态给存储池增加空间,这个空间立即对空间中的所有数据集(dataset)有效。要增加一个虚拟设备到池中,用“zpool add”命令,例如:
9 g5 }7 S, i' V6 d& [! [4 r9 l # zpool add zeepool mirror c2t1d0 c2t2d0
, {' J/ b O/ r 该命令也可以用 -n选项进行预览,例如: 7 w) P- u. H# C9 Q8 D9 H+ ^5 Z
# zpool add -n zeepool mirror c3t1d0 c3t2d0 - I- h5 g4 A$ g+ B, W
would update ’zeepool’ to the following configuration:
1 i( Y) Z7 Q& s- l& Y" I zeepool
& T; d- M' O# }5 `, c4 N/ i7 n$ G mirror; V- D+ x6 m4 |5 J; R( O5 \
c1t0d0
8 }* u$ V! q, Z' _ c1t1d0
) B5 Y0 O- e6 I5 y& U! G) J3 G: ~ mirror
2 U4 u; l$ I7 @ c2t1d0
- z! ^! L) k; r# F; r+ x c2t2d08 l6 _8 q" C; }' }* W; n( b
mirror
4 o# S5 n/ b( [% S- G' h; T0 _ c3t1d01 ~9 l9 |; ]4 Y
c3t2d0
6 J, \( p& R7 ?5 R 1 \0 |) H. I0 c Z1 X) o1 ^% ~ g
2、增加和减少一路镜像
. t$ }) p! b( I' T1 x% X5 E 用“zpool attach”命令增加一路镜像,例如:
3 f9 S7 v1 K7 P. W; p2 c j# ]. [ # zpool attach zeepool c1t1d0 c2t1d0+ d4 Q7 Z; g1 E
在这个例子中,假设 zeepool 是第一点里的那个zeepool(已经是两路镜像),那么这个命令将把zeepool升级成三路镜像。. d! w8 ]& T& a: P/ a5 u
用“zpool detach”命令来分离一路镜像+ H1 Q2 E2 {9 a( V7 e
# zpool detach zeepool c2t1d0
* j' m# a6 n# g! I5 \3 ~4 k2 K/ a 如果池中不存在镜像,这个才操作将被拒绝。错误提示如下边这个例子:4 F" U+ _/ o# z2 ?* p+ H" r Y! }3 _
# zpool detach newpool c1t2d0 cannot detach c1t2d0: onlyapplicable to mirror and replacing vdevs
" \5 n+ K' x9 J' f# Q$ _6 w
* M% V9 M. _: o" l 3、管理设备的“上线”和“下线”
2 `/ [- e6 D5 M" A9 a ZFS允许个别的设备处于offline或者online状态。当硬件不可靠或者还没有完全不能用的时候,ZFS会继续向设备读写数据,但不过是临时这么做,因为设备还能将就使用。一旦设备不能使用,就要指示ZFS忽略该设备,并让这个坏掉的设备下线。ZFS不会向offline的设备发送任何请求。
. L6 {, i( U0 k p 注意:如果只是为了更换设备(被换设备并没有出问题),不需要把他们offline。如果offline设备,然后换了一个新设备上去,再把新设备online,这么做会出错!7 h2 z6 }1 N7 l& T& a
用“zpool offline”命令让设备下线。例如:9 u% o9 ~" }+ U' o$ q" E' b X( Q4 w
# zpool offline tank c1t0d00 i8 U, T' f$ S3 h7 G( {0 J
bringing device c1t0d0 offline; W! r4 O0 C, D1 K a/ ?
下边这句话没怎么看懂:
! U6 k6 t+ Z! f4 E( g( S 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.% I( g8 [, C% {
# zpool offline tank c1t0d0
. ~- ^9 Q6 {* t# Z4 B' y1 h cannot offline c1t0d0: no valid replicas
4 C+ H9 O" m2 {5 } A$ ]7 E 默认情况下,offline设备将永久保持offline状态,直到系统重新启动。
4 o% K' h& x& L6 [ 要临时offline一个设备,用-t选项,例如:# q/ ?8 j( _; e
# zpool offline -t tank c1t0d0
! w Y/ L% I9 \" z A2 j bringing device ’c1t0d0’ offline& v; k8 h7 ?- k X0 m8 l5 T3 H
用“zpool onine”命令使设备上线* g: f y5 ~& B' E
# zpool online tank c1t0d0
% c) ^2 K* y; A5 ~ D: { bringing device c1t0d0 online! D/ _1 m3 ^$ f7 w9 L+ J
注意:如果只是为了更换设备(被换设备并没有出问题),不需要把他们offline。如果offline设备,然后换了一个新设备上去,再把新设备online,这么做会出错!在这个问题上文档是这么说的:(但愿我没理解错)
/ M' c6 m. x! G3 A2 q2 T- H8 i" h Note that you cannot use device onlining to replace a disk. If you offline a% t& r3 b2 v. b0 Q8 w
device, replace the drive, and try to bring it online, it remains in the faulted state.- I& V, Y* k5 \) a: {3 U3 B
5 |. b3 X+ [( d7 C# _ 4、清扫存储池设备 p1 m* X0 n* R* U
如果设备因为出现错误,被offline了,可以用“zpool clear”命令清扫错误。
' G# N! L9 Y2 ^# i 如果没有特别指定,zpool clear命令清扫池里所有设备。例如:# D9 ^4 V! K) Z {5 F& z' v
# zpool clear tank0 w9 Y3 x9 ^9 }$ s
如果要清扫指定设备,例如:
3 A- @* {& j; w* ~1 ^ # zpool clear tank c1t0d0
2 E! _: j8 I: h: Y, h
% q6 g: y- F) Q1 |5 M/ G& F 5、替换存储池里的设备2 f) w" a% F S0 C0 S
用“zpool replace”命令替换池中设备,例如: : S' t* e: g; f2 C; q
# zpool replace tank c1t1d0 c1t2d0
7 I. t/ V, @. e, K6 g u) A7 w c1t1d0 被 c1t2d0 替换: p% r2 l4 _# a4 n! n7 e
注意:如果是mirror或者RAID-Z,替换设备的容量必须大于或等于所有设备最小容量!
9 f# ^% P! z) p0 G: I5 |
; M! \. w- w4 ^1 f6 \: G查询ZFS存储池的状态5 J3 I6 q# X) g5 p* B( s1 y
1、ZFS存储池的基本信息
' Z: J) }9 R& | 用“zpool list”命令查看存储池的基本信息,例如:! q* {) O" G2 A9 h6 W( ~
# zpool list
: f2 R! H+ x3 C9 m* l+ d I NAME SIZE USED AVAIL CAP HEALTH ALTROOT: s2 E% S" `6 n* S+ [: j
tank 80.0G 22.3G 47.7G 28% ONLINE -% }: h2 k" `7 O0 y' m+ v# X. j
dozer 1.2T 384G 816G 32% ONLINE - Z; \ T- d, ]$ W" l
NAME: The name of the pool.% S9 D; x Y/ `: f l e
SIZE: The total size of the pool, equal to the sum of the size of all top-level virtual8 l4 v! c. }* x7 e
devices.) B. y; n6 W! R5 B6 N0 Q5 N/ s
USED: The amount of space allocated by all datasets and internal metadata. Note that
( i. A- a1 W- x5 Cthis amount is different from the amount of space as reported at the file system level. + Y5 X- J- D- S+ v* W7 w3 H
AVAILABLE: The amount of unallocated space in the pool./ P% v3 t* {1 ?+ Q; I1 t
CAPACITY (CAP): The amount of space used, expressed as a percentage of total space.
: A* x* p5 m! Z- V) I" t7 D/ H( F HEALTH: The current health status of the pool.
$ S- \' x2 O, K ALTROOT: The alternate root of the pool, if any.* c7 R2 X, Y8 s# l
可以通过指定名字来查看某一个池的状态,例如:2 ^2 u( b8 |" @, \+ Y, i- S
# zpool list tank
$ @4 k( @. F3 ? NAME SIZE USED AVAIL CAP HEALTH ALTROOT
8 M" a1 V" h, w' P7 K. _" ~ tank 80.0G 22.3G 47.7G 28% ONLINE -- y2 K' P- j4 Y# p2 A& t
. c7 s) E& E* ]. q$ Z; J3 G' N
如果要有选择看状态列表,可以用-o选项6 I- ~2 x& C/ \% e$ O1 N
# zpool list -o name,size
a: K" t8 @4 T3 J" M$ y* x NAME SIZE
2 ^! u6 D6 n; c/ o7 n tank 80.0G
6 h$ s7 T$ |1 X& a% K3 T, B5 s7 C dozer 1.2T
! t- f' W! A5 G
9 x' q o5 r3 L5 ^+ ~1 j1 N4 j Scripting ZFS Storage Pool Output
* X7 @ h ^/ ^3 U 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:4 Z% }; r9 ~7 u2 b2 Z. C# K6 o
上边这段话简单说就是为了方便编程,用-H选项,这样输出列表的域之间用tab相隔,而不是空格。- A! r% H# l0 d# Q( F
# zpool list -Ho name& g' p9 j/ G2 B
tank
# a, ]5 b* c# \( g" E5 K dozer
7 U# q. D) D! P4 V Here is another example:$ B6 E0 M+ P* e# h
# zpool list -H -o name,size
5 O- [5 x. _: F7 E: d o tank 80.0G9 C- d: \0 z" Z0 G
dozer 1.2T2 n" K9 c& K0 L' [) F1 F& \
8 B" U Q0 e+ d, |6 b
2、查看存储池的I/O状态
5 R# Z! K* u2 S4 P$ p1 m/ a, \ 用“zpool iostat”命令查看存储池的I/O状态,例如:$ o' x3 V- J% x9 A( @: T
# zpool iostat
, \, H, M( t+ R. O capacity operations bandwidth+ L5 x, e7 F/ Q& N
pool used avail read write read write; D+ k- q7 g- j1 ?& `; G
---------- ----- ----- ----- ----- ----- -----, S+ f6 |- ], W2 ]( C' o" e7 y) O5 e
tank 100G 20.0G 1.2M 102K 1.2M 3.45K* s0 k% T0 f+ c# e
dozer 12.3G 67.7G 132K 15.2K 32.1K 1.20K- m3 m4 X: b3 s2 u" M, T4 L
D3 p5 I$ B' m. Z. H7 P/ y" ^/ z
3、ZFS存储池的健康状态
: m0 S0 V! X$ U# I 用“zpool status”查看健康状态 |
|