一、MFS 簡介:
二、搭建 MFS:
第一步:配置 Master 服務器
第二步:搭建 MetaLogger server
第三步:搭建 chunkserver01
第四步:搭建 chunkserver02
第五步:客戶端配置
第六步:安裝 mfs 客戶端
第七步:master 啓動監控程序
一、MFS 簡介:
MooseFS是一個具有容錯性的網絡分佈式文件系統。它把數據分散存放在多個物理服務器上,而呈現給用戶的則是一個統一的資源。
(1)優勢:
1、高可靠(數據的多個拷貝被存儲在不同的計算機上);
2、通過附加新的計算機或者硬盤可以實現容量的動態擴展;
3、刪除的文件可以根據一個可配置的時間週期進行保留(一個文件系統級別的回收站);
4、不受訪問和寫入影響的文件連貫快照。
(2)體系結構:
1、管理服務器(master server):
一臺管理整個文件系統的獨立主機,存儲着每個文件的元數據(文件的大小、屬性、位置信息,包括所有非常規文件的所有信息,例如目錄、套接字、管道以及設備文件)
2、數據服務器羣(chunk servers):
任意數目的商用服務器,用來存儲文件數據並在彼此之間同步(如果某個文件有超過一個備份的話)
3、元數據備份服務器(metalogger server):
任意數量的服務器,用來存儲元數據變化日誌並週期性下載主要元數據文件,以便用於管理服務器意外停止時好接替其位置。
4、訪問mfs的客戶端:
任意數量的主機,可以通過mfsmount進程與管理服務器(接收和更改元數據)和數據服務器(改變實際文件數據)進行交流。
二、搭建 MFS:
角色 | IP地址 |
Master 服務器 | 192.168.109.66 |
log 日誌服務器 | 192.168.220.131 |
chunk01 服務器 | 192.168.109.138 |
chunk02 服務器 | 192.168.109.146 |
client 客戶端 | 192.168.109.135 |
第一步:配置 Master 服務器
1、安裝環境包: yum install -y zlib-devel gcc gcc-c++ 2、創建用戶: useradd -s /sbin/nologin mfs chown -R mfs.mfs /usr/local/mfs/ //授權 3、解壓、編輯源碼包: [root@localhost abc]# tar zxvf mfs-1.6.27-5.tar.gz -C /opt [root@localhost abc]# cd /opt/mfs-1.6.27/ [root@localhost mfs-1.6.27]# ./config \ > --prefix=/usr/local/mfs \ > --with-default-user=mfs \ > --with-default-group=mfs \ > --disable-mfschunkserver \ > --disable-mfsmount 4、安裝: [root@localhost mfs-1.6.27]# make [root@localhost mfs-1.6.27]# make install 5、複製相關文件: [root@Master mfs-1.6.27]# cd /usr/local/mfs/etc/mfs/ [root@Master mfs]# ls mfsexports.cfg.dist mfsmaster.cfg.dist mfsmetalogger.cfg.dist mfstopology.cfg.dist [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]# ls metadata.mfs.empty [root@Master mfs]# cp metadata.mfs.empty metadata.mfs 6、開啓服務: [root@Master mfs]# /usr/local/mfs/sbin/mfsmaster start //開啓 [root@Master mfs]# ps -ef | grep mfs //查看狀態 mfs 8526 1 0 14:21 ? 00:00:00 /usr/local/mfs/sbin/mfsmaster start root 8542 2511 0 14:21 pts/0 00:00:00 grep --color=auto mfs
第二步:搭建 MetaLogger server
1、安裝環境依賴包: yum install -y zlib-devel gcc gcc-c++ 2、創建用戶: useradd mfs -s /sbin/nologin chown -R mfs.mfs /usr/local/mfs/ 3、解壓、編譯源碼包: [root@log mfs]# tar zxvf mfs-1.6.27-5.tar.gz -C /opt [root@log mfs]# cd /opt/mfs-1.6.27/ [root@log mfs-1.6.27]# ./configure \ > --prefix=/usr/local/mfs \ > --with-default-user=mfs \ > --with-default-group=mfs \ > --disable-mfschunkserver \ > --disable-mfsmount 4、複製文件: [root@log mfs-1.6.27]# cd /usr/local/mfs/etc/mfs/ [root@log mfs]# ls mfsexports.cfg.dist mfsmaster.cfg.dist mfsmetalogger.cfg.dist mfstopology.cfg.dist [root@log mfs]# cp mfsmetalogger.cfg.dist mfsmetalogger.cfg vim mfsmetalogger.cfg //修改masterIP地址: MASTER_HOST = 192.168.109.66 5、開啓服務: /usr/local/mfs/sbin/mfsmetalogger start
第三步:搭建 chunkserver01
1、安裝依賴包: yum install -y gcc gcc-c++ zlib-devel 2、創建用戶: [root@chunk01 ~]# useradd mfs -s /sbin/nologin [root@chunk01 mfs]# mkdir /data [root@chunk01 mfs]# chown -R mfs.mfs /data/ 3、解壓、編譯: [root@chunk01 mfs]# tar zvxf mfs-1.6.27-5.tar.gz -C /opt/ [root@chunk01 mfs-1.6.27]# 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 4、安裝: [root@chunk01 mfs-1.6.27]# make && make install 5、複製文件: [root@chunk01 mfs-1.6.27]# cd /usr/local/mfs/etc/mfs/ [root@chunk01 mfs]# ls mfschunkserver.cfg.dist mfshdd.cfg.dist [root@chunk01 mfs]# cp mfschunkserver.cfg.dist mfschunkserver.cfg [root@chunk01 mfs]# cp mfshdd.cfg.dist mfshdd.cfg 6、修改配置文件: vim mfschunkserver.cfg MASTER_HOST = 192.168.109.66 vim mfshdd.cfg 添加一個目錄即可 /data 7、開啓服務: [root@chunk01 mfs]# /usr/local/mfs/sbin/mfschunkserver start
第四步:搭建 chunkserver02
配置和 chunkserver01 一模一樣,參照 chunkserver01 操作即可。
第五步:客戶端配置
1、安裝依賴包: yum install gcc gcc-c++ zlib-devel -y 2、解壓、編譯: [root@client mfs]# tar zvxf fuse-2.9.2.tar.gz -C /opt/ [root@client mfs]# cd /opt/fuse-2.9.2/ [root@client fuse-2.9.2]# ./configure [root@client fuse-2.9.2]# make && make install 3、檢索系統中安裝庫信息: vim /etc/profile 末尾添加以下這行: export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH 4、[root@client fuse-2.9.2]# source /etc/profile //使環境變量生效
第六步:安裝 mfs 客戶端
1、創建用戶: [root@client mfs]# useradd mfs -s /sbin/nologin 2、解壓、編譯: [root@client mfs]# tar zxvf mfs-1.6.27-5.tar.gz -C /opt/ [root@client mfs]# cd /opt/mfs-1.6.27/ [root@client mfs-1.6.27]# ./configure \ > --prefix=/usr/local/mfs \ > --with-default-user=mfs \ > --with-default-group=mfs \ > --disable-mfsmaster \ > --disable-mfschunkserver \ > --enable-mfsmount [root@client mfs-1.6.27]# make && make install 3、創建文件,進行掛載: [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.220.176
優化客戶端:
vim /etc/profile 添加以下這行: export PATH=/usr/local/mfs/bin:$PATH source /etc/profile mfssetgoal -r /opt/mfs //複製副本 mfssetgoal -r 3 /opt/mfs //數字代表複製幾個副本
第七步:master 啓動監控程序
[root@Master mfs]# /usr/local/mfs/sbin/mfscgiserv
瀏覽器訪問網頁:192.168.109.66:9425,可查看詳細信息