歡迎您光臨本站 註冊首頁

gfs和兩個gnbd_serv的問題,救命啊!

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

gfs和兩個gnbd_serv的問題,救命啊!

----------       ----------
  | GNBD   |       | GNBD   |
  | client | ....  | client |
  |   1    |       |   n    |
  ----------       ----------
      |                |
      ------------------  IP network
       |              |
   ----------      ----------
   | GNBD   |      | GNBD   |
   | server | .... | server |
   |   1    |      |   2   |
   ----------      ----------
        |              |
      
       | |          |         |
      |   |         |     |
     |     |       ***   ***
    ***   ***      ***   ***
    ***   ***      hda   hdb
     hda  hdb      data1 data2
    data1 data2
     
    我的機器都是普通pc機和ide硬碟 ,要實現如下功能:
1>兩個gnbd_serv向gnbd_client輸出存儲設備,實現鏡像功能即圖中1機的data1和2機的data1相同,1的

data2和2的data2相同
2>要做到冗餘即一台機器死掉,正個存儲工作能正常進行


請問各位大俠目前redhat的gfs+cluster+lvm2能做到嗎?若能做到該怎麼做啊?急死人了啊
目前我做出來了一個結點的以及我把gfs6.1翻譯了5章和6章的,翻譯得不是很好,供大家參考
  


這裡有各個前輩們在使用cluster 和gfs時遇到的問題和解答
http://www.spinics.net/lists/cluster/

一: Gfs 安裝:
1:升級到內核到2.6.15.23.server

1>        #uname  –a  
Linux test1 2.6.15-23-serv
2>        #apt-get dist-upgrade
  升級內核后cluster,gfs 已安裝,
3>        在gnbd服務端裝gnbd-server
# Aptitude install gnbd-sever
4>        在gnbd客戶端裝gnbd-client
2:系統結構
我這裡用192.168.0.23做gnbd服務端,把/dev/had/做共享磁碟,192.168.0.21 192.168.0.22做gnbd客戶端,它們使用0.23 export出來的gfs系統空間
----------       ----------
  | GNBD   |       | GNBD   |
  | client |       | client |       <-- these nodes use gfs
  | node21  |       | node22 |
  ----------       ----------
      |                |
      ------------------  IP network
               |
          ----------
          | GNBD   |
          | server |                <-- this node doesn't use gfs
          | node23  |
          ----------
3:服務端配置
1>        對/dev/had分區
fdisk -l
fdisk /dev/hda
其參數的使用如下:
              1. 輸入 m 顯示所有命令列示。

        2. 輸入 p 顯示硬碟分割情形。

        3. 輸入 a 設定硬碟啟動區。

        4. 輸入 n 設定新的硬碟分割區。

         4.1. 輸入 e 硬碟為[延伸]分割區(extend)。

         4.2. 輸入 p 硬碟為[主要]分割區(primary)。

        5. 輸入 t 改變硬碟分割區屬性。確認每一個LVM分區的類型為8e

        6. 輸入 d 刪除硬碟分割區屬性。

        7. 輸入 q 結束不存入硬碟分割區屬性。

        8. 輸入 w 結束並寫入硬碟分割區屬性。
我這裡只用了n 把整個/dev/hda分成一個區,用t指定為lvm分區類型8e,w保存
2>建立lvm邏輯分區
<1> pvcreate /dev/hda1
<2>vgcreate mygp /dev/hda1
<3>vgdisplay mygp| grep "Total PE"
<4>lvcreate -l 19632 mygp -n www1
<5>lvdisplay
3>配置cluster.conf
Vi /etc/cluster/cluster.conf

<?xml version="1.0"?>
<cluster name="mygfs" config_version="1">

<cman two_node="1" expected_votes="1">
</cman>

<clusternodes>
<clusternode name="test1">
        <fence>
                <method name="single">
                        <device name="gnbd" ipaddr="192.168.0.21"/>
                </method>
        </fence>
</clusternode>

<clusternode name="test2">
        <fence>
                <method name="single">
                        <device name="gnbd" ipaddr="192.168.0.22"/>
                </method>
        </fence>
</clusternode>
</clusternodes>

<fencedevices>
        <fencedevice name="gnbd" agent="fence_gnbd" servers="192.168.0.23"/>
</fencedevices>

</cluster>
這個文件放在客戶端任一個結點上,當另一個結點在使用cman_tool join後會自動去這個結點拿過來
4>在gnbd server export設備
啟動gnbd_serv進程
# /sbin/gnbd_serv –v –n
導出設備
# gnbd_export -d /dev/mygp/www1 -e global_disk -c

查看export狀態信息
# gnbd_export -v -l
Server : global_disk
--------------------------
      file : /dev/mygp/www1
   sectors : 160825344
  readonly : no
    cached : yes
   timeout : no
4:客戶端配置:
1>載入模塊
vi /etc/init.d/rc.local
modprobe gnbd
modprobe gfs
modprobe lock_dlm
vi /etc/modules
gnbd
gfs
lock_dlm
2>#cman_tool join

#ccsd
#ccs_test connect 應該返回
onnect successful.
Connection descriptor = 124>在兩個節點上啟動集群管理器(cman)
3>啟動集群LVM進程(CLVM)
# /sbin/clvmd

#fence_tool join
注意:如果你配置了多個fence域,而該域又不在本結點且還沒有配置好該結點,你得這樣啟動:fence_tool join –c
否則會出現這樣的錯誤:mount: permission denied 為這個問題我廢了一天半!建議凡是客戶端配置除mout步驟外其它步驟同時在結點上進行,而mount時得一個結點mount 完了才能接著mount

查看狀態,
#cat /proc/cluster/nodes
應該返回
Node Votes Exp Sts Name
1 1 1 M test1
2 1 1 M test2
4>加入fence域:
# /sbin/fence_tool join
5>激活LVM卷
# vgchange -aly

6>導入設備
#gnbd_import -i 192.168.0.23
查看導入狀態信息
# gnbd_import -v –l
Device name : global_disk
----------------------
    Minor # : 0
  Proc name : /dev/gnbd0
     Server : 192.168.0.23
       Port : 14567
      State : Close Connected Clear
   Readonly : No
    Sectors : 160825344
#cd /dev/gnbd
#ls 查看內容應是這樣
root@test1:/dev/gnbd# ls
global_disk
啟動dlm,ccsd,fence等服務

7>查看集群狀態
#cat /proc/cluster/status
Protocol version: 5.0.1
Config version: 1
Cluster name: mygfs
Cluster ID: 3443
Cluster Member: Yes
Membership state: Cluster-Member
Nodes: 1
Expected_votes: 1
Total_votes: 1
Quorum: 1   
Active subsystems: 3
Node name: test1
Node addresses: 192.168.0.21
8>建立gfs文件系統並且掛載
#gfs_mkfs -p lock_dlm -t mygfs:gfs -j 20 /dev/gnbd/global_disk
顯示如下內容
evice:                    /dev/gnbd/global_disk
Blocksize:                 4096
Filesystem Size:           19839184
Journals:                  8
Resource Groups:           304
Locking Protocol:          lock_dlm
Lock Table:                mygfs:gfs1
此步只需在一個結點做一次,其他結點掛載使用就行了
19>掛載文件系統
#mkdir /gfswww21
# mount -t gfs locktable=lock_dlm  /dev/gnbd/global_disk /gfswww21

10>關閉各服務
umount /mnt                       
vgchange -aln                    
killall clvmd                 
fence_tool leave            
cman_tool leave -w              
killall ccsd   

12>注意事項
在0.23上你千萬不要去訪問你對外輸出的設備,這樣會導致系統鎖死
   

5;測試
   1>
root@test1:/gfswww21/gou# df -h /gfswww21
Filesystem            Size  Used Avail Use% Mounted on
/dev/gnbd/global_disk
                       75G   60K   75G   1% /gfswww21
有/dev/gnbd/global_dis它說明是掛上了

2>在裡面建一個目錄,建一個文件,在該文件里寫入內容 然後重起該機,並再mount上看文件在不在

Mkdir /gfswww21/gou
Touch gou.txt
重起機后發現,再mount之前,用ls /gfswww21 無內容,說明文件存到0.23的/dev/mygp/www1上了



二   Gfs文件系統管理
1:創建gfs文件系統
使用方法:
gfs_mkfs -p LockProtoName -t LockTableName -j Number BlockDevice
LockProtoName:鎖協議,其值有:
lock_dlm標準協議
lock_gulm 早期版本使用
lock_nolock建立本地gfs系統時使用
例:
gfs_mkfs -p lock_dlm -t alpha:gfs2 -j 8 /dev/vg01/lvol1
gfs_mkfs -p lock_nolock -j 8 /dev/mygp/www1
2:mount文件系統
使用方法:mount -t gfs BlockDevice MountPoint -o option
例:mount -t gfs –o localcaching /dev/vg01/lvol0 /gfs1
-o的值:
Acl
如過一個文件系統在mount時沒有使用acl選項,只允許用getfacl
命令看acls,而不能設置

hostdata=HostIDInfo
給lock模塊定義主機的信息,當使用lock_dlm時
ignore_local_fs
localcaching

localflocks
上面三個當共享文件系統時不要使用

lockproto=LockModuleName//定義鎖協議
lockproto=lock_dlm
locktable=LockTableName//定義鎖表名
oopses_ok
upgrade 允許升級

3: 磁碟配額
1>設置硬限制

gfs_quota limit -u User -l Size -f MountPoint
gfs_quota limit -g Group -l Size -f MountPoint

例:gfs_quota limit -u Bert -l 1024 -f /gfs

2>設置軟限制
gfs_quota warn -u User -l Size -f MountPoint
gfs_quota warn -g Group -l Size -f MountPoint
例:
gfs_quota warn -g 21 -l 50 -k -f /gfs
3>顯示配額信心
<1>顯示用戶配額信息
quota get -u User -f MountPoint
<2>顯示組配額信息
gfs_quota get -g Group -f MountPoint

<3>顯示整個配額信息
gfs_quota  list  -f  /gfs
gfs_quota get -g users -f /gfs -s
4:同步配額信息
<1>同步配額信息

gfs_quota sync -f MountPoint

例:gfs_quota sync -f /gfs

<2>設置配額信息更新時間
gfs_tool settune MountPoint quota_quantum Seconds
例:gfs_tool settune /gfs quota_quantum 3600
5:強制使用還是不使用配額的設置,必須在每個節點和每次mount時都要做這樣的操作!
gfs_tool settune MountPoint quota_enforce {0|1}
1:使用配額
0:不使用配額
例:強制不使用配額
gfs_tool settune /gfs quota_enforce 0
例:強制使用配額
gfs_tool settune /gfs quota_enforce 1
6:設置是否統計磁碟配額,默認情況下統計,即使你沒有採用配額限制,所以這種情況是對資源的白白浪費,幸好可以設置!但是必須在每個節點和每次mount時都要做這樣的操作!
gfs_tool settune MountPoint quota_account {0|1}
0 = disabled
1 = enabled
7:當設置了使用配額統計,則必須初始化文件系統
gfs_quota init -f MountPoint.
gfs_tool settune /gfs quota_account 1
gfs_quota init -f /gfs
8:擴展文件系統
1> gfs_grow能夠把從當前所在磁碟的的結尾到新加的已被make成gfs的磁碟擴張成為某個原來的gfs文件系統的新空間,這個命令必須在已經被mouted過的gfs文件系統上操作,且只需在該節點上操作后,其他節點就能自動使用該節點的新空間
2>在執行這個命令前需要做的工作:
<1>備份這個文件系統上的重要的數據
<2> 運行gfs_tool df MountPoint命令顯示將要擴張的文件系統的已使用的空間大小
<3> Expand the underlying cluster volume with LVM.在lvm的cluster下擴展請看這個網址 (Refer to the LVM HOWTO at
http://www.tldp.org/HOWTO/LVM-HOWTO/index.html for command usage with
CLVM.)
3>使用df –h 查看一下磁碟空間
例:
gfs_grow /gfs1
檢查被擴張后的磁碟情況
gfs_grow -Tv /gfs1

4>gfs_grow的使用方法:
gfs_grow {MountPoint | Device}

8:曾加一個日誌Journals文件系統
1>gfs_jadd該命令是在增加文件系統後用來增加日誌文件系統,該命令也是在每次mount一個文件系統之後執行一次,且也只需要在該節點上執行一次后,整個cluster都能使用了
2>在執行這個命令前需要做的工作
<1>備份這個文件系統上的重要的數據
<2> 運行gfs_tool df MountPoint命令顯示將要擴張的文件系統的已使用的空間大小
<3> Expand the underlying cluster volume with LVM.在lvm的cluster下擴展請看這個網址 (Refer to the LVM HOWTO at
http://www.tldp.org/HOWTO/LVM-HOWTO/index.html for command usage with
CLVM.)
3>例:
gfs_jadd –j 1 /gfs1
gfs_jadd –j 2 /gfs1
gfs_jadd -Tv /gfs1
4> gfs_jadd 的使用方法:
gfs_jadd {MountPoint | Device}

Options;
-J:以m為單位指定日誌文件的大小默認是128M,每次新增加時至少為32m
-j:為新增加的日誌文件系統指定編號
9:直接I/O
1>        Direct I/O:它是一個文件系統的屬性,直接哪個應用存貯設備進行讀和寫,所謂直接就是繞過操作系統去讀寫cache的內容,Direct I/O僅僅被某種應用用來管理自己的緩存
2>        一個應用是如何調用Direct I/O的?
一個文件被綁定一個O_DIRECT屬性,一個應用就是使用這個屬性的值來調度Direct I/O的
3>有下面的方法使Direct I/O應用於一個文件或目錄上
. O_DIRECT
. GFS file attribute

GFS directory attribute
4>GFS File Attribute 給文件設置Direct I/O的例子:
為一個文件設置direct i/o屬性

gfs_tool setflag directio File
清出一個文件的direct i/o屬性
gfs_tool clearflag directio File
gfs_tool setflag directio /gfs1/datafile
5> GFS Directory Attribute為一個目錄設置direct i/o屬性
為一個目錄設置direct i/o屬性
gfs_tool setflag inherit_directio Directory
清出一個目錄的direct i/o屬性
gfs_tool clearflag inherit_directio Directory
例:gfs_tool setflag inherit_directio /gfs1/data/
10:Data Journaling數據日誌
1>        gfs通常是先把元數據寫到日誌里,文件內容是由內核周期性的刷新文件系統的buffers后再寫到磁碟的,內核是通過調用fsync()來完成把文件寫到disk的,Data journaling能減少fsync()調用的時間,所以比直接把文件寫到一個主文件系統里快,Data journaling能自動為一個gfs文件系統的目錄和文件設置jdata attribute屬性,即使是零長度的文件,當然也可以清處
2>        使用方法
<1>對目錄設置
gfs_tool setflag inherit_jdata Directory
gfs_tool clearflag inherit_jdata Directory
例:gfs_tool setflag inherit_jdata /gfs1/data/

<2>對文件設置
gfs_tool setflag jdata File
gfs_tool clearflag jdata File
例:gfs_tool setflag jdata /gfs1/datafile
11:Conguring atime Updates更新訪問時間的配置
1>        一個文件接點或目錄接點有三種時間戳,它們是:
ctime. 接點狀態最後一次被改變的時間
. mtime.文件和目錄最後一次被該變的時間
. atime. 文件和目錄最後一次被訪問的時間
2>        如果目錄和文件被訪問一次就更新一次時間戳,更定會影響系統性能,對於atime我們有兩種處理辦法,那就是:
. Mount with noatime
. Tune GFS atime quantum
1>        Mount with noatime就是在mount文件系統時使用-o noatime 選項屏蔽對atime的更新:
mount -t gfs BlockDevice MountPoint -o noatime
例:mount -t gfs /dev/vg01/lvol0 /gfs1 -o noatime
2> Tune GFS atime quantum調整atime被改變的周期
<1>顯示某個gfs系統所有可調的參數
gfs_tool gettune MountPoint
例:gfs_tool gettune /gfs1

<.2> gfs_tool settune MountPoint atime_quantum Seconds
例:gfs_tool settune /gfs1 atime_quantum 86400// (秒)[一天]
12: Suspending Activity on a File System在一個文件系統上執行掛起行為
1>在一個文件系統上執行gfs_tool freeze命令來掛起寫的行為,掛起寫的行為允許硬體設備使用快照捕獲文件系統的一個持續狀態
<1>開始掛起
gfs_tool freeze MountPoint
例:gfs_tool freeze /gfs
<2>結束掛起
gfs_tool unfreeze MountPoint
例:gfs_tool unfreeze /gfs
12: Displaying Extended GFS Information and
Statistics顯示gfs的擴展和統計的信息
1>Displaying Statistics顯示統計的信息
gfs_tool counters MountPoint

2>Displaying Space Usage顯示空間
gfs_tool df MountPoint
3>Displaying Extended Status顯示擴展狀態
gfs_tool stat File
例:gfs_tool df /gfs
gfs_tool stat /gfs/datafile
13: Repairing a File System修復一個文件系統
1>當一個接點的gfs文件系統失敗了,可以從文件系統的日誌文件中恢復,使用gfs_fsck命令,但該命令必須在被unmounted的文件系統上都執行
2>使用方法
gfs_fsck -y BlockDevice
gfs_fsck -y /dev/vg01/lvol0
14: Context-Dependent Path Names上下關聯路徑名
1>Context-Dependent Path Names (CDPNs)就是指向多個實際文件或目錄的符號連接。當一個應用使用這個符號連接時它可以解析到真實的文件和目錄上去,應用程序只能使用這個符號連接去找到真實文件或目錄
2>語法:ln -s Variable LinkName
它和我們平時使用的符號連接[ln -s Target LinkName
]的差別在於 連接目標是可變的,且其取值也是下的幾個:
<1>@hostname 主機名,可用這個命令得到:echo `uname -n`
<2>@mach 機器類型,可用這個命令得到:echo `uname -m`
<3> @os操著系統類型,可用這個命令得到:echo `uname -s`
<4> @sys機器類型和操著系統類型的組合,可用這個命令得到:echo `uname \
-m`_`uname -s`
<5> @uid 用戶id   可用這個命令得到echo `id -u`
<6> @gid 組id,可用這個命令得到:echo `id -g`

3>例:在這個例子中,在/gfs/下創建三個目錄:/gfs/n.1 /gfs/n02,/gfs/n03,用一個符號連接把三個目錄表示成一個目錄/gfs/log,這樣應用程序通過使用/gfs/log目錄,就能使用這三個目錄,即多個目錄對外虛擬一個目錄,外邊的程序使用虛擬目錄來使用實際目錄
n01# cd /gfs
n01# mkdir n01 n02 n03
n01# ln -s @hostname log
n01# ls -l /gfs
lrwxrwxrwx 1 root root 9 Apr 25 14:04 log -> @hostname/
drwxr-xr-x 2 root root 3864 Apr 25 14:05 n01/
drwxr-xr-x 2 root root 3864 Apr 25 14:06 n02/
drwxr-xr-x 2 root root 3864 Apr 25 14:06 n03/
n01# touch /gfs/log/fileA
n02# touch /gfs/log/fileB
n03# touch /gfs/log/fileC
n01# ls /gfs/log/
fileA
n02# ls /gfs/log/
fileB
n03# ls /gfs/log/
fileC



15 GNBD (Global Network Block Device)全局網路塊設備
1>        GNBD:有服務端和客戶端兩部分組成,GNBD服務接點從自己的塊存儲設備中輸出塊級別存儲到一個gfs接點
注意:多路塊設備映射機制不能用於GNBD,這裡是針對red hat gfs6.1來說的
Multipath GNBD is not available with Red Hat GFS 6.1. That is, device mapper multipath (dm-multipath) cannot use GNBD. GNBD without multipath is available.我對這一段理解不是很明白,只好把原文附上,
2>兩個主要模塊:
. gnbd_serv . Implements the GNBD server. It is a user-space daemon that allows a node to export local storage over a network.
實現GNBD服務端的功能,這就是在網路上把自己的存儲設備輸出到網路上的gfs接點上,它是一個用戶態進程
. gnbd.ko.Implements the GNBD device driver on GNBD clients (nodes using GNBD devices).
在客戶端實現gnbd設備驅動
2>        配置GNBD的兩個命令
.<1> gnbd_export 在gnbd服務端創建,輸出,管理gnbds
<2> gnbd_import在客戶端實現輸入和管理gnbds
3>啟動gnbd服務:
#gnbd_serv
啟動成功后顯示如下信息:
gnbd_serv: startup succeeded
3>        gnbd_export使用方法:
gnbd_export -d pathname -e gnbdname [-c]
pathname:指定要輸出的存儲設備
gnbdname:要被客戶端使用的設備名,在整個網路上必須是唯一的但是任意的
-o:以只讀方式輸出設備名
-c:能使用緩存,linux默認不使用
例:gnbd_export -d /dev/sdb2 -e delta -c
4>        gnbd_import:使用方法:
<1>在使用該命令前,一定要保證gnbd.ko內核模塊在接點上已經被載入了,另外,服務端已經要輸出塊設備
<2>使用方法:
gnbd_import -i Server
server:要輸入gnbds的主機名或ip地址
例:gnbd_import -i nodeA
16 :Running GFS on a GNBD Server Node在一個 gnbd服務接點上運行gfs
1>        你可以在gnbd服務端接點上運行gfs,但性能將受到影響且你必遵從下面的限制:
<1>你必須讓gnbd服務接點上的所有設備都mount成gfs文件系統,且沒有輸出任何其他gnbd設備
<2>gnbd服務接點必須一不能使用緩存的模式輸出所有的gnbds,切必須是裸設備
<3>GFS must be run on top of a logical volume device, not raw devices.
必須在一個邏輯設備的頂部運行而不是在raw devices.上
17後面的附錄講的是如何升級到gfs6.1,我們用不看了
《解決方案》

在redhat的網站有這樣的描述,但是沒有實現方法。我也有同樣的問題!那位高手能給出實現的辦法啊?

Another alternative configuration is given in Figure 7. GNBD serving using non-shared storage and mirroring in the cluster, which shows a GFS server attached to a group of GNBD servers where mirror volume pairs are maintained across sets of GNBD servers. These mirror pairs can be constructed using cluster volume mirroring software on the GFS servers. Notice in Figure 8. GNBD server or mirrored volume failures are tolerated how this configuration (non-shared storage devices that are mirrored across GNBD servers) allows both the GNBD server and storage device failures to occur without bringing the GFS cluster down. In this example, GNBD server B or storage device 2 has failed, so the mirror volume 2' for storage device 2 is accessed through GNBD server A. This example shows that non-shared storage can be attached to the GNBD server layer in such a way that both GNBD server and storage device failures can be tolerated, at the cost of mirroring all storage devices. Mirroring storage devices doubles the required storage hardware compared to the same capacity of non-mirrored storage. In addition, it increases the amount of storage traffic seen on the IP network (each disk block is written twice instead of just once).
GNBD serving using non-shared storage and mirroring in the cluster
http://www.redhat.com/magazine/008jun05/features/gfs/figs/mirroring.jpg
Figure 7. GNBD serving using non-shared storage and mirroring in the cluster
http://www.redhat.com/magazine/008jun05/features/gfs/figs/failure.jpg
GNBD server or mirrored volume failures are tolerated
《解決方案》

頂一下,我也想知道怎麼實現冗餘,誰幫忙解答一下!
《解決方案》

GNBD已經是一個過氣的玩意了,沒必要再去折騰,如果真想去折騰,可以看看本人的精華帖之一。
《解決方案》

http://linux.chinaunix.net/bbs/thread-1040310-1-1.html

兩次發帖間隔不能少於30s。
《解決方案》

GNBD用過一段時間,真的不好。不大喜歡。
《解決方案》

那樓上的,建議用什麼?

[火星人 ] gfs和兩個gnbd_serv的問題,救命啊!已經有728次圍觀

http://coctec.com/docs/service/show-post-5358.html