Thursday, May 21, 2015

Ubuntu 14.04 - GlusterFS for Wordpress

Here's my setup:  Client -> Varnish cache -> 2 x Worpdress -> Memcached -> 2 x MariaDB

I need to sync Wordpress folder on both Machine, just have a look on NFS, CEPH, GlusterFS and I go with GlusterFS
sudo apt-get -y install glusterfs-server

If you don't have a on premise DNS server, we can add the server name in to hosts files
192.20.1.1    srvr-phpnode1.mydomain.vn    srvr-phpnode1    
192.20.1.2    srvr-phpnode2.mydomain.vn    srvr-phpnode2

Create a directory for Gluster Volume on both hosts
mkdir /gluster-volume

Check for other peer status
sudo gluster peer probe srvr-phpnode2
peer probe: success

sudo gluster peer status
Number of Peers: 1

Hostname: srvr-phpnode2
Port: 24007
Uuid: 225698cb-a84f-4b5b-8537-27732d752aba
State: Peer in Cluster (Connected)

Glusterfs distributed vs Replica mode (GlusterFS docs):
Distributed mean data distributes across the available bricks in a volume: write 100 files, on average, 50 on one server, and 50 on another. This is faster than a “replicated” volume, but isn’t as popular since it doesn’t give you two of the most sought after features of Gluster — multiple copies of the data, and automatic failover if something goes wrong

Create wwwVol volume on host srvr-phpnode1
sudo gluster volume create wwwVol replica 2 transport tcp srvr-phpnode1:/gluster-volume srvr-phpnode2:/gluster-volume force

(GlusterFS docs): we tell it to make the volume a replica volume, and to keep a copy of the data on at least 2 bricks at any given time. Since we only have two bricks total, this means each server will house a copy of the data. Lastly, we specify which nodes to use, and which bricks on those nodes. The order here is important when you have more bricks

sudo gluster volume start wwwVol
sudo gluster volume info

Volume Name: wwwVol
Type: Replicate
Volume ID: 8c1430d4-8b25-4967-9a46-39287cdedbb2
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: srvr-phpnode1:/gluster-volume
Brick2: srvr-phpnode2:/gluster-volume

We need /var/www will be on GlusterFS so we will mount wwwVol to /var/www on both hosts
On both hosts
mkdir /var/www

On phpnode1
vi /etc/fstab
srvr-phpnode1:/wwwVol /var/www glusterfs defaults,_netdev 0 0

mount -a 

On phpnode2
vi /etc/fstab
srvr-phpnode2:/wwwVol /var/www glusterfs defaults,_netdev 0 0
mount -a 

Other GlusterFS command
gluster volume stop VOLNAME
gluster volume delete VOLNAME

gluster volume remove-brick VOLNAME wnode1:/www
http://www.gluster.org/community/documentation/index.php/Gluster_3.1:_Deleting_Volumes
http://www.gluster.org/community/documentation/index.php/Basic_Gluster_Troubleshooting

0 comments:

Post a Comment