在CentOS上安装部署MooseFS分布式文件系统


参考资料:
http://www.moosefs.org/tl_files/manpageszip/moosefs-step-by-step-tutorial-cn-v.1.1.pdf

环境介绍:
OS: CentOS 6.3 x86_64
server1 - mfsmaster & mfschunkserver
server2 - mfsmetalogger & mfschunkserver & mfsclient
server3 - mfschunkserver

1. 什么是MooseFS
MooseFS是一个具有容错能力的分布式文件系统,支持挂载(通过FUSE)和与本地文件系统相同的操作。

MooseFS具有以下几个角色:
主服务器:Managing Server(master server)
数据节点:Data server(chunk servers)
备份服务器:Metadata backup servers(metalogger servers)
客户端:Client computers that access(mount) the files in MooseFS

2. 安装配置主服务器(仅在server1上)
sudo rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
sudo rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
sudo yum install mfs

cd /etc/mfs
sudo cp mfsmaster.cfg.dist mfsmaster.cfg
sudo cp mfsmetalogger.cfg.dist mfsmetalogger.cfg
sudo cp mfsexports.cfg.dist mfsexports.cfg

修改主服务器的地址,比如10.197.29.251
sudo vim /etc/mfsmetalogger.cfg

MASTER_HOST = 10.197.29.251

初始化数据文件
cd /var/mfs
sudo cp metadata.mfs.empty metadata.mfs

安装WEB界面支持
sudo yum install mfs-cgi httpd
sudo vim /var/www/html/mfs/index.html

 document.location.href="/cgi-bin/mfs/mfs.cgi"

sudo vim /etc/httpd/conf/httpd.conf

Listen 9480

sudo /etc/init.d/mfsmaster restart
sudo /etc/init.d/httpd restart

访问WEB界面
http://server1:9480/mfs/

如下图所示

3. 安装配置备份服务器(仅在server2上)
sudo rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
sudo rpm -ivh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

sudo yum install mfs

cd /etc/mfs
sudo cp mfsmetalogger.cfg.dist mfsmetalogger.cfg

sudo vim /etc/mfsmetalogger.cfg

MASTER_HOST = 10.197.29.251

sudo /etc/init.d/mfsmetalogger restart

4. 安装配置数据节点(在server1-3上)
sudo rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
sudo rpm -ivh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

sudo yum install mfs

cd /etc/mfs
sudo cp mfschunkserver.cfg.dist mfschunkserver.cfg
sudo cp mfshdd.cfg.dist mfshdd.cfg

sudo vim mfschunkserver.cfg

MASTER_HOST = 10.197.29.251

sudo vim mfshdd.cfg

/mnt/mfschunks1
/mnt/mfschunks2

sudo mkdir /mnt/mfschunks1 /mnt/mfschunks2
sudo chown -R daemon:daemon /mnt/mfschunks*

sudo /etc/init.d/mfschunkserver restart

访问WEB界面,检查新增的chunkserver
http://server1:9480/cgi-bin/mfs/mfs.cgi?sections=CS

5. 安装配置客户端(在server2-3上)
sudo rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
sudo rpm -ivh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

sudo yum install mfs-client

sudo mkdir -p /mnt/mfsmount
sudo chown -R daemon:daemon /mnt/mfsmount

sudo mfsmount /mnt/mfsmount -H 10.197.29.251

mfsmaster accepted connection with parameters: read-write,restricted_ip ; root mapped to root:root

df -h | grep mfs

10.197.29.251:9421         25G     0   25G   0% /mnt/mfs

6. 测试MooseFS
在server2上创建文件server2.txt:
cd /mnt/mfsmount
echo "I am from server2" > server2.txt

在server3上检查文件是否存在:
cd /mnt/mfsmount

ls

server2.txt

  1. #1 by mcsrainbow on 2013/05/28 - 15:58

    最近在学习使用Salt,一个类似于Func+Puppet的自动化部署工具,以这篇文章为实践基础,通过Salt实现了自动化的安装部署,具体相关代码可以在 https://github.com/mcsrainbow/salt-states-moosefs 上看到。

  2. #2 by Juefei on 2013/06/18 - 17:10

    东哥这个碉堡了,赶紧学习之

(will not be published)
*