fbpx

Server Setup

GlusterFS Load Balancing

by ,


We have by far the largest RPM repository with NGINX module packages and VMODs for Varnish. If you want to install NGINX, Varnish, and lots of useful performance/security software with smooth yum upgrades for production use, this is the repository for you.
Active subscription is required.

When you receive a lot of traffic and have a few servers at hand, you may want to implement load balancing.
Common scenario is that you would have two or more server assigned for PHP processing. How do you share the files between two or more instances?

If you have just two servers and don’t care about redundancy, you can simply share one directory with NFS or Samba protocol on one server, and mount on another. In fact, this kind of setup might produce the fastest file sharing:

mount -t cifs //1.2.3.4/html /var/www/html -o guest,iocharset=utf8,file_mode=0777,dir_mode=0777,nounix,noserverino

If you want redundancy and failover, you will setup GlusterFS between two nodes.

Run this command on both servers:
mkdir /var/glusterfs/example.com

On first server

The following commands will create networked “RAID storage” contained of two “bricks”: each located in /var/glusterfs/example.com directory.


gluster volume create example_com replica 2 web1.example.com:/var/glusterfs/example.com force
gluster volume start example_com
gluster peer probe web2.example.com
gluster volume add-brick example_com web2.example.com:/var/glusterfs/example.com

Now you need to link your site files to GlusterFS storage. You cannot use brick files directly, otherwise there will be no sync between the two servers.

You need to mount using network protocol. I.e. your site root directory is /var/www/html and GlusterFS brick on the same machine is in /var/glusterfs/example.com

Most of the tutorials for GlusterFS setup want you to mount drives with the native glusterfs protocol.
But this is so slow! And not really optimized for PHP files. The best option is to mount with NFS. For this you have to disable built-in NFS server first:

systemctl disable nfs-server

Run this command to self mount:

mount -o tcp,vers=3 -t nfs 127.0.0.1:/example_com /var/www/html/

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.