0
点赞
收藏
分享

微信扫一扫

MFS搭建


一 MFS介绍:

Distinctive features of MooseFS are:

 

MooseFS优越特性如下:

- higher reliability (data can be stored in several copies on separate computers)

高可用性(数据可以存储在多个机器上的多个副本)

 

- dynamically expanding disk space by attaching new computers/disks

可动态扩展随时新增加机器或者是磁盘

 

- possibility of storing deleted files for a defined period of time ("trash bin" service on a file system level)

可回收在指定时间内删除的文件(“垃圾回收站”是一个系统级别的服务)

 

- possibility of creating snapshot of a file, which means coherent copy of the whole file, even while the file is being written.

可以对整个文件甚至在正在写入的文件创建文件的快照。

 

MFS文件系统结构(包含4种角色): 

1)管理服务器managing server (master) :负责各个数据存储服务器的管理,文件读写调度,文件空间回收以及恢复.多节点拷贝。单个机器管理整个文件系统,用来存储记录每一个文件的Metadata(记录文件的大小、文件的属性、文件的位置,也包括非规则文件的系统,如目录、sockets、管道和设备)

 

2)元数据日志服务器Metalogger server(Metalogger):负责备份master服务器的变化日志文件,文件类型为changelog_ml.*.mfs,以便于在master server出问题的时候接替其进行工作。

 

3)数据存储服务器data servers (chunkservers):负责连接管理服务器,听从管理服务器调度,提供存储空间,并为客户提供数据传输。

 

4)数据存储服务器data servers (chunkservers)  :负责连接管理服务器,听从管理服务器调度,提供存储空间,并为客户提供数据传输。

 

另外一个角色是:

客户机挂载使用client computers  :通过fuse内核接口挂接远程管理服务器上所管理的数据存储服务器,.看起来共享的文件系统和本地unix文件系统使用一样的效果。

 

 

master server:    172.25.11.1
metalogger server:172.25.11.2
chunk server: 172.25.11.3(可以是多台)
client: 172.25.11.4

 

一、搭建Master Server

(1)下载源码包和安装准备

[root@localhost ~]# systemctl stop firewalld.service 
[root@localhost ~]# setenforce 0

[root@localhost ~]# yum install gcc gcc-c++ zlib-devel -y

(2)创建用户

[root@localhost ~]# useradd -s /sbin/nologin mfs

(3)安装源码包

[root@localhost ~]# mkdir /abc
[root@localhost ~]# mount.cifs //172.25.11.1/yjs /abc
Password for root@//172.25.11.1/yjs:
[root@localhost ~]# cd /abc
[root@localhost abc]# ls
mfs-1.6.27-5.tar.gz

[root@localhost abc]# tar zxvf mfs-1.6.27-5.tar.gz -C /opt
[root@localhost abc]# cd /opt/mfs-1.6.27/
[root@localhost mfs-1.6.27]# ./config \
> --prefix=/usr/local/mfs \
> --with-default-user=mfs \
> --with-default-group=mfs \
> --disable-mfschunkserver \
> --disable-mfsmount
[root@localhost mfs-1.6.27]# make
[root@localhost mfs-1.6.27]# make install

(4)复制文件

[root@localhost mfs]# ls
mfsexports.cfg.dist mfsmaster.cfg.dist mfsmetalogger.cfg.dist mfstopology.cfg.dist
[root@localhost mfs]# ll
总用量 16
-rw-r--r--. 1 root root 4060 7月 26 16:39 mfsexports.cfg.dist
-rw-r--r--. 1 root root 1020 7月 26 16:39 mfsmaster.cfg.dist
-rw-r--r--. 1 root root 417 7月 26 16:39 mfsmetalogger.cfg.dist
-rw-r--r--. 1 root root 1123 7月 26 16:39 mfstopology.cfg.dist
[root@localhost mfs]# cp mfsexports.cfg.dist mfsexports.cfg
[root@localhost mfs]# cp mfsmaster.cfg.dist mfsmaster.cfg //挂载权限
[root@localhost mfs]# cp mfstopology.cfg.dist mfstopology.cfg //架构感知

[root@localhost mfs]# cd /usr/local/mfs/var/mfs/
[root@localhost mfs]# ls
metadata.mfs.empty
[root@localhost mfs]# cp metadata.mfs.empty metadata.mfs //防异常退出

(5)启动Master Server

[root@localhost mfs]# /usr/local/mfs/sbin/mfsmaster start

[root@localhost mfs]# ps -ef |grep mfs
mfs 6699 1 2 16:46 ? 00:00:01 /usr/local/mfs/sbin/mfsmaster start
root 6715 1493 0 16:47 pts/0 00:00:00 grep --color=auto mfs //检查是否启动

/usr/local/mfs/sbin/mfsmaster -s //停止Master Server的命令

二、搭建 Metalogger Server

(1)下载源码包及安装准备

[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# setenforce 0

[root@C-7-4 ~]# yum install gcc gcc-c++ zlib-devel -y

(2)创建用户

[root@C-7-4 ~]# useradd -s /sbin/nologin mfs

(3)安装源码包

[root@localhost ~]# mkdir /abc
[root@localhost ~]# mount.cifs //172.25.11.1/yjs /abc
Password for root@//172.25.11.1/yjs:
[root@localhost ~]# cd /abc
[root@localhost abc]# ls
mfs-1.6.27-5.tar.gz

[root@localhost abc]# tar zxvf mfs-1.6.27-5.tar.gz -C /opt
[root@localhost abc]# cd /opt/mfs-1.6.27/
[root@localhost mfs-1.6.27]# ./config \
> --prefix=/usr/local/mfs \
> --with-default-user=mfs \
> --with-default-group=mfs \
> --disable-mfschunkserver \
> --disable-mfsmount

[root@localhost mfs-1.6.27]# make
[root@localhost mfs-1.6.27]# make install

(4)复制文件

[root@C-7-4 mfs-1.6.27]# cd /usr/local/mfs/etc/mfs/
[root@C-7-4 mfs]# ll
总用量 16
-rw-r--r--. 1 root root 4060 4月 2 18:00 mfsexports.cfg.dist
-rw-r--r--. 1 root root 1020 4月 2 18:00 mfsmaster.cfg.dist
-rw-r--r--. 1 root root 417 4月 2 18:00 mfsmetalogger.cfg.dist
-rw-r--r--. 1 root root 1123 4月 2 18:00 mfstopology.cfg.dist
[root@C-7-4 mfs]# cp mfsmetalogger.cfg.dist mfsmetalogger.cfg

[root@C-7-4 mfs]# cd /usr/local/mfs/var/mfs/
[root@C-7-4 mfs]# ls
metadata.mfs.empty
[root@C-7-4 mfs]# cp metadata.mfs.empty metadata.mfs //同样需要设置防异常退出

(5)修改metalogger server配置文件

[root@C-7-4 mfs]# vim mfsmetalogger.cfg
MASTER_HOST = 172.25.11.1 //改为Master Server的ip地址

(6)开启Metalogger Server服务

[root@C-7-4 mfs]# /usr/local/mfs/sbin/mfsmetalogger start

[root@C-7-4 mfs]# ps -ef |grep mfs
mfs 6465 1 0 18:03 ? 00:00:00 /usr/local/mfs/sbin/mfsmetalogger start
root 6467 1497 0 18:04 pts/0 00:00:00 grep --color=auto mfs //检测是否开启

/usr/local/mfs/sbin/mfschunkserver -s //停止Metalogger Server的命令

三、搭建Chunk Server

(1)下载源码包及安装准备

[root@localhost ~]# systemctl stop firewalld.service 
[root@localhost ~]# setenforce 0

[root@localhost ~]# yum install gcc gcc-c++ zlib-devel -y

(2)创建用户

[root@C-7-4 ~]# useradd -s /sbin/nologin mfs

(3)安装源码包

[root@localhost ~]# mkdir /abc
[root@localhost ~]# mount.cifs //192.168.100.1/yjs /abc
Password for root@//172.25.11.1/yjs:
[root@localhost ~]# cd /abc
[root@localhost abc]# ls
mfs-1.6.27-5.tar.gz

[root@localhost abc]# tar zxvf mfs-1.6.27-5.tar.gz -C /opt
[root@localhost abc]# cd /opt/mfs-1.6.27/
[root@localhost mfs-1.6.27]# ./config \
> --prefix=/usr/local/mfs \
> --with-default-user=mfs \
> --with-default-group=mfs \
> --disable-mfsmaster \
> --disable-mfsmount

[root@localhost mfs-1.6.27]# make
[root@localhost mfs-1.6.27]# make install

(4)复制文件

[root@localhost mfs-1.6.27]# cd /usr/local/mfs/etc/mfs/
[root@localhost mfs]# ls
mfschunkserver.cfg.dist mfshdd.cfg.dist
[root@localhost mfs]# cp mfschunkserver.cfg.dist mfschunkserver.cfg
[root@localhost mfs]# cp mfshdd.cfg.dist mfshdd.cfg

(5)修改配置文件

[root@localhost mfs]# vim mfschunkserver.cfg
MASTER_HOST = 172.25.11.1 //改为Master Server的ip地址

[root@localhost mfs]# vim mfshdd.cfg
/data //在这里/data是一个给mfs的分区,最好使用独立的分区或磁盘挂载到此目录

(6)创建挂载目录并赋予权限

[root@localhost mfs]# mkdir /data
[root@localhost mfs]# chown -R mfs.mfs /data

(7)启动 Chunk Server

[root@localhost mfs]# /usr/local/mfs/sbin/mfschunkserver start

[root@localhost mfs]# ps -ef | grep mfs
mfs 7366 1 3 18:12 ? 00:00:00 /usr/local/mfs/sbin/mfschunkserver start
root 7392 1455 0 18:12 pts/0 00:00:00 grep --color=auto mfs

四、配置客户端

(1)下载源码包和安装准备

[root@localhost ~]# systemctl stop firewalld.service 
[root@localhost ~]# setenforce 0

[root@localhost ~]# yum install gcc gcc-c++ zlib-devel -y

(2)安装FUSE源码包

[root@localhost ~]# tar xzvf fuse-2.9.2.tar.gz -C  /opt
[root@localhost ~]# cd /opt/fuse-2.9.7/
[root@localhost fuse-2.9.2]# ./configure
[root@localhost fuse-2.9.2]# make
[root@localhost fuse-2.9.2]# make install

设置环境变量:

[root@localhost fuse-2.9.2]#vi /etc/profile
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
[root@localhost fuse-2.9.2]#source /etc/profile //刷新文件使生效

(3)安装MFS客户端

[root@localhost fuse-2.9.2]# useradd -s /sbin/nologin mfs
[root@localhost abc]# tar zxvf mfs-1.6.27-5.tar.gz -C /opt
[root@localhost abc]# cd /opt/mfs-1.6.27/
[root@localhost mfs-1.6.27]# ./configure \
> --prefix=/usr/local/mfs \
> --with-default-user=mfs \
> --with-default-group=mfs \
> --disable-mfsmaster \
> --disable-mfschunkserver \
> --enable-mfsmount

[root@localhost mfs-1.6.27]# make
[root@localhost mfs-1.6.27]# make install

(4)挂载MFS文件系统

[root@localhost mfs-1.6.27]# mkdir /opt/mfs
[root@localhost mfs-1.6.27]# modprobe fuse
[root@localhost mfs-1.6.27]# /usr/local/mfs/bin/mfsmount /opt/mfs -H 192.168.100.128

[root@localhost mfs-1.6.27]# df -TH
文件系统 类型 容量 已用 可用 已用% 挂载点
192.168.100.128:9421 fuse.mfs 6.4G 0 6.4G 0% /opt/mfs

(5)优化客户端

[root@localhost mfs-1.6.27]#vi /etc/profile
export PATH=/usr/local/mfs/bin:$PATH
[root@localhost mfs-1.6.27]#source /etc/profile

[root@localhost mfs-1.6.27]# mfsgetgoal -r /opt/mfs/
/opt/mfs/:
directories with goal 1 : 1 //mfsgetgoal命令用来查询文件被复制的份数,-r表示递归,goal指文件被复制的份数

五、MFS监控

Mfscgiserv是用python语言编写的一个web服务器,监听端口为9425,可以在Master Server上通过命令 /usr/local/mfs/sbin/mfscgiserv来启动。

在客户端上通过浏览器访问http:Master Server_ip:9425查看

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

举报

相关推荐

0 条评论