|
楼主 |
发表于 2008-7-31 08:45:57
|
显示全部楼层
用ZFS存储池管理设备& w+ N# T! r+ v7 K
1、增加设备到存储池& W) M8 L& C/ t* S% O
用户可以通过增加一个新的顶级虚拟设备的方法动态给存储池增加空间,这个空间立即对空间中的所有数据集(dataset)有效。要增加一个虚拟设备到池中,用“zpool add”命令,例如:1 _- c; D$ Y* d' B; ?
# zpool add zeepool mirror c2t1d0 c2t2d0 J Q; r/ q+ G& ], Y
该命令也可以用 -n选项进行预览,例如:
# n+ s w H, Y& I0 { # zpool add -n zeepool mirror c3t1d0 c3t2d0 + ?9 Y# H; G) B2 Q% c
would update ’zeepool’ to the following configuration:
. T/ g' q; A& e- }+ T( E8 O) f/ ] zeepool9 o: [2 P+ U/ n& j3 m: T
mirror4 k5 S) M( x: Z" f# h7 O4 U7 s
c1t0d0
# ^$ C d. J8 ~0 y& j c1t1d0
T! j" _+ g5 @* c# A mirror
3 H+ Y; }* v( {4 Z1 \. w+ I c2t1d0
0 c+ l; `* Y' q/ p, |0 {2 W" R c2t2d00 A' M* o/ Z3 N+ r
mirror8 j$ G7 E0 L# ]+ B7 s
c3t1d0
. S2 g; R. F5 g8 H# x c3t2d0
4 M% ~8 d7 v/ r2 x ) y: c- j' c! p9 m$ U( }
2、增加和减少一路镜像
3 s( ]) e8 y8 }! p; F& u 用“zpool attach”命令增加一路镜像,例如:% p. i( T3 E! F# }( R6 v9 W% k5 Y# k
# zpool attach zeepool c1t1d0 c2t1d0
/ Z5 X2 D* E0 n+ y- ?% Z- k$ m 在这个例子中,假设 zeepool 是第一点里的那个zeepool(已经是两路镜像),那么这个命令将把zeepool升级成三路镜像。' w+ d: Z: W5 X0 c/ d3 P% n* l* Z
用“zpool detach”命令来分离一路镜像/ p' _, B' V+ {: p2 `
# zpool detach zeepool c2t1d0
) {4 N% b9 `9 P3 ]3 n7 s 如果池中不存在镜像,这个才操作将被拒绝。错误提示如下边这个例子:8 a, ~5 _) t7 [2 R
# zpool detach newpool c1t2d0 cannot detach c1t2d0: onlyapplicable to mirror and replacing vdevs
" Y- r# K- c; I0 b3 c2 X* p. i. P & r0 a* \7 K0 B! p2 _
3、管理设备的“上线”和“下线”9 @, S, W( {9 U" e( W8 E
ZFS允许个别的设备处于offline或者online状态。当硬件不可靠或者还没有完全不能用的时候,ZFS会继续向设备读写数据,但不过是临时这么做,因为设备还能将就使用。一旦设备不能使用,就要指示ZFS忽略该设备,并让这个坏掉的设备下线。ZFS不会向offline的设备发送任何请求。: ~5 I# A3 N0 o$ d0 ^ e8 |
注意:如果只是为了更换设备(被换设备并没有出问题),不需要把他们offline。如果offline设备,然后换了一个新设备上去,再把新设备online,这么做会出错!
) h4 I. J1 Z( E7 a) D2 B5 ^* ?/ T& T 用“zpool offline”命令让设备下线。例如:
) C! I/ j( s& }3 e) T5 c # zpool offline tank c1t0d0
6 o( M% J! C4 b bringing device c1t0d0 offline( i9 S, J" s" t! I* }' l8 T
下边这句话没怎么看懂:
' B% r* D- g, l% I% z0 p0 p 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.# \1 F& E g. o5 D% Q
# zpool offline tank c1t0d0
9 {! b. P- n2 A3 B. Y8 V cannot offline c1t0d0: no valid replicas2 ^% g0 Y4 y2 s$ p. ~0 v- E
默认情况下,offline设备将永久保持offline状态,直到系统重新启动。
- R: f9 k! H* B 要临时offline一个设备,用-t选项,例如:8 l" v5 E5 ]' M7 ?0 r
# zpool offline -t tank c1t0d06 \" d) R! O4 [* E4 `1 u- W7 P! Q7 b4 v
bringing device ’c1t0d0’ offline5 X3 x3 Y( X, U+ l( N) p
用“zpool onine”命令使设备上线$ l- T7 z: L z/ a
# zpool online tank c1t0d00 X" T! E* \0 h( h) i2 P- ^9 r( Y( h
bringing device c1t0d0 online+ x$ B$ t1 J5 p
注意:如果只是为了更换设备(被换设备并没有出问题),不需要把他们offline。如果offline设备,然后换了一个新设备上去,再把新设备online,这么做会出错!在这个问题上文档是这么说的:(但愿我没理解错)0 }; M' I6 ~9 {. ]
Note that you cannot use device onlining to replace a disk. If you offline a) c$ `1 y4 c/ J* R8 C2 P# |
device, replace the drive, and try to bring it online, it remains in the faulted state.9 f- W. X% G* d% N) U
' q1 r' [& \: D 4、清扫存储池设备9 {; N9 K+ c: _- {
如果设备因为出现错误,被offline了,可以用“zpool clear”命令清扫错误。" ?! }/ V2 F s
如果没有特别指定,zpool clear命令清扫池里所有设备。例如:& g7 L5 Q8 f) A6 h( A! P5 f+ @8 A
# zpool clear tank" [3 M) ^, p! w, X5 o! e1 T9 @
如果要清扫指定设备,例如:
: ~; {% l. U8 o. ]( |! A; x # zpool clear tank c1t0d08 V* B8 o7 i- C" E, e5 T% y& B
" L9 Y% F. U" w0 E6 O/ ]- ? 5、替换存储池里的设备: j& ^6 O$ J" l% `
用“zpool replace”命令替换池中设备,例如: 5 V, ^7 Z6 r6 A* U- L
# zpool replace tank c1t1d0 c1t2d0) [1 a* I( k% s# ]
c1t1d0 被 c1t2d0 替换 H) K$ |4 n5 O8 R
注意:如果是mirror或者RAID-Z,替换设备的容量必须大于或等于所有设备最小容量!" h7 Z: [% a' E* z& O5 \ x$ E; \
8 H( b/ {6 s8 e/ x9 J5 L A3 S- _# `
查询ZFS存储池的状态; {" n* Q# `7 A# N0 Z
1、ZFS存储池的基本信息
3 D0 b- b+ x4 }+ ? 用“zpool list”命令查看存储池的基本信息,例如:
3 E( a- B8 q; ? # zpool list& t! V6 g9 ~) S i: b X
NAME SIZE USED AVAIL CAP HEALTH ALTROOT# z/ {$ m6 x/ q( p2 c/ N
tank 80.0G 22.3G 47.7G 28% ONLINE -
7 Q' O0 K6 U* V d dozer 1.2T 384G 816G 32% ONLINE -
8 f3 S; `. Z# f+ ~1 q0 h9 Y5 b g NAME: The name of the pool.
, Q- b. m; i) w9 b SIZE: The total size of the pool, equal to the sum of the size of all top-level virtual
* k' t7 [* ^& Hdevices.
2 _7 P8 c8 {1 K# n* o USED: The amount of space allocated by all datasets and internal metadata. Note that
* A) u! a3 D4 S3 y, L: E0 \+ \this amount is different from the amount of space as reported at the file system level. ( \: f0 }& x* ]2 p) \1 Y/ t3 L
AVAILABLE: The amount of unallocated space in the pool.; q+ y' Q- V9 p/ L7 f) D$ e q
CAPACITY (CAP): The amount of space used, expressed as a percentage of total space.
+ @* E7 ]) y, w; V! y HEALTH: The current health status of the pool.
! g7 {8 f0 M3 r ALTROOT: The alternate root of the pool, if any.9 ]2 E& J2 S4 ] s2 Y
可以通过指定名字来查看某一个池的状态,例如:% h7 V, Q9 J0 }; Q5 H
# zpool list tank
/ E# ^" z; @. S& b NAME SIZE USED AVAIL CAP HEALTH ALTROOT
: S1 I' b& t, l d8 | tank 80.0G 22.3G 47.7G 28% ONLINE -
. K- y" x8 ^! p" z: f8 I
7 l# m J: M0 J* F* n 如果要有选择看状态列表,可以用-o选项
$ Y- E7 Y( u; p& @8 I # zpool list -o name,size
: ?8 G7 o- N z! U7 x0 a) J NAME SIZE
) }) X& v5 w* F: j tank 80.0G+ K6 ?: o" c/ ?: U
dozer 1.2T9 }1 O, n- {+ s" L1 y
+ ?! K& C' C# s) g% z
Scripting ZFS Storage Pool Output
; p, [3 r" m L1 v+ j% Z( W& @; ]- b/ X 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:
' J+ |# o( D0 R' b6 N 上边这段话简单说就是为了方便编程,用-H选项,这样输出列表的域之间用tab相隔,而不是空格。, O! I- l& U, ?1 [9 G
# zpool list -Ho name$ }4 n1 b/ |$ ^. U$ `( C( f( i2 s1 r
tank8 t) G6 q1 R% F& @) L5 j! J
dozer
- A' C0 B" g" R6 Y5 j2 t Here is another example:' `" E$ @8 \0 C9 I" k
# zpool list -H -o name,size
0 g; y: Y: h" u2 k+ ^. o tank 80.0G
) r" D( X3 A; V5 k6 S) [8 J dozer 1.2T
3 u6 \: c) d2 \3 j/ R
6 X: p. }/ q3 }6 e 2、查看存储池的I/O状态- o# v9 [7 J1 d `, {
用“zpool iostat”命令查看存储池的I/O状态,例如:; z! _. \& l4 w: Y
# zpool iostat
2 W7 E, S; \9 O! C3 T/ o# \8 ^; L$ z' C capacity operations bandwidth6 w y, N& O! x" D3 Z6 n$ d% O. O
pool used avail read write read write+ R9 t/ x6 t9 s0 a1 b2 L
---------- ----- ----- ----- ----- ----- -----% X$ t, J% A/ F( l2 t3 o a
tank 100G 20.0G 1.2M 102K 1.2M 3.45K% }3 C3 f8 r; F( N+ j2 U" E8 k0 i
dozer 12.3G 67.7G 132K 15.2K 32.1K 1.20K$ e$ N4 P6 d$ T$ r9 w% i0 k/ W3 u
4 p4 J8 ?+ `3 p9 U* l8 S- Y4 t" h
3、ZFS存储池的健康状态0 y: F. r# t6 N7 u
用“zpool status”查看健康状态 |
|