Gluster-swift project enables object based access (over Swift and S3 API) to GlusterFS volumes.This guide is a great way to begin using gluster-swift, and can be easily deployed on a single virtual machine. The final result will be a single gluster-swift node.
The instructions provided in this guide has been tested specifically on:
- CentOS 7
- Ubuntu 16.04.2 LTS 'xenial'
If you are on other distributions, the steps related to where you fetch the installation packages may vary.
NOTE: In Gluster-Swift, accounts must be GlusterFS volumes.
If on Ubuntu 16.04:
# add-apt-repository ppa:gluster/glusterfs-3.10
# apt-get install glusterfs-server attr
# service glusterfs-server startIf on CentOS 7:
# yum install centos-release-gluster
# yum install glusterfs-server
# service glusterd startYou can use separate partitions as bricks. This guide illustrates using loopback devices as bricks.
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 -aYou can now create and start the GlusterFS volume. Make sure your hostname is in /etc/hosts or is DNS-resolvable.
# gluster volume create myvolume replica 2 transport tcp `hostname`:/export/brick{1..4}/data force
# gluster volume start myvolumeMount the GlusterFS volume:
# mkdir -p /mnt/gluster-object/myvolume
# mount -t glusterfs `hostname`:myvolume /mnt/gluster-object/myvolumeIf on Ubuntu 16.04:
# apt install python-pip libffi-dev memcached
# git clone https://github.com/openstack/swift; cd swift
# git checkout -b release-2.10.1 tags/2.10.1
# pip install -r ./requirements.txt
# python setup.py installIf on CentOS 7:
# yum install centos-release-openstack-newton
# yum install openstack-swift-*If on Ubuntu 16.04:
# git clone https://github.com/gluster/gluster-swift; cd gluster-swift
# pip install -r ./requirements.txt
# python setup.py installIf on CentoOS 7:
# yum install epel-release
# yum install python-scandir python-prettytable git
# git clone https://github.com/gluster/gluster-swift; cd gluster-swift
# python setup.py installAs with OpenStack Swift, gluster-swift uses /etc/swift as the
directory containing the configuration files. You will need to base
the configuration files on the template files provided. On new
installations, the simplest way is to copy the *.conf-gluster
files to *.conf files as follows:
Copy conf files from etc directory in gluster-swift repo to
/etc/swift and rename the template files.
# mkdir -p /etc/swift/
# cp etc/* /etc/swift/
# cd /etc/swift
# for tmpl in *.conf-gluster ; do cp ${tmpl} ${tmpl%.*}.conf; doneYou now need to generate the ring files, which informs gluster-swift which GlusterFS volumes are accessible over the object storage interface. The format is:
# gluster-swift-gen-builders [VOLUME] [VOLUME...]Where VOLUME is the name of the GlusterFS volume which you would like to access over gluster-swift.
Let's now expose the GlusterFS volume called myvolume you created above
by executing the following command:
# gluster-swift-gen-builders myvolumeUse the following commands to start gluster-swift:
# swift-init main startCreate a container using the following command:
# curl -i -X PUT http://localhost:8080/v1/AUTH_myvolume/mycontainerIt should return HTTP/1.1 201 Created on a successful creation. You can
also confirm that the container has been created by inspecting the GlusterFS
volume:
# ls /mnt/gluster-object/myvolumeYou can now place an object in the container you have just created:
# echo "Hello World" > mytestfile
# curl -i -X PUT -T mytestfile http://localhost:8080/v1/AUTH_myvolume/mycontainer/mytestfileTo confirm that the object has been written correctly, you can compare the test file with the object you created:
# cat /mnt/gluster-object/myvolume/mycontainer/mytestfileNow you can retreive the object and inspect its contents using the following commands:
# curl -i -X GET -o newfile http://localhost:8080/v1/AUTH_myvolume/mycontainer/mytestfile
# cat newfileFor more information, please visit the following links: