搭建 MFS Distributed File System

來源:互聯網
上載者:User

標籤:_id   spec   points   info   mem   ssi   tab   command   部分   

MFSDistributed File System

 

MFS是一種半Distributed File System,它是由波蘭人開發的。MFS檔案系統能夠實現RAID的功能,不但能夠更節約儲存成本,而且不比專業的儲存系統差,它還可以實現線上擴充。
 
Distributed File System是指檔案系統管理的實體儲存體資源下不一定直接連接在本地節點上,而是通過電腦網路與節點相連。

Distributed File System的優點是集中訪問、簡化操作、資料容災,以及提高了檔案的存取效能。

MFS檔案系統的組成架構:
  • 中繼資料服務器(Master):在整個體系中負責管理檔案系統,維護中繼資料;
  • 中繼資料Log Service器(Metalogger):備份Master伺服器的變化記錄檔,檔案類型為changlog_ml.*.mfs。當Master伺服器資料丟失或者損壞時,可以從Log Service器中取得檔案,進行恢複;
  • 資料存放區伺服器(Chunk Server):真正儲存的資料的伺服器。隱藏檔時,會把檔案分塊儲存,並在資料服務器之間進行複製。資料服務器越多,能夠使用的容量則越大,可靠性就越高,效能也就越好;
  • 用戶端(Client):可以像掛載NFS一樣掛載MFS檔案系統,其操作是相同的。
MFS讀取資料的過程:
  1. 用戶端向中繼資料服務器發出讀請求;
  2. 中繼資料服務器把所需資料存放的位置(ChunkServer的IP地址和Chunk編號)告知用戶端;
  3. 用戶端向已知的ChunkServer請求發送資料;
  4. Chunkserver向用戶端發送資料。
MFS寫入資料的過程:
  1. 用戶端向中繼資料服務器發送寫入請求;
  2. 中繼資料服務器與ChunkServer進行互動,但中繼資料服務器只在某些伺服器建立新的分塊Chunks,建立成功後由ChunkServers告知中繼資料服務器操作成功;
  3. 中繼資料服務器告知用戶端,可以在哪個ChunkServer的哪些Chunks吸入資料;
  4. 用戶端向指定的ChunkServer寫入資料;
  5. 該ChunkServer與其他ChunkServer進行資料同步,同步成功後ChunkServer告知用戶端資料寫入成功;
  6. 用戶端告知中繼資料服務器本次寫入完畢。
系統內容
主機 作業系統 IP地址
Master Server Centos 7.3 X86_64 192.168.1.11
Metalogger Centos 7.3 X86_64 192.168.1.12
Chunk1 Centos 7.3 X86_64 192.168.1.13
Chunk2 Centos 7.3 X86_64 192.168.1.14
Chunk3 Centos 7.3 X86_64 192.168.1.15
Client Centos 7.3 X86_64 192.168.1.22
開始部署

 

Master Server:

 

  1. 添加索引值
    # curl "https://ppa.moosefs.com/RPM-GPG-KEY-MooseFS" > /etc/pki/rpm-gpg/RPM-GPG-KEY-MooseFS

     

  2. 添加庫條目
    # curl "http://ppa.moosefs.com/MooseFS-3-el7.repo" > /etc/yum.repos.d/MooseFS.repo

     

  3. 安裝mfsmaster軟體包
    yum -y install moosefs-master moosefs-cgi moosefs-cgiserv moosefs-cli

    確認設定檔,在/etc/mfs下產生了相關的設定檔(mfsexports.cfg、mfsmaster.cfg等)
    以下設定檔均採用預設值,不需做修改:mfsmaster.cfg、mfsexports.cfg、mfstopology.cfg

     

  4. 啟動mfsmaster,檢查應用是否啟動
    mfsmaster startps -ef | grep mfs

     

Metalogger:

 

  1. 添加索引值
    # curl "https://ppa.moosefs.com/RPM-GPG-KEY-MooseFS" > /etc/pki/rpm-gpg/RPM-GPG-KEY-MooseFS
  2. 添加庫條目
    # curl "http://ppa.moosefs.com/MooseFS-3-el7.repo" > /etc/yum.repos.d/MooseFS.repo

     

  3. 安裝mfsmetalogger軟體包
    yum -y install moosefs-metalogger

     

  4. 編輯mfsmetalogger.cfg設定檔
    ## vim /etc/mfs/mfsmetalogger.cfg······省略部分語句################################################ RUNTIME OPTIONS                             ################################################ # user to run daemon as (default is mfs)# WORKING_USER = mfs # group to run daemon as (optional - if empty then default user group will be used)# WORKING_GROUP = mfs # name of process to place in syslog messages (default is mfsmetalogger)# SYSLOG_IDENT = mfsmetalogger # whether to perform mlockall() to avoid swapping out mfsmetalogger process (default is 0, i.e. no)# LOCK_MEMORY = 0 # Linux only: limit malloc arenas to given value - prevents server from using huge amount of virtual memor    y (default is 4)# LIMIT_GLIBC_MALLOC_ARENAS = 4 # Linux only: disable out of memory killer (default is 1)# DISABLE_OOM_KILLER = 1 # nice level to run daemon with (default is -19; note: process must be started as root to increase priorit    y, if setting of priority fails, process retains the nice level it started with)# NICE_LEVEL = -19 # set default umask for group and others (user has always 0, default is 027 - block write for group and bl    ock all for others)# FILE_UMASK = 027 # where to store daemon lock file (default is /var/lib/mfs)# DATA_PATH = /var/lib/mfs # number of metadata change log files (default is 50)# BACK_LOGS = 50 # number of previous metadata files to be kept (default is 3)# BACK_META_KEEP_PREVIOUS = 3 # metadata download frequency in hours (default is 24, should be at least BACK_LOGS/2)# META_DOWNLOAD_FREQ = 24 ################################################ MASTER CONNECTION OPTIONS                   ################################################ # delay in seconds before next try to reconnect to master if not connected (default is 5)# MASTER_RECONNECTION_DELAY = 5 # local address to use for connecting with master (default is *, i.e. default local address)# BIND_HOST = * # MooseFS master host, IP is allowed only in single-master installations (default is mfsmaster) 修改為Master的IP地址 MASTER_HOST = 192.168.1.11  # MooseFS master supervisor port (default is 9419)# MASTER_PORT = 9419 # timeout in seconds for master connections (default is 10)# MASTER_TIMEOUT = 10

     

  5. 啟動mfsmetalogger,檢查應用是否啟動
    mfsmetalogger startps -ef | grep mfs

     

ChunkServers:

 
以上三台資料存放區伺服器配置一致
 

  1. 添加索引值
    # curl "https://ppa.moosefs.com/RPM-GPG-KEY-MooseFS" > /etc/pki/rpm-gpg/RPM-GPG-KEY-MooseFS

     

  2. 添加庫條目
    # curl "http://ppa.moosefs.com/MooseFS-3-el7.repo" > /etc/yum.repos.d/MooseFS.repo

     

  3. 安裝mfsmaster軟體包
    yum -y install moosefs-chunkserver

     

  4. 修改主設定檔,修改Master的IP地址
    ## vim /etc/mfs/mfschunkserver.cfg······省略部分資訊################################################ MASTER CONNECTION OPTIONS                   ################################################ # labels string (default is empty - no labels)# LABELS = # local address to use for master connections (default is *, i.e. default local address)# BIND_HOST = * # MooseFS master host, IP is allowed only in single-master installations (default is mfsmaster) # 修改為Master的IP地址MASTER_HOST = 192.168.1.11 # MooseFS master command port (default is 9420)# MASTER_PORT = 9420  # timeout in seconds for master connections. Value >0 forces given timeout, but when value is 0 then CS as    ks master for timeout (default is 0 - ask master)# MASTER_TIMEOUT = 0 # delay in seconds before next try to reconnect to master if not connected # MASTER_RECONNECTION_DELAY = 5 # authentication string (used only when master requires authorization)# AUTH_CODE = mfspassword

     

  5. 指定資料存放區伺服器分配給MFSMaster使用的檔案位置
    ## vim /etc/mfs/mfshdd.cfg······省略部分資訊# This file keeps definitions of mounting points (paths) of hard drives to use with chunk server.# A path may begin with extra characters which swiches additional options:#  - ‘*‘ means that this hard drive is ‘marked for removal‘ and all data will be replicated to other hard drives (usually on other chunkservers)#  - ‘<‘ means that all data from this hard drive should be moved to other hard drives#  - ‘>‘ means that all data from other hard drives should be moved to this hard drive#  - ‘~‘ means that significant change of total blocks count will not mark this drive as damaged# If there are both ‘<‘ and ‘>‘ drives then data will be moved only between these drives# It is possible to specify optional space limit (after each mounting point), there are two ways of doing that:#  - set space to be left unused on a hard drive (this overrides the default setting from mfschunkserver.cfg)#  - limit space to be used on a hard drive# Space limit definition: [0-9]*(.[0-9]*)?([kMGTPE]|[KMGTPE]i)?B?, add minus in front for the first option.## Examples:## use hard drive ‘/mnt/hd1‘ with default options:#/mnt/hd1## use hard drive ‘/mnt/hd2‘, but replicate all data from it:#*/mnt/hd2## use hard drive ‘/mnt/hd3‘, but try to leave 5GiB on it:#/mnt/hd3 -5GiB## use hard drive ‘/mnt/hd4‘, but use only 1.5TiB on it:#/mnt/hd4 1.5TiB## use hard drive ‘/mnt/hd5‘, but fill it up using data from other drives#>/mnt/hd5## use hard drive ‘/mnt/hd6‘, but move all data to other hard drives#</mnt/hd6## use hard drive ‘/mnt/hd7‘, but ignore significant change of hard drive total size (e.g. compressed file systems)#~/mnt/hd7 #提供給MFS的分區目錄/data

     

  6. 建立目錄並修改屬主/屬組,啟動chunkserver服務,檢查應用是否啟動
    mkdir /datachown -R mfs:mfs /datamfschunkserver startps -ef | grep mfs
Client:

 

  1. 添加索引值
    # curl "https://ppa.moosefs.com/RPM-GPG-KEY-MooseFS" > /etc/pki/rpm-gpg/RPM-GPG-KEY-MooseFS

     

  2. 添加庫條目
    # curl "http://ppa.moosefs.com/MooseFS-3-el7.repo" > /etc/yum.repos.d/MooseFS.repo

     

  3. 安裝mfsmaster軟體包
    yum -y install moosefs-client

     

  4. 建立掛載點,載入fuse模組到核心,並掛載MFS
    mkdir -p /mfs/datamodprobe fusemfsmount /mfs/data -H 192.168.1.11

     

MFS監控

 
通過yum安裝方式已經預設安裝好Mfscgiserv功能,它是同Python編寫的一個web伺服器,其監聽連接埠為9425,可以在Master Server上通過mfscgiserv命令開啟,然後利用瀏覽器開啟就可以全面監控所有用戶端掛載、Chunk Server、Master Server,以及用戶端的各種操作等。
 
其中各部分的含義如下:

  • Info部分:顯示了MFS的基本資料
  • Server部分:列出現有的Chunk Server
  • Disks部分:列出每一台Chunk Server的磁碟目錄及使用量
  • Exports部分:列出被共用的目錄,即可被掛載的目錄
  • Mounts部分:顯示被掛載的情況
  • Operations部分:顯示正在執行的操作
  • Master Charts部分:顯示Master Server的操作情況,包括讀取、寫入、建立目錄、刪除目錄等

 

MFS常用操作

 

mfsgetgoal與mfssetgoal命令
 

目標是指檔案被複製的份數,設定了複製的份數後就可以通過mfsgetgoal命令來證實,也可以通過mfssetgoal來改變設定。

mfscheckfile與mfsfileinfo命令

實際的副本分數可以通過mfscheckfile和mfsfileinfo命令來證實。

mfsdirinfo命令

整個分類樹的內容摘要可以通過一個功能增強、等同於“du -s”的命令mfsdirinfo來顯示。

 

維護MFS

最重要的就是維護中繼資料服務器,而中繼資料服務器最重要的目錄為/var/lib/mfs/,MFS資料的儲存、修改、更新等操作變化都會記錄咋這個目錄的某個檔案中,因此只要保證這個目錄的資料安全,就能夠保證整個MFS檔案系統的安全性和可靠性。
/var/lib/mfs/目錄下的資料由兩部分組成:一部分是中繼資料服務器的改變日誌,檔案名稱類似於changelog.*.mfs;另一部分是中繼資料檔案metadata.mfs,運行mfsmaster時該檔案會被命名為metadata.mfs.back。只要保證了這兩部資料的安全,即使中繼資料服務器遭到致命×××,也可以通過備份的中繼資料檔案來部署一套中繼資料服務器。

搭建 MFS Distributed File System

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.