|
楼主 |
发表于 2008-7-31 08:45:57
|
显示全部楼层
用ZFS存储池管理设备
% |. P2 v( m/ }- F% x( w 1、增加设备到存储池
3 F+ m* j! {* X1 J! A0 H 用户可以通过增加一个新的顶级虚拟设备的方法动态给存储池增加空间,这个空间立即对空间中的所有数据集(dataset)有效。要增加一个虚拟设备到池中,用“zpool add”命令,例如:% |0 F. i/ S# a5 Z" a) o0 [ z& F
# zpool add zeepool mirror c2t1d0 c2t2d0
: b" u( Q s! D8 P 该命令也可以用 -n选项进行预览,例如:
9 q2 Z/ Q. i! b) Q4 |3 _3 w # zpool add -n zeepool mirror c3t1d0 c3t2d0
0 C/ g0 w! d3 N would update ’zeepool’ to the following configuration: x6 ?6 r; K/ x' H8 w
zeepool1 \" t0 K( V1 q9 {7 H
mirror
) o! v3 ~' P% X c1t0d0
* \, N' p6 ?; T* B c1t1d0% E) t, J2 H" V4 [
mirror
; N) n @! [$ P' b c2t1d0
! V' h1 Z/ O9 n) A c2t2d0
) y- M2 M6 Q4 D4 g% s mirror, u% K, K% U+ [
c3t1d00 U, F$ {/ i0 x
c3t2d0$ X9 m9 ~% ~6 ~$ u7 w' A
! U, l n. K. D& W 2、增加和减少一路镜像* g% n3 I+ ?( Y! E1 {4 J
用“zpool attach”命令增加一路镜像,例如:4 r$ h# J/ K( q" P2 } I: b% i
# zpool attach zeepool c1t1d0 c2t1d0
& R5 p7 C6 V4 K 在这个例子中,假设 zeepool 是第一点里的那个zeepool(已经是两路镜像),那么这个命令将把zeepool升级成三路镜像。
+ |7 S9 q: ?, L 用“zpool detach”命令来分离一路镜像
- U) q' Y$ m6 N* G" D4 J # zpool detach zeepool c2t1d0 6 r( d, A( u. v6 `5 J& K0 q) c
如果池中不存在镜像,这个才操作将被拒绝。错误提示如下边这个例子:! q5 B! E" _0 e6 l
# zpool detach newpool c1t2d0 cannot detach c1t2d0: onlyapplicable to mirror and replacing vdevs: O3 `/ {) _! D9 o7 j6 B
' j) |) N# K4 h( T+ ^+ G
3、管理设备的“上线”和“下线”
5 u B4 `7 a2 m, C( e7 ~ ZFS允许个别的设备处于offline或者online状态。当硬件不可靠或者还没有完全不能用的时候,ZFS会继续向设备读写数据,但不过是临时这么做,因为设备还能将就使用。一旦设备不能使用,就要指示ZFS忽略该设备,并让这个坏掉的设备下线。ZFS不会向offline的设备发送任何请求。
4 L& ~- Q4 f/ K& I# V4 j5 m 注意:如果只是为了更换设备(被换设备并没有出问题),不需要把他们offline。如果offline设备,然后换了一个新设备上去,再把新设备online,这么做会出错!
# a' s- z- t2 V( ^ 用“zpool offline”命令让设备下线。例如:
7 h; J2 ~# w6 v$ S. g: ~ # zpool offline tank c1t0d0! S A. O/ V2 G
bringing device c1t0d0 offline, y. Q5 J& T" m2 P9 b; F
下边这句话没怎么看懂:2 f- j0 z Y0 W
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.# D9 ^1 h8 z9 ~! M# @
# zpool offline tank c1t0d0
c+ m# z+ z* F& M, b% Z0 H cannot offline c1t0d0: no valid replicas& R" Q$ U# W4 v1 N
默认情况下,offline设备将永久保持offline状态,直到系统重新启动。
% G3 m1 [: j; C! E# B 要临时offline一个设备,用-t选项,例如:5 h$ J2 r9 F' y* i, @ _2 [- Y1 \
# zpool offline -t tank c1t0d0
2 C0 |& T$ X& ]6 E bringing device ’c1t0d0’ offline- m% w0 I6 M$ [$ P: x
用“zpool onine”命令使设备上线$ a' D7 S) B& K: `( W, m+ l/ O/ ~9 i& _
# zpool online tank c1t0d0+ _2 M* ^0 u* k
bringing device c1t0d0 online
1 m1 U+ M9 P7 H) o/ x. ]; T 注意:如果只是为了更换设备(被换设备并没有出问题),不需要把他们offline。如果offline设备,然后换了一个新设备上去,再把新设备online,这么做会出错!在这个问题上文档是这么说的:(但愿我没理解错)
/ e1 {1 C. c- Y* D Note that you cannot use device onlining to replace a disk. If you offline a0 q' Y" K' T) E" d" Z% f2 a
device, replace the drive, and try to bring it online, it remains in the faulted state.+ G1 w( X; G" u/ r' Z4 s- o3 D7 D
3 E2 O% z9 n! R! A# ^! g/ E2 k* G: V
4、清扫存储池设备
) g7 u! Z) f; S* H 如果设备因为出现错误,被offline了,可以用“zpool clear”命令清扫错误。! n& l' P3 n7 P- j2 v
如果没有特别指定,zpool clear命令清扫池里所有设备。例如:
' h/ e( R g: C& [$ \/ k* e- U' O1 p # zpool clear tank: E3 x; N! t X0 c# W/ \- Y
如果要清扫指定设备,例如:! s6 P# h0 R. c1 t, b
# zpool clear tank c1t0d0: T# i$ q0 `6 b1 ?/ Q
0 P/ C4 h3 g0 ~- Z
5、替换存储池里的设备 ^$ Q7 [* H7 A* L# {. ~; R4 C, w
用“zpool replace”命令替换池中设备,例如:
1 R( ~8 ^0 q) S1 l0 T9 t+ T$ H # zpool replace tank c1t1d0 c1t2d0" R7 D: }# f: s# Y' U; w2 w
c1t1d0 被 c1t2d0 替换
! @" R6 {* A6 b7 d 注意:如果是mirror或者RAID-Z,替换设备的容量必须大于或等于所有设备最小容量!. \& j4 z: U$ g$ H5 V
! p: O: y! ^; v9 ?查询ZFS存储池的状态( Z, E$ l: g$ U9 y3 y2 a0 H
1、ZFS存储池的基本信息1 K" s5 T* @5 G; j1 k |
用“zpool list”命令查看存储池的基本信息,例如:
7 n8 J" D+ C; x# {9 }6 ^ # zpool list) }; @3 ^: S& E. x9 Y1 C/ F! x
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
! B* x7 Y# U* v H1 t5 \ tank 80.0G 22.3G 47.7G 28% ONLINE -* l* x* X# }% b9 O8 r
dozer 1.2T 384G 816G 32% ONLINE -& U4 j4 i4 Z' \! X
NAME: The name of the pool.; a9 S" F6 c3 q) P+ O
SIZE: The total size of the pool, equal to the sum of the size of all top-level virtual
. v( F; E% F; U+ odevices.$ T9 a9 W! L+ p# J' e& M* g
USED: The amount of space allocated by all datasets and internal metadata. Note that
2 C* |0 R& ]: X3 v. z# `0 Vthis amount is different from the amount of space as reported at the file system level.
7 j* X9 u' o6 m AVAILABLE: The amount of unallocated space in the pool.
/ c. l* g+ x* Y CAPACITY (CAP): The amount of space used, expressed as a percentage of total space.
- l0 S2 @6 Z+ s: x' { `) d. | HEALTH: The current health status of the pool.
# c4 \6 \9 o/ W; ]. d) j% J' u ALTROOT: The alternate root of the pool, if any.
& m& s; y+ j! m" I* \ 可以通过指定名字来查看某一个池的状态,例如:
/ c( Q! K5 y1 x; W# @" x # zpool list tank' F# E) o% S" A5 w
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
' G4 N' L3 P$ z+ F tank 80.0G 22.3G 47.7G 28% ONLINE -( V- s2 ~. ?0 J9 o
! n n/ I: z- [. i
如果要有选择看状态列表,可以用-o选项
, q1 F3 s- q# r$ J # zpool list -o name,size
9 C( u$ t0 @+ V0 G NAME SIZE ' a; r0 I; v0 G5 E, M
tank 80.0G
& j4 q- Q% o) V; R, p dozer 1.2T$ D- m# x! P5 ]7 t5 q
' O" j; B" u. m Scripting ZFS Storage Pool Output
( C* ^* T0 ^8 g# Y: d" f 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:
1 w7 z+ b3 f" u5 I [- m. g 上边这段话简单说就是为了方便编程,用-H选项,这样输出列表的域之间用tab相隔,而不是空格。
1 c1 h* O7 ~3 H # zpool list -Ho name' x$ J4 }; _4 X: Y/ i! |6 N
tank# |/ q5 ^: W9 k! V/ g& Q
dozer8 F1 z o [# b8 F3 l
Here is another example:
# [' @# @) z2 U7 ^0 J # zpool list -H -o name,size
3 h1 Q, v" E$ b9 @& i l; R7 i; w tank 80.0G$ X1 M! q% n5 z( Y
dozer 1.2T
# h" g! G' d8 h; t$ F0 r# u3 h& X" E" L4 f2 S, e. S
2、查看存储池的I/O状态6 X- a) X) \8 l/ z" K- }* Q
用“zpool iostat”命令查看存储池的I/O状态,例如:' S& x( w5 N% B! Q* ^7 ~5 ~; w
# zpool iostat( _ S* n% }! E
capacity operations bandwidth
3 c3 k7 T4 L0 w: U; ]( ~ pool used avail read write read write7 ]) Y1 T5 j% m" `+ H
---------- ----- ----- ----- ----- ----- -----' T3 Y; B+ Z, |' U+ T0 {
tank 100G 20.0G 1.2M 102K 1.2M 3.45K( e9 ?! Z: o/ o% ?! R; V- `5 _" l
dozer 12.3G 67.7G 132K 15.2K 32.1K 1.20K
- C" U/ ~3 b* Q/ c/ N/ R
9 N& H9 v( q6 Y1 J* i" ^ 3、ZFS存储池的健康状态* T! b& U4 I7 A: N& C
用“zpool status”查看健康状态 |
|