How to automate the Offline compaction process in AEM 6.2

Statement  : Automate the offline compaction process.


Solution :

  • For Offline compaction is still applicable for AEM 6.2 but AEM 6.3 is not required beacuse it spports online compaction.
  • Below is the steps involved in the automation and script which is used automates entire process.

Steps involved in the Offline compaction Automation :

  1. Shutdown AEM Server
  2. Use Matching Oak jar version to find Old Checkpoints
  3. Use Matching Oak jar version to Remove Unreferenced Checkpoints
  4. Use Matching Oak jar version to Compact Oak
  5. Restart AEM
SCRIPT:
#!/bin/bash
todayDate="$(date +'%d-%m-%Y')"
logfile="compact-$ todayDate.log"
installfolder="/data/aem"
aemfolder="$installfolder/crx-quickstart"
oakrun="$installfolder/help/oak-run-1.6.1.jar"

## Shutdown AEM
printf "Shutting down AEM.\n"
$aemfolder/bin/stop
todayDate ="$(date)"
echo "AEM Shutdown at: $ todayDate " >> $installfolder/help/logs/$logfile

## Find old checkpoints
printf "Finding old checkpoints.\n"
java -Dtar.memoryMapped=true -Xms8g -Xmx8g -jar $oakrun checkpoints $aemfolder/repository/segmentstore >> $installfolder/help/logs/$logfile

## Delete unreferenced checkpoints
printf "Deleting unreferenced checkpoints.\n"
java -Dtar.memoryMapped=true -Xms8g -Xmx8g -jar $oakrun checkpoints $aemfolder/repository/segmentstore rm-unreferenced >> $installfolder/help/logs/$logfile

## Run compaction
printf "Running compaction. This may take a while.\n"
java -Dtar.memoryMapped=true -Xms8g -Xmx8g -jar $oakrun compact $aemfolder/repository/segmentstore >> $installfolder/help/logs/$logfile

## Report Completed
printf "Compaction complete. Please check the log at:\n"
printf "$installfolder/help/logs/$logfile\n"

## Start AEM back up
todayDate ="$(date)"
printf "Starting up AEM.\n"
$aemfolder/bin/start
echo "AEM Startup at: $ todayDate " >> $installfolder/help/logs/$logfile

Reference :
https://jackrabbit.apache.org/oak/docs/command_line.html


How to find Popular and Slow Queries in AEM through JMX console

Statement - Popular and Slow Queries in AEM through JMX console
Environment - AEM 6.3 GA

Solution :

  • Top 15 Slow Queries tweak slow queries/rewrite slow queries for better performance or create indexes for those slow queries.


  • Below is the screenshot to clear popular and slow queries, Click on each of the below Operation and click on invoke.

  • That's  it!

Oak QueryEngine Optimization Parameters and how to set these parameter in JMX console in AEM

Statement - Query engine Optimization parameters
Environment - AEM 6.3 GA

Solution :
Attributes
Attribute Name
Attribute Value
LimitInMemory
500000
LimitReads
100000
FailTraversal
true
FastQuerySize
false

  • Click on  each of these attribute value to increase/decrease as shown in below.

  • To return the query result size should return an estimation for large queries set the FastQuerysize to True
  • Set FailTraversal to True Whether queries that don't use an index will fail (throw an exception) as shown in below screenshot.
  • That's  it!