summaryrefslogtreecommitdiffstats
path: root/doc/markdown/quick_start_guide.md
blob: 9312ae95547aad4a4af7f39cee04c3b15ff78564 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# Quick Start Guide

## Contents
* [Overview](#overview)
* [Setting up GlusterFS](#gluster_setup)
* [Setting up gluster-swift](#swift_setup)
* [Using Gluster for Swift](#using_swift)
* [What now?](#what_now)

<a name="overview" />
## Overview
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.

<a name="gluster_setup" />
## Setting up GlusterFS

### Installing and starting GlusterFS

If on Ubuntu 16.04:

```sh
# add-apt-repository ppa:gluster/glusterfs-3.10
# apt-get install glusterfs-server attr
# service glusterfs-server start
```

If on CentOS 7:

```sh
# yum install centos-release-gluster
# yum install glusterfs-server
# service glusterd start
```

### Setting up a GlusterFS volume

You can use separate partitions as bricks. This guide illustrates using
loopback devices as bricks.

Create bricks:

```sh
# 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:

```sh
# mount -a
```

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

```sh
# gluster volume create myvolume replica 2 transport tcp `hostname`:/export/brick{1..4}/data force
# gluster volume start myvolume
```

Mount the GlusterFS volume:

```sh
# mkdir -p /mnt/gluster-object/myvolume
# mount -t glusterfs `hostname`:myvolume /mnt/gluster-object/myvolume
```

<a name="swift_setup" />
## Setting up gluster-swift

### Installing Openstack Swift (kilo version)

If on Ubuntu 16.04:

```sh
# apt install python-pip libffi-dev memcached
# git clone https://github.com/openstack/swift; cd swift
# git checkout -b kilo tags/kilo-eol
# pip install -r ./requirements.txt
# python setup.py install
```

If on CentOS 7:

```sh
# yum install centos-release-openstack-kilo
# yum install openstack-swift-*
```

### Installing gluster-swift (kilo version)

If on Ubuntu 16.04:

```sh
# git clone https://github.com/gluster/gluster-swift; cd gluster-swift
# pip install -r ./requirements.txt
# python setup.py install
```

If on CentoOS 7:

```sh
# 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 install
```

### gluster-swift configuration files
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:

Copy conf files from `etc` directory in gluster-swift repo to
`/etc/swift` and rename the template files.

```sh
# 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

You now need to generate the ring files, which informs gluster-swift
which GlusterFS volumes are accessible over the object storage interface.
The format is:

```sh
# 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:

```sh
# gluster-swift-gen-builders myvolume
```

### Start gluster-swift
Use the following commands to start gluster-swift:

```sh
# swift-init main start
```

<a name="using_swift" />
## Using gluster-swift

### Create a container
Create a container using the following command:

```sh
# curl -i -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:

```sh
# ls /mnt/gluster-object/myvolume
```

#### Create an object
You can now place an object in the container you have just created:

```sh
# echo "Hello World" > mytestfile
# curl -i -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:

```sh
# cat /mnt/gluster-object/myvolume/mycontainer/mytestfile
```

#### Request the object
Now you can retreive the object and inspect its contents using the
following commands:

```sh
# curl -i -X GET -o newfile http://localhost:8080/v1/AUTH_myvolume/mycontainer/mytestfile
# cat newfile
```

<a name="what_now" />
## What now?
For more information, please visit the following links:

* [Authentication Services Start Guide][]
* [GlusterFS Quick Start Guide][]
* [OpenStack Swift API][]
* [Accessing over Amazon S3 API][]


[GlusterFS Quick Start Guide]: http://www.gluster.org/community/documentation/index.php/QuickStart
[OpenStack Swift API]: http://docs.openstack.org/api/openstack-object-storage/1.0/content/
[Authentication Services Start Guide]: auth_guide.md
[Accessing over Amazon S3 API]: s3.md