混合模式下使用 H2 数据库的 Jackrabbit 集群
Posted
技术标签:
【中文标题】混合模式下使用 H2 数据库的 Jackrabbit 集群【英文标题】:Jackrabbit clustering with a H2 database in mixed mode 【发布时间】:2016-07-27 09:46:51 【问题描述】:我有一个 Magnolia CMS 系统,我尝试为包含用户生成内容的工作区配置一个集群存储库。 我们将有一个作者和一个公共实例,每个实例都有一个用于 magnolia 默认存储库的专用 mysql 数据库。 用户生成的内容应存储在 h2 数据库中,该数据库将位于共享目录中。 我们不能直接在服务器模式下启动 h2 数据库,因此,与 h2 数据库的连接将被配置为混合模式,带有 AUTO_SERVER=true 标志(请参阅http://www.h2database.com/html/features.html#auto_mixed_mode)。
存储库的初始化是完美的。一旦数据存储在集群存储库中,下一次重新启动将在集群存储库的加载阶段停止/挂起(参见日志)。
我错过了配置吗?甚至可以在混合模式下使用 h2 进行长耳兔聚类吗?
repository.xml:
<JCR>
<RepositoryMapping>
<Map name="userGeneratedContent" repositoryName="magnoliacluster" workspaceName="userGeneratedContent" />
<Map name="website" repositoryName="magnolia" workspaceName="website" />
<Map name="config" repositoryName="magnolia" workspaceName="config" />
<Map name="users" repositoryName="magnolia" workspaceName="users" />
<Map name="userroles" repositoryName="magnolia" workspaceName="userroles" />
<Map name="usergroups" repositoryName="magnolia" workspaceName="usergroups" />
<Map name="mgnlSystem" repositoryName="magnolia" workspaceName="mgnlSystem" /> <!-- System internal data -->
<Map name="mgnlVersion" repositoryName="magnolia" workspaceName="mgnlVersion" /> <!-- magnolia version workspace -->
</RepositoryMapping>
<!-- magnolia default repository -->
<Repository name="magnolia" provider="info.magnolia.jackrabbit.ProviderImpl" loadOnStartup="true">
<param name="configFile" value="$magnolia.repositories.jackrabbit.config" />
<param name="repositoryHome" value="$magnolia.repositories.home/magnolia" />
<!-- the default node types are loaded automatically
<param name="customNodeTypes" value="WEB-INF/config/repo-conf/nodetypes/magnolia_nodetypes.xml" />
-->
<param name="contextFactoryClass" value="org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory" />
<param name="providerURL" value="localhost" />
<param name="bindName" value="$magnolia.webapp" />
<workspace name="website" />
<workspace name="config" />
<workspace name="users" />
<workspace name="userroles" />
<workspace name="usergroups" />
<workspace name="mgnlSystem" />
<workspace name="mgnlVersion" />
</Repository>
<!-- magnolia cluster repository -->
<Repository name="magnoliacluster" provider="info.magnolia.jackrabbit.ProviderImpl" loadOnStartup="true">
<param name="configFile" value="$magnolia.repositories.jackrabbit.cluster.config" />
<param name="repositoryHome" value="$magnolia.repositories.home/magnoliacluster" />
<!-- the default node types are loaded automatically
<param name="customNodeTypes" value="WEB-INF/config/repo-conf/nodetypes/magnolia_nodetypes.xml" />
-->
<param name="contextFactoryClass" value="org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory" />
<param name="providerURL" value="localhost" />
<param name="bindName" value="cluster-$magnolia.webapp" />
<workspace name="userGeneratedContent" />
</Repository>
</JCR>
clustered-jackrabbit-bundle-h2-search.xml:
<Repository>
<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
<param name="url" value="jdbc:h2:/PATH/TO/db;AUTO_SERVER=TRUE"/>
<param name="schemaObjectPrefix" value="fs_"/>
<param name="user" value="sa"/>
<param name="password" value="sa"/>
</FileSystem>
<Security appName="magnolia">
<SecurityManager class="org.apache.jackrabbit.core.DefaultSecurityManager" />
<AccessManager
class="org.apache.jackrabbit.core.security.DefaultAccessManager">
</AccessManager>
<LoginModule
class="info.magnolia.jaas.sp.jcr.JackrabbitAuthenticationModule">
</LoginModule>
</Security>
<DataStore class="org.apache.jackrabbit.core.data.FileDataStore">
<param name="url" value="jdbc:h2:/PATH/TO/db;AUTO_SERVER=TRUE"/>
<param name="schemaObjectPrefix" value="datastore_"/>
<param name="user" value="sa"/>
<param name="password" value="sa"/>
</DataStore>
<Workspaces rootPath="$rep.home/workspaces"
defaultWorkspace="default" />
<Workspace name="default">
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<param name="path" value="$wsp.home/default" />
</FileSystem>
<PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.H2PersistenceManager">
<param name="url" value="jdbc:h2:/PATH/TO/db;AUTO_SERVER=TRUE"/>
<param name="schemaObjectPrefix" value="ws_$wsp.name_"/>
<param name="user" value="sa"/>
<param name="password" value="sa"/>
</PersistenceManager>
<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
<param name="path" value="$wsp.home/index" />
<param name="useCompoundFile" value="true" />
<param name="minMergeDocs" value="100" />
<param name="volatileIdleTime" value="3" />
<param name="maxMergeDocs" value="100000" />
<param name="mergeFactor" value="10" />
<param name="maxFieldLength" value="10000" />
<param name="bufferSize" value="10" />
<param name="cacheSize" value="1000" />
<param name="forceConsistencyCheck" value="false" />
<param name="autoRepair" value="true" />
<param name="queryClass" value="org.apache.jackrabbit.core.query.QueryImpl" />
<param name="resultFetchSize" value="100" />
<param name="extractorPoolSize" value="3" />
<param name="extractorTimeout" value="100" />
<param name="extractorBackLogSize" value="100" />
<!-- needed to highlight the searched term -->
<param name="supportHighlighting" value="true"/>
</SearchIndex>
<WorkspaceSecurity>
<AccessControlProvider
class="info.magnolia.cms.core.MagnoliaAccessProvider" />
</WorkspaceSecurity>
</Workspace>
<Versioning rootPath="$rep.home/version">
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<param name="path" value="$rep.home/workspaces/version" />
</FileSystem>
<PersistenceManager
class="org.apache.jackrabbit.core.persistence.bundle.H2PersistenceManager">
<param name="url" value="jdbc:h2:$rep.home/version/db" />
<param name="schemaObjectPrefix" value="version_" />
</PersistenceManager>
</Versioning>
<Cluster>
<Journal class="org.apache.jackrabbit.core.journal.DatabaseJournal">
<param name="driver" value="org.h2.Driver" />
<param name="url" value="jdbc:h2:/PATH/TO/db;AUTO_SERVER=TRUE"/>
<param name="schemaObjectPrefix" value="journal_"/>
<param name="databaseType" value="h2"/>
<param name="user" value="sa"/>
<param name="password" value="sa"/>
</Journal>
</Cluster>
</Repository>
日志:
---------------------------------------------
MAGNOLIA LICENSE
---------------------------------------------
Version number : 5.3.5
Build : 4. November 2014 (rev. of UNKNOWN)
Edition : Enterprise Edition
Provider : Magnolia International Ltd. (info@magnolia-cms.com)
2016-07-27 11:17:59,919 INFO info.magnolia.cms.beans.config.ConfigLoader : Initializing content repositories
2016-07-27 11:17:59,922 INFO info.magnolia.repository.DefaultRepositoryManager : Loading JCR
2016-07-27 11:17:59,931 INFO info.magnolia.repository.DefaultRepositoryManager : Loading JCR magnolia
2016-07-27 11:17:59,951 INFO info.magnolia.jackrabbit.ProviderImpl : Loading repository at /PATH/author/repositories/magnolia (config file: /PATH/WEB-INF/config/repo-conf/jackrabbit-bundle-h2-search.xml) - cluster id: "<unset>"
Jul 27, 2016 11:18:00 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /PATH/webapps/manager
Jul 27, 2016 11:18:00 AM org.apache.catalina.startup.TldConfig execute
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Jul 27, 2016 11:18:00 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /PATH/webapps/manager has finished in 417 ms
2016-07-27 11:18:02,174 INFO info.magnolia.repository.DefaultRepositoryManager : Loading JCR magnoliacluster
2016-07-27 11:18:02,174 INFO info.magnolia.jackrabbit.ProviderImpl : Loading repository at /PATH/author/repositories/magnoliacluster (config file: /PATH/WEB-INF/config/repo-conf/clustered-jackrabbit-bundle-h2-search.xml) - cluster id: "<unset>"
Ps.:我不知道为什么它会说“集群 id:”。虽然我在属性文件中将其设置为 org.apache.jackrabbit.core.cluster.node_id。
【问题讨论】:
【参考方案1】:来自以下wiki page:
集群 ID 标识实例并用于将更改写入日志以及从日志加载更改。确保这是一个唯一值,并且不与集群中的其他节点共享。
可以在属性文件中定义集群 id(最方便的方式),也可以在集群配置的持久性管理器中定义(两种方式都在附件中使用)
由于您没有在上面的 jackrabbit 配置文件中提供任何集群 ID,请检查您的 magnolia.properties
文件是否包含集群 ID?如果没有,只需为访问 JCR 集群的每个 Magnolia 实例设置一个唯一值。
【讨论】:
以上是关于混合模式下使用 H2 数据库的 Jackrabbit 集群的主要内容,如果未能解决你的问题,请参考以下文章
混合模式的 H2 数据库远程连接 (Auto_server=true)