当前位置:网站首页>MooseFS的简介、部署及应用
MooseFS的简介、部署及应用
2022-06-29 21:41:00 【星哥玩云】
mooseFS简介
MooseFS正式的推出是在2008-05-30,到2009-10-12为止,最新的版本是1.5.12。
mooseFS是一款网络分布式文件系统。它把数据分散在多台服务器上,但对于用户来讲,看到的只是一个源。MFS也像其他类unix文件系统一样,包含了层级结构(目录树),存储着文件属性(权限,最后访问和修改时间),可以创建特殊的文件(块设备,字符设备,管道,套接字),符号链接,硬链接。
mooseFS系统的组成
1.master(元数据服务器)
master负责在整个系统中管理数据。是整个系统的维护者。但是它有个弱点就是master只有一个!也就是说如果master坏掉,整个系统将停止工作!不过这算不上致命弱点,因为我们做好数据备份以后,恢复master是很简单的事。
2.chunkserver(数据存储服务器)
chunkserver是mfs系统中的数据存储者。真正的用户数据按照算法被分成chunk,并分发到各个chunkserver上。这样就保证了数据的安全性。
3.client
凡是使用mfs文件系统的机器都可以被称为client。client是mfs系统的使用者。当client把mfs文件系统挂载到本机以后,它可以像使用一个普通的磁盘分区一样,来使用mfs。
试验环境
本文只介绍moosefs的部署与应用,出于试验的目的,并没有考虑性能因素,因此所有的服务器均使用虚拟机来实现。以后有机会做单独的物理服务器,然后对其性能进行测试。
拓扑图
备注:
(1) chunkserver1-4 均添加了一块虚拟的磁盘sda(磁盘空间一定要大于1G,我这里设置了4G),挂载到系统的/data下。所有服务器均升级内核为2.6.18-164本版,为什么要升级内核,下文会有介绍。
(2) 所有服务器均安装了完整版的mfs组件
安装与配置
安装mfs的前提条件
由于mfs的客户端程序也就是加载mfs磁盘系统的命令是使用fuse编写的,因此只要是想挂载mfs的服务器,必要的前提条件就是先安装fuse,这样编译mfs的时候才能顺利通过。另外一点需要注意:linux 2.6.18-164.e15 版本的linux内核中已经内置了fuse模块。但在该版本之前的linux内核中是不包含这个模块的。另fuse 从2.8.0-pre1 版本的源码包中去掉了fuse系统模块的源码部分,原因就是上一点提到的。这样我们在编译安装当前最新版本的fuse(2.8以上版本) 且正在使用的linux内核版本低于2.6.18-164.e15版本,则系统中是不包含fuse模块的。
解决的方法:
1、升级系统内核为2.6.18-164版本
为了方便起见直接利用yum升级系统内核即可。yum install kernel
安装成功后需重启系统
2、使用fuse 2.7x版本编译安装
该版本的fuse中包含了linux内核需要的fuse模块,配置编译选项时指定 –enable-kernel-module 选项,make的时候就会编译相应的fuse模块,make intall会将fuse.ko复制到 /lib/modules/`uname -r`/kernel/fs/fuse/ 目录下 安装后利用
- # modprobe -l | grep fuse
- /lib/modules/2.6.18-128.el5xen/kernel/fs/fuse/fuse.ko
查看是否正常安装
3、利用yum安装当前内核版本的fuse模块
- yum install -y dkms-fuse dkms
安装fuse
如果只编译元数据服务端或数据存储服务端的话是没有必要安装fuse的。只有mfsmount需要fuse支持(编译时需要fuse的开发包,使用mfsmount挂载时需要fuse.ko系统模块)。可以使用源码或yum两种方式安装fuse
1、源码安装
- # wget http://ncu.dl.sourceforge.net/project/fuse/fuse-2.X/2.8.1/fuse-2.8.1.tar.gz
- # tar -xvzf fuse-2.8.1.tar.gz
- # cd fuse-2.8.1
- # ./configure –prefix=/usr/ –libdir=/usr/lib64
- # make && make install
由于我系统为64位,因此在编译fuse时将lib目录定为/usr/lib64。这样在下面编译安装mfs时就不会因为找不到fuse的lib文件报错了。
2、yum安装
- # yum install -y fuse fuse-devel
安装mfs
- # useradd mfs -s /sbin/nologin
- # ./configure –prefix=/usr/local/mfs –with-default-user=mfs –with-default-group=mfs –enable-mfsmount
- # make && make install
查看安装后目录结构
- # ll /usr/local/mfs/
- total 20
- drwxr-xr-x 2 root root 4096 Oct 14 15:14 bin
- drwxr-xr-x 2 root root 4096 Oct 14 12:13 etc
- drwxr-xr-x 2 root root 4096 Oct 14 15:14 sbin
- drwxr-xr-x 3 root root 4096 Oct 14 12:13 share
- drwxr-xr-x 3 root root 4096 Oct 14 12:13 var
bin – 客户端工具
etc – 元数据服务器,数据存储服务器的配置文件都放在该目录中
sbin – 元数据服务器端程序mfsmaster、数据存储服务器端服务程序mfschunkserver
share – 文档
var – 元数据目录(可在配置文件中自定义到其他目录)
配置master(元数据服务器)
IP:192.168.108.108
- [[email protected]~]#vi/usr/local/mfs/etc/mfsmaster.cfg
- #WORKING_USER=mfs
- #WORKING_GROUP=mfs
- #LOCK_FILE=/var/run/mfs/mfsmaster.pid
- #DATA_PATH=/usr/local/mfs/var/mfs
- #SYSLOG_IDENT=mfsmaster
- #BACK_LOGS=50
- #REPLICATIONS_DELAY_INIT=300
- #REPLICATIONS_DELAY_DISCONNECT=3600
- MATOCS_LISTEN_HOST=192.168.108.108
- #MATOCS_LISTEN_PORT=9420
- #MATOCU_LISTEN_HOST=*
- #MATOCU_LISTEN_PORT=9421
- #CHUNKS_LOOP_TIME=300
- #CHUNKS_DEL_LIMIT=100
- #CHUNKS_REP_LIMIT=15
注:这个配置文件中所有注掉的设置都是默认的配置。在这里我只更改了MATOCS_LISTEN_HOST的值,也就是将它修改为本机的ip地址:192.168.108.108 。如果又需要还可以修改DATA_PATH的设置将元数据目录存储到其他的分区或磁盘。其他的参数都很简单根据需要调整即可。
master会打开9420端口等待 mfschunkserver 连接
启动mfsmaster
- [[email protected]~]#/usr/local/mfs/sbin/mfsmaster
- [[email protected]~]#ps-ef|grepmfsmaster|grep-vgrep
- mfs101321017:37?00:00:00/usr/local/mfs/sbin/mfsmaster
- [[email protected]~]#netstat-tulnp|grepmfsmaster
- tcp00192.168.108.108:94200.0.0.0:*LISTEN10132/mfsmaster
- tcp000.0.0.0:94210.0.0.0:*LISTEN10132/mfsmaster
查看系统日志
- [[email protected]~]#tail-f/var/log/messages
- Oct1417:37:35mastermfsmaster:config:usingdefaultvalueforoption‘SYSLOG_IDENT’–‘mfsmaster’
- Oct1417:37:35mastermfsmaster[10130]:config:usingdefaultvalueforoption‘WORKING_USER’–‘mfs’
- Oct1417:37:35mastermfsmaster[10130]:config:usingdefaultvalueforoption‘WORKING_GROUP’–‘mfs’
- …
- Oct1417:37:35mastermfsmaster[10132]:config:usingdefaultvalueforoption‘CHUNKS_LOOP_TIME’–’300′
# 以上日志内容省略的很多,主要是程序读取配置的过程。
# 下面的部分为检查元数据和检查数据存储服务器的情况(每1分钟检查一次)。
# 由于我这里还没有启动chunkservers 因此在chunkservers status:的显示结果为空。total: usedspace: 的结果也为空。
- Oct1417:38:00mastermfsmaster[10132]:inodes:45
- Oct1417:38:00mastermfsmaster[10132]:dirnodes:3
- Oct1417:38:00mastermfsmaster[10132]:filenodes:42
- Oct1417:38:00mastermfsmaster[10132]:chunks:14
- Oct1417:38:00mastermfsmaster[10132]:chunkstodelete:0
- Oct1417:38:00mastermfsmaster[10132]:chunkserversstatus:
- Oct1417:38:00mastermfsmaster[10132]:total:usedspace:0(0GB),totalspace:0(0GB),usage:0.00%
设置服务随系统启动
- [[email protected]~]#echo“/usr/local/mfs/sbin/mfsmaster”>>/etc/rc.local
配置chunkserver(数据存储服务器)
IP:192.168.108.161~164
- [[email protected]~]#vi/usr/local/mfs/etc/mfschunkserver.cfg
- #WORKING_USER=mfs
- #WORKING_GROUP=mfs
- #DATA_PATH=/usr/local/mfs/var/mfs
- #LOCK_FILE=/var/run/mfs/mfschunkserver.pid
- #SYSLOG_IDENT=mfschunkserver
- #BACK_LOGS=50
- #MASTER_RECONNECTION_DELAY=30
- MASTER_HOST=192.168.108.108
- #MASTER_PORT=9420
- #MASTER_TIMEOUT=60
- #CSSERV_LISTEN_HOST=*
- #CSSERV_LISTEN_PORT=9422
- #CSSERV_TIMEOUT=60
- #CSTOCS_TIMEOUT=60
- #HDD_CONF_FILENAME=/usr/local/mfs/etc/mfshdd.cfg
配置存储分区
- [[email protected]~]#vi/usr/local/mfs/etc/mfshdd.cfg
- 删除
- /mnt/hd1
- /mnt/hd2
- /mnt/hd3
- /mnt/hd4
添加独立的分区
/data
修改分区所有者为mfs
- [[email protected]~]#chownmfs.mfs/data
注:mfschunkserver 服务器的主配置很简单,没有特殊要求只需要修改MASTER_HOST的地址即可。存储分区的配置选择一个独立的磁盘分区(分区必须大于1G)。
启动mfschunkserver
- [[email protected]~]#/usr/local/mfs/sbin/mfschunkserver
- [[email protected]~]#netstat-an|grep9420
- tcp00192.168.108.161:15099192.168.108.108:9420ESTABLISHED
同时查看系统日志
- Oct1417:53:45vm_web_1mfschunkserver[1992]:connecting…
- Oct1417:53:45vm_web_1mfschunkserver[1992]:connectedtoMaster
说明已经和master服务器成功连接
再查看master的日志查看
- Oct1417:59:00experimentmfsmaster[10132]:server1(192.168.108.161):usedspace:560484352(0GB),totalspace:4226125824(3GB),usage:13.26%
- Oct1417:59:00experimentmfsmaster[10132]:total:usedspace:560484352(0GB),totalspace:4226125824(3GB),usage:13.26%
同样也说明有一台 chunkserver 与自己连接,并给出了使用空间和剩余磁盘空间
剩余的3台mfschunkserver利用同样的方法配置好后启动mfschunkserver程序,这时候再查看master系统日志:
- Oct1615:27:00experimentmfsmaster[10132]:inodes:9
- Oct1615:27:00experimentmfsmaster[10132]:dirnodes:1
- Oct1615:27:00experimentmfsmaster[10132]:filenodes:8
- Oct1615:27:00experimentmfsmaster[10132]:chunks:18
- Oct1615:27:00experimentmfsmaster[10132]:chunkstodelete:0
- Oct1615:27:00experimentmfsmaster[10132]:chunkserversstatus:
- Oct1615:27:00experimentmfsmaster[10132]:server1(192.168.108.162):usedspace:924282880(0GB),totalspace:4226125824(3GB),usage:21.87%
- Oct1615:27:00experimentmfsmaster[10132]:server2(192.168.108.164):usedspace:924282880(0GB),totalspace:4226125824(3GB),usage:21.87%
- Oct1615:27:00experimentmfsmaster[10132]:server3(192.168.108.163):usedspace:924282880(0GB),totalspace:4226125824(3GB),usage:21.87%
- Oct1615:27:00experimentmfsmaster[10132]:server4(192.168.108.161):usedspace:924028928(0GB),totalspace:4226125824(3GB),usage:21.86%
- Oct1615:27:00experimentmfsmaster[10132]:total:usedspace:3696877568(3GB),totalspace:16904503296(15GB),usage:21.87%
这里可以看到有4台chunkserver已经连接到了master
客户端挂载与工具使用
192.168.108.109
挂载MFS
mfsmount
- [[email protected]~]#mkdir/mnt/mfs
- [[email protected]~]#mfsmount-h192.168.108.108
- *mfsmount默认情况下将分区加载到/mnt/mfs目录下。如果想加载到其他目录请利用-w参数。
- mfsmount–help
- usage:/usr/local/mfs/bin/mfsmount[-r][-m][-c][-v0..2][-hmasterhost][-pmasterport][-lpath][-wmountpoint]
- r:readonlymode
- m:mountmetadata
- c:allowusingcache
- v:verboselevel
- defaults:
- h:mfsmaster
- p:9421
- l:/
- w:/mnt/mfs
修改MFS文件删除延迟时间
- mfsrsettrashtime
- [[email protected]~]#mfsrsettrashtime100/mnt/mfs/
- /mnt/mfs/:
- inodeswithtrashtimechanged:1(1)
- inodeswithtrashtimenotchanged:0(0)
- inodeswithpermissiondenied:0(0)
查看MFS文件删除延迟时间
- mfsrgettrashtime
- #mfsrgettrashtime/mnt/mfs/
- /mnt/mfs/:
- directorieswithtrashtime100:1(1)
- mfssettrashtime
- [[email protected]~]#mfssettrashtime60/mnt/mfs/
- /mnt/mfs/:60
- mfsgettrashtime
- [[email protected]~]#mfsgettrashtime/mnt/mfs/
- /mnt/mfs/:60
- 设置文件保存份数
- mfssetgoal
- [[email protected]~]#mfssetgoal4/mnt/mfs/
- /mnt/mfs/:4
- 查看文件保存保存数
- mfsgetgoal
- [[email protected]~]#mfsgetgoal/mnt/mfs/
- /mnt/mfs/:4
- mfsrsetgoal
- [[email protected]~]#mfsrsetgoal3/mnt/mfs/
- /mnt/mfs/:
- inodeswithgoalchanged:1(1)
- inodeswithgoalnotchanged:0(0)
- inodeswithpermissiondenied:0(0)
- mfsrgetgoal
- [[email protected]~]#mfsrgetgoal/mnt/mfs/
- /mnt/mfs/:
- directorieswithgoal3:1(1)
文件(文件夹)的查看(检查)命令
- 先生成1个10M的文件
- [[email protected]~]#ddif=/dev/zeroof=filebs=1Mcount=10
- [[email protected]~]#cpfile/mnt/mfs
- 文件信息查看
- mfsfileinfo
- [[email protected]~]#mfsfileinfo/mnt/mfs/file
- /mnt/mfs/file:
- chunk0:0000000000000001_00000001/(id:1ver:1)
- copy1:192.168.108.161:9422
- copy2:192.168.108.162:9422
- copy3:192.168.108.163:9422
- 文件检查
- mfscheckfile
- [[email protected]~]#mfscheckfile/mnt/mfs/file
- /mnt/mfs/file:
- 3copies:1chunks
目录信息查看
mfsdirinfo
- [[email protected]~]#rm/mnt/mfs/file
- [[email protected]~]#mkdir/mnt/mfs/newdir
- [[email protected]~]#cpfile/mnt/mfs/newdir
- [[email protected]~]#mfsdirinfo/mnt/mfs/newdir
- /mnt/mfs/newdir/:
- inodes:2(2)//inode个数,1个目录,1个文件
- directories:1(1)//1个目录
- files:1(1)//1个文件
- goodfiles:1(1)//正常文件个数
- undergoalfiles:0(0)
- missingfiles:0(0)
- chunks:1(1)
- goodchunks:1(1)
- undergoalchunks:0(0)
- missingchunks:0(0)
- length:10M(10485760)
- size:10M(10490880)//这里是文件大小
- hddusage:30M(31472640)//由于我设置文件份数为3,因此这里为3*100M
- [[email protected]~]#cp/data/filenewdir/file_2
- /mnt/mfs/newdir/:
- inodes:3(3)
- directories:1(1)
- files:2(2)
- goodfiles:2(2)
- undergoalfiles:0(0)
- missingfiles:0(0)
- chunks:2(2)
- goodchunks:2(2)
- undergoalchunks:0(0)
- missingchunks:0(0)
- length:20M(20971520)
- size:20M(20981760)
- hddusage:60M(62945280)
创建文件快照
mfssnapshot
- [[email protected]/mnt/mfs/newdir]#mfssnapshotmysnapshotfile
- [[email protected]/mnt/mfs/newdir]#ll
- total30720
- -rw-r–r–1rootroot10485760Oct1616:43file
- -rw-r–r–1rootroot10485760Oct1616:44file_2
- -rw-r–r–1rootroot10485760Oct1616:58mysnapshot
- [[email protected]/mnt/mfs/newdir]#mfsfileinfomysnapshot
- mysnapshot:
- chunk0:0000000000000003_00000001/(id:3ver:1)
- copy1:192.168.108.161:9422
- copy2:192.168.108.162:9422
- copy3:192.168.108.163:9422
- [[email protected]/mnt/mfs/newdir]#mfsfileinfofile
- file:
- chunk0:0000000000000003_00000001/(id:3ver:1)
- copy1:192.168.108.161:9422
- copy2:192.168.108.162:9422
- copy3:192.168.108.163:9422
通过mfsfileinfo命令可以查看创建出来的文件快照,它只占用了一个inode,并不占用磁盘空间,就像ln命令创建硬链接类似。但mfsdirinfo的显示似乎有些问题:
- [[email protected]/mnt/mfs/newdir]#mfsdirinfo/mnt/mfs/newdir/
- /mnt/mfs/newdir/:
- inodes:4(4)
- directories:1(1)
- files:3(3)
- goodfiles:3(3)
- undergoalfiles:0(0)
- missingfiles:0(0)
- chunks:3(3)
- goodchunks:3(3)
- undergoalchunks:0(0)
- missingchunks:0(0)
- length:30M(31457280)
- size:30M(31472640)
- hddusage:90M(94417920)
利用mfsdirinfo查看目录信息发现刚刚创建的快照文件也占用了与原文件相同大小的磁盘空间。但实际情况真的如此吗?
查看master的系统日志
- Oct1617:14:00experimentmfsmaster[24445]:inodes:5
- Oct1617:14:00experimentmfsmaster[24445]:dirnodes:2
- Oct1617:14:00experimentmfsmaster[24445]:filenodes:3
- Oct1617:14:00experimentmfsmaster[24445]:chunks:2
- Oct1617:14:00experimentmfsmaster[24445]:chunkstodelete:0
通过日志的chunks: 2 可知有2个chunks 刚刚mfsfineinfo查看文件得知file文件占用1个chunks那么2个chunks 说明有2个文件。再往上看一行filenodes: 3 说明文件inode数为3 说明有3个文件,这正是2个文件+1个快照文件。
查看各个mfschunkserver的mfs文件
通过查看master日志和查看各个数据存储服务器上的mfs文件,验证了我们刚才用mfsfileinfo的检查结果!文件快照,它只占用了一个inode,并不占用磁盘空间,就像ln命令创建硬链接类似。
边栏推荐
- Divide the bonus pool of 10million + million yuan, and empower developers in the 2022 shengteng AI innovation competition
- Top ten questions for senior Performance Test Engineer
- A. Marathon
- 2022 openvino DevCon unveils secrets! Intel and many partners deepen the construction of developer ecology and release the innovation potential of AI industry
- About Effect Size
- 小型圖書館項目總結
- 掌握这28张图,面试再也不怕被问TCP知识了
- [force deduction 10 days SQL introduction] day7+8 calculation function
- Houdini graphic notes: VAT (3.0) import ue4/5 setup wizard [official document translation]
- Cloud native database query optimization - statistics and row count estimation
猜你喜欢

华为7年经验的软件测试总监,给所有想转行学软件测试的同学的几个建议

Summer Challenge harmonyos ark development framework arkui streamer button effect

After inventing anti-virus software, he chose to be a top-notch gangster

STM32 and gd32 notes

cout 不明确问题

一文2500字手把手教你使用jmeter进行分布式压力测试【保姆级教程】

什么是 SYN 洪水攻击?如何防护?

Summary of document level symbols under different systems

Realization of graduation project topic selection system based on JSP

89. (cesium article) cesium aggregation diagram (custom picture)
随机推荐
Desai wisdom number - other charts (basic sunrise chart): high frequency words in graduation speech
Is it safe to bind securities accounts to flush? Which securities firm can bind flush after opening an account
小型圖書館項目總結
[crossbeam series] 5 crossbeam util and crossbeam queue: some practical gadgets
jfinal中如何使用过滤器监控Druid监听SQL执行?
The inadvertently discovered [tidb cache table] can solve the read / write hotspot problem
Realization of graduation project topic selection system based on JSP
I want to register my stock account online. How do I do it? In addition, is it safe to open a mobile account?
Which brokerage commission is the lowest and safest
2022 openvino DevCon unveils secrets! Intel and many partners deepen the construction of developer ecology and release the innovation potential of AI industry
Layer 3 loop brought by route Summary - solution experiment
华为云AOM 2.0版本发布
JD alliance API - universal chain transfer interface - Jingpin library interface - Interface Customization
Detailed explanation of MySQL and mvcc and the difference between RC and RR for snapshot reading
After inventing anti-virus software, he chose to be a top-notch gangster
为什么要同时重写hashcode和equals方法之简单理解
Taro applet enables wxml code compression
研发测试时间比,BUG数据分析
A. Print a Pedestal (Codeforces logo?)