GlusterFS installation and configuration – first steps

GlusterFS

Hello guys, does someone wants to have a little cloud place between two or more computers? It can be done very successfully with GlusterFS. I will show you how to config it between two systems runs with Debian Squeeze.

So let’s begin.
First computer, will be server: IP: 192.168.1.10
Second one – to be client: IP: 192.168.1.11

First of all we have to add at both systems those lines in /etc/hosts:

cat > /etc/hosts

192.168.1.10   GlusterServer     GlusterServer
192.168.1.11   GlusterClient     GlusterClient

In that way we resolve the other system’s hostname.

When we are done with that we can proceed with installation of needed software:
For the Server Computer:

aptitude install glusterfs-server

Create some needed directories:

mkdir -p /glusterfs/export

Now we have to do configuration of server. File for that is : /etc/glusterfs/glusterfsd.vol , where we define which directory will be exported, and what client is allowed to connect.
It is strongly recommended always to make backup for files:

cp -p /etc/glusterfs/glusterfsd.vol /etc/glusterfs/glusterfsd.vol-bkup

And now we can do changes:

cat > /etc/glusterfs/glusterfsd.vol

volume posix
type storage/posix
option directory /glusterfs/export # directory which will be exported
end-volume

volume locks
type features/locks
option mandatory-locks on
subvolumes posix
end-volume

volume brick
type performance/io-threads
option thread-count 8
subvolumes locks
end-volume

volume server
type protocol/server
option transport-type tcp
option auth.addr.brick.allow 192.168.1.11 # Edit and add list of allowed clients comma separated IP addrs(names) here (e.g. 192.168.1.11,192.168.1.12)
subvolumes brick
end-volume

It is possible to define allowed IPs with wildcards (192.168.1.*).
Now we need just to start glusterfs-server:

/etc/init.d/glusterfs-server start

So it is time to config and client system. We can start it with install the software that we need it:

aptitude install glusterfs-client

and create following directory:

mkdir -p /mnt/glusterfs/

Now we have to create file that it is needed for GlusterFS and add some configuration on it:

cat > /etc/glusterfs/glusterfs.vol

volume remote
type protocol/client
option transport-type tcp
option remote-host GlusterServer #can it be IP of server (192.168.1.10)
option remote-subvolume brick
end-volume

volume writebehind
type performance/write-behind
option window-size 4MB
subvolumes remote
end-volume

volume cache
type performance/io-cache
option cache-size 512MB
subvolumes writebehind
end-volume

There is a two way to mount GlusterFS server:

glusterfs -f /etc/glusterfs/glusterfs.vol /mnt/glusterfs

or

mount -t glusterfs /etc/glusterfs/glusterfs.vol /mnt/glusterfs

And if everything it’s ok, you can see it with

mount

should be appear bellow:

/etc/glusterfs/glusterfs.vol on /mnt/glusterfs type fuse.glusterfs (rw,allow_other,default_permissions,max_read=131072)

The easiest way to mount it on boot is to add it at rc.local:

nano /etc/rc.local
glusterfs -f /etc/glusterfs/glusterfs.vol /mnt/glusterfs

Don’t forget, that it should be on top of “exit 0” in the file!

Alright, now we are ready 🙂 and we can test it with creating files on client:

touch /mnt/glusterfs/test01 /mnt/glusterfs/test02

and list it at server:

ls -lah /glusterfs/export/
root@GlusterServer:~# ls -lah /glusterfs/export/
total 8.0K
drwxr-xr-x 2 root root 4.0K Jan 25 05:17 .
drwxr-xr-x 3 root root 4.0K Jan 25 05:15 ..
-rw-r--r-- 1 root root    0 Jan 25 05:17 test01
-rw-r--r-- 1 root root    0 Jan 25 05:17 test02

Or opposite: touch files at server, and accept them in client.
We can add more than one client system, so everyone will be able to write in following directory that we export.
Do not forget to add new client’s IP to the /etc/glusterfs/glusterfsd.vol file of the server, and /etc/hosts file too!

Have fun and hope this will be helpful.