How to Create an Oak Cluster With MongoMK Failover
Are you looking for scalability (MongoDB) and high availability (oak clustering with replica set)? If so, read on. This post is a first step towards achieving a minimal set-up of an AEM 6.0 cluster with MongoDB in real-life scenarios.
To get the greatest benefit from this blog post, here’s what you’ll need :
- Oracle JRE 1.7
- AEM 6 Quick-Start Jar
- MongoDB Installed – see Installation
- MongoDB Replication
- AEM 6 Recommended Deployments
With the release of AEM 6.0, clustering has been rethought—resulting in the introduction of “Oak” and the concept of microkernels. Here I’ll provide a working example of a minimal AEM 6 (Oak) cluster, similar to the image below. This example implies multiple Oak instances accessing one MongoDB instance. A secondary MongoDB is provided for failover within the same data center.
How Does Oak Clustering Work?
An Oak cluster is formed by two AEM 6.0 instances and a MongoDB for persistence. All these instances are linked together to ensure that if one node fails, the other nodes are active and accessible for your application, with no system interruption. This enables you to easily recover and re-start failed nodes.
Why Do You Need It?
MongoDB offers high availability with replicaSets and scalability with sharding, to support deployments with very large data sets and high throughput operations.
Advantages and Disadvantages
- The ability to scale AEM instances
- Acceptable complexity
- Lesser performance than TarMK
First, set up three instances of MongoDB with replicaSet. For help creating a replicaSet, please refer to this MongoDB tutorial.
As you can see in this example, a three-node replica set has been configured. This same process can be applied to configuring any number of nodes in a replica set.
Set up the AEM 6.0 servers.
- Take two new AEM 6.0 instances (since we are creating an Oak cluster with two AEM 6.0 instances and one MongoDB).
- Run each of the AEM instances with the following commands.
Note: Make sure that all of the MongoDB instances are up and running. Also check to make sure the replica set status (replicaSet) is active and running with PRIMARY, SECONDARY and arbiter.
java -jar <aem instance jar name> -r crx3,crx3mongo -Doak.mongo.uri=mongodb://<primaryhost>:<port>,<secondaryhost>:<port>/?replicaSet=<replicaSet name>
The actual command would look like this:
java -jar aem-author-4512.jar -r crx3,crx3mongo -Doak.mongo.uri=mongodb://localhost:27017,localhost:27018/?replicaSet=oak-cluster
java -jar aem-author-4513.jar -r crx3,crx3mongo -Doak.mongo.uri=mongodb://localhost:27017,localhost:27018/?replicaSet=oak-cluster
In the above command, two hosts are given in the mongo URI—the first being the PRIMARY and the second being the SECONDARY MongoDB instance for automatic failover.
Note: Initial startup takes some time, so please be patient and monitor the log files of both AEM and MongoDB.
- Once the AEM servers are up, log onto the servers and open the Geometrixx outdoors website for testing.
- Open any of the two AEM servers and open the Geometrixx outdoors website. Try adding/modifying/deleting some content on the pages. These changes will get reflected in the other AEM server instantaneously.
Test the automatic failover
- Shut down the primary MongoDB server (ctl+c).
- Open the Mongo shell of the secondary Mongo instance.
- Now check the replSet status using the rs.status() command or in your native browser.
- The PRIMARY server will shut down and the SECONDARY server will get elected as PRIMARY.
- Open the AEM instance and Geometrixx outdoors website, which should still be working. You should be able to add/modify/delete content.
Explore Additional Resources
Learn more on how to select the right CMS for your business and improve your customer’s Digital Experience.
Our Adobe Experience Cloud Consulting team specializes in helping you deliver a seamless, intelligent, and personalized customer experience.
GET HELP FROM OUR EXPERTS
We have one of the largest and deepest multi-solutions digital consulting teams in the world. Our proprietary processes and years of Digital Experience expertise have earned us a 97% customer satisfaction rating with our clients ranging from Global Fortune 1000 to Mid-Market Enterprises, leading educational institutions, and Non-Profits.
Contact us today if you would like more help on AEM 6.0 cluster with MongoDB.
About TA Digital
TA Digital is an innovative digital transformation agency, specializing in delivering the digital experience, commerce, and marketing solutions. For nearly two decades, we have been helping traditional businesses transform and create dynamic digital cultures through disruptive strategies and agile deployment of innovative solutions.