CentOS上安装MooseFS分布式文件系统2种方式

作者:袖梨 2022-11-14

方法一

概述:
MooseFS是一种分布式文件系统,MooseFS文件系统结构包括以下四种角色:
  1 管理服务器managing server (master)
  2 元数据日志服务器Metalogger server(Metalogger)
  3 数据存储服务器data servers (chunkservers)
  4 客户机挂载使用client computers

各种角色作用:
   1 管理服务器:负责各个数据存储服务器的管理,文件读写调度,文件空间回收以及恢复.多节点拷贝
   2 元数据日志服务器: 负责备份master服务器的变化日志文件,文件类型为changelog_ml.*.mfs,以便于在master server出问题的时候接替其进行工作
   3 数据存储服务器:负责连接管理服务器,听从管理服务器调度,提供存储空间,并为客户提供数据传输.
   4 客户端: 通过fuse内核接口挂接远程管理服务器上所管理的数据存储服务器,.看起来共享的文件系统和本地unix文件系统使用一样的效果.

安装环境
Master Server
master 10.0.0.141 Centos5.5(64X)

Metalogger Server
metalogger 10.0.0.142 Centos5.5(64X)

Chunk Servers
chunk01 10.0.0.143 Centos5.5(64X)
chunk02 10.0.0.144 Centos5.5(64X)

Client Server
client01 10.0.0.150 Centos5.5(64X)
client02 10.0.0.155 Centos5.5(64X)


——————————————————————————————————-
master 安装(10.0.0.141)

mkdir -p /root/tools/moosefs/
cd /root/tools/moosefs/

/usr/sbin/groupadd -g 660 mfs
/usr/sbin/useradd -g mfs mfs -u 660 -s /sbin/nologin

wget http://www.moosefs.org/tl_files/mfscode/mfs-1.6.20-2.tar.gz
tar zxvf mfs-1.6.20-2.tar.gz
cd mfs-1.6.20-2
./configure
–prefix=/elain/apps/mfs
–sysconfdir=/elain/apps/mfs/etc
–localstatedir=/elain/apps/mfs/lib
–with-default-user=mfs
–with-default-group=mfs
–disable-mfschunkserver
–disable-mfsmount
make && make install
cd ..

cd /elain/apps/mfs/etc/
cp mfsmaster.cfg.dist mfsmaster.cfg
cp mfsmetalogger.cfg.dist mfsmetalogger.cfg
cp mfsexports.cfg.dist mfsexports.cfg

vi mfsexports.cfg

10.0.0.0/24 / rw,alldirs,maproot=0

cd /elain/apps/mfs/lib/mfs
cp metadata.mfs.empty metadata.mfs

vi /etc/hosts

10.0.0.141 mfsmaster

运行mfs服务
/elain/apps/mfs/sbin/mfsmaster start

master metaloggers module: listen on *:9419
master chunkservers module: listen on *:9420
main master server module: listen on *:9421

运行监控平台
/elain/apps/mfs/sbin/mfscgiserv

starting simple cgi server (host: any , port: 9425 , rootpath: /elain/apps/mfs/share/mfscgi)

这时,可通过浏览器访问:http://10.0.0.141:9425/ 查看 master 的运行情况

——————————————————————————————————–
metalogger 安装(10.0.0.142)

cd /root/tools/
/usr/sbin/groupadd -g 660 mfs
/usr/sbin/useradd -g mfs mfs -u 660 -s /sbin/nologin

wget http://www.moosefs.org/tl_files/mfscode/mfs-1.6.20-2.tar.gz
tar zxvf mfs-1.6.20-2.tar.gz
cd mfs-1.6.20-2
./configure
–prefix=/elain/apps/mfs
–sysconfdir=/elain/apps/mfs/etc
–localstatedir=/elain/apps/mfs/lib
–with-default-user=mfs
–with-default-group=mfs
–disable-mfschunkserver
–disable-mfsmount
make && make install
cd ..

cd /elain/apps/mfs/etc/
cp mfsmetalogger.cfg.dist mfsmetalogger.cfg

vi /etc/hosts

10.0.0.141 mfsmaster

/elain/apps/mfs/sbin/mfsmetalogger start

——————————————————————————————————-
Chunk01 安装(10.0.0.143)

cd /root/tools/

/usr/sbin/groupadd -g 660 mfs
/usr/sbin/useradd -g mfs mfs -u 660 -s /sbin/nologin

wget http://www.moosefs.org/tl_files/mfscode/mfs-1.6.20-2.tar.gz
tar zxvf mfs-1.6.20-2.tar.gz
cd mfs-1.6.20-2
./configure
–prefix=/elain/apps/mfs
–sysconfdir=/elain/apps/mfs/etc
–localstatedir=/elain/apps/mfs/lib
–with-default-user=mfs
–with-default-group=mfs
–disable-mfsmaster
make && make install
cd ..

cd /elain/apps/mfs/etc/
cp mfschunkserver.cfg.dist mfschunkserver.cfg
cp mfshdd.cfg.dist mfshdd.cfg

vi /etc/hosts

10.0.0.141 mfsmaster

mkdir /data/mfschunks{1,2}
chown -R mfs:mfs /data/mfschunks{1,2}

vi /elain/apps/mfs/etc/mfshdd.cfg

/data/mfschunks1
/data/mfschunks2

/elain/apps/mfs/sbin/mfschunkserver start

————————————————————————————————-
Chunk02 安装(10.0.0.144)
cd /root/tools/
/usr/sbin/groupadd -g 660 mfs
/usr/sbin/useradd -g mfs mfs -u 660 -s /sbin/nologin

wget http://www.moosefs.org/tl_files/mfscode/mfs-1.6.20-2.tar.gz
tar zxvf mfs-1.6.20-2.tar.gz
cd mfs-1.6.20-2
./configure
–prefix=/elain/apps/mfs
–sysconfdir=/elain/apps/mfs/etc
–localstatedir=/elain/apps/mfs/lib
–with-default-user=mfs
–with-default-group=mfs
–disable-mfsmaster
make && make install
cd ..

cd /elain/apps/mfs/etc/
cp mfschunkserver.cfg.dist mfschunkserver.cfg
cp mfshdd.cfg.dist mfshdd.cfg

vi /etc/hosts

10.0.0.141 mfsmaster

mkdir /data/mfschunks{1,2}
chown -R mfs:mfs /data/mfschunks{1,2}

vi /elain/apps/mfs/etc/mfshdd.cfg

/data/mfschunks1
/data/mfschunks2

/elain/apps/mfs/sbin/mfschunkserver start

——————————————————————————————————————
Client01 Server安装 (10.0.0.150)

cd /root/tools/
/usr/sbin/groupadd -g 660 mfs
/usr/sbin/useradd -g mfs mfs -u 660 -s /sbin/nologin

wget http://cdnetworks-kr-2.dl.sourceforge.net/project/fuse/fuse-2.X/2.8.5/fuse-2.8.5.tar.gz
tar -zxvf fuse-2.8.5.tar.gz
cd fuse-2.8.5
./configure
make
make install
cd ..

运行以下export命令,否则挂载moosefs系统会失败

vi /etc/profile
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
source /etc/profile

cd /root/tools/moosefs/
wget http://www.moosefs.org/tl_files/mfscode/mfs-1.6.20-2.tar.gz
tar -zxvf mfs-1.6.20-2.tar.gz
cd mfs-1.6.20-2
./configure
–prefix=/elain/apps/mfs
–sysconfdir=/elain/apps/mfs/etc
–localstatedir=/www/lib
–with-default-user=mfs
–with-default-group=mfs
–enable-mfsmount
make && make install
cd ..

vi /etc/hosts

10.0.0.141 mfsmaster

挂接操作
mkdir -p /elain/data/htdocs/elain/upload
/elain/apps/mfs/bin/mfsmount /elain/data/htdocs/elain/upload/ -H mfsmaster
umount -l /elain/data/htdocs/elain/upload

————————————————————————————————————-
Client02 Server安装 (10.0.0.155)
cd /root/tools/
/usr/sbin/groupadd -g 660 mfs
/usr/sbin/useradd -g mfs mfs -u 660 -s /sbin/nologin

wget http://cdnetworks-kr-2.dl.sourceforge.net/project/fuse/fuse-2.X/2.8.5/fuse-2.8.5.tar.gz
tar zxvf fuse-2.8.5.tar.gz
cd fuse-2.8.5
./configure
make
make install
cd ..

运行以下export命令,否则挂载moosefs系统会失败

vi /etc/profile
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
source /etc/profile

#加载fuse
modprobe fuse

[root@web1 ~#]lsmod |grep fuse
fuse 83057 8

wget http://www.moosefs.org/tl_files/mfscode/mfs-1.6.20-2.tar.gz
tar -zxvf mfs-1.6.20-2.tar.gz
cd mfs-1.6.20-2
./configure
–prefix=/elain/apps/mfs
–sysconfdir=/elain/apps/mfs/etc
–localstatedir=/elain/apps/mfs/lib
–with-default-user=mfs
–with-default-group=mfs
–enable-mfsmount
make && make install
cd ..

vi /etc/hosts

10.0.0.141 mfsmaster

挂接操作
mkdir -p /mnt/mfs
/elain/apps/mfs/bin/mfsmount /mnt/mfs -H mfsmaster

安装完毕。

停止 MooseFS
为了安全停止 MooseFS 集群,建议执行如下的步骤:

umount -l /mnt/mfs #客户端卸载MooseFS 文件系统
/elain/apps/mfs/sbin/mfschunkserver stop #停止 chunk server 进程
/elain/apps/mfs/sbin/mfsmetalogger stop #停止 metalogger 进程
/elain/apps/mfs/sbin/mfsmaster stop #停止主控 master server 进程

安全的启动MooseFS集群

/elain/apps/mfs/sbin/mfsmaster start #启动 master 进程
/elain/apps/mfs/sbin/mfschunkserver start #启动 chunkserver 进程
/elain/apps/mfs/sbin/mfsmetalogger start #启动 metalogger 进程
/elain/apps/mfs/bin/mfsmount /mnt/mfs -H master #客户端挂载 MooseFS 文件系统

MooseFS 命令的使用方法及参考文档:
http://www.moosefs.org/reference-guide.html#using-moosefs

http://www.moosefs.org/moosefs-faq.html

FAQ:
/elain/apps/mfs/bin/mfsmount /elain/data/htdocs/elain/upload -H master
mfsmaster accepted connection with parameters: read-write,restricted_ip ; root mapped to root:root
fuse: device not found, try 'modprobe fuse' first
error in fuse_mount
答:modprobe fuse
[root@client01 ~]# lsmod |grep fuse
fuse 83057 6

方法二

环境介绍:
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


1 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


1 document.location.href="/cgi-bin/mfs/mfs.cgi"
sudo vim /etc/httpd/conf/httpd.conf


1 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


1 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


1 MASTER_HOST = 10.197.29.251
sudo vim mfshdd.cfg


1 /mnt/mfschunks1

2 /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


1 mfsmaster accepted connection with parameters: read-write,restricted_ip ; root mapped to root:root
df -h | grep mfs


1 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


1 server2.txt

相关文章

精彩推荐