MFS分布式文件系统(一) ——MFS简介+部署+使用

分布式文件系统简介

分布式文件系统是指文件系统管理的物理存储资源,不一定在本地节点上,而是通过网络与节点相连。

就是把一些分散的(分布在局域网内各个计算机上)共享文件夹,集合到一个文件夹内(虚拟共享文件夹)。

对于用户来说,要访问这些共享文件夹时,只要打开这个虚拟共享文件夹,就可以看到所有链接到虚拟共享文件夹内的共享文件夹,用户感觉不到这些共享文件是分散在各个计算机上的。

分布式文件系统的好处是集中访问、简化操作、数据容灾,以及提高文件的存取性能。

MFS简介

MooseFS是一个具有容错性的网络分布式文件系统。
它把数据分散存放在多个物理服务器上,而呈现给用户的则是一个统一的资源。

MFS的组成

元数据服务器Master在整个体系中负责管理文件系统,维护元数据。
元数据日志服务器MetaLogger备份Master服务器的变化日志文件,文件类型为changelog_ml.*.mfs。当Master服务器数据丢失或者损坏时,可以从日志服务器中取得文件,进行修复。
数据存储服务器Chunk Server真正存储数据的服务器。存储文件时,会把文件分块保存,在数据服务器之间进行复制。数据服务器越多,能使用的“容量”就越大,可靠性就越高,性能也就越好。
客户端Client可以像挂载NFS一样挂载MFS文件系统,其操作是相同的。

MFS的工作过程

MFS读取数据的处理过程
在这里插入图片描述

#客户端向元数据服务器发出读请求

#元数据服务器把数据存放的位置Chunk Server的IP地址和Chunk编号)告知客户端
(一份大的数据会被分块,存储在不同的数据服务器上)

#客户端向已知的Chunk Server请求发送数据

#Chunk Server向客户端发送数据

在这里插入图片描述
分为create创建和update 修改文件:

#客户端向元数据服务器发送写入请求

#元数据服务器与Chunk Server进行交互(只有当所需的分块Chunks存在的时候才进行交互),

但元数据服务器只在某些服务器创建新的分块Chunks,创建成功后由Chunk Server告知元数据服务器操作成功。

#元数据服务器告知客户端,可以在哪个Chunk Server的哪些Chunks写入数据
(副本数是由master来维护的)


#客户端向指定的Chunk Server写入数据

#该Chunk Server与按照要求和其他Chunk Server进行数据同步,同步成功后Chunk Server告知客户端数据写入成功


#客户端告知元数据服务器本次写入完毕

实验环境:

192.168.122.101 master 结点
192.168.122.1012数据结点1 (Chunk结点)
192.168.122.103 数据结点2
192.168.122.201真机 客户端

在每个节点上

1、添加键值

curl "https://ppa.moosefs.com/RPM-GPG-KEY-MooseFS" > /etc/pki/rpm-gpg/RPM-GPG-KEY-MooseFS

2、添加YUM源

curl "http://ppa.moosefs.com/MooseFS-3-el7.repo" > /etc/yum.repos.d/MooseFS.repo
[root@mfs1 mfs]# curl "https://ppa.moosefs.com/RPM-GPG-KEY-MooseFS" > /etc/pki/rpm-gpg/RPM-GPG-KEY-MooseFS
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1796  100  1796    0     0    392      0  0:00:04  0:00:04 --:--:--   531
[root@mfs1 mfs]# curl "http://ppa.moosefs.com/MooseFS-3-el7.repo" > /etc/yum.repos.d/MooseFS.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   168  100   168    0     0    121      0  0:00:01  0:00:01 --:--:--   121

在这里插入图片描述

master上

3、安装MooseFS组件。

yum install moosefs-master moosefs-cgi moosefs-cgiserv moosefs-cli -y

4、编辑解析文件 /etc/hosts,并发送给其他节点。

5、安装完,可以看到MFS的配置文件 mfsmaster.cfg 和 mfsexports.cfg

mfsexports.cfg:被挂接目录及权限设置

mfsmaster.cfg:主配置文件,凡是用#注释掉的变量均使用其默认值。

6、此时,启动moosefs-master和moosefs-cgiserv,查看端口发现开启了9419,9420,9421,9425端口。

systemctl start moosefs-master  #启动MASTER

systemctl start moosefs-cgiserv  #启动WEBUI监控服务

[root@mfs1 mfs]# netstat -antuple
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name    
tcp        0      0 0.0.0.0:9419            0.0.0.0:*               LISTEN      997        26226      2425/mfsmaster      
tcp        0      0 0.0.0.0:9420            0.0.0.0:*               LISTEN      997        26227      2425/mfsmaster      
tcp        0      0 0.0.0.0:9421            0.0.0.0:*               LISTEN      997        26228      2425/mfsmaster      
tcp        0      0 0.0.0.0:9425            0.0.0.0:*               LISTEN      0          26317      2435/python2        
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      0          17434      1326/sshd           
tcp        0      0 192.168.122.101:22      192.168.122.1:44176     ESTABLISHED 0          20120      1954/sshd: root@pts 
tcp6       0      0 :::22                   :::*                    LISTEN      0          17443      1326/sshd         
9419:metalogger监听的端口地址,和元数据服务器通信的,当master宕机,可以通过它的日志,接管master的服务
9420:用于chunkserver连接的端口地址
9421:用于客户端挂接连接的端口地址
9425:web界面监控各个分布节点的端口

在这里插入图片描述
输入master的主机名
在这里插入图片描述
此时还没有chunk server数据结点,所以server这里是空的

在这里插入图片描述
Chunk Server

8、在真正存储数据的节点安装moosefs-chunkserver

yum install moosefs-chunkserver -y

9、安装之后在两个节点都会生成一个mfs用户

[root@mfs2 ~]# id mfs
uid=997(mfs) gid=995(mfs)=995(mfs)

10、编辑配置文件mfshdd.cfg,写入mfs的分区/mnt/chunk1

mfshdd.cfg:空间配置文件
/mnt/chunk1 是一个给mfs 的分区,但在本机上是一个独立的目录,最好是一个单独的硬盘或者一个raid 卷,最低要求是一个分区。

在这里插入图片描述

11、更改目录/mnt/chunk 的权限,因为mfschunkserver进程是用mfs运行的

chown -R mfs:mfs /mnt/chunk1
[root@mfs2 mnt]# mkdir /mnt/chunk1
[root@mfs2 mnt]# chown -R mfs:mfs /mnt/chunk1

做解析
在这里插入图片描述

12、开启chunkserver

systemctl start moosefs-chunkserver
netstat -antlupe  ##开通监控的端口9422
[root@mfs2 mfs]# netstat -antuple
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name    
tcp        0      0 0.0.0.0:9422            0.0.0.0:*               LISTEN      997        26134      2566/mfschunkserver 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      0          16724      1063/sshd           
tcp        0      0 192.168.122.102:22      192.168.122.1:53190     ESTABLISHED 0          18664      1951/sshd: root@pts 
tcp        0      0 192.168.122.102:40370   192.168.122.101:9420    ESTABLISHED 997        26137      2566/mfschunkserver 
tcp6       0      0 :::22                   :::*                    LISTEN      0          16733      1063/sshd        

13、此时就可以看到,mfsmaster与chunkserver建立了连接

在这里插入图片描述

[root@mfs1 mfs]# lsof -i :9420
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mfsmaster 2425  mfs   11u  IPv4  26227      0t0  TCP *:9420 (LISTEN)
mfsmaster 2425  mfs   13u  IPv4  26938      0t0  TCP mfs1:9420->mfs2:40370 (ESTABLISHED)
mfsmaster 2425  mfs   14u  IPv4  26940      0t0  TCP mfs1:9420->mfs3:59054 (ESTABLISHED)

客户端结点:

[root@git1 ~]# curl "http://ppa.moosefs.com/MooseFS-3-el7.repo" > /etc/yum.repos.d/MooseFS.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   168  100   168    0     0    186      0 --:--:-- --:--:-- --:--:--   186

[root@git1 ~]# curl "http://ppa.moosefs.com/MooseFS-3-el7.repo" > /etc/yum.repos.d/MooseFS.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   168  100   168    0     0    186      0 --:--:-- --:--:-- --:--:--   186
[root@git1 ~]# yum install moosefs-client -y

做解析

测试使用

在客户端创建空目录:
[root@git1 ~]# mkdir /mnt/mfs
[root@git1 ~]# cd /mnt/mfs/

挂载
[root@git1 mfs]# mfsmount /mnt/mfs/
mfsmaster accepted connection with parameters: read-write,restricted_ip,admin ; root mapped to root:root

客户端和master通信使用的是master的9421端口
[root@git1 mfs]# mount
mfsmaster:9421 on /mnt/mfs type fuse.mfs (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)

第一次创建时失败

[root@git1 mfs]# mkdir data1
[root@git1 mfs]# mfsgetgoal data1
data1: realpath error on (/mnt/mfs/data1): ENOENT (No such file or directory)
[root@git1 mfs]# ls
data1
[root@git1 mfs]# cd
[root@git1 ~]# cd /mnt/mfs/
[root@git1 mfs]# ls
[root@git1 mfs]# 

再创建一次就好了

[root@git1 mfs]# mkdir data1
[root@git1 mfs]# mkdir data2
[root@git1 mfs]# ls
data1  data2
[root@git1 mfs]# mfsgetgoal data1
data1: 2
[root@git1 mfs]# mfsgetgoal data2
data2: 2

目标(goal),是指文件被拷贝的份数,设定了拷贝的份数后是可以通过mfsgetgoal ,mfscheckfile 和mfsfileinfo命令来证实的,也可以通过mfsrsetgoal 来改变设定。

mfssetgoal -r 份数 目录/文件

[root@git1 mfs]# mfssetgoal -r 1 data1
data1:
 inodes with goal changed:                       1
 inodes with goal not changed:                   0
 inodes with permission denied:                  0
[root@git1 mfs]# cd data1
[root@git1 data1]# cp /etc/passwd .
[root@git1 data1]# ls
passwd

data2设置拷贝2份,并拷贝文件

[root@git1 mfs]# mfsgetgoal data2
data2: 2
[root@git1 mfs]# cd data2
[root@git1 data2]# cp /etc/fstab .

查看各自的信息

[root@git1 mfs]# mfsfileinfo data1/passwd 
data1/passwd:
	chunk 0: 0000000000000001_00000001 / (id:1 ver:1)
		copy 1: 192.168.122.103:9422 (status:VALID)
[root@git1 mfs]# mfsfileinfo data2/fstab 
data2/fstab:
	chunk 0: 0000000000000002_00000001 / (id:2 ver:1)
		copy 1: 192.168.122.102:9422 (status:VALID)
		copy 2: 192.168.122.103:9422 (status:VALID)

测试挂掉mfs3

[root@mfs3 mfs]#  systemctl stop moosefs-chunkserver
[root@git1 mfs]# mfsfileinfo data1/passwd 
data1/passwd:
	chunk 0: 0000000000000001_00000001 / (id:1 ver:1)
		no valid copies !!!
[root@git1 mfs]# cat data1/passwd 
^C


不影响data2的访问,因为它还有一个副本
[root@git1 mfs]# mfsfileinfo data2/fstab 
data2/fstab:
	chunk 0: 0000000000000002_00000001 / (id:2 ver:1)
		copy 1: 192.168.122.102:9422 (status:VALID)

测试大文件会在数据结点上分开存储

[root@git1 data1]# dd if=/dev/zero  of=bigoff bs=1M count=100
记录了100+0 的读入
记录了100+0 的写出
104857600字节(105 MB)已复制,9.78126 秒,10.7 MB/[root@git1 data1]# ls
bigoff  passwd
[root@git1 data1]# mfsfileinfo bigoff 
bigoff:
	chunk 0: 0000000000000003_00000001 / (id:3 ver:1)
		copy 1: 192.168.122.103:9422 (status:VALID)
	chunk 1: 0000000000000004_00000001 / (id:4 ver:1)
		copy 1: 192.168.122.102:9422 (status:VALID)

在chunkserver中,文件是这样存储的
在这里插入图片描述

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
mfs-1.6.27-1.tar.gz 压缩文件, 解包大小为 3,673,037 字节 2013.3.24 发布版 --------------------------------------------------------- MooseFS is an Open Source, easy to deploy and maintain, distributed, fault tolerant file system for POSIX compliant OSes. MooseFS uses FUSE (http://fuse.sourceforge.net/). MooseFS v1.5 - 1.6 ============ Date of first public release: 2008-05-30 Project web site: http://www.moosefs.com/ Installation and using MooseFS: http://www.moosefs.org/reference-guide.html Sourceforge project site with source repository: http://sourceforge.net/projects/moosefs/ Reporting bugs: bugs@moosefs.com General contact address: contact@moosefs.com Copyright ========= Copyright 2005-2011 Gemius SA. MooseFS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3. MooseFS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with MooseFS. If not, see <http://www.gnu.org/licenses/>. Compatibility matrix ==================== (tested Operating Systems only): Client Master Chunkserver Linux 2.6.x (i386): YES YES YES FreeBSD 5.x (i386+amd64): NO YES YES FreeBSD 6.x (i386+amd64): YES YES YES FreeBSD 7.x (i386+amd64): YES YES YES FreeBSD 8.x (i386+amd64): YES YES YES MacOS X 10.3 (Panther, ppc): NO YES YES MacOS X 10.4 (Tiger, ppc+i386): YES YES YES MacOS X 10.5 (Leopard, ppc+i386): YES YES YES MacOS X 10.6 (Snow Leopard): YES YES YES Solaris 10 (sparc): NO YES YES OpenSolaris (i386): YES YES YES
根据引用,MooseFS是一种分布式文件系统,用作共享存储服务器。要手动切换MooseFS的主备节点,可以按照以下步骤进行操作: 1. 首先,根据引用中的指示,需要通过运行"./configure --prefix=/usr/local/mfs --with-default-user=mfs --with-default-group=mfs --enable-mfsmount"来配置MooseFS。 2. 接下来,根据引用中的指示,需要修改配置文件"/usr/local/mfs/etc/mfshdd.cfg"。在这个文件中,你需要指定MooseFS的主备角色。 3. 修改配置文件时,你需要注意以下几个步骤: a. 确保每个服务器只贡献一个分区作为MooseFS的一部分。 b. 根据你的服务器配置,将分区的挂载点修改为MooseFS的写目录的属主。 c. 确保配置文件中只包含一行内容,指定MooseFS的主备角色。 通过完成以上步骤,你就可以手动切换MooseFS的主备节点。请确保按照正确的配置和指示进行操作,以确保系统的正常运行。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [分布式文件系统MFS(moosefs)实现存储共享](https://blog.csdn.net/weixin_35953844/article/details/119661796)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值