rdbmsslingjackrabbit-oak

How to set up Apache Sling to use a relational DB


I am on Sling 11, which uses Jackrabbit Oak as content repository. I was wondering how to set up Sling to store the JCR repo on an RDBMS (DB2 to be specific).

I found this link on Jackrabbit Persistence, but looks like it does not apply to Oak and Oak documentation is mostly about MongoDB.

Also found an implementation of a Cassandra Resource Provider, although that seems designed to access specific paths mapped to Cassandra without using Oak.

Thanks,


Solution

  • Answering here but credit goes to Sling user's mailing list

    1. Package the DB driver in an OSGi bundle
    2. Download Sling's starter project
    3. In boot.txt add a new running mode (in my case oak_db2)

      [settings] sling.run.mode.install.options=oak_tar,oak_mongo,oak_db2

    4. Download Sling's datasource project and compile it.

    5. In oak.txt configure the running mode (this will load the bundles for you in Felix):

      [artifacts startLevel=15 runModes=oak_db2] com.h2database/h2-mvstore/1.4.196 com.ibm.db2/jcc4/11.1
      org.apache.sling/org.apache.sling.datasource/1.0.3-SNAPSHOT

    And set-up the services that will manage persistence:

    [configurations runModes=oak_db2] 
    org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService
    documentStoreType="RDB"
    
    org.apache.sling.datasource.DataSourceFactory   
    url="jdbc:db2://10.1.2.3:50000/sling"            
    driverClassName="com.ibm.db2.jcc.DB2Driver"     
    username="****"     
    password="****"     
    datasource.name="oak"
    
    1. Create a 'sling' named database.
    2. run with java -jar -Dsling.run.modes=oak_db2 sling-starter.jar