|
楼主 |
发表于 2008-7-31 08:45:57
|
显示全部楼层
用ZFS存储池管理设备9 K: E# |3 Y# \9 Z. v
1、增加设备到存储池
' w$ G( F# h& l, {; W 用户可以通过增加一个新的顶级虚拟设备的方法动态给存储池增加空间,这个空间立即对空间中的所有数据集(dataset)有效。要增加一个虚拟设备到池中,用“zpool add”命令,例如:* @: {1 P0 t1 s0 J
# zpool add zeepool mirror c2t1d0 c2t2d04 j1 P6 S, L8 {
该命令也可以用 -n选项进行预览,例如:
- w' q5 Q/ X, E9 ~! @$ u6 r # zpool add -n zeepool mirror c3t1d0 c3t2d0 ! a" j. S: z3 z$ V$ b8 a+ k W
would update ’zeepool’ to the following configuration:$ b2 O& S& @. P- w
zeepool
5 E3 ?# v s7 J( R0 w, B3 u1 j mirror
% r6 `7 Q# c# `, R/ x c1t0d0* |* l: C7 `$ H# x& [
c1t1d0- `' D& b% a0 B8 h( E) B
mirror4 v" Z2 E/ h7 K( H
c2t1d0
+ _8 x% C+ O$ C- O c2t2d0+ H: T5 [1 k( L/ l) I6 z
mirror
) p, C+ Z/ z' M( S; ~, c$ q c3t1d0. N3 R+ F) f- i: O i/ \
c3t2d0
" T) V( e: I2 y2 q& h4 I% Z 8 f* G# f) \0 Q5 ^* D$ g3 |! l
2、增加和减少一路镜像 f* c; B' }' Z2 ]2 ~; a
用“zpool attach”命令增加一路镜像,例如:" z9 g' w& d" t a% S& S' B3 g; X
# zpool attach zeepool c1t1d0 c2t1d0% c) w# q& l& R0 w; e) O. ]$ W
在这个例子中,假设 zeepool 是第一点里的那个zeepool(已经是两路镜像),那么这个命令将把zeepool升级成三路镜像。
- A% G/ J, g2 z+ E6 k1 s G 用“zpool detach”命令来分离一路镜像5 ^+ f' i, t. X* N* o+ r* Y
# zpool detach zeepool c2t1d0 ; N* @) Q1 y2 V# l! K6 Q
如果池中不存在镜像,这个才操作将被拒绝。错误提示如下边这个例子: q* P) T2 [7 M& W) g _' R
# zpool detach newpool c1t2d0 cannot detach c1t2d0: onlyapplicable to mirror and replacing vdevs
1 k3 v6 |& I; f% W2 Z: U 6 p$ j0 g& S( w9 K7 u# }- e
3、管理设备的“上线”和“下线”% Q$ o8 R( I, g3 }# p4 ^
ZFS允许个别的设备处于offline或者online状态。当硬件不可靠或者还没有完全不能用的时候,ZFS会继续向设备读写数据,但不过是临时这么做,因为设备还能将就使用。一旦设备不能使用,就要指示ZFS忽略该设备,并让这个坏掉的设备下线。ZFS不会向offline的设备发送任何请求。+ ?0 O3 g0 O5 z. h2 V* m
注意:如果只是为了更换设备(被换设备并没有出问题),不需要把他们offline。如果offline设备,然后换了一个新设备上去,再把新设备online,这么做会出错!
0 o6 x/ B, [) ] x0 ] 用“zpool offline”命令让设备下线。例如:
4 l/ v; M) c+ {" G1 \$ I8 ^ # zpool offline tank c1t0d0
& A, N! P5 I8 W. N bringing device c1t0d0 offline
: y7 P( f' w4 a" L6 X5 | 下边这句话没怎么看懂:
6 G% D: Z4 x0 N$ N s: v3 E5 q 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., Y# s0 D4 z! R
# zpool offline tank c1t0d05 f. o+ _8 I! r6 h* Y
cannot offline c1t0d0: no valid replicas5 M2 [9 b6 t, l' w" f7 O" A
默认情况下,offline设备将永久保持offline状态,直到系统重新启动。
* T2 X! e" n7 I9 I! `- b 要临时offline一个设备,用-t选项,例如:
1 K5 u$ V1 D; F9 }, S3 `4 A # zpool offline -t tank c1t0d0
" D8 ~& x( j; X: Q& I bringing device ’c1t0d0’ offline7 m: a. U6 r$ i, F
用“zpool onine”命令使设备上线
8 f1 g7 p% ^7 B # zpool online tank c1t0d0. e* Z& z" l. S$ K
bringing device c1t0d0 online0 i' u/ P- k3 n% F4 G
注意:如果只是为了更换设备(被换设备并没有出问题),不需要把他们offline。如果offline设备,然后换了一个新设备上去,再把新设备online,这么做会出错!在这个问题上文档是这么说的:(但愿我没理解错)2 x$ v# F" P; n5 e' T. H
Note that you cannot use device onlining to replace a disk. If you offline a
# D: \# x1 }9 y( X L0 u* ldevice, replace the drive, and try to bring it online, it remains in the faulted state.( R) J% T* W& d& m0 `" n5 s+ z7 @: m: h
, L3 q& m( A1 [; W& g% p3 S
4、清扫存储池设备
& q& C3 {# z( _ 如果设备因为出现错误,被offline了,可以用“zpool clear”命令清扫错误。/ A# T% f/ g3 n4 h) f6 A$ j1 e- z+ H5 H
如果没有特别指定,zpool clear命令清扫池里所有设备。例如:
9 f0 g; I- i0 }8 i # zpool clear tank( X. y, h) p7 d) R
如果要清扫指定设备,例如:
0 J, M/ Q0 O" V # zpool clear tank c1t0d0! s8 v* V) x8 s- S* M, a$ M) G7 l) ~
$ M9 I" ]$ n, i) {% Q' j% e 5、替换存储池里的设备
2 J) k/ }; z: x$ l2 R4 Y8 u 用“zpool replace”命令替换池中设备,例如: + u- s% X- d2 }/ k7 _% v- l) D
# zpool replace tank c1t1d0 c1t2d0
% _ h B5 R# `0 i" _& x c1t1d0 被 c1t2d0 替换& M, \, U& X$ i2 M
注意:如果是mirror或者RAID-Z,替换设备的容量必须大于或等于所有设备最小容量!
# y% v6 I, m9 b- q1 \. X @
& |# q, X- f( ~0 P9 @' m查询ZFS存储池的状态* @/ K0 a" V8 y& Y0 A r
1、ZFS存储池的基本信息% s% a# v4 E) Q
用“zpool list”命令查看存储池的基本信息,例如:
4 z; o8 J6 {* s # zpool list
+ ~$ z2 W6 k6 b) u$ M3 `3 L NAME SIZE USED AVAIL CAP HEALTH ALTROOT5 w# O& T, {* x) i, F
tank 80.0G 22.3G 47.7G 28% ONLINE -
3 U1 K5 L6 e( _& Q/ {1 m dozer 1.2T 384G 816G 32% ONLINE -9 t. m4 o6 _1 _0 @" h7 ]) g
NAME: The name of the pool.
( \- \6 e5 C, R; ]0 ~ SIZE: The total size of the pool, equal to the sum of the size of all top-level virtual
2 W4 ^* E; B$ V; T! T( Odevices., R/ o4 S( a+ d6 _6 d' y9 i# n6 S
USED: The amount of space allocated by all datasets and internal metadata. Note that
- d# T' {% f; e( K" Uthis amount is different from the amount of space as reported at the file system level.
4 C h. \# n$ Z/ h3 {: C AVAILABLE: The amount of unallocated space in the pool.
( V3 \$ A- r7 ^3 h9 O CAPACITY (CAP): The amount of space used, expressed as a percentage of total space.8 h* ^+ w& K# y; X, H) X
HEALTH: The current health status of the pool.
* p: b& a3 q8 c* q3 Q ALTROOT: The alternate root of the pool, if any.
/ B, t1 W4 z" f& R3 J9 l* X 可以通过指定名字来查看某一个池的状态,例如:% w1 Z# p: H$ j! _; U2 ^, P
# zpool list tank
/ y) j: J4 }! p. d( P P6 T8 v NAME SIZE USED AVAIL CAP HEALTH ALTROOT
, X' H, i, Z2 z. ?* Y tank 80.0G 22.3G 47.7G 28% ONLINE -6 D4 @1 ^0 B6 i9 q6 E
& P3 B2 W, e6 u, P 如果要有选择看状态列表,可以用-o选项
! ^$ O6 i/ j7 s8 R* T( j5 L # zpool list -o name,size
' T* q( Q, O4 } j& p( |0 z NAME SIZE / s' q* U7 V A- M# j; y
tank 80.0G0 j+ w e* p! R, f( j
dozer 1.2T. [$ P+ s' a* C# v7 b
& s/ u3 Z+ a" h& S C Scripting ZFS Storage Pool Output
+ ]# T# b2 [7 U) Y w$ Q3 s 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:
$ ~- t3 |- z8 P* ~ 上边这段话简单说就是为了方便编程,用-H选项,这样输出列表的域之间用tab相隔,而不是空格。
4 ?4 Z) U& k" _1 s" L( ? # zpool list -Ho name' D4 s+ ~# l+ G4 f$ r3 f
tank2 |" h5 V( {8 x* T. c& H$ G. L/ ^- W
dozer
6 ^: j1 s9 b) ?9 C6 K Here is another example:
+ f1 T: b2 O. y! t! ]' b2 g # zpool list -H -o name,size
# O' L' c* D, W% d ~* x: x, S, g tank 80.0G1 Z& S7 a4 n* X' }
dozer 1.2T
5 Y+ E2 y; M# M/ g
: K" k6 V4 F3 J 2、查看存储池的I/O状态
/ Z* X% |& W, D/ [& } 用“zpool iostat”命令查看存储池的I/O状态,例如:
% |' T* ^3 s6 O# D5 `/ M7 W: M # zpool iostat0 I2 N( G+ W* ~' y* A
capacity operations bandwidth6 K/ W, t E( J* V
pool used avail read write read write
4 t1 l: B( |; ?3 F ---------- ----- ----- ----- ----- ----- -----
* \4 d8 d6 Y! {" s% z tank 100G 20.0G 1.2M 102K 1.2M 3.45K
# x# l7 E& m" N- {) ? dozer 12.3G 67.7G 132K 15.2K 32.1K 1.20K
& U# x& d5 C2 ?1 h2 `
6 }# [ i1 ^0 u- z/ \ 3、ZFS存储池的健康状态0 R4 n, k5 k# O* f& T8 D' M
用“zpool status”查看健康状态 |
|