MooseFS
-
简介
http://moosefs.org/
-
MFS特性
-
安装和配置简单方便
-
可靠性高(数据的多个拷贝被存储在多个不同的服务器上)
-
通过添加新的服务器或硬盘就可以实现容量的动态扩展
-
删除的数据可在一定时间内保留(类似windows里面的回收站机制,数据保留时间需要配置)
-
系统优点
-
系统缺点
-
系统应用场景
-
大规模高并发的线上数据存储及访问(大文件、小文件)
-
大规模的数据处理,如日志分析。HDFS
-
温馨提示:有很多应用不适合用分布式文件系统,我们不要为了用而用。
-
结构原理
每个角色的作用如下:
1、管理服务器,负责各个数据存储服务器的管理,文件读写调度,文件空间回收以及恢复多节点拷贝。
2、元数据日志服务器,负责备份master服务器的变化日志文件,文件类型为changelog_ml.*.mfs,以便于在master server出问题的时候接替其进行工作。
3、数据存储服务器,负责连接管理服务器,听从管理服务器调度,提供存储空间,并为客户提供数据传输。
4、客户端,通过fuse内核接口挂接远程管理服务器上所管理的数据存储服务器,看起来共享的文件系统和本地unix文件系统使用一样的效果。
-
读流程
-
写流程
-
约定
-
规划
-
-
配置全网hosts
cat >>/etc/hosts< 192.168.233.150 mfsmaster 192.168.233.111 mfsmaster.etiantian.org 192.168.233.154 mfsbackup 192.168.233.155 mfsdata01 192.168.233.156 mfsdata02 192.168.233.160 mfsdata03 192.168.233.157 mfsclient EOF [root@M-s tools]# wget http://ppa.moosefs.com/src/moosefs-2.0.91-1.tar.gz 或去这个页面找到相应版本 packs: https://sourceforge.net/projects/moosefs/files/ 例:https://sourceforge.net/projects/moosefs/files/3.0.78/moosefs-packages-linux-3.0.78.tar.gz/download useradd mfs -M -s /bin/nologin #yum install fuse fuse-devel -y #yum install zlib-devel -y tar xf moosefs-2.0.91-1.tar.gz cd moosefs-2.0.91 ./configure --prefix=/application/mfs-2.0.91 --with-default-user=mfs --with-default-group=mfs make make install 编译时如出现此错误: checking for library containing pcap_lib_version... no ****** mfsnetdump disabled ****** * mfsnetdump needs pcap library * ********************************* checking for FUSE... no ******************************** mfsmount disabled ******************************** * fuse library is too old or not installed - mfsmount needs version 2.6 or higher * *********************************************************************************** checking for fuse_version in -lfuse... no #yum install fuse fuse-devel -y checking for zlibVersion in -lz... no configure: error: zlib development library not found #yum install zlib-devel -y 将来升级时,重新做软连接即可 [root@M-s moosefs-2.0.91]# ln -s /application/mfs-2.0.91/ /application/mfs 检查的习惯必要丢 [root@M-s moosefs-2.0.91]# ll /application/|grep mfs lrwxrwxrwx. 1 root root 24 11月 25 10:05 mfs -> /application/mfs-2.0.91/ drwxr-xr-x. 7 root root 4096 11月 25 10:03 mfs-2.0.91 [root@M-s moosefs-2.0.91]# ll /application/mfs/ 总用量 20 drwxr-xr-x. 2 root root 4096 11月 25 10:03 bin drwxr-xr-x. 3 root root 4096 11月 25 10:03 etc drwxr-xr-x. 2 root root 4096 11月 25 10:03 sbin drwxr-xr-x. 4 root root 4096 11月 25 10:03 share drwxr-xr-x. 3 root root 4096 11月 25 10:03 var [root@M-s mfs]# pwd /application/mfs/etc/mfs [root@M-s mfs]# ll 总用量 32 -rw-r--r--. 1 root root 3040 11月 25 10:03 mfschunkserver.cfg.dist -rw-r--r--. 1 root root 4051 11月 25 10:03 mfsexports.cfg.dist #exports==联想到nfs有木有,mfs是参考了nfs的配置方法。mfsexports.cfg即权限控制文件,挂载给谁,读写权限等 -rw-r--r--. 1 root root 946 11月 25 10:03 mfshdd.cfg.dist -rw-r--r--. 1 root root 6868 11月 25 10:03 mfsmaster.cfg.dist #主配置文件 -rw-r--r--. 1 root root 1953 11月 25 10:03 mfsmetalogger.cfg.dist -rw-r--r--. 1 root root 402 11月 25 10:03 mfsmount.cfg.dist -rw-r--r--. 1 root root 1052 11月 25 10:03 mfstopology.cfg.dist 去掉dist,使之生效 [root@M-s mfs]# cp mfsexports.cfg.dist mfsexports.cfg [root@M-s mfs]# cp mfsmaster.cfg.dist mfsmaster.cfg [root@M-s mfs]# echo "192.168.233.0/24 / rw,alldirs,mapall=mfs:mfs,pawwsword=123456" > mfsexports.cfg 本命令提示: 允许的地址 被挂载的目录 :根,表示所有的数据服务器 权限: ro 只读模式共享 rw 读写的方式共享 alldirs 允许挂载任何指定的子目录 maproot 映射为root;mapall指定用户 password 指定客户端密码 提示:此处修改配置文件,希望重启后还生效;要是做负载均衡,将来做迁移的话用命令就可以,不要在配置文件中配置,即: cd /etc/sysconfig/network-scripts cp ifcfg-eth0 ifcfg-eth0:0 vi ifcfg-eth0:0 DEVICE=eth0:0 TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=none IPADDR=192.168.233.111 NETMASK=255.255.255.0 DNS2=8.8.8.8 DNS1=219.146.0.130 USERCTL=no PEERDNS=yes IPV6INIT=no 使用IP命令添加: 原本配置有IP址,默认会添加辅助地址 ifconfig eth0:1 192.168.1.2 netmask 255.255.255.0 ip addr {add|del} IPADDR dev INTERFACE 例: ip addr add 192.168.233.112/24 dev eth0:0 添加辅助ip ip addr del 192.168.233.111/24 dev eth0:0 删除辅助ip CentOS 7 nmcli connection modify eno16777736 +ipv4.addresses 172.16.100.1/24 [root@M-s ~]# mfsmaster start open files limit has been set to: 16384 working directory: /var/lib/mfs#####这应当是我之前用yun安装的原因 lockfile created and locked initializing mfsmaster modules ... exports file has been loaded topology file has been loaded loading metadata ... metadata file has been loaded no charts data file - initializing empty charts master <-> metaloggers module: listen on *:9419 master <-> chunkservers module: listen on *:9420 main master server module: listen on *:9421 mfsmaster daemon initialized properly 编译安装用的启动方式 [root@M-s mfs]# /application/mfs/sbin/mfsmaster start open files limit has been set to: 4096 working directory: /application/mfs-2.0.91/var/mfs lockfile created and locked initializing mfsmaster modules ... exports file has been loaded mfstopology configuration file (/application/mfs-2.0.91/etc/mfstopology.cfg) not found - using defaults loading metadata ... can't find metadata.mfs - try using option '-a' init: metadata manager failed !!! error occurred during initialization – exiting 排错: [root@M-s var]# cd /application/mfs/var/mfs [root@M-s mfs]# ll 总用量 4 -rw-r--r--. 1 mfs mfs 8 11月 25 10:03 metadata.mfs.empty [root@M-s mfs]# cp metadata.mfs.empty metadata.mfs 正常启动: [root@M-s mfs]# /application/mfs/sbin/mfsmaster start open files limit has been set to: 4096 working directory: /application/mfs-2.0.91/var/mfs lockfile created and locked initializing mfsmaster modules ... exports file has been loaded mfstopology configuration file (/application/mfs-2.0.91/etc/mfstopology.cfg) not found - using defaults loading metadata ... metadata file has been loaded no charts data file - initializing empty charts###无数据文件,刚安装完的原因,没事 master <-> metaloggers module: listen on *:9419 master <-> chunkservers module: listen on *:9420 main master server module: listen on *:9421 mfsmaster daemon initialized properly 看健康状态 提示:kill -9 mongodb mysql等都会出问题,可能会起不来 echo "export PATH=$PATH:/application/mfs/sbin:/application/mfs/bin" >> /etc/profile . /etc/profile 提示:如果是yum安装的,不用此步骤。直接用 服务名+start/stop即可 此处用的ie浏览器,用搜狗的时候回出图不全,其他的没有测试。 同master 安装与主完全相同,区别在于配置文件。 #如果不是用域名来区别主机,这步省略即可 cd /application/mfs/etc/mfs/ cp mfsmetalogger.cfg.dist mfsmetalogger.cfg sed -i 's@# MASTER_HOST = mfsmaster@MASTER_HOST = mfsmaster.etiantian.org@g' mfsmetalogger.cfg [root@BK mfs]# nmap mfsmaster.etiantian.org -p 9419|grep open 9419/tcp open unknown [root@BK mfs]# /application/mfs/sbin/mfsmetalogger start open files limit has been set to: 4096 working directory: /application/mfs/var/mfs lockfile created and locked initializing mfsmetalogger modules ... mfsmetalogger daemon initialized properly 已和master的9419建立连接 [root@BK mfs]# netstat -an | grep EST tcp 0 52 192.168.233.154:52113 192.168.233.1:59385 ESTABLISHED tcp 0 0 192.168.233.154:44573 192.168.233.111:9419 ESTABLISHED [root@M-s local]# netstat -an | grep EST tcp 0 0 192.168.233.150:52113 192.168.233.1:51728 ESTABLISHED tcp 0 0 192.168.233.111:9419 192.168.233.154:44573 ESTABLISHED 同master cd /application/mfs/etc/mfs/ cp mfschunkserver.cfg.dist mfschunkserver.cfg cp mfshdd.cfg.dist mfshdd.cfg 修改配置文件 sed -i 's@# MASTER_HOST = mfsmaster@MASTER_HOST = mfsmaster.etiantian.org@g' mfschunkserver.cfg 本例采用虚拟机添加硬盘及分区方便,故用的fdisk,生产中可以采用dd if 的方式 fdisk mkfs.ext3 /dev/sdb1 tune2fs -c -1 mkdir /mfsdata chown -R mfs.mfs /mfsdata mount -t ext3 /dev/sdb1 /mfsdata df -h | grep mfs #[root@data01 mfs]# df -h | grep mfs #挂载好了 #/dev/sdb1 106M 5.6M 95M 6% /mfsdata 卸载 umount /mfsdata 加入开机自启 vi /etc/fstab /dev/sdb1 /mfsdata ext3 defaults 0 0 查看一下 [root@data02 mfs]# mount -a #挂载 [root@data02 mfs]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 19G 2.7G 15G 15% / tmpfs 120M 0 120M 0% /dev/shm /dev/sda1 190M 27M 153M 15% /boot /dev/sdb1 106M 5.6M 95M 6% /mfsdata 空间分的太少了。。。。 - _- 满了 -_- 卸载以后 [root@data02 mfs]# echo "/mfsdata" > mfshdd.cfg [root@data02 mfs]# /application/mfs/sbin/mfschunkserver start open files limit has been set to: 16384 working directory: /application/mfs-2.0.91/var/mfs lockfile created and locked setting glibc malloc arena max to 8 setting glibc malloc arena test to 1 initializing mfschunkserver modules ... hdd space manager: path to scan: /mfsdata/ hdd space manager: start background hdd scanning (searching for available chunks) main server module: listen on *:9422 no charts data file - initializing empty charts mfschunkserver daemon initialized properly [root@data02 mfs]# lsof -i :9422 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME mfschunks 29994 mfs 11u IPv4 62727 0t0 TCP *:9422 (LISTEN) [root@data02 mfs]# netstat -an | grep EST tcp 0 0 192.168.233.156:3306 192.168.233.156:54672 ESTABLISHED tcp 0 0 192.168.233.156:54672 192.168.233.156:3306 ESTABLISHED tcp 0 52 192.168.233.156:52113 192.168.233.1:59380 ESTABLISHED tcp 0 0 192.168.233.156:36061 192.168.233.111:9420 ESTABLISHED 视频到008开头。 查本地进程及端口 [root@data02 mfs]# netstat -lntup | grep EST [root@data02 mfs]# netstat -lntup | grep mfs [root@data02 mfs]# lsof -i :9422 查和主服务器间的连接 [root@data02 mfs]# netstat -an | grep EST 查看主服务器的日志 [root@M-s ~]# tail /var/log/messages Nov 25 17:27:28 zhang mfsmaster[26306]: csdb: generate new server id for (192.168.233.160:9422): 1 Nov 25 17:27:28 zhang mfsmaster[26306]: chunkserver register end (packet version: 6) - ip: 192.168.233.160 / port: 9422 Nov 25 17:27:42 zhang mfsmaster[26306]: csdb: server not found (192.168.233.155:9422,0), add it to database Nov 25 17:27:42 zhang mfsmaster[26306]: chunkserver register begin (packet version: 6) - ip: 192.168.233.155 / port: 9422, usedspace: 0 (0.00 GiB), totalspace: 0 (0.00 GiB) Nov 25 17:27:42 zhang mfsmaster[26306]: csdb: generate new server id for (192.168.233.155:9422): 2 Nov 25 17:27:42 zhang mfsmaster[26306]: chunkserver register end (packet version: 6) - ip: 192.168.233.155 / port: 9422 Nov 25 17:27:51 zhang mfsmaster[26306]: csdb: server not found (192.168.233.156:9422,0), add it to database Nov 25 17:27:51 zhang mfsmaster[26306]: chunkserver register begin (packet version: 6) - ip: 192.168.233.156 / port: 9422, usedspace: 0 (0.00 GiB), totalspace: 0 (0.00 GiB) Nov 25 17:27:51 zhang mfsmaster[26306]: csdb: generate new server id for (192.168.233.156:9422): 3 Nov 25 17:27:51 zhang mfsmaster[26306]: chunkserver register end (packet version: 6) - ip: 192.168.233.156 / port: 9422 1#install mfs master yum install fuse fuse-devel -y yum install zlib-devel -y cd /home/zhang/tools wget http://ppa.moosefs.com/src/moosefs-2.0.91-1.tar.gz useradd mfs -M -s /bin/nologin tar xf moosefs-2.0.91-1.tar.gz cd moosefs-2.0.91 ./configure --prefix=/application/mfs-2.0.91 --with-default-user=mfs --with-default-group=mfs make make install ln -s /application/mfs-2.0.91/ /application/mfs ll /application/|grep mfs cd ../ 2#config master cd /application/mfs/etc/mfs cp mfsmaster.cfg.dist mfsmaster.cfg cp mfsexports.cfg.dist mfsexports.cfg echo "192.168.233.0/24 / rw,alldirs,mapall=mfs:mfs,pawwsword=123456" > mfsexports.cfg 3#启动master echo "export PATH=$PATH:/application/mfs/sbin:/application/mfs/bin" >> /etc/profile . /etc/profile mfsmaster start 同master cd /application/mfs/etc/mfs/ cp mfsmetalogger.cfg.dist mfsmetalogger.cfg sed -i 's@# MASTER_HOST = mfsmaster@MASTER_HOST = mfsmaster.etiantian.org@g' mfsmetalogger.cfg MfsMaster Install: yum install -y fuse-devel zlib-devel useradd mfs -s /sbin/nologin ./configure --prefix=/usr/local/mfs --with-default-user=mfs --with-default-group=mfs --disable-mfsmount --disable-mfschunkserver make && make install Mfschunk Install: yum install -y fuse-devel zlib-devel useradd mfs -s /sbin/nologin ./configure --prefix=/usr/local/mfs --with-default-user=mfs --with-default-group=mfs --disable-mfsmaster --disable-mfsmount make && make install MfsMount Install: yum install -y fuse-devel zlib-devel useradd mfs -s /sbin/nologin ./configure --prefix=/usr/local/mfs --with-default-user=mfs --with-default-group=mfs --disable-mfsmaster --disable-mfschunkserver make && make install
Master安装
安装配置
下载安装包
创建mfs用户和组
编译安装
做软连接
主服务器目录结构
应用配置文件
配置vip,对外提供服务
启动主服务器mfs master
停止主服务器
其他相关配置
环境变量
开启主服务器图形监控
效果图
备份服务器BACKUP(metalogger)
安装
配置
远程检测master
启动
查看检测
数据服务器
安装
配置mfschunkserver.cfg
分区
挂载
配置mfshdd.cfg
启动
安装客户端
检查的几种方法
批量安装
mfs master
mfs backup(metaloggers)
安装
配置
dataserver(chunkserver)
其他