唯*的遗憾是没有进内核,只能在用户态运行。
在gcc4.2.2 下编译zfs-fuse,在dmu.c的433行或者450行会有个错误: warning: passing argument 6 of 'dmu_buf_hold_array' discards qualifiers from pointer target type中
这时,只要将gcc的编译参数由-O2改成-O1就行了。
这里有个zfs手册 下载
1.安装:
apt-get install devscripts build-essential zlib1g-dev libfuse-dev scons debhelper fakeroot0.4.0~beta2在svn上下载
dget http://www.fushizen.net/zfs-fuse/zfs-fuse_0.4.0~beta1.hg20070509.2-1.dsc
dpkg-source -x zfs-fuse_0.4.0~beta1.hg20070509.2-1.dsc
cd zfs-fuse-0.4.0~beta1.hg20070509
dpkg-buildpackage -rfakeroot -us -uc -b
sudo dpkg -i ../zfs-fuse_0.4.0~beta1.*.deb
hg clone http://www.wizy.org/mercurial/zfs-fuse/trunk
hg命令在这个包里:mercurial
aptitude install mercurial
2.nfs发布:
zfs命令里面的share命令 是用来设置nfs共享的,
它通过调用sun的unix的nfs共享命令:share来实现,
在linux下没有这个命令,也就无法通过zfs share tank来发布nfs服务。
在linux下还有*个不同的地方是内核中带的fuse模块不支持nfs,需要另外编译安装fuse模块
这在debian下用module-assistant 命令来编译并安装fuse内核模块。
使用新的内核模块,并且在/etc/exports的相应的导出行加个参数 fsid=nnn 如下:
/home/bak 10.0.0.1(rw,no_root_squash,subtree_check,fsid=123)
3.每日快照,压缩,备份:
在测试服务器上用zfs管理*个5个硬盘组成的阵列, 对主域服务器的 768G的进行rsync备份。
用zfs的压缩功能,第*次同步需要18小时, 以后每日的扫描只要1小时就可以完成。
700G左右的数据在zfs上只用了311G, 在rsync之前, 对zfs做*个快照,作为昨天的日备份
rsync*后的报告:
sent 1624462 bytes received 223872021 bytes 39158.89 bytes/sec
total size is 750267563615 speedup is 3327.18
zfs list:
files2:/home/liushiwei# zfs list
NAME USED AVAIL REFER MOUNTPOINT
tank 319G 87.1G 26.9K /tank
tank/bak 313G 84.8G 308G /home/bak
tank/bak@20071207 4.35G - 310G -
tank/bak@20071209 4.13M - 306G -
tank/bak@20071210 386M - 307G -
tank/home 4.69G 87.1G 4.69G /home
tank/mysql 1.50G 87.1G 1.50G /mysql
tank/mysql@20071207 132K - 1.50G -
脚本:
#!/bin/bash
zfs snapshot tank/bak@`date +%Y%m%d -d -1day`
rsync -Hv8rtopg --timeout=7200 --max-size=40m --exclude *.avi --exclude mysql/* rsync://bak@10.0.0.1:/root/home /home/bak/ --password-file=/etc/rsync_bak.pass
后记:
2008-08-06 计算机突然断电, 启动后,所有的pool丢失:
#zpool status
no pools available
用 import修复,提示如下错误
# zpool import
pool: tank
id: 3148487495623594969
state: ONLINE
status: The pool was last accessed by another system.
action: The pool can be imported using its name or numeric identifier and
the '-f' flag.
see: http://www.sun.com/msg/ZFS-8000-EY
config:
tank ONLINE
raidz1 ONLINE
sda6 ONLINE
sdb6 ONLINE
sdc6 ONLINE
sdd6 ONLINE
意思是pool被其他的系统修改过, 不能完成imported
用 -f参数强制imported,加载成功.
#zpool import -f -a
2008-11-11
更換主板,硬盘盘符变化,以及其他的问题,造成zfs不能加载,现象如下:
files2:/# zpool status
pool: tank
state: UNAVAIL
status: One or more devices could not be used because the label is missing
or invalid. There are insufficient replicas for the pool to continue
functioning.
action: Destroy and re-create the pool from a backup source.
see: http://www.sun.com/msg/ZFS-8000-5E
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
tank UNAVAIL 0 0 0 insufficient replicas
raidz1 UNAVAIL 0 0 0 insufficient replicas
sda6 FAULTED 0 0 0 corrupted data
sdb6 FAULTED 0 0 0 corrupted data
sdc6 ONLINE 0 0 0
hda6 ONLINE 0 0 0
用 zpool online 不能奏效,
*用 zpool destroy tank 命令将卷销毁,
然后用zpool import -f tank 把卷重新建立, 加载成功!
替换硬盘
尽量用原来的接口,接上新硬盘,
比如 /dev/sdb6 被更换. 执行如下命令:
zpool replace tank sdb6 sdb6
1个1T的硬盘, 大约25小时完成, 进度可以通过zpool status 看到.
zpool status -v 可以看到出错的文件的列表
在删除掉很多不必要的快照之后, resilver 速度加快了很多
更换过程的status:
bak:~# zpool status
pool: tank
state: DEGRADED
status: One or more devices has experienced an error resulting in data
corruption. Applications may be affected.
action: Restore the file in question if possible. Otherwise restore the
entire pool from backup.
see: http://www.sun.com/msg/ZFS-8000-8A
scrub: resilver in progress for 2h7m, 5.43% done, 37h1m to go
config:
NAME STATE READ WRITE CKSUM
tank DEGRADED 0 0 206
raidz1 DEGRADED 0 0 653
sdc6 ONLINE 0 0 0 297K resilvered
sda6 ONLINE 0 0 2 8.36M resilvered
sdd6 ONLINE 0 0 0 288K resilvered
replacing DEGRADED 0 0 613K
sdb6/old UNAVAIL 0 0 0 cannot open
sdb6 ONLINE 0 0 0 33.3G resilvered
errors: 14446 data errors, use '-v' for a list
#!/bin/bash
zfs snapshot tank/bak@`date +%Y%m%d -d -1day`
rsync -Hv8rtopg --timeout=7200 --max-size=40m --exclude *.avi --exclude mysql/* rsync://bak@10.0.0.1:/root/home /home/bak/ --password-file=/etc/rsync_bak.pass
后记:
2008-08-06 计算机突然断电, 启动后,所有的pool丢失:
#zpool status
no pools available
用 import修复,提示如下错误
# zpool import
pool: tank
id: 3148487495623594969
state: ONLINE
status: The pool was last accessed by another system.
action: The pool can be imported using its name or numeric identifier and
the '-f' flag.
see: http://www.sun.com/msg/ZFS-8000-EY
config:
tank ONLINE
raidz1 ONLINE
sda6 ONLINE
sdb6 ONLINE
sdc6 ONLINE
sdd6 ONLINE
意思是pool被其他的系统修改过, 不能完成imported
用 -f参数强制imported,加载成功.
#zpool import -f -a
2008-11-11
更換主板,硬盘盘符变化,以及其他的问题,造成zfs不能加载,现象如下:
files2:/# zpool status
pool: tank
state: UNAVAIL
status: One or more devices could not be used because the label is missing
or invalid. There are insufficient replicas for the pool to continue
functioning.
action: Destroy and re-create the pool from a backup source.
see: http://www.sun.com/msg/ZFS-8000-5E
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
tank UNAVAIL 0 0 0 insufficient replicas
raidz1 UNAVAIL 0 0 0 insufficient replicas
sda6 FAULTED 0 0 0 corrupted data
sdb6 FAULTED 0 0 0 corrupted data
sdc6 ONLINE 0 0 0
hda6 ONLINE 0 0 0
用 zpool online 不能奏效,
*用 zpool destroy tank 命令将卷销毁,
然后用zpool import -f tank 把卷重新建立, 加载成功!
替换硬盘
尽量用原来的接口,接上新硬盘,
比如 /dev/sdb6 被更换. 执行如下命令:
zpool replace tank sdb6 sdb6
1个1T的硬盘, 大约25小时完成, 进度可以通过zpool status 看到.
zpool status -v 可以看到出错的文件的列表
在删除掉很多不必要的快照之后, resilver 速度加快了很多
更换过程的status:
bak:~# zpool status
pool: tank
state: DEGRADED
status: One or more devices has experienced an error resulting in data
corruption. Applications may be affected.
action: Restore the file in question if possible. Otherwise restore the
entire pool from backup.
see: http://www.sun.com/msg/ZFS-8000-8A
scrub: resilver in progress for 2h7m, 5.43% done, 37h1m to go
config:
NAME STATE READ WRITE CKSUM
tank DEGRADED 0 0 206
raidz1 DEGRADED 0 0 653
sdc6 ONLINE 0 0 0 297K resilvered
sda6 ONLINE 0 0 2 8.36M resilvered
sdd6 ONLINE 0 0 0 288K resilvered
replacing DEGRADED 0 0 613K
sdb6/old UNAVAIL 0 0 0 cannot open
sdb6 ONLINE 0 0 0 33.3G resilvered
errors: 14446 data errors, use '-v' for a list