分佈式文件系統---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

#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






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