ChinaUnix首页 > 精华文章 > BSD > 正文

[精彩] freebsd-MOOSEFS-MFS实施笔记!!


http://www.chinaunix.net 作者:vitas333  发表于:2009-07-11 08:20:46
发表评论】 【查看原文】 【BSD讨论区】【关闭

引用:原帖由 zhengwei_zw 于 2009-4-6 20:14 发表 [url=http://bbs.chinaunix.net/redirect.php?goto=findpost&pid=10343688&ptid=1422602]
MFS分布式文件系统架设笔记
什么是MFS文件系统?
    Moose File System 是一个具备容错功能的网络分布式文件系统,它将数据分布在网络中的不同服务器上,MooseFS 通过 FUSE 使之看起来就是一个 Unix 的文件系 ... 




看了这篇文章,自己进行了实施。以下是自己的实施过程。  

[color=blue]之前看过的文章都要配置ports,我觉得太麻烦了,还是pkg_add 方便,所以下面就没用ports 。当然,如果服务器以后还有别的用途,还是配置下ports,我就不多累赘。[/color]

################################

个人联系方式:
[color=green]MSN: harley.chen at  msn 点 com
QQ :  二八二久三 two two two 久[/color]


################################


[attach]331807[/attach]
[attach]331808[/attach]


系统 freebsd 7.2: 
[color=darkred]master:  1台  192.168.150.7
data: 2台       192.168.150.8   192.168.150.9
client: 1台      192.168.150.10 [/color]


[color=darkred]1: 系统安装。[/color]

全部统一 选择mini 最小安装。 如果是客户端client,请一起安装 sys.  因为fuse需要用到source 。
[color=indigo]sysinstall--configure--Distributions---src --sys[/color]  应该很容易安装了。具体就不详细解说。

[color=darkred]2: 设置好网络ip。[/color] 
   确定能连接网络。  主要是设置/etc/rc.conf, 和 /etc/resolv.conf

以下是我的2个文件的设置,各自环境修 ,自己改下。

master: 
=======================================================
[color=indigo]# cat /etc/rc.conf

# -- sysinstall generated deltas -- # Mon May 18 11:51:48 2009
# Created: Mon May 18 11:51:48 2009
# Enable network daemons for user convenience.
# Please make all changes to this file, not to /etc/defaults/rc.conf.
# This file now contains just the overrides from /etc/defaults/rc.conf.
keymap="us.iso"
ifconfig_le0="inet 192.168.150.7 netmask 255.255.255.0"
defaultrouter="192.168.150.2"
sshd_enable="yes"
[color=Blue]fusefs_enable="yes"[/color]   ===========>>  [color=Red]因为之前测试,装了下fuse,如果Master没有装fuse,这里可以去掉。应该是不影响的[/color]
hostname="master.local"


# cat /etc/resolv.conf
nameserver 192.168.150.2
[/color]
=======================================================



data1:
=======================================================

[color=indigo]# cat /etc/rc.conf

# -- sysinstall generated deltas -- # Mon May 18 11:51:48 2009
# Created: Mon May 18 11:51:48 2009
# Enable network daemons for user convenience.
# Please make all changes to this file, not to /etc/defaults/rc.conf.
# This file now contains just the overrides from /etc/defaults/rc.conf.
keymap="us.iso"
ifconfig_le0="inet 192.168.150.8 netmask 255.255.255.0"
defaultrouter="192.168.150.2"
sshd_enable="yes"
hostname="data1.local"

# cat /etc/resolv.conf
nameserver 192.168.150.2
[/color]

=======================================================


data2,client1 类似,就不多累赘。


[color=darkred]3:安装mfs的master组件:[/color]

  我这统一新建组 和用户,mfs:mfs。
  
[color=indigo]pw groupadd mfs
pw useradd mfs -g mfs -s /sbin/nologin -d /sbin/nologin

fetch [url=http://www.moosefs.com/files/mfs-1.5.12.tar.gz]http://www.moosefs.com/files/mfs-1.5.12.tar.gz
tar zxvf mfs-1.5.12.tar.gz
cd mfs-1.5.12
./configure --prefix=/usr/local/mfs --with-default-user=mfs --with-default-group=mfs  && make && make install
[/color]


就可以直接启动master了
[color=indigo]/usr/local/mfs/sbin/mfsmaster start[/color]

设置开机启动。
[color=indigo]# cat /etc/rc.local
/usr/local/mfs/sbin/mfsmaster start[/color]


************************************************************
如果以上不能安装成功。估计需要安装fuse相关组件 。可以通过
[color=indigo]pkg_add -r fusefs-kmod fusefs-libs pkg-config[/color]
命令进行添加。个人觉得master可以不需要。除非你要同时做客户端挂载mfs磁盘。
************************************************************



[color=darkred]4: 安装data服务器[/color]
这里以data1作为案例解说,其他data服务器照搬即可。

我这 每台data服务器都是双硬盘,其中一块硬盘作为mfs挂载来用。
将第二块磁盘分区好。设置好挂载点。  挂载点 为/data1.

[color=indigo]sysinstall---custom--partition [/color]  选择a, 然后w。 最后q。  (这个就不用解释了)
@  [color=indigo]sysinstall---custom--lable [/color]     选择 c 。  整个磁盘, 挂载点设置为/data1. 保存退出即可。  其他data数据服务器设置类同。

同时设置下/data1属主:
chmod -R mfs:mfs /data1



按照master前期步骤,安装设置好相关信息。
安装mfs.

[color=indigo]pw groupadd mfs
pw useradd mfs -g mfs -s /sbin/nologin -d /sbin/nologin


fetch [url=http://www.moosefs.com/files/mfs-1.5.12.tar.gz]http://www.moosefs.com/files/mfs-1.5.12.tar.gz
tar zxvf mfs-1.5.12.tar.gz
cd mfs-1.5.12
./configure --prefix=/usr/local/mfs --with-default-user=mfs --with-default-group=mfs  && make && make install

[/color]

设置master连接信息,以及数据存储路径。


vi /usr/local/mfs/etc/mfschunkserver.cfg

==================================================
[color=indigo]# cat mfschunkserver.cfg
# WORKING_USER = mfs
# WORKING_GROUP = mfs

# DATA_PATH = /usr/local/mfs/var/mfs
# LOCK_FILE = /var/run/mfs/mfschunkserver.pid
# SYSLOG_IDENT = mfschunkserver

# BACK_LOGS = 50

# MASTER_RECONNECTION_DELAY = 30

MASTER_HOST = 192.168.150.7
MASTER_PORT = 9420

# MASTER_TIMEOUT = 60

# CSSERV_LISTEN_HOST = *
# CSSERV_LISTEN_PORT = 9422

# CSSERV_TIMEOUT = 60

# CSTOCS_TIMEOUT = 60

# HDD_CONF_FILENAME = /usr/local/mfs/etc/mfshdd.cfg
#
[/color]

==================================================


数据存储全部清空,设置自己的挂载点,我这 是/ad1.

[color=indigo]# cat mfshdd.cfg
/ad1
[/color]


设置开机启动
[color=indigo]# cat /etc/rc.local
/usr/local/mfs/sbin/mfschunkserver start


[/color]

[color=darkred]5: 安装mfs客户端[/color]

客户端系统安装需要用到fuse 组件。


@ sources安装,(光盘安装的)[color=indigo]sysinstall--configure--Distributions---src --sys[/color]

[color=indigo]pkg_add -r fusefs-kmod fusefs-libs pkg-config[/color]



**************************************************************
这里说明下,我个人觉得没有必要单独安装fuse了,如果上面方法安装后,没法用
可以自己下载fuse包,单独配置下。
[color=indigo]fetch  [url=http://nchc.dl.sourceforge.net/sourceforge/fuse/fuse-2.7.4.tar.gz]http://nchc.dl.sourceforge.net/sourceforge/fuse/fuse-2.7.4.tar.gz 
tar zxvf fuse-2.7.4.tar.gz
cd fuse-2.7.4
./configure && make && make install[/color]

**************************************************************

[color=indigo]



pw groupadd mfs
pw useradd mfs -g mfs -s /sbin/nologin -d /sbin/nologin

fetch  [url=http://www.moosefs.com/files/mfs-1.5.12.tar.gz]http://www.moosefs.com/files/mfs-1.5.12.tar.gz 
tar zxvf mfs-1.5.12.tar.gz
cd mfs-1.5.12
./configure --prefix=/usr/local/mfs --with-default-user=mfs --with-default-group=mfs --enable-mfsmount  && make && make install

rehash (刷新)
[/color]

设置客户端挂载目录

mkdir /mfsclient1


连接mfs网络分区:

[color=indigo]/usr/local/mfs/bin/mfsmount -h 192.168.150.7  -w /mfsclient1[/color]
(各个参数就不多说,一看就好理解。)

开机挂载:

[color=indigo]cat /etc/rc.local
/usr/local/mfs/bin/mfsmount -h 192.168.150.7  -w /mfsclient1[/color]



基本架设完毕。


其中有一部分 疑问。就是安全优化部分,比如mfsgetgoal 命令,就提示出错了
暂时没有深入研究。 大家有空的可以看看 国外主站点上的说明。如果有知道的 请告诉我下,谢谢。
这是我的出错信息。
[attach]331802[/attach]



其中安装部分也可以利用参数,单一设置各个服务器安装的角色,比如仅作为master, data, client  对应参数如下:

[color=indigo]Source package supports standard ./configure && make && make install procedure. Significant configure options are:

--disable-mfsmaster - don't build managing server (useful for plain node installation) 
--disable-mfschunkserver - don't build chunkserver 
--disable-mfsmount - don't build mfsmount and mfstools (they are built by default if fuse development package is detected) 
--enable-mfsmount - make sure to build mfsmount and mfstools (error is reported if fuse development package cannot be found) 
--prefix=DIRECTORY - install to given prefix (default is /usr/local) 
--sysconfdir=DIRECTORY - select configuration files directory (default is ${prefix}/etc) 
--localstatedir=DIRECTORY - select top variable data directory (default is ${prefix}/var; MFS metadata are stored in mfs subdirectory, i.e. ${prefix}/var/mfs by default) 
--with-default-user=USER - user to run daemons as if not set in configuration files (default is nobody) 
--with-default-group=GROUP - group to run daemons as if not set in configuration files (default is nogroup)[/color]


[ 本帖最后由 vitas333 于 2009-5-20 10:50 编辑 ]


















 axlrose 回复于:2009-05-20 09:38:53

好文,顶一个


 nzg88992 回复于:2009-05-20 10:16:07

不错文章 有机会 用用


 cathyleung 回复于:2009-05-21 14:18:42

确实是好文章~


 xiaoqi8866 回复于:2009-05-22 11:16:35

你比我慢了一天 我是 18号  搞定的 。

我搞的是 2台 linux  完成的 MFS 。


 OraBSD 回复于:2009-05-22 12:10:35

笔记呢?


 vitas333 回复于:2009-05-24 10:48:04

最近不知道研究啥.. 刚看了mfs 所以就 实施了下..  希望各位大佬 多多指教...   现在感觉学什么都没啥方向了...  想研究研究有意思的项目....


 聪明笨小孩 回复于:2009-06-08 10:28:26

谢谢


 剑心通明 回复于:2009-06-08 10:43:52

转载了,呵呵


 5sky 回复于:2009-06-08 17:10:13

好文 ,收藏了


 yuyuou 回复于:2009-06-28 21:27:03

好文,顶一个。


 sopato 回复于:2009-07-04 17:49:32

收藏一下,以后肯定能用得上的。


 huowz 回复于:2009-07-11 08:20:46

好文,收藏一下。




原文链接:http://bbs.chinaunix.net/viewthread.php?tid=1457559
转载请注明作者名及原文出处