|

楼主 |
发表于 2008-7-31 08:45:57
|
显示全部楼层
用ZFS存储池管理设备2 E j$ E1 c( N ]- d
1、增加设备到存储池
- H. ^) l: i$ C3 X6 I 用户可以通过增加一个新的顶级虚拟设备的方法动态给存储池增加空间,这个空间立即对空间中的所有数据集(dataset)有效。要增加一个虚拟设备到池中,用“zpool add”命令,例如:
; [- [: ?6 K) {, K # zpool add zeepool mirror c2t1d0 c2t2d03 N. w: Y0 }8 q
该命令也可以用 -n选项进行预览,例如:
& K3 `! U* `1 V% Z # zpool add -n zeepool mirror c3t1d0 c3t2d0
) _$ b# G, A4 D4 d; U5 X% D would update ’zeepool’ to the following configuration: K: y3 i4 [3 b' d4 W& S* O" O! N
zeepool& y: k2 ]2 [: f$ s, M
mirror' ~2 w, Y% m' {8 p/ Y! e
c1t0d0 s2 E* G: }* u) s/ h+ u
c1t1d0, g% B/ ]: @, I: F0 {
mirror
& ?1 _ ?5 G, g2 Z c2t1d01 G$ n! o& z5 }2 Y) z" N
c2t2d0
( q) M5 c6 t }7 U! V7 S mirror7 Z6 m/ [4 M- \3 \& s- L" t& ~# l- ]3 l
c3t1d0
; p& D5 D9 y$ E2 @8 S c3t2d0
+ s2 m q# s' c4 i) M
' C. h! j9 c: e0 F 2、增加和减少一路镜像4 E; x8 H' e4 N. [( Q2 X9 ~9 `( T
用“zpool attach”命令增加一路镜像,例如:
, u$ o* ?5 Y4 V3 m# c # zpool attach zeepool c1t1d0 c2t1d08 G; W2 Q3 ~4 e9 h# w3 T5 q. e
在这个例子中,假设 zeepool 是第一点里的那个zeepool(已经是两路镜像),那么这个命令将把zeepool升级成三路镜像。2 j9 {' K: ]% h4 Z
用“zpool detach”命令来分离一路镜像+ u3 S& i t3 l
# zpool detach zeepool c2t1d0 " w* R1 a3 i: J) c* S
如果池中不存在镜像,这个才操作将被拒绝。错误提示如下边这个例子:7 p+ Q& K, N! y, i- r. h( \
# zpool detach newpool c1t2d0 cannot detach c1t2d0: onlyapplicable to mirror and replacing vdevs3 ?% V2 ^3 m) o
& T9 b2 I/ P. J$ F* E9 }
3、管理设备的“上线”和“下线”0 n2 B4 F" C7 o, f+ ^! h4 h
ZFS允许个别的设备处于offline或者online状态。当硬件不可靠或者还没有完全不能用的时候,ZFS会继续向设备读写数据,但不过是临时这么做,因为设备还能将就使用。一旦设备不能使用,就要指示ZFS忽略该设备,并让这个坏掉的设备下线。ZFS不会向offline的设备发送任何请求。
# r8 E. C+ {$ B7 R% r3 [5 f2 A; G 注意:如果只是为了更换设备(被换设备并没有出问题),不需要把他们offline。如果offline设备,然后换了一个新设备上去,再把新设备online,这么做会出错!1 l p% s: I- [) l; e
用“zpool offline”命令让设备下线。例如:
, S3 t' W- R8 E l # zpool offline tank c1t0d0, A7 v& r; a! m8 k. b
bringing device c1t0d0 offline
1 C; c3 T3 P0 y. G1 O1 [ 下边这句话没怎么看懂:* Y4 h6 a4 B5 F# |- m
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., K! m' |1 T8 S- \8 u
# zpool offline tank c1t0d0: W% f: ~* \, e! m
cannot offline c1t0d0: no valid replicas4 I& y4 s" Z+ i- o$ n' i( V9 I
默认情况下,offline设备将永久保持offline状态,直到系统重新启动。
% ~5 j8 L+ n# [3 H 要临时offline一个设备,用-t选项,例如:
& l" U! E* x3 ?6 _% S8 q8 L: m! M # zpool offline -t tank c1t0d0
8 ~! E1 k2 t" { g1 J+ ^4 K( f bringing device ’c1t0d0’ offline0 p6 X. n9 u- R" |& d1 F
用“zpool onine”命令使设备上线
' R0 _- o* f+ P Q, I, C # zpool online tank c1t0d0
4 p- Z, o7 L+ }8 m d* z% v5 c6 z bringing device c1t0d0 online+ a% |9 l# l1 d
注意:如果只是为了更换设备(被换设备并没有出问题),不需要把他们offline。如果offline设备,然后换了一个新设备上去,再把新设备online,这么做会出错!在这个问题上文档是这么说的:(但愿我没理解错)
6 b9 k; L, c8 M& ]$ A Note that you cannot use device onlining to replace a disk. If you offline a
1 w/ s; I- J/ H, `. H7 `1 \device, replace the drive, and try to bring it online, it remains in the faulted state.
r5 s- A* a. h8 F k! } k
! K; [8 p; U* y1 d0 l& a x 4、清扫存储池设备" q/ l4 i7 R! K2 A) u% c$ {! F
如果设备因为出现错误,被offline了,可以用“zpool clear”命令清扫错误。
i, i( l" `1 Q* o) p( s) T8 I5 ^ 如果没有特别指定,zpool clear命令清扫池里所有设备。例如:
8 s* n( m$ O0 G: J' ? # zpool clear tank$ J. F0 a+ p- ? ?
如果要清扫指定设备,例如:
! q2 h" S. e4 j! a& c: P # zpool clear tank c1t0d01 @" L. w' W" v# L! W3 V2 ~5 Z
$ \& b% W: y/ i( s 5、替换存储池里的设备
; P8 z V6 |$ Y 用“zpool replace”命令替换池中设备,例如:
" X, h, p' h/ n& \ # zpool replace tank c1t1d0 c1t2d0! W9 L5 U: l0 ~" t( k
c1t1d0 被 c1t2d0 替换; ?" ]+ t" E7 z$ I# K% H( D
注意:如果是mirror或者RAID-Z,替换设备的容量必须大于或等于所有设备最小容量!+ @" y" w. [4 M, ~5 u
; H; ^% g5 i+ q7 L- H$ t7 L查询ZFS存储池的状态
x) r" e5 \7 M/ z 1、ZFS存储池的基本信息; e; s3 |! @; v& ~+ h
用“zpool list”命令查看存储池的基本信息,例如:
; F" Y8 A6 {2 o3 d( S0 N @ # zpool list, B5 M$ r+ {5 T5 _# Y4 Q4 V# _
NAME SIZE USED AVAIL CAP HEALTH ALTROOT' { E) Z) B+ j( k1 ]/ L4 M, E N% e
tank 80.0G 22.3G 47.7G 28% ONLINE -. n) U1 U- `6 \, v$ I
dozer 1.2T 384G 816G 32% ONLINE -
2 P7 r" A! ?, L, G+ H+ L NAME: The name of the pool.
3 u! Z& {2 K; Z: F8 L, V SIZE: The total size of the pool, equal to the sum of the size of all top-level virtual
; b# m' L3 u2 v9 e" L5 fdevices.
4 p! l9 ]1 S- {7 Z& } USED: The amount of space allocated by all datasets and internal metadata. Note that) m. l3 j! a+ P
this amount is different from the amount of space as reported at the file system level.
y& u4 ?2 x/ V- ^, e. i( D AVAILABLE: The amount of unallocated space in the pool.
/ Q7 W2 {, ` y. ~1 A CAPACITY (CAP): The amount of space used, expressed as a percentage of total space.
% |* N8 k; F" O J% ^- ~- I6 @8 V HEALTH: The current health status of the pool.
4 s4 }. C. B* E5 o* g) v4 Q! A; Z h ALTROOT: The alternate root of the pool, if any.
- u; U0 y- R8 z+ q/ t: D! ~# N 可以通过指定名字来查看某一个池的状态,例如:
0 h! ]% F, q# j2 B! }" q, X* h- P # zpool list tank6 W: y" R% I4 v d, U
NAME SIZE USED AVAIL CAP HEALTH ALTROOT: j* z/ |& ~/ |6 q7 ^0 a! {
tank 80.0G 22.3G 47.7G 28% ONLINE -5 C, r* [/ j6 ?, m1 X
+ B: I- a, I) ?/ Q
如果要有选择看状态列表,可以用-o选项* K; N8 Q4 N( P, ?4 b8 p. X6 p9 m
# zpool list -o name,size
" |2 q8 z3 y3 j5 P& v% z NAME SIZE . }! Z9 w# k; |3 V0 M
tank 80.0G/ d* P+ d& J' j& D |) p& s6 n
dozer 1.2T, Q4 ?9 b8 d4 @& o. l/ W/ u' h) T
% u( I4 w' ~, c0 N
Scripting ZFS Storage Pool Output
; R% Q, Q F" }) D 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:
6 }; p2 ?) I5 P 上边这段话简单说就是为了方便编程,用-H选项,这样输出列表的域之间用tab相隔,而不是空格。
) o1 I. O, a$ y! B/ M4 _ # zpool list -Ho name
, [. b' ?) P1 V) [ tank) a+ S4 ?7 w# M0 \) W
dozer8 x8 T9 w5 l# C8 y$ v: M# `
Here is another example:5 s' m+ K% e R2 r
# zpool list -H -o name,size
2 e. d$ U, a' r4 R6 N tank 80.0G
6 N6 k9 y( ?& c0 m3 B dozer 1.2T, B7 ~$ M! D$ u& S
9 J: q/ q+ \5 U4 @+ g, } 2、查看存储池的I/O状态; x8 m Y( \0 ? U9 I
用“zpool iostat”命令查看存储池的I/O状态,例如:: n. X1 |. U( Y; V' o+ i+ d) M5 R
# zpool iostat
2 A- G& I# x, N( v! x$ Y6 I8 o; w4 x capacity operations bandwidth
$ f9 _% z9 K/ U6 C2 |+ b! l pool used avail read write read write+ e0 c& j' |+ h8 E
---------- ----- ----- ----- ----- ----- -----
+ a! `+ _! ]0 N. T4 u) w) O tank 100G 20.0G 1.2M 102K 1.2M 3.45K
/ [+ ]) g, w; N' m Y9 a0 ] dozer 12.3G 67.7G 132K 15.2K 32.1K 1.20K+ y# f5 |% {( d$ Y) q: ~1 C2 C! @
- x+ T& U9 ]3 @) D 3、ZFS存储池的健康状态. h) C* T% m! o1 h% e8 P+ a3 j# @
用“zpool status”查看健康状态 |
|