|
楼主 |
发表于 2008-7-31 08:45:57
|
显示全部楼层
用ZFS存储池管理设备
3 t6 ?7 G0 f. d/ I+ P 1、增加设备到存储池
; x; ^" a! p0 W) x* G. l& m( B/ N 用户可以通过增加一个新的顶级虚拟设备的方法动态给存储池增加空间,这个空间立即对空间中的所有数据集(dataset)有效。要增加一个虚拟设备到池中,用“zpool add”命令,例如:) J9 ~8 ]3 [6 V9 {$ x
# zpool add zeepool mirror c2t1d0 c2t2d0
) L3 [7 Z- u4 p$ H" L9 R, C 该命令也可以用 -n选项进行预览,例如:
6 G! D( k; ]9 J, U2 Q$ Y0 P # zpool add -n zeepool mirror c3t1d0 c3t2d0 ! Y- J$ q0 v3 | d, K) ^ b
would update ’zeepool’ to the following configuration:
! B' B. p" d2 E4 c7 a' P zeepool
2 V5 f! F+ N, F. F mirror
/ z1 @$ y/ p" L6 a( m c1t0d0; t# w: W. r" y; b
c1t1d0) u: v9 e6 Y0 B% ^. K' W
mirror
; U5 n" K; }/ \' h5 ^ c2t1d0
3 P; Y6 {0 k6 Z3 n& k c2t2d0" c1 Y% {" m1 _6 v% J
mirror
5 W7 ?5 W- p1 P) k5 C: V c3t1d0 _/ B: T) f. y
c3t2d05 ?' e- x7 O* j# X, W
- F9 t- a9 \: J7 X- i* g7 }3 i
2、增加和减少一路镜像
: d. h, @: B# H1 g% D% \) e 用“zpool attach”命令增加一路镜像,例如:
. A! V! p5 Z& i4 R' N # zpool attach zeepool c1t1d0 c2t1d0. ~: G& o+ L& l- f
在这个例子中,假设 zeepool 是第一点里的那个zeepool(已经是两路镜像),那么这个命令将把zeepool升级成三路镜像。, z4 p P4 B) O) d( c$ U- I- Z+ W
用“zpool detach”命令来分离一路镜像) R5 @( M1 F% k8 X8 g
# zpool detach zeepool c2t1d0
2 L$ J7 F2 O6 }# D8 T! @: m 如果池中不存在镜像,这个才操作将被拒绝。错误提示如下边这个例子:3 E: V D0 f' J* T: ] f
# zpool detach newpool c1t2d0 cannot detach c1t2d0: onlyapplicable to mirror and replacing vdevs
# V6 I* g- e4 d! a+ r5 z1 S. u . P* `# o/ g# ], u& H' n
3、管理设备的“上线”和“下线”
1 [7 T, h( r+ [ ZFS允许个别的设备处于offline或者online状态。当硬件不可靠或者还没有完全不能用的时候,ZFS会继续向设备读写数据,但不过是临时这么做,因为设备还能将就使用。一旦设备不能使用,就要指示ZFS忽略该设备,并让这个坏掉的设备下线。ZFS不会向offline的设备发送任何请求。
5 m! j1 n9 ~. a/ u! A 注意:如果只是为了更换设备(被换设备并没有出问题),不需要把他们offline。如果offline设备,然后换了一个新设备上去,再把新设备online,这么做会出错!4 n' o! x* C7 h
用“zpool offline”命令让设备下线。例如:
1 X. q3 j4 T) X2 X, H; ] # zpool offline tank c1t0d03 i+ T& l8 s' s1 o" z
bringing device c1t0d0 offline* g4 Z* E0 o0 |' D; |0 q# e! E3 O
下边这句话没怎么看懂:
4 y" _" Y2 n& t4 x; K, ?8 R# ~ 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.0 U7 ?, P; C' v
# zpool offline tank c1t0d0
9 q# F5 Q v1 o2 Y" K cannot offline c1t0d0: no valid replicas
' E& A- a9 ~1 t; o J/ l 默认情况下,offline设备将永久保持offline状态,直到系统重新启动。
/ d, g' _2 b. }& e 要临时offline一个设备,用-t选项,例如:
3 e, u" S5 e9 D- w2 m* V9 Z: T # zpool offline -t tank c1t0d02 U3 ?1 p1 ?2 G# \% v. j3 @5 W
bringing device ’c1t0d0’ offline
# d5 ]$ A& ]0 j# U& u$ O 用“zpool onine”命令使设备上线
0 b C# w+ V {3 x% M0 p8 E # zpool online tank c1t0d0- A4 a( ]& K% _: Z& n. G
bringing device c1t0d0 online+ `& Q6 R* N0 c# t
注意:如果只是为了更换设备(被换设备并没有出问题),不需要把他们offline。如果offline设备,然后换了一个新设备上去,再把新设备online,这么做会出错!在这个问题上文档是这么说的:(但愿我没理解错)# s, s8 A1 D" G4 F) Z; `+ {
Note that you cannot use device onlining to replace a disk. If you offline a& k/ l( c; L8 D1 u# b. k) [
device, replace the drive, and try to bring it online, it remains in the faulted state. f& J, {. m9 E1 }' _& X8 L
# i! ~$ v7 D" r s5 a5 a 4、清扫存储池设备9 W) d! \8 {. ~
如果设备因为出现错误,被offline了,可以用“zpool clear”命令清扫错误。; R% c& W9 a3 |" L; |' ]! G8 Q
如果没有特别指定,zpool clear命令清扫池里所有设备。例如:8 C- @" X2 X( {% d7 l
# zpool clear tank) [7 l5 y6 Z8 [
如果要清扫指定设备,例如:% I. w V: ^; q8 Y
# zpool clear tank c1t0d0
' ?7 o0 x( v( Y0 u5 h% r9 I- u R8 y% }
5、替换存储池里的设备6 J. k0 G8 y. w2 f; r, W" @
用“zpool replace”命令替换池中设备,例如:
4 x& t, ^; k! P- Y! t # zpool replace tank c1t1d0 c1t2d0
- G& }3 s( N% Y0 F" z% l c1t1d0 被 c1t2d0 替换
b4 @$ X; h9 ~1 L 注意:如果是mirror或者RAID-Z,替换设备的容量必须大于或等于所有设备最小容量!) }. } p9 V# p, H
% d5 Z5 q% ~" [! `查询ZFS存储池的状态
4 C0 N+ R* v; @* [# A: j: @ 1、ZFS存储池的基本信息
( t @9 d0 `3 h& K2 B1 p/ r 用“zpool list”命令查看存储池的基本信息,例如:
' C/ v. Q8 t4 B( n% o+ Y # zpool list
" y, Y7 M/ W+ V3 w, ]9 _ NAME SIZE USED AVAIL CAP HEALTH ALTROOT! F+ B; q* ?% z9 {/ B+ Z2 _
tank 80.0G 22.3G 47.7G 28% ONLINE -
W$ X: d- L0 z* O& q0 d( @ dozer 1.2T 384G 816G 32% ONLINE -
; Y9 M& A* T2 S1 e) d4 ^' h NAME: The name of the pool.) y( E5 V4 ]- [3 |
SIZE: The total size of the pool, equal to the sum of the size of all top-level virtual
! Q# ]8 e: m" O0 R, v1 e3 Ndevices.7 ^1 ^- b) |& ]' @
USED: The amount of space allocated by all datasets and internal metadata. Note that. Y" Z0 x0 [: j5 U# w. O
this amount is different from the amount of space as reported at the file system level.
- n# w% j) @1 r; ? AVAILABLE: The amount of unallocated space in the pool.) }) i+ H/ e! q3 ]. l2 H4 \
CAPACITY (CAP): The amount of space used, expressed as a percentage of total space., H3 X9 _" \$ }
HEALTH: The current health status of the pool.
! J$ \' n& S- e; g ALTROOT: The alternate root of the pool, if any.' |2 K, Q p9 D- z
可以通过指定名字来查看某一个池的状态,例如:
1 H- z9 ]+ m5 r3 b/ v7 [+ V- I1 d; A # zpool list tank
8 q) m* {. w" ]) H$ b# O NAME SIZE USED AVAIL CAP HEALTH ALTROOT9 E' n/ z- i; N; O0 S
tank 80.0G 22.3G 47.7G 28% ONLINE -; L1 `% K9 j' L) u5 I k0 g9 B
* V) |2 W) A \3 Z) p7 ]$ J
如果要有选择看状态列表,可以用-o选项1 O4 _4 f; x1 v! t& T/ ~
# zpool list -o name,size% u: {2 a+ N. y
NAME SIZE
, C' r4 ~. z d9 r3 e tank 80.0G
" d. Y1 ?9 @- f4 E0 c+ w+ Z dozer 1.2T6 m: z* m4 R, Q- @
$ u$ s8 I1 g. w2 k( y Scripting ZFS Storage Pool Output+ _$ S5 T. l) g2 p1 _
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:! h4 s& t: ~4 o! f3 K
上边这段话简单说就是为了方便编程,用-H选项,这样输出列表的域之间用tab相隔,而不是空格。
- p: s, s. N! i" b # zpool list -Ho name% U) {* w: \# R( |
tank* _1 y% u2 C3 j6 p' q/ W; L
dozer
) a8 C3 q& q' E6 F0 B1 ? Here is another example:2 W3 H8 ?! ]; w! b: B. [
# zpool list -H -o name,size6 o2 i* h7 f5 C! Q$ [: _
tank 80.0G
( D1 @4 o% X7 w7 l& s3 i dozer 1.2T
+ K$ \( D X* a, l( {7 ]2 y) n- T3 c0 g3 p J
2、查看存储池的I/O状态
0 ^4 u y4 {; W$ }( ?9 g 用“zpool iostat”命令查看存储池的I/O状态,例如:5 ?! F- `9 D; q! l9 E+ B
# zpool iostat
% ]) J+ S& S) F y capacity operations bandwidth, w: Y: r; Y1 V7 A- ^& U
pool used avail read write read write
4 ^' v! N' k( Y7 W9 K6 B! I2 b7 J ---------- ----- ----- ----- ----- ----- -----
$ C# v, j% H% _2 v2 H. [. w tank 100G 20.0G 1.2M 102K 1.2M 3.45K& M- m+ r6 w" c# ^
dozer 12.3G 67.7G 132K 15.2K 32.1K 1.20K0 N8 d- E* \: q& C
1 I! j# U# F- D) J; h* e 3、ZFS存储池的健康状态! L j @& h( m: n( y
用“zpool status”查看健康状态 |
|