Changing repository to MySQL
This is a quick step by step guide how a MySQL 5 database could be used as the underlying repository for magnolia.
- Install and configure MySQL on your server and create an empty database such as magnolia_author (or similar) on it. The specifics of using MySQL are outside the scope of this page
Do not use Mysql 4. Mysql 5 or newer is recommended.
- Take a fresh not yet started 3.5 instance or stop an existing one and delete (after exporting data you want continue to use!) the whole repository folder.
- Download the mysql-connector jdbc driver (http://dev.mysql.com/downloads/connector/j) and place it in WEB-INF/lib
- Edit the WEB-INF/config/default/magnolia.properties file: magnolia.repositories.jackrabbit.config = WEB-INF/config/repo-conf/jackrabbit-mysql-search.xml
- Edit WEB-INF/config/repo-conf/jackrabbit-mysql-search.xml, for Workspace/PersistenceManager and Versioning/PersistenceManager:
<PersistenceManager class="org.apache.jackrabbit.core.persistence.db.SimpleDbPersistenceManager">
<param name="driver" value="com.mysql.jdbc.Driver" />
<param name="url" value="jdbc:mysql: />
<param name="schema" value="mysql" /><!-- warning, this is not the schema name, it's the db type -->
<param name="user" value="your-user" />
<param name="password" value="your-password" />
<param name="schemaObjectPrefix" value="${wsp.name}_" />
<param name="externalBLOBs" value="true" />
</PersistenceManager>
- autoReconnect=true: reinitializes the database connection if down.
- externalBLOBS: set to true will store binary data on filesystem instead of in the database.
- ${wsp.name} is a variable that gets substituted with the workspace name.
- Remember to change the database name (url) for your public instance(s), esp. if they are on the same server.
 |
The code above is correct for Workspace/PersistenceManager. For Versioning/PersistenceManager(the second one in the file), replace
<param name="schemaObjectPrefix" value="${wsp.name}_" />
with
<param name="schemaObjectPrefix" value="version_" />
|
6. Start Magnolia. If succeeded you will see a bunch of new tables in your created database. If not, you should take a look at the logs to see where it failed. (which is always a good idea when trying new configurations anyway)
Important Note:
After the first start of the system, Jackrabbit creates files describing the repository and its workspaces under repositories/magnolia/..., most notably the workspace.xml files; you'll have to modify these if you want to modify parameters later on during the lifecycle of your system.
Alternatives
When running Magnolia 3.5.x and higher you might consider using org.apache.jackrabbit.core.persistence.bundle.MySqlPersistenceManager persistence manager instead of default org.apache.jackrabbit.core.persistence.db.SimpleDbPersistenceManager. This newer persistence manager offers superior performance in cases when having many properties per node and also provides better consistency checks and self repairing functions.