The following guide will get you quickly started with a gluster-swift environment on a Fedora or RHEL/CentOS system. 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.
## System SetupNOTE: In Gluster-Swift, accounts must be GlusterFS volumes.
On CentOS/RHEL you will need to setup GlusterFS and EPEL repos.
- CentOS
wget -O /etc/yum.repos.d/glusterfs-epel.repo \
http://download.gluster.org/pub/gluster/glusterfs/LATEST/CentOS/glusterfs-epel.repo
- RHEL
wget -O /etc/yum.repos.d/glusterfs-epel.repo \
http://download.gluster.org/pub/gluster/glusterfs/LATEST/RHEL/glusterfs-epel.repo
Please refer to EPEL for more information on how to setup the EPEL repo.
Install and start the required packages on your system to create a GlusterFS volume.
yum install glusterfs glusterfs-server glusterfs-fuse memcached xfsprogs
Type the following to start memcached
and glusterfs
services:
service memcached start
service glusterd start
Type the following to start the services automatically on system startup:
chkconfig memcached on
chkconfig glusterd on
Now you need to determine whether you are going to use a partition or a loopback device for storage.
If you are using a separate disk partition, please execute the following instructions to create a GlusterFS brick:
mkfs.xfs -i size=512 /dev/<disk partition>
mkdir -p /export/brick
Add the following line to /etc/fstab
to mount the storage automatically on system
startup:
/dev/<disk partition> /export/brick xfs inode64,noatime,nodiratime 0 0
Now type the following to mount the storage:
mount -a
If you do not have a separate partition, please execute the following instructions to create a disk image as a file:
truncate -s 5GB /srv/swift-disk
mkfs.xfs -i size=512 /srv/swift-disk
mkdir -p /export/brick
Add the following line to /etc/fstab
to mount the storage automatically on system
startup:
/srv/swift-disk /export/brick xfs loop,inode64,noatime,nodiratime 0 0
Now type the following to mount the storage:
mount -a
You now need to create a GlusterFS volume (make sure your hostname is in /etc/hosts or is DNS-resolvable)
mkdir /export/brick/b1
gluster volume create myvolume `hostname`:/export/brick/b1
gluster volume start myvolume
Gluster-Swift requires OpenStack Swift's Havana release, which may not be available on some older operating systems. For RHEL/CentOS systems, please setup Red Hat RDO's repo by executing the following command:
yum install -y http://rdo.fedorapeople.org/rdo-release.rpm
Download the latest Havana release RPMs from launchpad.net downloads:
Install the RPM by executing the following:
yum install -y <path to RPM>
Type the following to make sure gluster-swift is enabled at system startup:
chkconfig openstack-swift-proxy on
chkconfig openstack-swift-account on
chkconfig openstack-swift-container on
chkconfig openstack-swift-object on
Currently gluster-swift requires its processes to be run as root
. You need to
edit the openstack-swift-*.service
files in
/etc/systemd/system/multi-user.target.wants
and change the User
entry value
to root
.
Then run the following command to reload the configuration:
systemctl --system daemon-reload
As 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:
cd /etc/swift
for tmpl in *.conf-gluster ; do cp ${tmpl} ${tmpl%.*}.conf; done
You now need to generate the ring files, which inform 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:
cd /etc/swift
/usr/bin/gluster-swift-gen-builders myvolume
Use the following commands to start gluster-swift:
service openstack-swift-object start
service openstack-swift-container start
service openstack-swift-account start
service openstack-swift-proxy start
Create a container using the following command:
curl -v -X PUT http://localhost:8080/v1/AUTH_myvolume/mycontainer
It 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/myvolume
You can now place an object in the container you have just created:
echo "Hello World" > mytestfile
curl -v -X PUT -T mytestfile http://localhost:8080/v1/AUTH_myvolume/mycontainer/mytestfile
To 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/mytestfile
Now you can retreive the object and inspect its contents using the following commands:
curl -v -X GET -o newfile http://localhost:8080/v1/AUTH_myvolume/mycontainer/mytestfile
cat newfile