The servers setup:
To install the required packages run on both servers:sudo apt-get install glusterfs-serverIf you want a more up to date version of GlusterFS you can add the following repo:
sudo add-apt-repository ppa:semiosis/ubuntu-glusterfs-3.4Now from one of the servers you must connect to the other:
sudo gluster peer probe <ip_of_the_other_server>You should see the following output:
peer probe: successYou can check the status from any of the hosts with:
sudo gluster peer statusNow we need to create the volume where the data will reside. For this run the following comand:
sudo gluster volume create datastore1 replica 2 transport tcp <server1_IP>:/mnt/gfs_block <server2_IP>:/mnt/gfs_blockWhere /mnt/gfs_block is the mount point where the data will be on each node and datastore1 is the name of the volume you are creating.
If this has been sucessful, you should see:
Creation of volume datastore1 has been successful. Please start the volume to access data.As the message indicates, we now need to start the volume:
sudo gluster volume start datastore1As a final test, to make sure the volume is available, run gluster volume info.
sudo gluster volume infoYour GlusterFS volume is ready and will maintain replication across two nodes.
If you want to Restrict Access to the Volume, you can use the following command:
sudo gluster volume set datastore1 auth.allow gluster_client1_ip,gluster_client2_ipIf you need to remove the restriction at any point, you can type:
sudo gluster volume set volume1 auth.allow *
Setup the clients:
Install the needed packages with:sudo apt-get install glusterfs-clientTo mount the volume you must edit the fstab file:
sudo vi /etc/fstabAnd append the following to it:
[HOST1]:/[VOLUME] /[MOUNT] glusterfs defaults,_netdev,backupvolfile-server=[HOST2] 0 0Where [HOST1] is the IP address of one of the servers and [HOST2] is the IP of the other server. [VOLUME] is the Volume name, in our case datastore1 and [MOUNT] is the path where you whant the files on the client.
Or, you can also mount the volume using a volume config file:
Create a volume config file for your GlusterFS client.
vi /etc/glusterfs/datastore.volCreate the above file and replace [HOST1] with your GlusterFS server 1, [HOST2] with your GlusterFS server 2 and [VOLNAME] with the Gluster FS volume to mount.
volume remote1Finally, edit fstab to add this config file and it's mount point. Replace [MOUNT] with the location to mount the storage to.
type protocol/client
option transport-type tcp
option remote-host [HOST1]
option remote-subvolume [VOLNAME]
end-volume
volume remote2
type protocol/client
option transport-type tcp
option remote-host [HOST2]
option remote-subvolume [VOLNAME]
end-volume
volume replicate
type cluster/replicate
subvolumes remote1 remote2
end-volume
volume writebehind
type performance/write-behind
option window-size 1MB
subvolumes replicate
end-volume
volume cache
type performance/io-cache
option cache-size 512MB
subvolumes writebehind
end-volume
/etc/glusterfs/datastore.vol [MOUNT] glusterfs rw,allow_other,default_permissions,max_read=131072 0 0
No comments:
Post a Comment