### Installing Gluster
wget -P /etc/yum.repos.d http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/glusterfs-epel.repo
yum install glusterfs{-fuse,-server}
# 查看gluster版本信息
glusterfs -V
# 啟動停止服務(wù)
service glusterd start
service glusterd stop
service glusterd stop
# 存儲主機(jī)加入信任存儲池
gluster peer probe fs-server-2
gluster peer probe fs-server-3
gluster peer probe fs-server-3
# 查看狀態(tài)
gluster peer status
# 五中類型的volume可以被創(chuàng)建:
Distributed:分布式卷,文件通過hash算法隨機(jī)的分布到由bricks組成的卷上。
Replicated:復(fù)制式卷,類似raid1,replica數(shù)必須等于volume中brick所包含的存儲服務(wù)器數(shù),可用性高。
Striped:條帶式卷,類似與raid0,stripe數(shù)必須等于volume中brick所包含的存儲服務(wù)器數(shù),文件被分成數(shù)據(jù)塊,以Round Robin的方式存儲在bricks中,并發(fā)粒度是數(shù)據(jù)塊,大文件性能好。
Distributed Striped:分布式的條帶卷,volume中brick所包含的存儲服務(wù)器數(shù)必須是stripe的倍數(shù)(>=2倍),兼顧分布式和條帶式的功能。
Distributed Replicated:分布式的復(fù)制卷,volume中brick所包含的存儲服務(wù)器數(shù)必須是 replica 的倍數(shù)(>=2倍),兼顧分布式和復(fù)制式的功能。
# 創(chuàng)建分布卷
gluster volume create gv0 fs-server-1:/data/gfs fs-server-2:/data/gfs
# 創(chuàng)建復(fù)制卷
gluster volume create gv0 replica 2 fs-server-1:/data/gfs fs-server-2:/data/gfs
# 創(chuàng)建條帶卷
gluster volume create gv0 stripe 2 fs-server-1:/data/gfs fs-server-2:/data/gfs
# 啟動卷
gluster volume start gv0
# 查看卷
gluster volume info gv0
#如果以后要添加服務(wù)器,可以使用add-brick命令:
gluster volume add-brick gv0 fs-server-3:/data/gfs fs-server-4:/data/gfs
gluster volume remove-brick VOLNAME BRICK
注意:當(dāng)你給分布式復(fù)制卷和分布式條帶卷中增加bricks時,你增加的bricks的數(shù)目必須是復(fù)制或者條帶數(shù)目的倍數(shù),例如:你給一個分布式復(fù)制卷的replica為2,你在增加bricks的時候數(shù)量必須為2、4、6、8等。
當(dāng)移除分布式復(fù)制卷或者分布式條帶卷的時候,移除的bricks數(shù)目必須是replica或者stripe的倍數(shù)。例如:一個分布式條帶卷的stripe是2,當(dāng)你移除bricks的時候必須是2、4、6、8等。
#掛載glusterfs
mount -t glusterfs fs-server-1:/gv0 /mnt/gfs
mount -t nfs fs-server-1:/gv0 /mnt/gfs
mount -v -t nfs -o mountproto=tcp,vers=3 fs-server-1:/gv0 /mnt/gfs-nfs
mount -t nfs fs-server-1:/gv0 /mnt/gfs
mount -v -t nfs -o mountproto=tcp,vers=3 fs-server-1:/gv0 /mnt/gfs-nfs