Pages

Thursday, September 26, 2013

Jackrabbit Configuration for Document Library in Liferay Clustering environment

Jackrabbit Configuration for Document Library in Liferay Clustering environment

·         Jackrabbit is the standards-based (JSR-170) content repository that ships with Liferay.
·         By default, Liferay is configured to store files on the local file system.
·         This will not work in a clustered environment, because all the nodes need to be able to access the repository.
·         For this reason, we will configure jackrabbit on both nodes to store documents in the Liferay database, and then we will enable its cluster configuration.
·         Liferay ships with the database and cluster configuration available, but commented out, so all we will need to do is comment out the default configuration and uncomment the database / cluster configuration.


Enabling Jackrabbit

·         By default Liferay portal 6.1 uses direct file system storage for the Document Library.
·         To enable Jackrabbit change the DL storage setting the following property in portal-ext.properties of all the Liferay nodes
dl.store.impl=com.liferay.portlet.documentlibrary.store.JCRStore

·         Copy all the jackrabbit properties from portal.properties and paste it in portal-ext.properties file for all the Liferay nodes
jcr.initialize.on.startup=true (by default its value is false)
jcr.wrap.session=true
jcr.workspace.name=liferay
jcr.node.documentlibrary=documentlibrary

jcr.jackrabbit.repository.root=${liferay.home}/data/jackrabbit

jcr.jackrabbit.config.file.path=${jcr.jackrabbit.repository.root}/repository.xml

jcr.jackrabbit.repository.home=${jcr.jackrabbit.repository.root}/home
jcr.jackrabbit.credentials.username=none
jcr.jackrabbit.credentials.password=none
[Note: Do not change the storage used by the Document Library if there are documents already loaded. Do it always for empty database.]

Modify Jackrabbit Configuration

·         Open repository.xml file from Liferay_Home_1/data/repository.xml.
§  Main Section of the File :
·         <FileSystem /> declaration that points Jackrabbit to the local file system.
§  Commented  out <FileSystem/> section that points Jackrabbit to the Database.
·         <Security/>: no change will be needed here.
·         <Workspace /> section that has the following subsections :
§  <FileSystem/> that points to the local file system.
§  <PersistenceManager/> for a local file system.
§  Commented out <FileSystem/> and <PersistenceManager/> for cluster conf.
·         <Versioning/> with a similar structure than the Work Space section.
·         Commented out <Cluster/> configuration.
·         Go through the file and comment out the <FileSystem/> sections and <PersistenceManager/> sections that point to the file system, and uncomment the sections that point to the database.
·         For each database section, specify your database username and password like user name root and password root.
·         Please find the sample repository.xml file after modifying here. Where uncommented portion is in bold and commented portion is in different highlighted color.
<?xml version="1.0"?>

<Repository>
<!—
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<param name="path" value="${rep.home}/repository" />
</FileSystem>-->

     <!--
     Database File System (Cluster Configuration)

     This is sample configuration for mysql persistence that can be used for
     clustering Jackrabbit. For other databases, change the connection,
     credentials, and schema settings.
     -->

     <FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
          <param name="driver" value="com.mysql.jdbc.Driver"/>
          <param name="url" value="jdbc:mysql://localhost/jcr" />
          <param name="user" value="root" />
          <param name="password" value="root" />
          <param name="schema" value="mysql"/>
          <param name="schemaObjectPrefix" value="J_R_FS_"/>
     </FileSystem>

     <Security appName="Jackrabbit">
          <AccessManager class="org.apache.jackrabbit.core.security.SimpleAccessManager" />
          <LoginModule class="org.apache.jackrabbit.core.security.SimpleLoginModule">
              <param name="anonymousId" value="anonymous" />
          </LoginModule>
     </Security>
     <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="liferay" />
     <Workspace name="${wsp.name}">
     <!—
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
          <param name="path" value="${wsp.home}" />
</FileSystem>
<PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.BundleFsPersistenceManager" />
-->

          <!--
          Database File System and Persistence (Cluster Configuration)

          This is sample configuration for mysql persistence that can be used for
          clustering Jackrabbit. For other databases, change the  connection,
          credentials, and schema settings.
          -->

<PersistenceManager class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager">
     <param name="driver" value="com.mysql.jdbc.Driver" />
     <param name="url" value="jdbc:mysql://localhost/jcr" />
     <param name="user" value="root" />
     <param name="password" value="root" />
     <param name="schema" value="mysql" />
<param name="schemaObjectPrefix" value="J_PM_${wsp.name}_" />
     <param name="externalBLOBs" value="false" />
</PersistenceManager>

<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
     <param name="driver" value="com.mysql.jdbc.Driver"/>
     <param name="url" value="jdbc:mysql://localhost/jcr" />
<param name="user" value="root" />
     <param name="password" value="root" />
     <param name="schema" value="mysql"/>
     <param name="schemaObjectPrefix"            value="J_FS_${wsp.name}_"/>
</FileSystem>
</Workspace>
<Versioning rootPath="${rep.home}/version">
<!--     
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
          <param name="path" value="${rep.home}/version" />
</FileSystem>
<PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.BundleFsPersistenceManager" /> -->

<!--
          Database File System and Persistence (Cluster Configuration)

          This is sample configuration for mysql persistence that can be used for
          clustering Jackrabbit. For other databases, change the connection,
          credentials, and schema settings.
          -->

<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
     <param name="driver" value="com.mysql.jdbc.Driver"/>
     <param name="url" value="jdbc:mysql://localhost/jcr" />
     <param name="user" value="root" />
     <param name="password" value="root" />
     <param name="schema" value="mysql"/>
     <param name="schemaObjectPrefix" value="J_V_FS_"/>
</FileSystem>

<PersistenceManager class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager">
<param name="driver" value="com.mysql.jdbc.Driver" />
     <param name="url" value="jdbc:mysql://localhost/jcr" />
     <param name="user" value="root" />
     <param name="password" value="root" />
     <param name="schema" value="mysql" />
     <param name="schemaObjectPrefix" value="J_V_PM_" />
     <param name="externalBLOBs" value="false" />
</PersistenceManager>
</Versioning>

     <!--
     Cluster Configuration

     This is sample configuration for mysql persistence that can be used for
     clustering Jackrabbit. For other databases, change the  connection,
     credentials, and schema settings.
     -->

<Cluster id="node_1" syncDelay="5">
<Journal class="org.apache.jackrabbit.core.journal.DatabaseJournal">
     <param name="revision" value="${rep.home}/revision"/>
     <param name="driver" value="com.mysql.jdbc.Driver"/>
     <param name="url" value="jdbc:mysql://localhost/jcr"/>
     <param name="user" value="root"/>
     <param name="password" value="root"/>
     <param name="schema" value="mysql"/>
     <param name="schemaObjectPrefix" value="J_C_"/>
</Journal>
</Cluster>
</Repository>

·         Repeat the same change in the repository.xml file from Liferay_Home_2/data/repository.xml

Adding a Database

·         Note that the database URLs in this file point to a new database called jcr.
·         You will need to create a database before you start Liferay.
·         This is easy to do with MySQL. We will do this via the command line.

Create database jcr;

Test Case

Start both Liferay nodes and upload a new document in Node1. And try to download from node1 and node2. If it allow to download then you did successful integration.

Congratulation! It’s done.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.