Setting up AFR on two servers with client side replication

From GlusterDocumentation

Jump to: navigation, search

Contents

Introduction

NOTE: Before beginning, BE SURE TO HAVE A BACKUP OF ALL YOUR DATA BEFOREHAND! Remember to always keep a backup handy if you are working on live/important data. Things that CAN go wrong have a way of going wrong!

In this tutorial we will walk through setting up an AFR cluster using two servers and a single client, using client side replication.

This tutorial is based on the assumption that you have already gone through installing GlusterFS and it is in a working state. If not please refer to Install and run GlusterFS v1.3 in 10mins.

NOTE: Also see Setting up AFR on two servers with server side replication

The Scenario

Here we assume we are working with three machines. Two are servers and one is the client. Server1 and server2 both have raids mounted under /mnt/raid. Each of these will have a glusterfs exported volume directory of web which the client will mount as /mnt/web. We will be using client side AFR, meaning the client(s) will handle the file replication as opposed to doing this server side.

Below are the machines defined.

Server1

  • IP address : 192.168.0.1
  • Export volume directory : /mnt/raid/web

Server2

  • IP address : 192.168.0.2
  • Export volume directory : /mnt/raid/web

Client

  • IP address : 192.168.0.3
  • Server volume mount point : /mnt/web

Preparing the directories

Ok first lets create our server volume directories. On both server1 and server2, create a directory called web under /mnt/raid/.

$ mkdir /mnt/raid/web

Now lets make sure we do not have any extended attributes, we remove them here if they happen to exist (for instance if you are on your second or more attempt at this). Type these commands on both server1 and server2:

$ setfattr -x trusted.glusterfs.version /mnt/raid/web
$ setfattr -x trusted.glusterfs.createtime /mnt/raid/web

Configuring the volume spec files

Now that we have our volume directories on both servers, we will create the server and client volume spec files. The volume spec files provided here are very basic and only provided to illustrate getting AFR to work. Once you have a working setup you can start adding performance translators, but that is beyond the scope of this particular tutorial.

Server volume spec file

Both servers will use the same volume spec file, exporting the /mnt/raid/web directory. This example does not use/include any performance translators. Please refer to GlusterFS Volume Specification Examples for more ideas on how to configure spec files.

Create or edit the server volume specification file (/etc/glusterfs/glusterfs-server.vol) to match the example below.

volume brick
    type storage/posix
    option directory /mnt/raid/web
end-volume

volume server
    type protocol/server
    option transport-type tcp/server
    subvolumes brick
    option auth.ip.brick.allow 192.168.0.* # Allow access to brick
end-volume

Client volume spec file

In this tutorial we are assuming there is only a single client, but you can add more simply by copying the below client volume spec file to other machines.

Create or edit the client volume specification file (/etc/glusterfs/glusterfs-client.vol) to match the example below.

volume brick1
    type protocol/client
    option transport-type tcp/client # for TCP/IP transport
    option remote-host 192.168.0.1   # IP address of server1
    option remote-subvolume brick    # name of the remote volume on server1
end-volume

volume brick2
    type protocol/client
    option transport-type tcp/client # for TCP/IP transport
    option remote-host 192.168.0.2   # IP address of server2
    option remote-subvolume brick    # name of the remote volume on server2
end-volume

volume afr
   type cluster/afr
   subvolumes brick1 brick2
end-volume

Start the GlusterFS servers

Start the GlusterFS server (glusterfsd) on both servers. Then tail the log to make sure we had no errors.

NOTE: The location of your log files may be different if you specified a --prefix during installation.

$ glusterfsd -f /etc/glusterfs/glusterfs-server.vol
$ tail /var/log/glusterfsd.log

Mount the server volume

Now on the client machine mount the server volume.

$ glusterfs -f /etc/glusterfs/glusterfs-client.vol /mnt/web
$ cd /mnt/web
$ ls -l

You should see no files or directories listed. Now lets test out our cluster.

Verify AFR replication

Create a new file

You should be on the client machine. To test out our setup, we will touch a single file and then look on both servers to make sure it was created successfully.

On the client machine, first make sure you are in the /mnt/gfs directory.

$ cd /mnt/raid/web
$ touch file.txt
$ ls
file.txt

Check for new file on both servers

Now that we created a file, lets make sure that it was replicated on both servers. To do this, get on each server and go to the /mnt/raid/web/ directory and do an 'ls'.

$ cd /mnt/raid/web
$ ls
file.txt

Great! The file was created successfully.

Conclusion

You should now have a successfully operational AFR setup using two servers mirroring data using AFR.

Things to keep in mind / gotchas

Refer to AFR (Automatic File Replication) - Things to keep in mind and gotchas

Credits

  • Author : Brandon Lamb
  • Email  : brandonlamb@gmail.com
  • GlusterFS rules!
Personal tools