MFS分佈式文件系統

一、MFS 簡介:

MooseFS是一個具有容錯性的網絡分佈式文件系統。它把數據分散存放在多個物理服務器上,而呈現給用戶的則是一個統一的資源。

(1)優勢:

1、高可靠(數據的多個拷貝被存儲在不同的計算機上);
2、通過附加新的計算機或者硬盤可以實現容量的動態擴展;
3、刪除的文件可以根據一個可配置的時間週期進行保留(一個文件系統級別的回收站);
4、不受訪問和寫入影響的文件連貫快照。

(2)體系結構:

1、管理服務器(master server):
一臺管理整個文件系統的獨立主機,存儲着每個文件的元數據(文件的大小、屬性、位置信息,包括所有非常規文件的所有信息,例如目錄、套接字、管道以及設備文件)
2、數據服務器羣(chunk servers):
任意數目的商用服務器,用來存儲文件數據並在彼此之間同步(如果某個文件有超過一個備份的話)
3、元數據備份服務器(metalogger server):
任意數量的服務器,用來存儲元數據變化日誌並週期性下載主要元數據文件,以便用於管理服務器意外停止時好接替其位置。
4、訪問mfs的客戶端:
任意數量的主機,可以通過mfsmount進程與管理服務器(接收和更改元數據)和數據服務器(改變實際文件數據)進行交流。

搭建MFS分佈式文件系統

修改服務器主機名

[root@localhost ~]# hostnamectl set-hostname master
[root@localhost ~]# su
[root@master ~]#

[root@localhost ~]# hostnamectl set-hostname log
[root@localhost ~]# su
[root@log ~]#

[root@localhost ~]# hostnamectl set-hostname chunk01
[root@localhost ~]# su
[root@chunk01 ~]#

[root@localhost ~]# hostnamectl set-hostname chunk02
[root@localhost ~]# su
[root@chunk02 ~]#

[root@localhost ~]# hostnamectl set-hostname client

[root@localhost ~]# su
[root@client ~]#

搭建Master server

#關閉防火牆
[root@master ~]# systemctl stop firewalld.service
[root@master ~]# setenforce 0

#安裝軟件包
[root@master ~]# yum install zlib-devel gcc gcc-c++ -y

#創建用戶
[root@master ~]# useradd mfs -s /sbin/nologin

#創建掛載點並掛載軟件包文件
[root@master ~]# makdir /abc
[root@master ~]# mount.cifs //192.168.10.59/LAMP-C7 /abc/
Password for root@//192.168.10.59/LAMP-C7:
[root@master ~]# cd /abc/rpm/mfs/

#解壓軟件包
[root@master mfs]# tar zxvf mfs-1.6.27-5.tar.gz -C /opt/
[root@master mfs]# cd /opt/mfs-1.6.27/

#編譯源碼包
[root@master mfs-1.6.27]# ./configure \
--prefix=/usr/local/mfs \
--with-default-user=mfs \
--with-default-group=mfs \
--disable-mfschunkserver \
--disable-mfsmount

#編譯並安裝
[root@master mfs-1.6.27]# make && make install

#複製相關文件
[root@master mfs-1.6.27]# cd /usr/local/mfs/etc/mfs/
[root@master mfs]# cp mfsmaster.cfg.dist mfsmaster.cfg
[root@master mfs]# cp mfsexports.cfg.dist mfsexports.cfg
[root@master mfs]# cp mfsmetalogger.cfg.dist
mfsmetalogger.cfg
[root@master mfs]# cd /usr/local/mfs/var/mfs/
[root@master mfs]# cp metadata.mfs.empty metadata.mfs

#對用戶授權
[root@master mfs]# chown -R mfs.mfs /usr/local/mfs/

#開啓服務
[root@master mfs]# /usr/local/mfs/sbin/mfsmaster start
[root@master ~]# ps -ef | grep mfs
mfs 73676 1 0 00:33 ? 00:00:25 /usr/local/mfs/sbin/mfsmaster start
root 114704 90019 0 08:54 pts/1 00:00:00 grep --color=auto mfs

搭建MetaLogger server

#關閉防火牆
[root@log ~]# systemctl stop firewalld.service
[root@log ~]# setenforce 0

#安裝軟件包
[root@log ~]# yum install zlib-devel gcc gcc-c++ -y

#創建用戶
[root@log ~]# useradd mfs -s /sbin/nologin

#創建掛載點並掛載軟件包文件
[root@log ~]# mkdir /abc
[root@log ~]# mount.cifs //192.168.10.59/LAMP-C7 /abc/
Password for root@//192.168.10.59/LAMP-C7:
[root@log ~]# cd /abc/rpm/mfs/

#解壓軟件包
[root@log ~]# tar zxvf mfs-1.6.27-5.tar.gz -C /opt/
[root@log mfs-1.6.27]# cd /opt/mfs-1.6.27/

#編譯源碼包
[root@log ~]# ./configure \
--prefix=/usr/local/mfs \
--with-default-user=mfs \
--with-default-group=mfs \
--disable-mfschunkserver \
--disable-mfsmount

#編譯並安裝
[root@log mfs-1.6.27]# make && make install

#複製相關文件
[root@log mfs-1.6.27]# cd /usr/local/mfs/etc/mfs/
[root@log mfs]# cp mfsmetalogger.cfg.dist mfsmetalogger.cfg
[root@log mfs]# vim mfsmetalogger.cfg
去除15行註釋,並修改爲MASTER_HOST = 192.168.18.128

#對用戶授權
[root@log ~]# chown -R mfs.mfs /usr/local/mfs/

#開啓服務
[root@log ~]# /usr/local/mfs/sbin/mfsmetalogger start
[root@log ~]# ps -ef | grep mfs
root 45092 21706 0 08:54 pts/1 00:00:00 grep --color=auto mfs
mfs 65494 1 0 07:20 ? 00:00:03 :

搭建chunkserver
(兩臺服務器配置一樣)

#安裝軟件包
[root@chunk01 ~]# yum install zlib-devel gcc gcc-c++ -y
[root@chunk01 ~]# useradd mfs -s /sbin/nologin

#創建掛載點並掛載軟件包文件
[root@chunk01 ~]# mkdir /abc
[root@chunk01 ~]# mount.cifs //192.168.10.59/LAMP-C7 /abc/
Password for root@//192.168.10.59/LAMP-C7:
[root@chunk01 ~]# cd /abc/rpm/mfs/

#解壓軟件包
[root@chunk01 mfs]# tar zxvf mfs-1.6.27-5.tar.gz -C /opt/
[root@chunk01 mfs]# cd /opt/mfs-1.6.27/

#編譯源碼包
[root@chunk01 mfs-1.6.27]#./configure \
--prefix=/usr/local/mfs \
--with-default-user=mfs \
--with-default-group=mfs \
--disable-mfsmaster \
--disable-mfsmount

#編譯並安裝
[root@chunk01 mfs-1.6.27]# make && make install

複製文件並修改配置文件
[root@chunk01 mfs-1.6.27]# cd /usr/local/mfs/etc/mfs/
[root@chunk01 mfs]# cp mfschunkserver.cfg.dist mfschunkserver.cfg
[root@chunk01 mfs]# cp mfshdd.cfg.dist mfshdd.cfg
[root@chunk01 mfs]# vim mfschunkserver.cfg
去除12行註釋,並修改爲MASTER_HOST = 192.168.18.128
[root@chunk01 mfs]# vim mfschunkserver.cfg
在文末加上目錄data
/data
[root@chunk01 mfs]# mkdir /data
[root@chunk01 mfs]# cd
[root@chunk01 ~]# chown -R mfs.mfs /data/

#開啓服務
[root@chunk01 ~]# /usr/local/mfs/sbin/mfschunkserver start
working directory: /usr/local/mfs/var/mfs
lockfile created and locked
initializing mfschunkserver modules ...
hdd space manager: path to scan: /data/
hdd space manager: start background hdd scanning (searching for available chunks)
main server module: listen on *:9422
no charts data file - initializing empty charts
mfschunkserver daemon initialized properly

客戶端配置

#關閉防火牆
[root@client ~]# systemctl stop firewalld.service
[root@client ~]# setenforce 0

安裝軟件包
[root@client ~]# yum install gcc gcc-c++ zlib-devel -y
[root@client ~]# mkdir /abc
[root@client ~]# mount.cifs //192.168.10.59/LAMP-C7 /abc/
Password for root@//192.168.10.59/LAMP-C7:
[root@client ~]# cd /abc/rpm/mfs/
[root@client mfs]# tar zxvf fuse-2.9.2.tar.gz -C /opt/
[root@client fuse-2.9.2]# ./configure
[root@client fuse-2.9.2]# make && make install
[root@client fuse-2.9.2]# vim /etc/profile
在文末插入下面這句話
exportPKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
[root@client fuse-2.9.2]# source /etc/profile
[root@client fuse-2.9.2]# useradd mfs -s /sbin/nologin
[root@client fuse-2.9.2]# cd
[root@client ~]# cd /abc/rpm/mfs/
[root@client mfs]# tar zxvf mfs-1.6.27-5.tar.gz -C /opt/
[root@client mfs-1.6.27]# ./configure \
--prefix=/usr/local/mfs \
--with-default-user=mfs \
--with-default-group=mfs \
--disable-mfschunkserver \
--disable-mfsmaster \
--enable-mfsmount

#編譯及安裝
[root@client mfs-1.6.27]# make && make install

#創建文件,進行掛載
[root@client mfs-1.6.27]# mkdir /opt/mfs
[root@client mfs-1.6.27]# modprobe fuse
[root@client mfs-1.6.27]# /usr/local/mfs/bin/mfsmount /opt/mfs -H 192.168.18.128
mfsmaster accepted connection with parameters: read-write,restricted_ip ; root mapped to root:root
優化客戶端
[root@client mfs-1.6.27]# vim /etc/profile
在文末插入下面這句話
export PATH=/usr/local/mfs/bin:$PATH
[root@client mfs-1.6.27]# source /etc/profile

mater server 啓動監控程序

[root@master ~]# /usr/local/mfs/sbin/mfscgiserv
lockfile created and locked
starting simple cgi server (host: any , port: 9425 , rootpath: /usr/local/mfs/share/mfscgi)
[root@master ~]#

在宿主機輸入地址http://192.168.18.128:9425訪問頁面

MFS分佈式文件系統

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章