天天看點

分布式檔案系統---GlusterFS安裝配置

一、環境規劃

GlusterFS服務端:10.100.0.41/10.100.0.44

GlusterFS用戶端:10.100.0.43

二、所需軟體包

glusterfs-server-3.4.2-1.el6.x86_64

glusterfs-3.4.2-1.el6.x86_64

三、安裝

     3.1、服務端安裝

#wget -P /etc/yum.repos.d http://download.gluster.org/pub/gluster/glusterfs/3.6/3.6.2/CentOS/glusterfs-epel.repo

#service glusterd start

#chkconfig glusterd on

     3.2、配置存儲目錄

          GlusterFS預設不能使用根分區作為GlusterFS的存儲目錄,本例中使用第二塊磁盤來做

# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x423f8af8.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

         switch off the mode (command 'c') and change display units to

         sectors (command 'u').

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-78325, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-78325, default 78325):

Using default value 78325

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

# mkfs.ext4 /dev/sdb1

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

39321600 inodes, 157286382 blocks

7864319 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

4800 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,

        102400000

Writing inode tables: done                           

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 35 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

# mkdir /gfs

# mount /dev/sdb1 /gfs

# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda2              30G  1.8G   27G   7% /

tmpfs                 495M     0  495M   0% /dev/shm

/dev/sda1             194M   28M  157M  15% /boot

/dev/sda4              65G  180M   62G   1% /home

/dev/sdb1             591G  198M  561G   1% /gfs

     3.3、加入随機啟動

#echo "/dev/sdb1                                 /gfs                    ext4    defaults        1 2" >> /etc/fstab

     3.4、在第一台GlusterFS server中加入存儲節點。即(10.100.0.44)

# gluster peer probe 10.100.0.44       # 加入新節點

.......

     3.5、檢視節點資訊

# gluster peer status

Number of Peers: 1

Hostname: 10.100.0.44

Uuid: c674ccbb-072b-4f26-97a2-facd15add645

State: Peer in Cluster (Connected)

     3.5、建立存儲卷。即叢集磁盤

#gluster volume create gfsv replica 2 10.100.0.41:/gfs 10.100.0.44:/gfs

Creation of volume gfsv has been successful. Please start the volume to access data.

     3.6、啟動存儲卷

# gluster volume start gfsv      # 啟動卷

     3.7、檢視存儲卷資訊

# gluster volume info

Volume Name: gfsv

Type: Replicate

Volume ID: be627a08-1d36-40f5-add0-1277be47c328

Status: Started

Number of Bricks: 1 x 2 = 2

Transport-type: tcp

Bricks:

Brick1: 10.100.0.41:/gfs/data

Brick2: 10.100.0.44:/gfs/data

     3.8、配置通路ACL規則

# gluster volume set gfs auth.allow 10.100.0.*     # 授權通路

四、用戶端安裝配置

     4.1、安裝用戶端

          用戶端需要fuse支援

# yum -y install glusterfs glusterfs-fuse glusterfs-api glusterfs-devel glusterfs-libs

     4.2、挂載glusterfs存儲

#mount -t glusterfs -o rw 10.100.0.41:gfsv /home/gfs/data/

五:存儲卷模式

     (1)distribute volume:分布式卷,檔案通過hash算法分布到brick server上,這種卷是glusterfs的基礎和最大特點;

     (2)stripe volume:條帶卷,類似RAID0,條帶數=brick server數量,檔案分成資料塊以Round Robin方式分布到brick server上,并發粒度是資料塊,大檔案性能高;

     (3)replica volume:鏡像卷,類似RAID1,鏡像數=brick server數量,是以brick server上檔案資料相同,構成n-way鏡像,可用性高;

     (4)distribute stripe volume:分布式條帶卷,brick server數量是條帶數的倍數,兼具distribute和stripe卷的特點;

     (5)distribute replica volume:分布式鏡像卷,brick server數量是鏡像數的倍數,兼具distribute和replica卷的特點; 

六、 平衡布局是很有必要的,因為布局結構是靜态的,當新的bricks加入現有卷,新建立的檔案會分布到舊的bricks中,是以需要平衡布局結構,使新加入 的bricks生效。布局平衡隻是使新布局生效,并不會在新的布局移動老的資料,如果你想在新布局生效後,重新平衡卷中的資料,還需要對卷中的資料進行平 衡。

gluster volume rebalance VOLNAME fix-layout start

gluster volume rebalance VOLNAME migrate-data start

也可以兩步合一步同時操作

gluster volume rebalance VOLNAME start

你也可以删除/停止卷

gluster volume stop/delete VOLNAME

你可以在在平衡過程中檢視平衡資訊:

你也可以暫停平衡,再次啟動平衡的時候會從上次暫停的地方繼續開始平衡。

gluster volume rebalance VOLNAME stop

本文轉自  亮公子  51CTO部落格,原文連結:http://blog.51cto.com/iyull/1946587

繼續閱讀