安装篇请看:mfs分布式文件系统-(安装篇)

配置篇请看:mfs分布式文件系统-(配置篇)
mfs测试,接上文

一.删除,回收站测试

1.设置删除文件后空间回收时间
默认回收时间为1天,86400秒

[root@mfsclient data]# mfssettrashtime 86400 /data/mfs
/data/mfs: 86400

查看设置

[root@mfsclient data]# mfsgettrashtime /data/mfs
/data/mfs: 86400

2.trash
删除的文件可以通过trash找回,安装mfsclient后,可以通过 -m 参数来挂载mfsmeta文件系统来查看trash

[root@mfsclient /]# mfsmount /data/mfs -m -H mfsmaster
mfsmaster accepted connection with parameters: read-write,restricted_ip
[root@mfsclient /]# cd /data/mfs
[root@mfsclient mfs]# ls
sustained  trash

所有在mfs中被删除的文件都会在trash中,所以要找回时,使用-m参数挂载即可
sustained 是正在被读取的文件,等读取结束后会被删除到trash中
测试trash

[root@mfsclient mfs]# touch insoz.com/index.html
[root@mfsclient mfs]# ls
insoz.com
[root@mfsclient mfs]# rm -rf insoz.com
trash中
[root@mfstrash trash]# ls
00000028|insoz.com  0000002B|insoz.com|index.html  undel
[root@mfstrash trash]#

文件名由一个八位十六进制的数i-node和被删文件的文件名组成,在文件名和i-node之间用|隔开
将这些文件移动到undel目录下,将会恢复原始文件到正确的MooseFS文件系统的路径下

mv 00000030\|insoz.com\|index.html undel/

二.破坏性测试

1.把环境中的数据存储服务器依次停止,剩下一个,整个mfs还能继续提供服务。
然后上传一个文件,把文件副本更改为3,接着依次启动刚被关闭的另外两台数据存储服务器,再关闭刚才没有关闭的那台数据存储服务器,最后验证最后上传的那个文件是否可以正常访问,如果可以,证明文件被同步到多台数据存储服务器了。

三.元数据服务器测试

1.模拟元数据服务器进程被意外结束,执行回复操作
停止元数据服务器
[root@mfsmaster trash]# ps -ef|grep mfsmaster
root 21269 5485 0 13:48 pts/4 00:00:00 grep mfsmaster
mfs 26880 1 0 Jun02 ? 00:10:47 mfsmaster -a
[root@mfsmaster trash]# kill -9 26880
启动元数据服务器

[root@mfsmaster trash]# mfsmaster start
open files limit has been set to: 4096
working directory: /var/lib/mfs
lockfile created and locked
initializing mfsmaster modules ...
exports file has been loaded
topology file has been loaded
loading metadata ...
can't find metadata.mfs - try using option '-a'
init: metadata manager failed !!!
error occured during initialization - exiting

提示初始化数据失败
执行恢复操作

[root@mfsmaster trash]# mfsmaster -a
open files limit has been set to: 4096
working directory: /var/lib/mfs
lockfile created and locked
initializing mfsmaster modules ...
exports file has been loaded
topology file has been loaded
loading metadata ...
loading sessions data ... ok (0.0000)
loading objects (files,directories,etc.) ... ok (0.0354)
loading names ... ok (0.0354)
loading deletion timestamps ... ok (0.0000)
loading quota definitions ... ok (0.0000)
loading xattr data ... ok (0.0000)
loading posix_acl data ... ok (0.0000)
loading open files data ... ok (0.0000)
loading chunkservers data ... ok (0.0000)
loading chunks data ... ok (0.0000)
checking filesystem consistency ... ok
connecting files and chunks ... ok
all inodes: 4
directory inodes: 2
file inodes: 2
chunks: 0
metadata file has been loaded
stats file has been loaded
master < -> metaloggers module: listen on *:9419
master < -> chunkservers module: listen on *:9420
main master server module: listen on *:9421
mfsmaster daemon initialized properly

启动元数据服务器

[root@mfsmaster lib]# mfsmaster start
open files limit has been set to: 4096
working directory: /var/lib/mfs
lockfile created and locked
initializing mfsmaster modules ...
exports file has been loaded
topology file has been loaded
loading metadata ...
loading sessions data ... ok (0.0000)
loading objects (files,directories,etc.) ... ok (0.0354)
loading names ... ok (0.0354)
loading deletion timestamps ... ok (0.0000)
loading quota definitions ... ok (0.0000)
loading xattr data ... ok (0.0000)
loading posix_acl data ... ok (0.0000)
loading open files data ... ok (0.0000)
loading chunkservers data ... ok (0.0000)
loading chunks data ... ok (0.0000)
checking filesystem consistency ... ok
connecting files and chunks ... ok
all inodes: 7
directory inodes: 5
file inodes: 2
chunks: 0
metadata file has been loaded
stats file has been loaded
master < -> metaloggers module: listen on *:9419
master < -> chunkservers module: listen on *:9420
main master server module: listen on *:9421
mfsmaster daemon initialized properly

不出意外客户端会自动恢复挂载信息,并且数据正常
2.模拟进程被意外关闭,并且日志文件被损毁
kill -9 杀掉mfsmaster进程
删除mfs目录,模拟故障,启动元数据服务器,提示初始化数据失败

[root@mfsmaster trash]# mfsmaster start
open files limit has been set to: 4096
working directory: /var/lib/mfs
lockfile created and locked
initializing mfsmaster modules ...
exports file has been loaded
topology file has been loaded
loading metadata ...
can't find metadata.mfs - try using option '-a'
init: metadata manager failed !!!
error occured during initialization - exiting

从元数据日志服务器把备份文件恢复过来
把所有文件名字中的_ml去掉
mv changelog_ml.0.mfs changelog.0.mfs
mv changelog_ml.2.mfs changelog.2.mfs
mv changelog_ml.1.mfs changelog.1.mfs
mv metadata_ml.mfs.back metadata.mfs.back
执行恢复操作

[root@mfsmaster trash]# mfsmaster -a
open files limit has been set to: 4096
working directory: /var/lib/mfs
lockfile created and locked
initializing mfsmaster modules ...
exports file has been loaded
topology file has been loaded
loading metadata ...
loading sessions data ... ok (0.0000)
loading objects (files,directories,etc.) ... ok (0.0354)
loading names ... ok (0.0354)
loading deletion timestamps ... ok (0.0000)
loading quota definitions ... ok (0.0000)
loading xattr data ... ok (0.0000)
loading posix_acl data ... ok (0.0000)
loading open files data ... ok (0.0000)
loading chunkservers data ... ok (0.0000)
loading chunks data ... ok (0.0000)
checking filesystem consistency ... ok
connecting files and chunks ... ok
all inodes: 4
directory inodes: 2
file inodes: 2
chunks: 0
metadata file has been loaded
stats file has been loaded
master < -> metaloggers module: listen on *:9419
master < -> chunkservers module: listen on *:9420
main master server module: listen on *:9421
mfsmaster daemon initialized properly

需要注意的是,metadata.mfs.back 必须与日志文件在一起才能正常恢复
启动元数据服务器

mfsmaster start

客户端挂载,数据正常