Moodle cluster and MySQL database service on OCI

When it comes to thinking about e-learning or distance learning, yes there are tonnes of education platform today on market and one of the most popular is Moodle, it is most importantly an open-source e-learning platform which is no wonder why this platform widely used by many educational institutions to create and administer online courses around the world.

It also an extremely easy platform for administrators to manage and run, surely it is very easy to deploy Moodle Cluster on Oracle Cloud Infrastructure.

I'd like to acknowledge that I used some useful resources from the MySQL team and OCI team, links are in the bottom section.

In this article, I am going to show you how to deploy Moodle 3.8 on top of the OCFS clustered file system and of course MySQL Database system.

Architecture Review

  • A virtual cloud network with a public and a private subnet to avoid direct access from the public internet, hence you will have a public load balancer. Of course, you have dedicated security lists for each subnet.
  • Your Moodle application servers will run in the private network because you will not want to expose your application servers, just a thought.
  • Two read-write shareable block storages for your cluster files. This bit was a little confusing for me, but after I found a nice article about OCFS2, done it easily I used OCFS2 for configuring the cluster file system, developed by Oracle, to allow users to perform read/write operations simultaneously. You may want to consider glusterfs also, either way, should work.
  • MySQL database service, enterprise-level database cloud service running on OCI in the private subnet. Why MySQL on OCI? Because MySQL Database Service is a fully-managed Oracle Cloud Infrastructure native service, developed, managed, and supported by the same team who develops MySQL Community and Enterprise Editions in Oracle. Oracle automates all tasks such as backup and recovery, database and operating system patching, and so on. You are responsible solely for managing your data, schema designs, and access policies. Cool?
  • A bastion server will grant your access wish to your application servers and MySQL Database service. This is a security best practice for almost any industry, even for open-source education platform :)


How to create this environment? If you are an experienced cloud engineer, you can create everything by hand, will take just about an hour. Luckily, I uploaded all of these steps in GitHub and you have 2 options to deploy.

1. Using OCI resource manager to upload my latest GitHub zip file.

Resource Manager is an Oracle Cloud Infrastructure service that allows you to automate the process of provisioning your Oracle Cloud Infrastructure resources. Using Terraform, Resource Manager helps you install, configure, and manage resources through the "infrastructure-as-code" model.

  • If you have your cloud tenancy running ready and ready to start with this deployment on using resource manager stack, which is an automated terraform manager. Click here and will re-direct you to OCI.
  • Log in to your Oracle cloud tenancy with appropriate credentials.
  • Review and accept terms and condition
  • Enter a name for this deployment and choose the target compartment, then click next
  • Follow the on-screen prompts and instructions to create the stack.
  • Once the stack is created, click on Terraform Actions, and choose Plan.
  • Wait for the planned job to be completed. Click on Terraform Actions again, this time choose to Apply.
  • Check out apply job output and wait until it finishes. It will take about 15 mins.

2. Git clone my environment and terraform it from your local machine.

If you have a GitHub account, you can just simply clone my environment and deploy terraform plan & apply the command.

git clone
cd moodle
terraform init
terraform plan
terraform apply

No matter which way you choose to deploy, in the end, you'd see a Moodle_load_balancer_ip in output log. Copy IP address and simply open your web browser and paste there.

For example, following was my output:


You will have to simply follow the wizard here and update some parameters:

  • Database host, this is your MysqlDB_Private_IP output
  • Database name, moodle
  • Database user, moodle
  • Database password, MoodleAdm1n_
  • Tables prefix, mdl_
  • Database port, 3306

Okay, that is it, I hope you would try this.

Here are some links I used to configure this environment.

Good luck and join our discord community