MFS是什么
MFS全称MooseFS,是文件管理系统的抽象层,将用户的数据通过master之后,存储在多个网络存储节点上面,这个过程对于用户来说时透明的,并且MFS具有很强大的网络容错能力;
MFS的特性
MFS的文件系统结构
配置环境
hostname|ip|功能|os
[root@server11 ~]# cd 3.0.100/
[root@server11 3.0.100]# ls
moosefs-cgi-3.0.100-1.rhsystemd.x86_64.rpm
moosefs-cgiserv-3.0.100-1.rhsystemd.x86_64.rpm
moosefs-chunkserver-3.0.100-1.rhsystemd.x86_64.rpm
moosefs-cli-3.0.100-1.rhsystemd.x86_64.rpm
moosefs-client-3.0.100-1.rhsystemd.x86_64.rpm
moosefs-master-3.0.100-1.rhsystemd.x86_64.rpm
moosefs-metalogger-3.0.100-1.rhsystemd.x86_64.rpm
moosefs-netdump-3.0.100-1.rhsystemd.x86_64.rpm
[root@server11 3.0.100]# yum install moosefs-cgi-3.0.100-1.rhsystemd.x86_64.rpm moosefs-cgiserv-3.0.100-1.rhsystemd.x86_64.rpm moosefs-master-3.0.100-1.rhsystemd.x86_64.rpm
[root@server11 3.0.100]# vim /etc/hosts
172.25.254.11 server11 mfsmaster
[root@server11 3.0.100]# systemctl start moosefs-master
[root@server11 3.0.100]# systemctl start moosefs-cgiserv.service
[root@server11 3.0.100]# netstat -antlp | grep 94*
tcp 0 0 0.0.0.0:9419 0.0.0.0:* LISTEN 2308/mfsmaster
tcp 0 0 0.0.0.0:9420 0.0.0.0:* LISTEN 2308/mfsmaster
tcp 0 0 0.0.0.0:9421 0.0.0.0:* LISTEN 2308/mfsmaster
tcp 0 0 0.0.0.0:9425 0.0.0.0:* LISTEN 2355/python
server12和server13想同
[root@server12 ~]# vim /etc/hosts
172.25.254.11 server11 mfsmaster
[root@server12 ~]# yum install -y moosefs-chunkserver-3.0.100-1.rhsystemd.x86_64.rpm
实验中我们将/mnt/mfs/作为chunkserver,使用根空间,实际生产环境下应该创建目录后,将磁盘挂载在该目录下
[root@server12 ~]# mkdir /mnt/chunk1
[root@server12 ~]# chown mfs.mfs /mnt/chunk1/ -R
[root@server13 ~]# mkdir /mnt/chunk2
[root@server13 ~]# chown mfs.mfs /mnt/chunk2/ -R
[root@server13 ~]# vim /etc/mfs/mfshdd.cfg
35
36 /mnt/chunk2
[root@server12 ~]# vim /etc/mfs/mfshdd.cfg
35
36 /mnt/chunk1
[root@server12 ~]# systemctl start moosefs-chunkserver
[root@server13 ~]# systemctl start moosefs-chunkserver
[root@foundation77 3.0.100]# yum install -y moosefs-client-3.0.100-1.rhsystemd.x86_64.rpm
[root@foundation77 mfs]# mkdir /mnt/mfs ##建立挂载目录
[root@foundation77 mfs]# mfsmount ##执行mfsmount命令,可以直接挂载
mfsmaster accepted connection with parameters: read-write,restricted_ip,admin ; root mapped to root:root
[root@foundation77 mfs]# df ##查看
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda9 116584840 29723816 86861024 26% /
devtmpfs 1870976 0 1870976 0% /dev
tmpfs 1885984 528 1885456 1% /dev/shm
tmpfs 1885984 9448 1876536 1% /run
mfsmaster:9421 16748544 2964864 13783680 18% /mnt/mfs
[root@foundation77 mfs]# mkdir dir1 dir2
[root@foundation77 mfs]# mfsgetgoal dir1 ##默认建立的文件,会保存两份,分别在两个chunkserver上
dir1: 2
[root@foundation77 mfs]# mfsgetgoal dir2
dir2: 2
[root@foundation77 mfs]# cp /etc/passwd dir1
[root@foundation77 mfs]# cp /etc/fstab dir2
[root@foundation77 mfs]# mfssetgoal -r 1 dir1 ##设置dir1目录下的文件,只cp一份
dir1:
inodes with goal changed: 2
inodes with goal not changed: 0
inodes with permission denied: 0
[root@foundation77 mfs]# mfsgetgoal dir1
dir1: 1
[root@foundation77 mfs]# mfsfileinfo dir1/passwd ##查看
dir1/passwd:
chunk 0: 0000000000000001_00000001 / (id:1 ver:1)
copy 1: 172.25.254.12:9422 (status:VALID)
[root@foundation77 mfs]# mfsfileinfo dir2/fstab ##查看
dir2/fstab:
chunk 0: 0000000000000002_00000001 / (id:2 ver:1)
copy 1: 172.25.254.12:9422 (status:VALID)
copy 2: 172.25.254.13:9422 (status:VALID)
[root@server12 ~]# systemctl stop moosefs-chunkserver
[root@foundation77 mfs]# mfsfileinfo dir1/passwd ##可以查看到看到有这文件,但是不能查看
dir1/passwd:
chunk 0: 0000000000000001_00000001 / (id:1 ver:1)
no valid copies !!!
[root@server12 ~]# systemctl start moosefs-chunkserver ##重新打开chunkserver后文件恢复正常
[root@foundation77 mfs]# mfsfileinfo dir1/passwd
dir1/passwd:
chunk 0: 0000000000000001_00000001 / (id:1 ver:1)
copy 1: 172.25.254.12:9422 (status:VALID)
[root@foundation77 dir1]# rm -fr passwd
[root@foundation77 dir1]# cd ..
[root@foundation77 mfs]# mkdir /mnt/mfsmeta
[root@foundation77 mfs]# mfsmount -m /mnt/mfsmeta/
mfsmaster accepted connection with parameters: read-write,restricted_ip
[root@foundation77 mfs]# cd /mnt/mfsmeta/trash/
[root@foundation77 trash]# ls
[root@foundation77 trash]# ls -R passwd
00000004\|dir1\|passwd
[root@foundation77 trash]# mv 00000004\|dir1\|passwd undel/
[root@foundation77 trash]# ls /mnt/mfs/dir1
passwd
[root@foundation77 trash]#