Moosefs文件系统搭建

系统Centos 7

MfsMaster:192.168.1.100
MfsChukserver1:192.168.1.110
MfsChukserver2:192.168.1.120
MfsMetalogger:192.168.1.130
MfsClient:192.168.1.140

1.安装Mfs软件包

MfsMaster:
curl "http://ppa.moosefs.com/RPM-GPG-KEY-MooseFS" > /etc/pki/rpm-gpg/RPM-GPG-KEY-MooseFS
curl "http://ppa.moosefs.com/MooseFS-3-el7.repo" > /etc/yum.repos.d/MooseFS.repo
yum install moosefs-master moosefs-cgi moosefs-cgiserv moosefs-cli

MfsChukserver1,MfsChukserver2:
curl "http://ppa.moosefs.com/RPM-GPG-KEY-MooseFS" > /etc/pki/rpm-gpg/RPM-GPG-KEY-MooseFS
curl "http://ppa.moosefs.com/MooseFS-3-el7.repo" > /etc/yum.repos.d/MooseFS.repo
yum install moosefs-chunkserver

MfsMetalogger:
curl "http://ppa.moosefs.com/RPM-GPG-KEY-MooseFS" > /etc/pki/rpm-gpg/RPM-GPG-KEY-MooseFS
curl "http://ppa.moosefs.com/MooseFS-3-el7.repo" > /etc/yum.repos.d/MooseFS.repo
yum install moosefs-metalogger

2.修改Hosts文件,在所有节点上为192.168.1.100增加一个别名mfsmaster

vim /etc/hosts
192.168.1.100   mfsmaster
wq!

3.启动程序(Master)

systemctl start moosefs-master
systemctl start moosefs-cgiserv
[root@MoosefsMaster mfs]# netstat -lntp | grep mfs
tcp        0      0 0.0.0.0:9419            0.0.0.0:*               LISTEN      1031/mfsmaster      
tcp        0      0 0.0.0.0:9420            0.0.0.0:*               LISTEN      1031/mfsmaster      
tcp        0      0 0.0.0.0:9421            0.0.0.0:*               LISTEN      1031/mfsmaster      
mfsmaster开启三个端口:客户端连接9421端口,监听9422端口;数据节点9420端口

4.修改MfsMetalogger配置文件,使其连接到Master,并启动

vim /etc/mfs/mfsmetalogger.cfg
MASTER_HOST = mfsmaster       # 这里是需要连接的 mfs master server 的地址
systemctl start moosefs-metalogger

5.修改MfsChukserver1,MfsChukserver2

分别是 mfschunkserver.cfg 和 mfshdd.cfg
配置mfschunkserver.cfg 
vim /etc/mfs/mfschunkserver.cfg
MASTER_HOST = mfsmaster        # 该地址为 Master Server 的IP地址或者主机名

配置mfshdd.cfg
mfshdd.cfg该文件用来设置你将 Chunk Server 的哪个目录共享出去给 Master Server进行管理
mkdir /mfsshare
chown -R mfs.mfs /mfsshare
vim /etc/mfs/mfshdd.cfg
/mfsshare
wq!

systemctl start moosefs-chunkserver

ls /mfsshare
00  10  20  30  40  50  60  70  80  90  A0  B0  C0  D0    DF  EF  FF
01  11  21  31  41  51  61  71  81  91  A1  B1  C1  D1    E0  F0  
02  12  22  32  42  52  62  72  82  92  A2  B2  C2  D2    E1  F1
03  13  23  33  43  53  63  73  83  93  A3  B3  C3  D3    E2  F2
04  14  24  34  44  54  64  74  84  94  A4  B4  C4  D4    E3  F3
05  15  25  35  45  55  65  75  85  95  A5  B5  C5  D5    E4  F4
06  16  26  36  46  56  66  76  86  96  A6  B6  C6  D6    E5  F5
07  17  27  37  47  57  67  77  87  97  A7  B7  C7  D7    E6  F6
08  18  28  38  48  58  68  78  88  98  A8  B8  C8  D8    E7  F7
09  19  29  39  49  59  69  79  89  99  A9  B9  C9  D9    E8  F8
0A  1A  2A  3A  4A  5A  6A  7A  8A  9A  AA  BA  CA  DA    E9  F9
0B  1B  2B  3B  4B  5B  6B  7B  8B  9B  AB  BB  CB  DB    EA  FA
0C  1C  2C  3C  4C  5C  6C  7C  8C  9C  AC  BC  CC  DC    EB  FB
0D  1D  2D  3D  4D  5D  6D  7D  8D  9D  AD  BD  CD  DD    EC  FC
0E  1E  2E  3E  4E  5E  6E  7E  8E  9E  AE  BE  CE  DE    ED  FD

6.Mfs客户端安装挂载

yum install moosefs-client
mfsmount /mnt -H 192.168.10.2    # 使用 -p 后面,下面会提示输入密码 
[root@MfsClient ~]# df -TH
Filesystem        Type      Size  Used Avail Use% Mounted on
/dev/sda2         ext4       20G  2.4G   16G  14% /
tmpfs             tmpfs     981M     0  981M   0% /dev/shm
/dev/sda1         ext4      508M   34M  448M   7% /boot
192.168.1.100:9421 fuse.mfs   21G  856M   20G   5% /mnt

开机挂载
echo '/usr/bin/mfsmount /mfsshare -H 192.168.1.100 ' >> /etc/rc.local

推荐阅读更多精彩内容