glusterfs實踐(二)cluster/unify的學習

上次的學習已經對glusterfs這個系統有了初步的認識,這次繼續,上次只是簡單的實現了一個類似NFS的配置,但這個並不是glusterfs出現的主要目的,而且也不是我們應用glusterfs的主要目的,我們要是實現的是分佈式存儲,另外一個最簡單的想法就是,如何能把多臺server目前空餘的硬盤空間利用起來。這其實就是glusterfs最主要的功能之一,多存儲空間的聚合。
 
個人感覺:
glusterfs感覺和moosefs有點類似,就是在備份的方面moosefs用的是創建副本的形式,而glusterfs用的是單獨的一個空間來做交換,在下面的實驗中就會得到體驗
一.實驗環境
目的:將兩臺server的剩餘空間合併,讓client掛載,所需3臺服務器,兩臺server,一臺client,IP分別爲:
192.168.4.189----------------glusterfs_server01
192.168.4.190----------------glusterfs_server02
192.168.4.188----------------glusterfs_client
系統使用centos5.1,有個奇怪的問題是系統使用centos4.4的時候編譯glusterfs的時候總報錯,用centos5.1就沒事,這問題還以待研究
 
二.安裝
1.首先安裝fuse
tar -zxvf fuse-2.7.4.tar.gz
cd fuse-2.7.4
./configure -enable-dependency-tracking -enable-kernel-module -enable-lib -enable-util
make && make isntall
2.安裝glusterfs
tar -zxvf glusterfs-2.0.0rc1.tar.gz
cd glusterfs-2.0.0rc1
./configure
make && make install
兩臺glusterfs_server和glusterfs_client端操作一樣
 
三. 配置
gluster_server端的操作
1.gluster_server端服務器有一個單獨的硬盤/dev/hdb,對/dev/hdb分區並mount到/disk上,執行chmod 777 /disk
  兩臺server一樣的操作
2.配置文件的修改
glusterfs_server01上:
mv glusterfs-server.vol.sample glusterfs-server.vol
vi /usr/local/etc/glusterfs/glusterfs-server.vol
修改後內容如下:
volume brick
  type storage/posix
  option directory /disk/export # Note: Once exported, DO NOT WRITE DIRECTLY TO THIS DIRECTORY
end-volume
volume brick-ns
  type storage/posix
  option directory /disk/export_ns
end-volume
volume server
  type protocol/server
  subvolumes brick brick-ns
  option transport-type tcp/server     # For TCP/IP transport
  option auth.ip.brick.allow *
  option auth.ip.brick-ns.allow *
end-volume
glusterfs_server02上:
mv glusterfs-server.vol.sample glusterfs-server.vol
vi /usr/local/etc/glusterfs/glusterfs-server.vol
修改後內容如下:
volume brick
  type storage/posix
  option directory /disk/export # Note: Once exported, DO NOT WRITE DIRECTLY TO THIS DIRECTORY
end-volume
volume brick-ns
  type storage/posix
  option directory /disk/export_ns
end-volume
volume server
  type protocol/server
  subvolumes brick brick-ns
  option transport-type tcp/server     # For TCP/IP transport
  option auth.ip.brick.allow *
  option auth.ip.brick-ns.allow *
end-volume
3.mkdir -p /disk/export
  mkdir -p /disk/export_ns
  兩臺server操作一樣
 
gluster_cliengt端的操作:
cd /usr/local/etc/glusterfs/
mv glusterfs-client.vol.sample  glusterfs-client.vol
修改後的內容如下:
volume client1-ns
  type protocol/client
  option transport-type tcp/client
  option remote-host 192.168.4.189
  option remote-subvolume brick-ns
end-volume
volume client1
  type protocol/client
  option transport-type tcp/client
  option remote-host 192.168.4.189
  option remote-subvolume brick
end-volume
volume client2
  type protocol/client
  option transport-type tcp/client
  option remote-host 192.168.4.190
  option remote-subvolume brick
end-volume
volume unify
  type cluster/unify
  subvolumes client1 client2
  option namespace client1-ns
  option scheduler rr
end-volume

四. 操作
glusterfs_server端的操作
1.glusterfsd -f /usr/local/etc/glusterfs/glusterfs-server.vol  啓動server端
2.ps -ef | grep glusterfs                                      查看進程存在不存在
3.netstat -ln | grep 6996                                      查看端口是否監聽
兩臺server一樣
glusterfs_client端的操作
1.modprobe -i fuse                加載fuse模塊
2.glusterfs -l /tmp/glusterfs.log -f /usr/local/etc/glusterfs/glusterfs-client.vol /mnt      掛載到/mnt上,同時可以查看 /tmp下的glusterfs.log日誌
3.[root@glusterfs_client]# df -h
文件系統              容量  已用 可用 已用% 掛載點
/dev/hda1             8.5G  5.0G  3.2G  62% /
tmpfs                 125M     0  125M   0% /dev/shm
glusterfs             6.0G  147M  5.5G   3% /mnt
看看/mnt的容量是不是兩個server磁盤的總和,是的話就證明OK!!!
 
五. 測試
1.glusterfs_client端的/mnt目錄下:
  touch {1,2,3,4,5,6,7,8,9,10}
2.到glusterfs_server的/disk/export目錄下ls
server01:
   [root@glusterfs_server01 export]# ls
    1  3  5  7  9
server02:
  [root@glusterfs_server02 export]# ls
    2  4  6  8  10
3.再到server01上的/disk/export_ns目錄下ls
  [root@glusterfs_client export_ns]# ls
  1  10  2  3  4  5  6  7  8  9
由上面看到,10個新的文件是依次創建到了兩個server的/disk/export中,server01中的/disk/export_ns就是我們配置的namespace,用於交換空間
到此,我的試驗就算完成了,而且試驗目的也達成了
4.在server端進行一個破壞性的實驗,把server02的gluster進程殺掉,到client端看,發現/mnt的空間把server02的去掉了變成了3G,但是到/mnt裏touch文件是沒問題
  但是把server01端的gluster進程殺掉後:
  [root@glusterfs_client mnt]# ls
  ls: .: 沒有那個文件或目錄
  當把server01端的glusterfs進程啓動後恢復正常
5.到此有幾個問題比較疑惑
(1).交換空間也就是namespace需要設置多大,是應該每個存儲空間之和還是和一個空間大小一樣就行,個人感覺應該是每個存儲空間之和
(2).感覺只要namespace的服務器的進程不down,client就可以正常訪問,namespace可以和其他的server在一臺服務器上也可以單獨一臺服務器,單獨出來出問題的危險小點
    還可以把namespace的服務器做成HA爲了更保險的話,這樣就感覺namespace太浪費磁盤了
對於以上2個問題,我會再之後的學習中進行研究,並實現glusterfs的其他功能,對於其中的參數下次一併討論吧

                                 
                                                   
 
 

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