Skip to content

Instantly share code, notes, and snippets.

@andrewmkhoury
andrewmkhoury / oakTreeNodeCount.groovy
Last active April 29, 2021 08:21
Counting nodes in a tree of Oak repository using the oak-run console tool
import org.apache.jackrabbit.oak.spi.state.NodeState
import java.util.concurrent.atomic.AtomicInteger
def countNodes(NodeState n, String path = "/", flush = 5000, AtomicInteger count = new AtomicInteger(0), root = true) {
if(root) {
println "Counting nodes in tree ${path}"
}
cnt = count.incrementAndGet()
if (cnt % flush == 0) println(" " + cnt)
@andrewmkhoury
andrewmkhoury / readme.md
Last active April 29, 2021 08:21
How to clean up unreferenced checkpoints in Oak 1.0.x

Clean up unreferenced checkpoints

  1. Download or build oak-run 1.x matching the version you have installed in your Oak environment.
  2. Stop all AEM instances
  3. Upload the oak-run to the AEM server if using TarMK or MongoDB server (if using MongoMK)
  4. Run this command to cleanup unreferenced checkpoints on TarMK:
java -Xmx4096m -jar /apps/staging/oak-run-1.*.jar checkpoints crx-quickstart/repository/segmentstore rm-unreferenced

Clean up unreferenced checkpoints on MongoMK:

  1. Download https://files.acrobat.com/a/preview/e885654b-8424-4698-b5e9-7751b647276b (or build oak-run 1.1.x version)
  2. Stop all AEM instances
  3. Upload the oak-run 1.1 version to the AEM server if using TarMK or MongoDB server (if using MongoMK)
  4. Run this command to start the oak console
  • on TarMK:
   java -jar target/oak-run.jar console --quiet /path/to/segmentstore
  • For MongoMK run this:
@andrewmkhoury
andrewmkhoury / README.md
Last active May 10, 2018 20:50
How to use oak-mongo.js to delete an index
  1. Stop all Oak cluster nodes (or AEM6 cluster nodes)
  2. On the mongo server, run these commands to log in to mongo shell with oak-mongo.js loaded wget http://svn.apache.org/repos/asf/jackrabbit/oak/trunk/oak-run/src/main/js/oak-mongo.js mongo 127.0.0.1/aem-author --shell oak-mongo.js
  3. In the mongo shell run this command to get a list of all index names oak.listChildren("/oak:index")
@andrewmkhoury
andrewmkhoury / OakMaintenanceLogMessages.md
Last active August 29, 2017 21:22
Apache Oak Maintenance Log Messages

MongoDB Storage (aka "MongoMK") and RDBMK:

Revision GC:

12.09.2015 00:00:00.857 *INFO* [pool-7-thread-10] org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector Starting revision garbage collection. Revisions older than [2015-09-11 00:00:00.857] would be removed
13.09.2015 00:00:15.912 *INFO* [pool-7-thread-9] org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector Iterated through 10000 documents so far. 9698 found to be deleted
14.09.2015 00:00:49.358 *INFO* [pool-7-thread-12] org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector Deleted 859050 (58.28%) documents so far
12.09.2015 00:39:43.490 *INFO* [pool-7-thread-10] org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector Version garbage collected in 39.71 min. VersionGCStats{ignoredGCDueToCheckPoint=false, deletedDocGCCount=180021, splitDocGCCount=4853, intermediateSplitDocGCCount=441, timeToCollectDeletedDocs=14.62 min, timeTakenToDeleteDocs=23.52 min}

AEM6.x Migration

  • How to Rebuild a Pre-Existing AEM+Mongo Cluster
  • or migrate from Tar to MongoDB or MongoDB to Tar"
  • or migrate from 5.6.1 or 6.x to 6.x via data migration instead of jar upgrade
  1. (Mongo to Mongo only) Remove one replica from the replica set and delete/recreate the db
    1. Remove the replica node from the set: http://docs.mongodb.org/master/tutorial/remove-replica-set-member/
    2. Validate that no other nodes in the set consider that node to be part of the set anymore. Log into each node in the cluster via mongo shell and run rs.status() to validate that the node that was taken out is not in the cluster any longer.
    3. Drop the aem database on that node http://docs.mongodb.org/manual/reference/command/dropDatabase/
  2. Re-add the database with the correct user permissions (do not add the mongo instance back to the replica set)
@andrewmkhoury
andrewmkhoury / INSTRUCTIONS.md
Last active July 15, 2019 12:33
Apache Sling - enabling debug log level for all java packages when instance won't start up
  1. Open this file in an editor crx-quickstart/launchpad/config/org/apache/sling/commons/log/LogManager.config
  2. Change org.apache.sling.commons.log.level value from "info" to "debug"
  3. Try to start the instance again
@andrewmkhoury
andrewmkhoury / ClonedReindexingInstructions.md
Last active April 29, 2021 08:20
Reindexing Oak Async Indexes on a Clone AEM Instance

How to Reindex AEM on a Clone Instance and Sync over the Changes

  1. Clone your AEM instance to another VM for reindexing
  2. Download these oak-run jars:
  1. Upload the oak-run jars to the clone server
  2. Stop AEM (stop all AEM instances if a cluster or cold standby)
  3. Run this command (using oak-run-1.6.6.jar)
  • java -Xmx4096m -jar oak-run-1.6.6.jar checkpoints /path/to/repository/segmentstore
  1. Run this command (using oak-run-1.6.6.jar)

Note that offline compaction requires a long duration of downtime from 30 minutes to 7 hours (and in extreme cases more time).

Offline Oak compaction with debug logging:

  1. Stop Oak / AEM
  2. Install the latest Oak hotfix to your AEM instance:

Clean up sling jobs at the mongodb level in AEM6.0

  1. Log into mongo shell on the primary mongo node
  2. Download oak-mongo.js to the server
wget http://s.apache.org/oak-mongo.js
  1. Run this on the command line