#webdev #bash #cloud #aws

DAY 17 – GFS-Moo – Script For Moodle, GlusterFS, LAMP on Cloud- Day Seventeen

Image Cover

100 days of Cloud on GitHub – Read On iCTPro.co.nz – Read on Dev.to

Tweet

Do you want to create a

  • scalable E-learing Solution with Moodle ,
  • Single server e-learning IAAS Solution ,
  • Gluster File System &
  • LAMP server

With-out worrying about complex Setup ?

Let us read, and let us dance; these two amusements will never do any harm to the world. – Voltaire

Here is a one click solution for your Moodle Infrastructure.

Why GlusterFS for Moodle?

During a rearchitecting phase for Moodle server, We found out that Moodle is not performing as expected when its been clustered.

Files are stored in $CFG->dataroot (moodledata) need to be accessed by all front end clustered servers & Database.

I tried integrating AWS EFS ( even though running on GlusterFS on backend), AWS S3fs (AWS S3 as a filesystem), Microsoft Azure File Storage was not giving the results as expected.

Unfortunately the results was devastating , the time to first byte always takes more than fourteen seconds https://moodle.org/mod/forum/discuss.php?d=418443 . I have seen cases of thirty mins in moodle community discussion (https://moodle.org/mod/forum/discuss.php?d=405061 )

There are complex solutions available on the worldWideWeb , but I wanted a simple ,effective and easy to setup Solution.

Solution One

If you are using public cloud provider like AWS, Attaching a Multi attach EBS to servers will resolve the issue. $CFG->dataroot (moodledata) have to be in the Multi attach EBS.

The Limitation to this solution is Multi-Attach for io1 volumes is available in the following Regions only: us-east-1 , us-west-2 , eu-west-1 , and ap-northeast-2 . It can change in future but by the time I am writing this post this are the only available regions.

If you are considering data sovereignty or for any other compliance requirement you need a different approach.

Solution Two

Using GlusterFS

What is GlusterFS?

GlusterFS (Gluster File System) is an open source Distributed File System that can scale out in building-block fashion to store multiple petabytes of data.

How can you integrate to your architecture ?

Introducing GFS-Moo , Gluster file system for Moodle.

This tutorial will help you to implement GlusterFS for your Moodle

I will be using AWS EC2 to implement the GFS-Moo.

Architecture

Image Architecture

In this blog I will be showing you how to install and configure Moodle with Gluster File System

How to ?

You can run this script in any Debian based Linux instance.

Supports On-Prem & Public Cloud, here i am using AWS for demonstration purpose.

Step 1 – Launching EC2 Instances

  • Login to AWS Console and Create three EC2 (Ubuntu)
  • Create Three Ec2 Instance with Security Group as shown below,(if you want to install just Moodle on a single server launch one EC2 with Moodle Security group)
  • Note own all Public IP address of instance (if you have attached EIP then note down EIP)

For Security Groups Please refer from GitHub Repo

Step 2 Rename EC2

Let’s Re-name Servers on Console

ServerRename toPublic IP
Server 1GFS-Moo-01ip1 (use your server1 public IP)
Server 2GFS-Moo-02ip2 (use your server2 public IP)
Server 3GFS-Moo-03ip3 (use your server3 public IP)

Step 3 lets install LAMP, Moodle & GFS.

  • Use Putty to SSH into all three Servers, Configure putty
  • If you want to use muti-SSH try mRemoteNG
  • Also Note down the Public IP for all three servers, for the easy of understanding.

Basic Installation

SSH into Servers orderly and run commands

Get root privilages to run command

sudo su -
StageOn ServerCommand
1GFS-Moo-03wget https://raw.githubusercontent.com/anuvindhs/GFS-Moo/main/install.sh chmod u+x install.sh ./install.sh
2GFS-Moo-02wget https://raw.githubusercontent.com/anuvindhs/GFS-Moo/main/install.sh chmod u+x install.sh ./install.sh
3GFS-Moo-01wget https://raw.githubusercontent.com/anuvindhs/GFS-Moo/main/install.sh chmod u+x install.sh ./install.sh

Inspect install.sh Code

Demo

Installing on GFS-Moo-03

  • Step 1
  • Step 2
    • As we are installing GFS+Moodle+LAMP select option 5Image GFSmoomenu
  • Step 3
    • Enter the Public IP Address for GFSImage IP
Image moodleinstall

Visit the IP http://yourip , you can see Moodle installation page

  • Step 4 GFS
    • Now you will be asked to enter current host , lets select 3 , and press Enter.
Image host3
  • ResultsImage Results

Installing on GFS-Moo-02

  • Follow Similar instruction as GFS-Moo-03Image gfs2

Installing on GFS-Moo-01 (MasterNode for GFS)

  • Follow Similar instruction as GFS-Moo-03
  • As we are running this script on Master node which is GFS-Moo-01, The script will try to probe the other nodes. This is why its important to run the script in other two nodes initially.
Image probing

Setup Moodle Connect your Database

  • Get your DB Credentials. , if you don’t know how to create RDS , Follow this Tutorial
  • Goto any of one server and get the Moodle link , or got http://Public IP of that server.
  • Setup Moodle, go to link provided by script.
    and setup your Moodle.
Image moodlesetup
  • Now do the Same with other two servers, make sure you enter same username and password, if you are doing this on an existing Moodle server update config.php file from the Moodle folder

Now lets mount the gluster folder to moodledata folder

Now run this command on all servers

sudo mount -t glusterfs gfs-moo-01:/gv0 /var/www/moodledata

Test Replication

  • goto Moodledata folder (/var/www/moodledata)
touch test.txt
  • Now check on other serves on same folder. You will be able to see the replicated test.txt file.

Congratulations … You have successfully configured glusterfs for Moodle


✅Connect with me on Twitter
🤝🏽Connect with me on Linkedin
🧑🏼‍🤝‍🧑🏻 Read more post on dev.to or iCTPro.co.nz
💻 Connect with me on GitHub