Compacter la base de données H2/ Compact H2 Database

Produit concerné / Related product

JMapVersions7.0

Problème

La base de données H2 augmente indéfiniment et la durée d'un backup augmente relativement.

Explication

Selon http://h2database.com/html/features.html#compacting, «L'espace vide du fichier de base de données a été réutilisé automatiquement.
Lorsque vous fermez la base de données, celle-ci est automatiquement compactée par défaut pendant 200 millisecondes au maximum." Pour compacter plus utilisez la solution ci-après.

Solution

Pour éviter le crash du serveur lors du démarrage, nous suggérons un manuel SHUTDOWN COMPACT comme solution de contournement pour compacter d'avantage. Voici les étapes :

  1.  Arrêter le serveur JMap

  2. Ouvrez un terminal ou une invite de commande et accédez à <JMAP_HOME> / db

  3. Exécuter la commande ci-dessous (remplacer <JMAP_HOME> par le chemin de votre installation JMap):

    ..\jre\bin\java -cp ../lib/ignite/ignite-indexing/h2-1.4.195.jar org.h2.tools.Script -url "jdbc:h2:/<JMAP_HOME>/db/system;DB_CLOSE_ON_EXIT=TRUE;AUTO_SERVER=TRUE;TRACE_LEVEL_FILE=4;TRACE_LEVEL_SYSTEM_OUT=0" -user sa -script backup.zip -options compression zip

    3.1 Faire un backup manuellement des fichiers system.*.db

  4.  Supprimer les fichiers de base de données : <JMAP_HOME>/db/system.*

  5.  Exécuter la commande ci-dessous (remplacez <JMAP_HOME> par le chemain de votre installation JMap):

    ..\jre\bin\java -cp ../lib/ignite/ignite-indexing/h2-1.4.195.jar org.h2.tools.RunScript -url "jdbc:h2:/<JMAP_HOME>/db/system;DB_CLOSE_ON_EXIT=TRUE;AUTO_SERVER=TRUE;TRACE_LEVEL_FILE=4;TRACE_LEVEL_SYSTEM_OUT=0" -user sa -script backup.zip -options compression zip
  6. Redémarrer JMap Server


English version

Problem

The H2 database increases indefinitely and the duration of a backup increases relatively.

Explication

According to http://h2database.com/html/features.html#compacting, "Empty space in the database file re-used automatically. When closing the database, the database is automatically compacted for up to 200 milliseconds by default. " To compact more use the solution below.

Solution

To prevent the server crashing during startup, we suggest a manual SHUTDOWN COMPACT as a workaround to compact more. Here are the steps:

  1. Stop the JMap Server

  2. Open a terminal or command prompt and navigate to <JMAP_HOME> / db

  3. Run the command below (replace <JMAP_HOME> with the path of your JMap installation):

    ..\jre\bin\java -cp ../lib/ignite/ignite-indexing/h2-1.4.195.jar org.h2.tools.Script -url "jdbc:h2:/<JMAP_HOME>/db/system;DB_CLOSE_ON_EXIT=TRUE;AUTO_SERVER=TRUE;TRACE_LEVEL_FILE=4;TRACE_LEVEL_SYSTEM_OUT=0" -user sa -script backup.zip -options compression zip
  4.  Delete the database files: <JMAP_HOME> /db/system.*

  5. Run the command below (replace <JMAP_HOME> with the path of your JMap installation):

    ..\jre\bin\java -cp ../lib/ignite/ignite-indexing/h2-1.4.195.jar org.h2.tools.RunScript -url "jdbc:h2:/<JMAP_HOME>/db/system;DB_CLOSE_ON_EXIT=TRUE;AUTO_SERVER=TRUE;TRACE_LEVEL_FILE=4;TRACE_LEVEL_SYSTEM_OUT=0" -user sa -script backup.zip -options compression zip
  6. Restart JMap Server