Difference between revisions of "MySQL"

From OpenKM Documentation
Jump to: navigation, search
(Created page with '== Repository configuration == <source lang="xml"> <?xml version="1.0" encoding="UTF-8"?> <Repository> <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">…')
 
(Change MySQL default engine to InnoDB)
 
(58 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Repository configuration ==
+
{{TOCright}} __TOC__
  
<source lang="xml">
+
Download MySQL JDBC driver from [http://www.mysql.com/products/connector/ MySQL Home Page] and move it to ''$TOMCAT_HOME/lib'' or ''$JBOSS_HOME/server/default/lib'' depending on your OpenKM version..
<?xml version="1.0" encoding="UTF-8"?>
+
 
<Repository>
+
{{Note|If you get an error like this:
  <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+
 
    <param name="path" value="${rep.home}/repository"/>
+
Packet for query is too large (1708726 > 1048576).
  </FileSystem>
+
You can change this value on the server by setting the 'max_allowed_packet' variable.
  <Security appName="OpenKM">
+
 
    <AccessManager class="com.openkm.core.OKMAccessManager"/>
+
You need to modify your MySQL server configuration file and increase the value of the '''max_allowed_packet''' property. Don't forget to restart the MySQL after any change in this file. In Debian based distros like Ubuntu, this configuration file is located at ''/etc/mysql/my.cnf''.}}
  </Security>
+
 
  <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/>
+
* [[MySQL-OpenKM 6.0 | OpenKM 6.0]] (also valid for OpenKM 6.X+)
  <Workspace name="${wsp.name}">
+
* [[MySQL-OpenKM 5.0 | OpenKM 5.0]] (also valid for OpenKM 5.X+)
    <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+
* [[MySQL-OpenKM 4.1 | OpenKM 4.1]]
      <param name="path" value="${wsp.home}"/>
+
 
    </FileSystem>
+
== Change MySQL default engine to InnoDB ==
    <PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.MySqlPersistenceManager">
+
Check if your MySQL installation has InnoDB engin enabled:
      <param name="driver" value="com.mysql.jdbc.Driver"/>
+
 
      <param name="url" value="jdbc:mysql://localhost:3306/openkm? autoReconnect=true"/>
+
  $ mysql -h localhost -u root -p
      <param name="schema" value="mysql"/>
+
  mysql> show engines;
      <param name="user" value="root"/>
+
 
      <param name="password" value="xxx"/>
+
In order to change the default storage engine edit '''/etc/mysql/my.cnf''' and under '''[mysqld]''' section in your ini file, and add:
      <param name="schemaObjectPrefix" value="${wsp.name}_"/>
+
 
      <param name="externalBLOBs" value="false"/>
+
  default-storage-engine = innodb
    </PersistenceManager>
+
 
    <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+
{{Advice|[http://en.wikipedia.org/wiki/InnoDB InnoDB] is the preferred engine because it support transactions. [http://en.wikipedia.org/wiki/MyISAM MyISAM] is more responsive but does not support transactions.}}
      <param name="path" value="${wsp.home}/index"/>
+
 
      <param name="useCompoundFile" value="true"/>
+
If you want to show which engine is using every table, do:
      <param name="minMergeDocs" value="100"/>
+
 
      <param name="volatileIdleTime" value="3"/>
+
<source lang="sql">
      <param name="maxMergeDocs" value="100000"/>
+
SHOW TABLE STATUS WHERE name like 'OKM_%';
      <param name="mergeFactor" value="10"/>
 
      <param name="bufferSize" value="10"/>
 
      <param name="cacheSize" value="1000"/>
 
      <param name="forceConsistencyCheck" value="false"/>
 
      <param name="autoRepair" value="true"/>
 
      <param name="analyzer" value="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
 
      <param name="respectDocumentOrder" value="false"/>
 
      <param name="indexingConfiguration" value="$ {wsp.home}/../../../indexing_configuration.xml"/>
 
      <param name="textFilterClasses" value="
 
org.apache.jackrabbit.core.query.lucene.TextPlainTextFilter,
 
org.apache.jackrabbit.extractor.PdfTextExtractor,
 
org.apache.jackrabbit.extractor.HTMLTextExtractor,
 
org.apache.jackrabbit.extractor.XMLTextExtractor,
 
org.apache.jackrabbit.extractor.RTFTextExtractor,
 
org.apache.jackrabbit.extractor.OpenOfficeTextExtractor,
 
com.openkm.extractor.MsExcelTextExtractor,
 
com.openkm.extractor.MsPowerPointTextExtractor,
 
com.openkm.extractor.MsWordTextExtractor,
 
com.openkm.extractor.MsOffice2007TextExtractor,
 
com.openkm.extractor.ExifTextExtractor,
 
com.openkm.extractor.TiffTextExtractor,
 
com.openkm.extractor.AudioTextExtractor" />
 
    </SearchIndex>
 
  </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.MySqlPersistenceManager">
 
      <param name="driver" value="com.mysql.jdbc.Driver"/>
 
      <param name="url" value="jdbc:mysql://localhost:3306/openkm? autoReconnect=true"/>
 
      <param name="schema" value="mysql"/>
 
      <param name="user" value="root"/>
 
      <param name="password" value="xxx"/>
 
      <param name="schemaObjectPrefix" value="version_"/>
 
      <param name="externalBLOBs" value="false"/>
 
    </PersistenceManager>
 
  </Versioning>
 
</Repository>
 
 
</source>
 
</source>
 +
 +
To see all the tables included in a database:
 +
 +
<source lang="sql">
 +
SHOW FULL TABLES FROM okmdb;
 +
</source>
 +
 +
You can also filter by table name:
 +
 +
<source lang="sql">
 +
SHOW FULL TABLES FROM okmdb LIKE 'OKM_%'
 +
</source>
 +
 +
== Database repair ==
 +
If you have problems with a database and need to be repaired, you can use this command:
 +
 +
  $ mysqlcheck -u root -p --auto-repair --optimize --all-databases
 +
 +
See also:
 +
* [http://dev.mysql.com/doc/refman/5.0/en/converting-tables-to-innodb.html Converting Tables from Other Storage Engines to InnoDB]
 +
* [http://highervisibilitywebsites.com/convert-your-mysql-database-myisam-innodb-and-get-ready-drupal-7-same-time Convert your MySQL database from MyISAM to InnoDB]
 +
 +
[[Category: Installation Guide]]

Latest revision as of 09:55, 25 November 2013

Download MySQL JDBC driver from MySQL Home Page and move it to $TOMCAT_HOME/lib or $JBOSS_HOME/server/default/lib depending on your OpenKM version..


Nota clasica.png If you get an error like this:
Packet for query is too large (1708726 > 1048576).
You can change this value on the server by setting the 'max_allowed_packet' variable.
You need to modify your MySQL server configuration file and increase the value of the max_allowed_packet property. Don't forget to restart the MySQL after any change in this file. In Debian based distros like Ubuntu, this configuration file is located at /etc/mysql/my.cnf.

Change MySQL default engine to InnoDB

Check if your MySQL installation has InnoDB engin enabled:

 $ mysql -h localhost -u root -p
 mysql> show engines;

In order to change the default storage engine edit /etc/mysql/my.cnf and under [mysqld] section in your ini file, and add:

 default-storage-engine = innodb

Nota idea.png InnoDB is the preferred engine because it support transactions. MyISAM is more responsive but does not support transactions.

If you want to show which engine is using every table, do:

SHOW TABLE STATUS WHERE name like 'OKM_%';

To see all the tables included in a database:

SHOW FULL TABLES FROM okmdb;

You can also filter by table name:

SHOW FULL TABLES FROM okmdb LIKE 'OKM_%'

Database repair

If you have problems with a database and need to be repaired, you can use this command:

 $ mysqlcheck -u root -p --auto-repair --optimize --all-databases

See also: