- 論壇徽章:
- 0
|
用GlusterFS搭建高可用存儲(chǔ)集群
概述
實(shí)驗(yàn)環(huán)境:ubuntu 8.04 server
網(wǎng)絡(luò)結(jié)構(gòu)如下圖所示:
![]()
192.168.253.41和192.168.253.43、192.168.253.42與192.168.253.44分別做互備
然后兩個(gè)group再做分布式存儲(chǔ)。
一: 安裝
因?yàn)閡buntu 8.04本身并沒有帶gluster套件,所以我們還需要自己編譯安裝
1.首先需要在某臺(tái)ubuntu 8.04的電腦上安裝基本的編譯工具
#apt-get install sshfs build-essential flex bison byacc vim wget checkinstall
2.去官方網(wǎng)站下載fuse,之所以需要下載這個(gè)是因?yàn)閡buntu 8.04自己fuse套件并沒有提供對(duì)GlusterFS的支持
#wget http://ftp.gluster.com/pub/gluster/glusterfs/fuse/fuse-2.7.4glfs11.tar.gz
#tar -zxvf fuse-2.7.4glfs11.tar.gz
#cd fuse-2.7.4glfs11
3.進(jìn)行編譯
#./configure
#make
4.安裝fuse。這里有一點(diǎn)需要注意一下,因?yàn)槲覀円还灿兴呐_(tái)ubuntu server 8.04,所以如果要一臺(tái)臺(tái)編譯顯然是不太現(xiàn)實(shí)的事情,所以我們可以用checkinstall工具生成deb包,這樣在這臺(tái)電腦上編譯好的東西,直接拿到其它電腦上用dpkg安裝一下就搞定了,省卻了在每臺(tái)電腦上進(jìn)行編譯的工作。具體做法如下
首先是用make install進(jìn)行安裝
#make install
安裝完成后,現(xiàn)在輸入如下命令生成deb包
#checkinstall
在安裝過程中會(huì)出現(xiàn)如下提示:
checkinstall 1.6.1, Copyright 2002 Felipe Eduardo Sanchez Diaz Duran
本軟件以 GNU GPL 版權(quán)協(xié)議頒布
The package documentation directory ./doc-pak does not exist.
Should I create a default set of package docs? [y]:
直接按回車?yán)^續(xù),然后出現(xiàn)如下的提示,
請(qǐng)為這個(gè)軟件包寫一個(gè)描述。
用一個(gè)空行或 EOF 來結(jié)束你的描述。
>>
這里我們繼續(xù)按回車,因?yàn)楫吘刮覀冎皇亲约河糜,又不是用來發(fā)布的。所以描述信息不填也沒有關(guān)系。(哈哈,好像這種態(tài)度實(shí)在不太好哦。呵呵 )
然后再出現(xiàn)如下提示:
*****************************************
**** Debian package creation selected ***
*****************************************
軟件包將用下面的值來創(chuàng)建:
0 - Maintainer: [ root@fs4 ]
1 - Summary: [ Package created with checkinstall 1.6.1 ]
2 - Name: [ fuse ]
3 - Version: [ 2.7.4glfs11 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ checkinstall ]
7 - Architecture: [ i386 ]
8 - Source location: [ fuse-2.7.4glfs11 ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
輸入一個(gè)數(shù)字來改變它們,或按回車鍵繼續(xù):
繼續(xù)偷懶,啥都不用輸入,checkinstall會(huì)自動(dòng)幫我們生成漂亮的文件名的
當(dāng)一切都按計(jì)劃處理完畢后,就會(huì)出現(xiàn)如下提示了
================= 安裝成功 =================
Copying documentation directory...
./
./doc/
./doc/Doxyfile
./doc/how-fuse-works
./doc/kernel.txt
./COPYING
./INSTALL
./NEWS
./AUTHORS
./FAQ
./README.NFS
./COPYING.LIB
./README
./ChangeLog
grep: /var/tmp/XNpcLnGoHbTOOEXLjRXbA/newfile: No such file or directory
把文件拷貝到臨時(shí)目錄……OK
Stripping ELF binaries and libraries...OK
壓縮 man 手冊(cè)頁……OK
創(chuàng)建文件列表……OK
創(chuàng)建 Debian 包……OK
安裝 Debian 包…… FAILED!
*** 安裝軟件包失敗
你想看日志文件么? [y]:
直接按回車,等待程序處理結(jié)束后,再看一下安裝目錄下,是否有多出來一個(gè)deb包了。
#ls *deb -lh
-rw-r--r-- 1 root root 341K 2009-09-12 18:51 fuse_2.7.4glfs11-1_i386.deb
*將我們剛剛生成的deb包放到一個(gè)安全的目錄下(之所以這么說是因?yàn),如果你喜歡在/tmp目錄下臨時(shí)編譯一些東西的話,那么當(dāng)你重新啟動(dòng)你的電腦后,/tmp目錄將會(huì)被自動(dòng)清空掉。)
至此我們的fuse安裝完畢。
5.安裝gluster
下面依樣畫葫蘆的安裝gluster
首先從官方下載gluster的源碼包并解包
#wget
http://ftp.gluster.com/pub/gluster/glusterfs/2.0/LATEST/glusterfs-2.0.6.tar.gz
#tar -zxvf glusterfs-2.0.6.tar.gz
#cd glusterfs-2.0.6
#./configure
#make
#make install
#checkinstall
到此安裝成功,并且已經(jīng)生成了我們需要的deb包,現(xiàn)在輸入命令 ldconfig刷新下動(dòng)態(tài)鏈接庫緩存
#ldconfig
安裝完成。
6.其它電腦上面gluster套件的安裝
其它電腦上面gluster套件的安裝相當(dāng)簡單了,因?yàn)槲覀儎偵闪藘蓚(gè)deb包嘛,所以只需要把那兩個(gè)DEB包拷貝到其它電腦上面,然后使用 dpkg -i 包名> 就可以安裝了。省時(shí)省力。
二:配置
1.首先將gluster的配置文件拷貝到 /etc/目錄下
#cp /usr/local/etc/glusterfs/ /etc -rv
然后進(jìn)入etc目錄,里面會(huì)看到兩個(gè)sample文件,我們直接將這兩個(gè)sample文件改名成我們需要的配置檔
#cd /etc/glusterfs/
#ls -alh
total 16K
drwxr-xr-x 2 root root 4.0K 2009-09-12 19:36 .
drwxr-xr-x 64 root root 4.0K 2009-09-12 19:36 ..
-rw-r--r-- 1 root root 1.9K 2009-09-12 19:37 glusterfsd.vol.sample
-rw-r--r-- 1 root root 2.1K 2009-09-12 19:37 glusterfs.vol.sample
# mv glusterfsd.vol.sample glusterfsd.vol
# mv glusterfs.vol.sample glusterfs.vol
其中的glusterfsd.vol是我們的glusterfs服務(wù)的配置文件。而glusterfs.vol則是客戶端配置文件。下面我們來分別配置這兩個(gè)文件
#glusterfsd.vol 這是服務(wù)端配置檔
volume posix
type storage/posix
option directory /srv/export
end-volume
volume locks
type features/locks
subvolumes posix
end-volume
volume brick
type performance/io-threads
option thread-count 8
subvolumes locks
end-volume
### Add network serving capability to above brick.
volume server
type protocol/server
option transport-type tcp
option auth.addr.brick.allow * # Allow access to "brick" volume
end-volume
#glusterfs.vol 這是客戶端配置檔
#volume setup
volume remote41
type protocol/client
option transport-type tcp
option remote-host 192.168.253.41
option remote-subvolume brick
end-volume
volume remote42
type protocol/client
option transport-type tcp
option remote-host 192.168.253.42
option remote-subvolume brick
end-volume
volume remote43
type protocol/client
option transport-type tcp
option remote-host 192.168.253.43
option remote-subvolume brick
end-volume
volume remote44
type protocol/client
option transport-type tcp
option remote-host 192.168.253.44
option remote-subvolume brick
end-volume
#replicate setup
volume replicate1
type cluster/replicate
subvolumes remote41 remote43
end-volume
volume replicate2
type cluster/replicate
subvolumes remote42 remote44
end-volume
#distribute setup
volume distribute
type cluster/distribute
subvolumes replicate1 replicate2
end-volume
volume writebehind
type performance/write-behind
option window-size 1MB
subvolumes distribute
end-volume
volume cache
type performance/io-cache
option cache-size 512MB
subvolumes writebehind
end-volume
配置完配置檔后,我們還需要為服務(wù)建立相關(guān)的目錄。在服務(wù)端是我們配置了option directory /srv/export 所以我們需要建立一個(gè)提供存儲(chǔ)的目錄。另外我們還需要建立一個(gè)掛載點(diǎn),以供客戶端可以掛載我們的分布式文件系統(tǒng)。
#mkdir /mnt/glusterfs 這是將要掛載gluster文件系統(tǒng)的目錄
#kkdir /srv/export -p 這是glusterfsd將要export出來的卷
最后我們還需要做一步,將glusterfsd守護(hù)進(jìn)程加入到我們的啟動(dòng)服務(wù)里面去
#update-rc.d glusterfsd defaults
Adding system startup for /etc/init.d/glusterfsd ...
/etc/rc0.d/K20glusterfsd -> ../init.d/glusterfsd
/etc/rc1.d/K20glusterfsd -> ../init.d/glusterfsd
/etc/rc6.d/K20glusterfsd -> ../init.d/glusterfsd
/etc/rc2.d/S20glusterfsd -> ../init.d/glusterfsd
/etc/rc3.d/S20glusterfsd -> ../init.d/glusterfsd
/etc/rc4.d/S20glusterfsd -> ../init.d/glusterfsd
/etc/rc5.d/S20glusterfsd -> ../init.d/glusterfsd
至此配置完畢。
另:如果我們還需要在開機(jī)的時(shí)候讓系統(tǒng)能夠自動(dòng)掛載glusterfs的話,可以通過在/etc/fstab里面添加以下項(xiàng)目來實(shí)現(xiàn)
/etc/glusterfs/glusterfs.vol /mnt/glusterfs glusterfs auto 0 0
三:測試
Ladies and gentlemans ,電視機(jī)前的各位觀眾朋友們,最激動(dòng)人心的事情馬上就要到來了,讓我們一起大聲開始倒計(jì)時(shí), 10、 9、 8、 7 ........... :)
我們先用手工掛載的方式掛載glusterfs看是否可以成功
mount -t glusterfs /etc/glusterfs/glusterfs.vol /mnt/glusterfs
如果沒有錯(cuò)誤提示,則表示OK
哈哈
如果不正確,請(qǐng)查看/usr/local/var/log/glusterfs目錄下的日志文件查看錯(cuò)誤信息
![]()
文件:glusterfs_config_file.zip
大小:1KB
下載:
下載
本文來自ChinaUnix博客,如果查看原文請(qǐng)點(diǎn):http://blog.chinaunix.net/u/23094/showart_2061102.html |
|