MoosefsDistributed File System叢集講解配置

來源:互聯網
上載者:User

標籤:伺服器   server   master   軟體包   依賴性   


1 管理伺服器(master-server):負責各個資料存放區伺服器的管理,檔案讀寫調度,檔案空間回收以及恢複.多節點拷貝

2 中繼資料Log Service器(changelog-server): 負責備份master伺服器的變化,(一般情況下可以和管理伺服器放在一起)檔案類型為changelog_ml.*.mfs,以便於在master server出問題的時候接替其進行工作

3資料存放區伺服器(chunk-server):負責串連管理伺服器,聽從管理伺服器調度,提供儲存空間,並為客戶提供資料轉送.

4用戶端(clients): 通過fuse核心介面掛接遠端管理伺服器上所管理的資料存放區伺服器,.看起來共用的檔案系統和本地unix檔案系統使用一樣的效果.

MFS檔案系統的讀寫原理:



MFSDistributed File System搭建:

系統內容:

                RHEL6.4 

                selinux is disabled

                iptables is flush

一、yum 源定義,用來解決軟體包的依賴性問題
# cat yum.repo
[base]
name=yum
baseurl=ftp://192.168.2.234/pub/RHEL6.4
gpgcheck=0
[HA]
name=ha
baseurl=ftp://192.168.2.234/pub/RHEL6.4/HighAvailability
gpgcheck=0
[lb]
name=LB
baseurl=ftp://192.168.2.234/pub/RHEL6.4/LoadBalancer
gpgcheck=0
[Storage]
name=St
baseurl=ftp://192.168.2.234/pub/RHEL6.4/ResilientStorage
gpgcheck=0
[SFS]
name=FS
baseurl=ftp://192.168.2.234/pub/RHEL6.4/ScalableFileSystem
gpgcheck=0
二、主機解析準備
# cat /etc/hosts
192.168.2.88 node1        mfsmaster
192.168.2.89 node2
192.168.2.90 node3
192.168.2.82 node4
192.168.2.85 node5
實驗將用node1作為master-server
node3和node4作為chunk-server
node5作為clients
所有節點必須有以上準備

三、安裝準備
#yum install rpm-build gcc make fuse-devel zlib-devel -y         安裝編譯環境使用的依賴(其實安裝過程中會提示安裝)
#rpmbuild -tb mfs-1.6.27.tar.gz                              將gz包構建成rpm包的方式  注意:包的格式很重要(只支援大的版本)


## ls /root/rpmbuild/RPMS/x86_64/                            產生的rpm包
mfs-cgi-1.6.27-2.x86_64.rpm          mfs-client-1.6.27-2.x86_64.rpm
mfs-cgiserv-1.6.27-2.x86_64.rpm      mfs-master-1.6.27-2.x86_64.rpm
mfs-chunkserver-1.6.27-2.x86_64.rpm  mfs-metalogger-1.6.27-2.x86_64.rpm

1.master-server安裝:
# yum localinstall mfs-cgi-1.6.27-2.x86_64.rpm mfs-master-1.6.27-2.x86_64.rpm mfs-cgiserv-1.6.27-2.x86_64.rpm -y
可以用cgi進行頁面監控

master-server:主要檔案和目錄
/var/lib/mfs            mfs資料目錄
metadata.mfs            mfs開機檔案
/etc/mfs                    主目錄(儲存設定檔)
mfsmaster.cfg            mfs主設定檔(定義相關參數,使用者、組等設定)
mfsexports.cfg            mfs被掛接目錄及其許可權控制檔案
mfstopology.cfg            定義 MFS 網路拓撲結構的檔案

設定檔預設不需要修改就可以使用
#chown -R nobody /var/lib/mfs      注意給資料目錄以mfs的許可權

# mfsmaster            啟動mfs
#mfsmaster stop            關閉mfs

#netstat  -antlpe(mfsmaster開啟三個連接埠:用戶端串連9421連接埠,監聽9422連接埠;資料節點9420連接埠)

#/usr/share/mfscgi
#chmod +x  *.cgi            給所有的cgi頁面可執行許可權(以便與在web下查看狀態)
# mfscgiserv -------        -》啟動cgi監控

http://192.168.2.88:9425/
查看mfs監控資訊

2.chunk-server安裝配置(node3 and node4)
#rpm -ivh mfs-chunkserver-1.6.27-2.x86_64.rpm
#cd /etc/mfs/
#cp mfschunkserver.cfg.dist mfschunkserver.cfg
# cp mfshdd.cfg.dist mfshdd.cfg
# vim mfshdd.cfg            隱藏檔
    /mnt/chunk            真正儲存的目錄(將用戶端/mnt/mfs的檔案儲存體)

#mkdir /mnt/chunk
#mkdir /var/lib/mfs
#chown nobody /var/lib/mfs/
#chown nobody /mnt/chunk

# mfschunkserver         啟動mfs伺服器(注意,mfsmaster的解析必須到位)

#l.                                    產生一個隱藏鎖檔案
.mfschunkserver.lock


3.clients端的安裝與配置;
# yum localinstall mfs-client-1.6.27-2.x86_64.rpm
#cp mfsmount.cfg.dist mfsmount.cfg
#vim mfsmount.cfg
        修改master和分布式目錄/mnt/mfs
#mkdir /mnt/mfs
#mfsmounts        執行用戶端掛載
mfsmaster accepted connection with parameters: read-write,restricted_ip ; root mapped to root:root            掛載成功

# df                查看掛載裝置
mfsmaster:9421         6714624         0   6714624   0% /mnt/mfs

# ll -d /mnt/mfs/            掛載後自動讀寫
drwxrwxrwx 2 root root 0 Jun  8 10:29 /mnt/mfs/




測試:MFS測試:
# mkdir hello{1,2}
# ls
hello1  hello2

# mfsdirinfo hello1/
hello1/:
 inodes:                          1
  directories:                    1
  files:                          0
 chunks:                          0
 length:                          0
 size:                            0
 realsize:                        0

# mfssetgoal -r 3 hello1/        設定備份次數
hello1/:
 inodes with goal changed:               1
 inodes with goal not changed:           0
 inodes with permission denied:          0

# mfsgetgoal hello1/        查看檔案備份數
hello1/: 3
# mfsgetgoal hello2
hello2: 1

#cp /etc/fstab hello1/
# cp /etc/passwd hello2/

# mfsfileinfo /hello/fstab             查看檔案具體資訊
fstab:
    chunk 0: 000000000000000B_00000001 / (id:11 ver:1)
        copy 1: 192.168.2.82:9422
        copy 2: 192.168.2.90:9422

# mfscheckfile passwd

測試儲存關係:

# mfsfileinfo fstab
fstab:
    chunk 0: 000000000000000B_00000001 / (id:11 ver:1)
        copy 1: 192.168.2.90:9422
[[email protected] hello1]# mfsfileinfo ../hello2/passwd
../hello2/passwd:
    chunk 0: 000000000000000C_00000001 / (id:12 ver:1)
        no valid copies !!!


用戶端:誤刪除檔案(不小心刪除/mnt/mfs/hello*/passwd)
# mfsmount -m /mnt/test/ -H mfsmaster        恢複目錄掛載到mfsmaster上
mfsmaster accepted connection with parameters: read-write,restricted_ip
# mount

#cd /mnt/test/
## mfscheckfile passwd
# mv 00000005\|hello2\|passwd undel/
直接恢複到之前的mfs目錄中
# umount /mnt/meta/


mfschunk-server可以自動檢測用戶端的設定檔:
# mfschunkserver stop

在用戶端重新拷貝檔案,
#cp /etc/inittab /mnt/mfs/hello1
#mfsgetgoal hello1/fstab        查看檔案份數
#mfsgetgoal hello1/inittab

# mfsfileinfo inittab             剛開始只有一個chukserver,只能儲存一份

開啟chunkserver
#mfschunkserver

# mfsfileinfo inittab             查看檔案的備份數,恢複成chunkserver的數
inittab:
    chunk 0: 0000000000000006_00000001 / (id:6 ver:1)
        copy 1: 192.168.2.184:9422
        copy 2: 192.168.2.185:9422


注意:
在mfsmaster中,正常運行時,資料檔案為metadata.mfs.back
當主機出現故障,資料檔案會儲存成metadata.mfs

使用非正常關閉,(kill -9  pid) 資料檔案將不會恢複

# mfsmetarestore -a-            非正常啟動後會丟失metadata.mfs檔案,必須恢複一下

然後重新啟動mfsmaster(mfsmaster啟動必須有metadata.mfs檔案)


本文出自 “營運” 部落格,轉載請與作者聯絡!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.