Tuesday, 7 July 2015

Configuring AEM 6.0 with mongoMK

One of the most important feature of AEM 6.0 is introduction of "Apache Jackrabbit Oak" with this new version of AEM. Jackrabbit oak is an effort to enhance the scalability and performance of the backend of the AEM content reporsitory. Oak introduces the micro-kernel for persistence of repository data, there are two micro-kernel implementation supported with oak :
  • Mongo MK
  • Tar MK

Tar MK:
Tar storage uses tar files for storing the repository content. The content is stored in segments that can be upto 256 MB in size. Segments are immutable which makes it easy to cache frequently accessed segments.

Mongo MK: 
Mongo storage uses Mongo DB to storing the content of the repository. Mongo MK makes oak repository scalable as mongo DB supports sharding and clustering.

In this post I will be discussing how to configure Mongo storage or MongoMK with AEM. Here are the set of steps for setting up mongo MK with AEM :

Setting Up Mongo DB (Ubuntu specific) :

  1. Download the mongo binaries from https://www.mongodb.org/downloads
  2. Extract the files from the downloaded archive.
tar -zxvf mongodb-linux-i686-3.0.4-rc0.tgz
  1. Copy the extracted folder to the location from which MongoDB will run.
mkdir -p /opt/mongodb
cp -R -n mongodb-linux-x86_64-ubuntu1404-3.0.3/* /opt/mongodb
  1. Ensure the location of the binaries is in the PATH variable.
export PATH=/opt/mongodb/bin:$PATH
  1. Run MongoDB : mongod (run mongod command from termilnal)
  2. Create the data directory.
mkdir -p /data/db
  1. Set permissions for the data directory.
Before running mongod for the first time, ensure that the user 
account running
mongod has read and write permissions for the directory.
  1. Run MongoDB.
mongod or /opt/mongodb/bin/mongod

I used Robomongo which is a client to access Mongo DB server and  
perform the manipulations on the mongo DB.

AEM Setup
  1. Unpack AEM by running the following command:
    java –jar cq-quickstart-6.0.0.jar -unpack
  2. Create a folder named crx-quickstart\install in the installation directory.
  3. Configure the node store by creating a configuration file with the name of the configuration you want to use in the crx-quickstart\install directory. The Document Node Store (which is the basis for AEM's MongoDB storage implementation) uses a file called org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService.cfg. Here is the sample DocumentNodeStoreService.cfg file :
  1. Start the AEM 6 jar with a MongoDB storage backend by running:
     java -jar cq-quickstart-6.0.0.jar -r crx3,crx3mongo

Here is the link to github repository : https://github.com/ankit-gubrani/Codebrains

Wednesday, 1 July 2015

Configuring AEM 6.0 with remote SOLR server

Apache Jackrabbit Oak is the next generation repository implementation which powers in AEM 6.0. Oak does not index content by default to offer improved performance. Every JCR query will traverse whole repository, impacting the performance of the repository. Custom indexes need to be created to reduce node traversal with for every query in the repository.

The SOLR index

There are multiple options to index data in AEM, in this post we will be covering "The SOLR index".The Solr index in oak can be used for any type of JCR query. The integration in AEM 6.0 happens at repository level so Solr is one of the possible indexes that can be used in oak. 

Here are the steps for configuring AEM 6.0 with remote SOLR server : 

  1. First extract the Solr zip prior to version 5.0 (I used solr 4.9.1) in folder named Solr .
  1. This solr folder should be parallel to crxfolder folder AEM installation directory, i.e inside Author directory.

  1. Copy the example folder and paste in the same directory (Solr), rename the folder as node1 (any name).

  1. Repeat step 3, just rename the folder as node2.

  1. Create a folder in node1 and node2 with name cfg. Inside this folder paste solr.xml, zoo.cfg and oak core config folder. (I used default core collection1 in my case)

  1. Now start the first solr shard with zookeeper configured. Run the following command from node1 directory :

java -Xmx256m -Dbootstrap_confdir=./cfg/oak/conf
-Dcollection.configName=myconf -DzkRun -DnumShards=2 -jar start.jar

  1. Now start the second shard by running the following command from node2 directory :
java -Xmx256m -Djetty.port=7574 -DzkHost=temphost.ig.com:9983 -jar  start.jar
Catch here is Solrcloudserver does not use the URL for initialization, rather it uses the connection string. Connnection string is same we pass with the zkHost parameter. In my case it was not working if I passed value as localhost:9983. I had to create a custom host name and the pass the same connection string while configuring with AEM.

  1. Once second shard is up and running, check if it both the shards are working or not by accessing the url :


  1. Now open the Configuration Manager console (localhost:3502/system/console/configMgr), and set the value of Oak Solr server provider as Remote Solr from drop down.

  1. Now edit Oak Solr remote server configuration and set the values as :

Solr HTTP URL : http://localhost:8983/solr/
ZooKeeper host : http://temphost.ig.com:9983
Solr collection : collection1
No. of collection shards : 2
Replication factor : 1
Solr configuration directory : /home/codebrains/CQ_Instance/Author/solr/node1/cfg/oak


  1. Now open the CRXDE Lite and create a node under oak:index with following properties :
Name : solrindex (String)
jcr:primaryType : oak:QueryIndexDefinition
reindex : true (Boolean)
async : async
type : solr