一.什么是MFS文件系统:
MooseFS是一个具有容错性的网络分布式文件系统。它把数据分散存放在多个物理服务器上,而呈现给用户的则是一个统一的资源。
二.MFS文件系统的配置:
1.在server1安装master和web图形界面
[root@server1 3.0.103]# yum install -y moosefs-cgi-3.0.103-1.rhsystemd.x86_64.rpm moosefs-cgiserv-3.0.103-1.rhsystemd.x86_64.rpm moosefs-master-3.0.103-1.rhsystemd.x86_64.rpm
2.打开服务并查看端口
[root@server1 ~]# systemctl start moosefs-master
[root@server1 mfs]# netstat -antlp
9419 metalogger 监听的端口地址(默认是9419),和源数据日志结合。定期和master端同步数据
9420 用于chunkserver 连接的端口地址(默认是9420),通信节点
9421 用于客户端对外连接的端口地址(默认是9421)
3. 打开图形处理工具
[root@server1 ~]# systemctl start moosefs-cgiserv
[root@server1 ~]# netstat -antlp
4.浏览器访问 http://172.25.70.1:9425
5.在sevrer2和server3中配置从属节点
1.安装MFS的客户端软件
[root@server2 3.0.103]# rpm -ivh moosefs-chunkserver-3.0.103-1.rhsystemd.x86_64.rpm
[root@server3 3.0.103]# rpm -ivh moosefs-chunkserver-3.0.103-1.rhsystemd.x86_64.rpm
2.编辑客户端的配置文件
[root@server2 ~]# vim /etc/mfs/mfshdd.cfg
最后一行添加: /mnt/westos #存储位置
[root@server3 ~]# vim /etc/mfs/mfshdd.cfg
/mnt/westos1
3.建立该目录,修改该挂载目录的所有人和所有组,这样才可以在目录中进行读写操作
[root@server2 ~]# mkdir /mnt/westos
[root@server2 ~]# chown mfs.mfs /mnt/westos/
[root@server3 ~]# mkdir /mnt/westos1
[root@server3 ~]# chown mfs.mfs /mnt/westos1/
4.开启服务
[root@server2 mfs]# systemctl start moosefs-chunkserver
[root@server3 mfs]# systemctl start moosefs-chunkserver
5.搭建客户端(真机)
1.安装客户端
[root@foundation70 3.0.103]# yum install -y moosefs-client-3.0.103-1.rhsystemd.x86_64.rpm
2.创建在真机挂载数据的目录并编辑配置文件
[root@foundation70 ~]# mkdir /mnt/mfs
[root@foundation70 3.0.103]# vim /etc/mfs/mfsmount.cfg
/mnt/mfs
[root@foundation70 3.0.103]# mfsmount ##客户端挂载文件系统
mfsmaster accepted connection with parameters: read-write,restricted_ip,admin ; root mapped to root:root
3.在挂载的目录下新建两个目录,并查看数据存储服务器
[root@foundation70 ~]# cd /mnt/mfs
[root@foundation70 mfs]# mkdir dir1
[root@foundation70 mfs]# mkdir dir2
[root@foundation70 mfs]# mfsgetgoal dir1/
dir1/: 2
[root@foundation70 mfs]# mfsgetgoal dir2/
dir2/: 2
4.修改dir1的文件备份份数为1(为了做实验对比)
[root@foundation70 mfs]# mfssetgoal -r 1 dir1/
dir1/:
inodes with goal changed: 1
inodes with goal not changed: 0
inodes with permission denied: 0
[root@foundation70 mfs]# mfsgetgoal dir1/
dir1/: 1
5.将文件存储到/mnt/mfs/dir中,并查看文件信息
[root@foundation70 mfs]# cp /etc/passwd dir1/
[root@foundation70 mfs]# cp /etc/fstab dir2/
[root@foundation70 mfs]# cd dir1/
[root@foundation70 dir1]# mfsfileinfo passwd
passwd:
westos 0: 0000000000000001_00000001 / (id:1 ver:1)
copy 1: 172.25.70.3:9422 (status:VALID)
[root@foundation70 dir1]# cd ..
[root@foundation70 mfs]# cd dir2
[root@foundation70 dir2]# mfsfileinfo fstab
fstab:
westos 0: 0000000000000002_00000001 / (id:2 ver:1)
copy 1: 172.25.70.2:9422 (status:VALID)
copy 2: 172.25.70.3:9422 (status:VALID)
7.存储passwd的westosserver(server3)关掉
[root@server3 3.0.103]# systemctl stop moosefs-chunkserver
[root@foundation70 dir2]# cd ..
[root@foundation70 mfs]# cd dir1/
[root@foundation70 dir1]# mfsfileinfo passwd
passwd:
westos 0: 0000000000000001_00000001 / (id:1 ver:1)
no valid copies !!!
[root@foundation70 dir2]# mfsfileinfo fstab
fstab:
westos 0: 0000000000000002_00000001 / (id:2 ver:1)
copy 1: 172.25.70.2:9422 (status:VALID)
[root@server3 3.0.103]# systemctl start moosefs-chunkserver
8.离散存储
[root@foundation70 dir1]# dd if=/dev/zero of=bigfile bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 0.532317 s, 134 MB/s
[root@foundation70 dir1]# mfsfileinfo bigfile
bigfile:
westos 0: 0000000000000003_00000001 / (id:3 ver:1)
copy 1: 172.25.14.2:9422 (status:VALID)
westos 1: 0000000000000004_00000001 / (id:4 ver:1)
copy 1: 172.25.14.3:9422 (status:VALID)
[root@foundation70 dir1]# cd ../dir2/
[root@foundation70 dir2]# dd if=/dev/zero of=bigfile bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 0.568865 s, 157 MB/s
[root@foundation70 dir2]# mfsfileinfo bigfile
bigfile:
westos 0: 0000000000000005_00000001 / (id:5 ver:1)
copy 1: 172.25.70.2:9422 (status:VALID)
copy 2: 172.25.70.3:9422 (status:VALID)
westos 1: 0000000000000006_00000001 / (id:6 ver:1)
copy 1: 172.25.70.2:9422 (status:VALID)
copy 2: 172.25.70.3:9422 (status:VALID)
数据恢复
- 删除passwd
[root@foundation70 dir1]# ls bigfile passwd [root@foundation70 dir1]# rm -fr passwd 文件删除后存放在 “ 垃圾箱 ” 中的时间称为隔离时间, 这个时间可以用 mfsgettrashtime 命令来查看,用 mfssettrashtime 命令来设置,单位为秒,默认为 86400 秒 [root@foundation70 dir1]# mfsgettrashtime . .: 86400
2.恢复
-
[root@foundation70 ~]# mkdir /mnt/mfsmeta [root@foundation70 ~]# mfsmount -m /mnt/mfsmeta mfsmaster accepted connection with parameters: read-write,restricted_ip [root@foundation70 ~]# cd /mnt/mfsmeta/ [root@foundation70 mfsmeta]# ls sustained trash [root@foundation70 mfsmeta]# cd trash/ #进入trash,该目录下有很多文件 [root@foundation70 trash]# find -name *passwd* #查找要恢复的文件 ./004/00000004|dir1|passwd [root@foundation70 trash]# mv ./004/00000004\|dir1\|passwd undel/ ##注意要加反斜线 [root@foundation70 trash]# cd /mnt/mfs/dir1 [root@foundation70 dir1]# ls file1 passwd #查看删除的文件被找回来了
来源:CSDN
作者:yingwuzhe1107
链接:https://blog.csdn.net/yingwuzhe1107/article/details/103639851