一、獲取源碼安裝包
到官網下載最新版本moosefs:
https://moosefs.com/download/sources-archive-3-0.html
到官網下載最新版本fuse源碼
https://github.com/libfuse/libfuse
也可以下載rpm包:
http://www.rpmfind.net/linux/rpm2html/search.php?query=libfuse-devel
還可以:
yum install -y fuse fuse-devel
二、安裝
先添加mfs用戶:
[root@localhost mfs]# groupadd mfs
[root@localhost mfs]# useradd -g mfs mfs
然后就是正常的源碼安裝過程:
[root@local mfs]#./configure --prefix=/usr/local/moosefs --sysconfdir=/etc --localstatedir=/var/lib --with-default-user=mfs --with-default-group=mfs
[root@local mfs]# make
[root@local mfs]# makeinstall
configure中--disable-mfschunkserver --disable-mfsmount --disable-mfsmaster這三個是可選項,比如使用前兩個,就表示服務器上只裝master,metalogserver和master是一樣的。
三、修改配置文件
[root@localhost mfs]# cd /etc/mfs [root@localhost mfs]# cp mfsmaster.cfg.sample mfsmaster.cfg [root@localhost mfs]# cp mfsmetalogger.cfg.sample mfsmetalogger.cfg [root@localhost mfs]# cp mfsexports.cfg.sample mfsexports.cfg [root@localhost mfs]# vi mfsexports.cfg * / rw,alldirs,ignoregid,maproot=0:0,mapall=0:0 [root@localhost mfs]# cd /var/lib/mfs [root@localhost mfs]# cp metadata.mfs.empty metadata.mfs [root@localhost mfs]# chown -R mfs:mfs /var/lib/mfs [root@localhost mfs]# vi /etc/hosts 192.168.1.1 mfsmaster
修改配置文件,基本上是把原來命名的配置文件樣例重新命名成標准配置文件;
mfsexports.cfg中的配置文件,是為了賦予訪問權限;
/etc/hosts中標識master的ip,是為了給mfscgiserv和mfschunkserver找mfsmaster用的。
四、啟動和停止
啟動:
[root@lh mfs]# mfsmaster start
[root@lh mfs]# mfscgiserv start
[root@lh mfs]# mfsmetalogger start
[root@lh mfs]# mfschunkserver start
停止:
[root@lh mfs]# mfsmaster stop
[root@lh mfs]# mfscgiserv stop
[root@lh mfs]# mfsmetalogger stop
[root@lh mfs]# mfschunkserver stop
五、mfs的使用
安裝好后就到有mfsmount的的服務器上掛載一個本地目錄:(后面跟的是master的ip)
[root@lh mfs]mfsmount /mnt/mfs/ -H 192.168.1.1
其實本身mfsmount就相當於是一個客戶端。使用的時候就把掛載的目錄當成本地的磁盤目錄一樣使用即可。不過此目錄使用的是mfschunk上的空間,而操作這個雲文件系統的命令都封裝在在mfstool中:
[root@lh mfs]# man mfstools
Mossefs整個系統的狀態(mfschunk、mfsmaster、mfsmount、mfsmetalogger和文件等)的狀態都可以用mfs自帶的cgi查看,網址:
" http://ip.to.mfscgi.server:9425/ "
其中goal表示一個文件復制了幾份,copy表示文件放在了幾個服務器上,這些也都可以用mfstools中的fileinfo和checkfile命令查看。
六、mfs見過的錯誤和解決方法
1、mfsmount取消掛載的問題:
ps -ef | grep mfsmount fuser -m -k -i [mfsmountpid] 如果不行就 kill -9 [mfsmountpid] 如果df或者訪問/path/to/mountdir卡死,那么就 umount -l /mnt/mfs 然后killall mfsmount
當然卡死也有可能是由於與服務端網絡不通斷開連接,這種情況下kill掉mfsmount會導致mfsmount編程僵屍進程,
所以建議在mfsmount時加上參數-o mfstimeout N來指定IO出錯的超時時間。
2、新加的服務器死活連到master上都是disconnect的狀態
到mfschunkserver所在的服務器:
[root@lh mfs]#tail -100f /var/log/message [root@lh mfs]#Aug 11 11:24:14 localhost mfschunkserver[15871]: connected to Master [root@lh mfs]#Aug 11 11:24:14 localhost mfschunkserver[15871]: MATOCS_MASTER_ACK - wrong meta data id. Can't connect to master
那么就清空/var/lib/mfs目錄,
然后到好的chunkserver的disk(也就是mfschunk1,2,3之類的)目錄下復制".metaid"文件到目標disk,問題就可以解決了。
3、權限問題
can't create lockfile in working directory: Permission denied
[root@lh mfs]# chown -R mfs:mfs /path/to/thatdir
4、目錄非空
fuse: mountpoint is not empty
那就刪了再來,或者換個目錄,或者修復:
fsck -y /dev/sda1