用GlusterFS+Swift搭建对象存储

Posted **小君哥**

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用GlusterFS+Swift搭建对象存储相关的知识,希望对你有一定的参考价值。

在已经搭建好的GlusterFS服务器上(如不知道如何搭建GlusteFS请参考上一篇):

Create bricks:

# truncate -s 1GB /srv/disk{1..4}# for i in `seq 1 4`;do mkfs.xfs -i size=512 /srv/disk$i ;done# mkdir -p /export/brick{1..4}

Add the following lines to /etc/fstab to auto-mount the the bricks on system startup:

/srv/disk1    /export/brick1   xfs   loop,inode64,noatime,nodiratime 0 0
/srv/disk2    /export/brick2   xfs   loop,inode64,noatime,nodiratime 0 0
/srv/disk3    /export/brick3   xfs   loop,inode64,noatime,nodiratime 0 0
/srv/disk4    /export/brick4   xfs   loop,inode64,noatime,nodiratime 0 0

Mount the bricks:

# mount -a

You can now create and start the GlusterFS volume. Make sure your hostname is in /etc/hosts or is DNS-resolvable.

# gluster volume create swift-test-vol-01 replica 2 transport tcp cnsz22VLK5966.ossit.sfdc.com.cn:/export/brick{1..4}/data force
 
 
Mount the GlusterFS volume:
# mkdir -p /mnt/gluster-object/test-vol-01 
# mount -t glusterfs cnsz22VLK5966.ossit.sfdc.com.cn:swift-test-vol-01  /mnt/gluster-object/test-vol-01
 
 
Installing Openstack Swift
# yum install centos-release-openstack-newton    (http://mirrors.aliyun.com/centos/7/extras/x86_64/Packages/
# yum install openstack-swift-*   (http://mirrors.aliyun.com/centos/7/cloud/x86_64/openstack-newton/
 
 
Installing gluster-swift  (注意安装版本要与openstack swift版本一致)
# yum install epel-release     (http://mirrors.aliyun.com/centos/7/extras/x86_64/Packages/
#yum install python-prettytable     (安装python相关包过程中如果遇到gcc相关编译报错,请执行yum install python-devel 安装python开发包)
#yum install git
# git clone https://github.com/gluster/gluster-swift; cd gluster-swift
# python setup.py install
 
 
gluster-swift configuration files
# mkdir -p /etc/swift/
# cp etc/* /etc/swift/
# cd /etc/swift
# for tmpl in *.conf-gluster ; do cp ${tmpl} ${tmpl%.*}.conf; done
 
 
Export GlusterFS volumes over gluster-swift   
# gluster-swift-gen-builders [VOLUME] [VOLUME...](命令格式)
# gluster-swift-gen-builders swift-test-vol-01 (命令实例)
 
 
Start gluster-swift
# swift-init main start
 
 
Using gluster-swift
 
Create a container
# curl -i -X PUT http://localhost:8080/v1/AUTH_swift-test-vol-01/test-container-01
# ls /mnt/gluster-object/swift-test-vol-01/
 
Create an object
# echo "Hello Swift" > test.txt
#curl -i -X PUT -T test.txt http://localhost:8080/v1/AUTH_swift-test-vol-01/test-container-01/test.txt
# cat /mnt/gluster-object/swift-test-vol-01/test-container-01/test.txt
 
Request the object
# curl -i -X GET -o newTest.txt http://localhost:8080/v1/AUTH_swift-test-vol-01/test-container-01/test.txt
#cat newTest.txt
 
Delete the object
#curl -i -X DELETE http://localhost :8080/v1/AUTH_swift-test-vol-01/test-container-01/test.txt
 
如果不是GlusterFS服务器,需要先安装以下包:
 
Installing and starting GlusterFS
 
# yum install centos-release-gluster
# yum install glusterfs glusterfs-server  glusterfs-cli glusterfs-libs glusterfs-client glusterfs-fuse glusterfs-api

以上是关于用GlusterFS+Swift搭建对象存储的主要内容,如果未能解决你的问题,请参考以下文章

【Minio】基于AWS S3协议搭建个人云存储服务

3.GlusterFS 企业分布式存储的搭建

swift对象存储环境搭建

GFS分布式文件系统

九Swift对象存储服务(双节点搭建)

对象存储glusterfs使用