GlusterFS Quickstart Howto on Fedora
By Jon Archer
Here’s a (very) quick howto showing how to get GlusterFS up and running on Fedora. Its probably better situated on a distro like CentOS/RHEL, Ubuntu Server LTS or Debian stable but where’s the fun in knowing it won’t break? Most of these commands are transferrable to other distros though, its Fedora centric due to the use of yum, selinux and systemd (systemctl).
Pre-requisites: 2x (or more) servers running Fedora, I used 18 in this example but i’m sure it shouldn’t change a great deal for newer releases. If it does I’ll try update this doc. The idea behind this setup is to use 2 servers as hypervisors (KVM) and have local storage but reslience, I won’t be covering the virtualisation side, purely storage so VM’s will be adequate for this setup.
So at this point we should have 2 clean installs of Fedora on 2 servers fully updated. For arguments sake we’ll all them host1 and host2. with IP addresses of 192.168.1.50 and 192.168.1.51 respectively. (you will need to add hostnames and IPs to /etc/hosts if you don’t use DNS)
Lets disable selinux and iptables for now to make this process easier:
sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config setenforce 0 systemctl stop firewalld.service systemctl disable firewalld.service
yum install nfs-utils glusterfs-server systemctl start glusterd.service systemctl start rpcbind.service
OK so now we’re installed we’re ready to start setting up Gluster, lets create a directory on both servers
root@host1 ~ # mkdir /gluster root@host2 ~ # mkdir /gluster
Now lets get a volume created: Do this on only 1 host.
root@host1 ~ # gluster peer probe host2 root@host1 ~ # gluster volume create vol1 replica 2 host1:/gluster host2:/gluster These commands told the 2 hosts to become “friends” then created a glusterfs volume called vol1 with 2 replicas (hosts), you will need to change this to the number of hosts you run, and the paths to the volume on each host.
When you run the last command above it will tell you that your volume creation has been successful and that it needs to be started to access data. Lets do this:
root@host1 ~ # gluster volume start vol1
So now we have a functioning gluster cluster we need to mount it somewhere.
root@host1 ~ # yum install glusterfs-fuse glusterfs Installs the relevant software to allow us to mount the volume, lets create directories and mount:
root@host1 ~ # mkdir /store root@host2 ~ # mkdir /store
root@host1 ~ # mount -t glusterfs host1:/vol1 /store root@host2 ~ # mount -t glusterfs host2:/vol1 /store
You should now be able to create files in /store on host1 and them be visible to host2 /store. Notice how we mounted the volume on the same machine it is hosted, this way we are always writing to local storage and syncing out.
Update: the same instructions will work on CentOS/RHEL/Scientific Linux, you will just need to install the EPEL yum repositories first - http://fedoraproject.org/wiki/EPEL