As North American University IT department we setup a cluster for the need of scalability. Normally with only 1000 students we didn’t need a cluster at all but by the time we decided to give it a try and expose the cluster infrastructure for institutions who are using Moodle.
The Diagram shows the NAU Network that holds the main servers. Each blue node is a different Centos 7 server which are in total 10 servers. Every tool we used on this architecture is open-source.
The main flow occurs on the NAU side that holds the main servers.
The Public IP is pointed to Haproxy3 which is used to load balance Web1 and Web2 along with roundrobin algorithm. Since Session server is connected to both Web1 and Web2 we used roundrobin instead of source algorithm on Haproxy3 server. This way the same user can have single session regardless load balanced between Web1 or Web2.
While Web1 and Web2 holds the Moodle Web files, NFS keeps the moodle data files (/var/moodledata) along with MUC. Web1 and Web2 is mounted to see the same moodle data folder on NFS (/var/moodledata).
The flow goes next to the Haproxy1 that holds the VIP (Virtual IP) . keepalived helps to switch to Haproxy2 in case of Haproxy1 fails but keeps the same VIP. So when Haproxy1 fails Web1 and Web2 point automatically to the same VIP that is connected to Haproxy2 and vice versa. Haproxy1 and Haproxy2 are two same load balancer servers for database which Haproxy1 is pointed as the start node as load balancer.
Let’s say there is no failure on Haproxy1, then Haproxy1 goes first MariaDB Node1. For extra overload requests, the load balancer Haproxy1 can go to the MariaDB Node 2 and for more extra load Haproxy1 goes to MariaDB Node3. So the workload is separated through 3 database servers by the roundrobin algorithm setup on Haproxy1 even for a single user with multiple connections.
MariaDB Node 1, Node 2 and Node 3 rely on the same Galera Wsrep Replicaton Cluster which all of them are masters. Any update, insert or delete, all of the changes reflected to each other. Thanks to Galera Cluster! It replicates every record update on the same level.
Single Sign-On Office 365
Actually, the users use Office 365 as single sign-on (openID) to all applications including moodle. The students never to manual sign in for moodle.
We have in total 10 servers, each of them runs on CentOS 7.
- MariaDB Node1
- MariaDB Node2
- MariaDB Node3
How to Setup the Moodle Cluster
Let’s go over the cluster architecture step by step starting from bottom to top
1- Galera Wsrep Replication (Node1, Node2, Node3)
Follow this tutorial first: MARIADB CLUSTER ON CENTOS 7
2- Haproxy for Databases along with Keepalived VIP (Haproxy1, Haproxy2)
Follow this tutorial : INSTALL HAPROXY AND KEEPALIVED ON CENTOS 7 FOR MARIADB CLUSTER
3- Install LAMP or LEMP on Centos 7 (Web1, Web2)
Follow this tutorial: INSTALL LAMP OR LEMP ON CENTOS 7 FOR MOODLE
4- Memcached Server (Session)
Follow this tutorial: INSTALL SEPARATE MEMCACHE SERVER (SESSION) FOR MOODLE ON CENTOS 7
5- NFS & Unison – Network File System (NFS) to sync data files and MUC
Follow this tutorial: INSTALL & CONFIGURE NFS SERVER & CLIENT ON CENTOS 7
(We don’t sync anymore) Follow also this tutorial: INSTALL & RUN & SYNC UNISON ON CENTOS 7
6- Haproxy Layer 7 Load Balancer on CentOS 7 (Haproxy3)
Follow this tutorial: INSTALL HAPROXY LAYER 7 LOAD BALANCER ON CENTOS 7 NGINX WEBSERVERS
7 – SSL on Haproxy for Centos 7 or Ubuntu 10.04 (Haproxy3)
Follow this tutorial: INSTALL SSL ON HAPROXY CENTOS 7 OR UBUNTU 14.04 FOR MOODLE