QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 3829|回复: 0

Gfs安装配置参考文档

[复制链接]
发表于 2008-1-29 10:02:51 | 显示全部楼层 |阅读模式
----------       ----------
  | GNBD   |       | GNBD   |
  | client | ....  | client |
  |   1    |       |   n    |
  ----------       ----------
      |                |
      ------------------  IP network
       |              |
   ----------      ----------
   | GNBD   |      | GNBD   |
   | server | .... | server |
   |   1    |      |   2   |
   ----------      ----------
        |              |
      
       | |          |         |
      |   |         |     |
     |     |       ***   ***
    ***   ***      ***   ***
    ***   ***      hda   hdb
     hda  hdb      data1 data2
    data1 data2

这里有在使用cluster gfs时遇到的问题和解答
http://www.spinics.net/lists/cluster/




1
:升级到内核到2.6.15.23.server
IXDBA.NET社区论坛

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.23gnbd服务端,把/dev/had/做共享磁盘,192.168.0.21 192.168.0.22gnbd客户端,它们使用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:服务端配置[192.168.0.23]
1>        
/dev/had分区
fdisk -l
fdisk /dev/hda
其参数的使用如下:
              1.
输入 m 显示所有命令列示。

2. 输入 p 显示硬盘分割情形。

3. 输入 a 设定硬盘启动区。
IXDBA.NET社区论坛


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分区类型8ew保存
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[1] : 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
IXDBA.NET社区论坛
# /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上了

IXDBA.NET技术社区

   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
能够把从当前所在磁盘的结尾到新加的已被makegfs的磁盘扩张成为某个原来的gfs文件系统的新空间,这个命令必须在已经被mouted过的gfs文件系统上操作,且只需在该节点上操作后,其他节点就能自动使用该节点的新空间
2>
在执行这个命令前需要做的工作:
<1>
备份这个文件系统上的重要的数据
<2>
运行gfs_tool df MountPoint命令显示将要扩张的文件系统的已使用的空间大小
IXDBA.NET社区论坛
<3> Expand the underlying cluster volume with LVM.
lvmcluster下扩展请看这个网址 (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 [Options] {MountPoint | Device} [MountPoint | Device]

8:
曾加一个日志Journals文件系统

1>gfs_jadd
该命令是在增加文件系统后用来增加日志文件系统,该命令也是在每次mount一个文件系统之后执行一次,且也只需要在该节点上执行一次后,整个cluster都能使用了
2>
在执行这个命令前需要做的工作
<1>
备份这个文件系统上的重要的数据
<2>
运行gfs_tool df MountPoint命令显示将要扩张的文件系统的已使用的空间大小
<3> Expand the underlying cluster volume with LVM.
lvmcluster下扩展请看这个网址 (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 [Options] {MountPoint | Device} [MountPoint | Device]

Options;
-J:
m为单位指定日志文件的大小,默认是128M,每次新增加时至少为32m
-j:为新增加的日志文件系统指定编号

9
:直接I/O[Direct 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.
文件和目录最后一次被访问的时间
IXDBA.NET社区论坛
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来说的.
IXDBA.NET技术社区
MultipathGNBD is not available with Red Hat GFS 6.1. That is, device mappermultipath (dm-multipath) cannot use GNBD. GNBD without multipath isavailable.我对这一段理解不是很明白,只好把原文附上.


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

你可以在gnbd服务端接点上运行gfs,但性能将受到影响
且你必遵从下面的限制:
<1>你必须让gnbd服务接点上的所有设备都mountgfs文件系统,且没有输出任何其他gnbd设备.
<2>gnbd
服务接点必须一不能使用缓存的模式输出所有的gnbds,切必须是裸设备
<3>GFS must be run on top of a logical volume device, not raw devices.
必须在一个逻辑设备的顶部运行而不是在raw devices..
redhat的网站有这样的描述,但是没有实现方法。我也有同样的问题!那位高手能给出实现的办法啊?

Another alternative configuration is given in Figure 7. GNBD servingusing non-shared storage and mirroring in the cluster, which shows aGFS server attached to a group of GNBD servers where mirror volumepairs are maintained across sets of GNBD servers. These mirror pairscan be constructed using cluster volume mirroring software on the GFSservers. Notice in Figure 8. GNBD server or mirrored volume failuresare tolerated how this configuration (non-shared storage devices thatare mirrored across GNBD servers) allows both the GNBD server andstorage device failures to occur without bringing the GFS cluster down.In this example, GNBD server B or storage device 2 has failed, so themirror volume 2' for storage device 2 is accessed through GNBD serverA. This example shows that non-shared storage can be attached to theGNBD server layer in such a way that both GNBD server and storagedevice failures can be tolerated, at the cost of mirroring all storagedevices. Mirroring storage devices doubles the required storagehardware compared to the same capacity of non-mirrored storage. Inaddition, it increases the amount of storage traffic seen on the IPnetwork (each disk block is written twice instead of just once).
GNBD serving using non-shared storage and mirroring in the cluster

Figure 7. GNBD serving using non-shared storage and mirroring in the cluster

GNBD server or mirrored volume failures are tolerated
您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-4-20 23:25 , Processed in 0.151427 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表