Skip to main content

mercury-cmd: administrative commands and backup of the Lucene index

Info

mercury-cmd runs the administrative commands of the server: generating and checking the Lucene index, reindexing, encoding passwords, testing database connections, calibrating the query optimizer and, through REST, the backup and restore of the Lucene index. This article describes how to run it, how to configure it, all its commands and how the backup works.

Running​

mercury-cmd.sh --help                      # list of the commands
mercury-cmd.sh <command> --help # help of one command
mercury-cmd.sh --version
mercury-cmd.sh <command> [arguments and options]
  • Every command has a long name (generate-lucene) and a short alias (gl). The older form with a leading dash (-gl) no longer works: the name of the command is the first argument, without a dash.
  • The option -Dkey=value sets a JVM system property for the command, before or after the name of the command (for example -Dmercury.lucene.config.file=lucene.properties).
  • The scripts are in the directory bin of the installation package; they find the installation directory themselves and read the configuration from ../config. In the Docker image of the server the scripts are in /opt/mercury-3.0/bin, so a command can be run with docker exec <container> /opt/mercury-3.0/bin/mercury-cmd.sh ....

Exit codes​

CodeMeaning
0success
1error of the operation (configuration, login, a response of the server, a transfer error, a timeout)
2wrong arguments (the help or the reason is printed)

The commands that start the application context of the server (generate-lucene, reindex-cases and the like) print Operation finished without errors. and, when the process stays alive, Please press 'Ctrl+C' to finish process. Scripts rely on these English lines, so they are not translated.

Language​

The help and the messages are printed in the first language that is set in this order:

  1. the option --lang <code> (for example --lang de),
  2. the environment variables LC_ALL, LC_MESSAGES, LANG (for example pl_PL.UTF-8; C and POSIX mean English),
  3. the language of the JVM,
  4. English.

The scripts of the installation package set LANG and LC_ALL to pl_PL.UTF-8; change them in the script or give --lang.

Configuration: config/commandLine.properties​

PropertyMeaning
mercury.config.file, sclogger.config.file, mercury.lucene.config.fileLocations of the configuration files of the server (by default in ../config)
mercury.lucene.build.threads, mercury.lucene.build.pageSizeNumber of threads (default 10) and size of the page (default 100) when the index is generated
mercury.cmd.jms.brokerURLAddress of Apache ActiveMQ (for example tcp://localhost:61616)
mercury.cmd.db.default.url, .dbUser, .dbPasswordThe main database (offline commands)
mercury.cmd.db.common.url, .dbUser, .dbPasswordThe common database
cmis.integrationtrue enables the commands that need the CMIS repository (sync-types)
mercury.cmd.rest.urlAddress of the server application for the commands that call REST, for example http://localhost:8080/mercury-ws-app
mercury.cmd.rest.nodeName of the cluster node that should do the operation (the option --node has priority)
mercury.cmd.rest.url.<node>Address of the given node (for example mercury.cmd.rest.url.node1)
mercury.cmd.rest.clientId, mercury.cmd.rest.clientSecretData of the OAuth client (client_id and client_secret) used to log in

The passwords and the secrets can be written in plain text or encoded with the command ep (mercury-cmd.sh ep 'my password' prints the value to paste into the file).

mercury.cmd.db.default.url=jdbc:postgresql://localhost:5432/mercury-db
mercury.cmd.db.default.dbUser=mercury
mercury.cmd.db.default.dbPassword=-9f9cc3fdab740a564265f4892564719
mercury.cmd.rest.url=http://localhost:8080/mercury-ws-app
mercury.cmd.rest.clientId=GIUPortalClient
mercury.cmd.rest.clientSecret=<the secret of the client, plain or encoded with ep>

Commands of mercury-cmd​

CommandAliasWhat it does
encode-password <password>epEncodes a password for a configuration file
sync-typestsSynchronizes the document types with the document repository (needs the CMIS integration)
generate-lucene <Case|GroupCase> [--threads n]glGenerates the Lucene index of an entity
validate-entities <Case|GroupCase> [--threads n]vlValidates an entity: builds the index without saving it
reindex-cases <fromScn> [<toScn>]ricIndexes the cases again, starting after the given archive SCN number (the case with this number is not included) up to toScn (default: no limit)
reload-predefinedrpdReloads the predefined parameter definitions
jdbc-testjdbctestTests the connections to the SQL databases
lucene-calibration [options]lcCalibrates the query optimizer of Lucene, see Calibrating the Lucene query optimizer
index-backup [options]ibOrders the server to create a backup of the Lucene index of cases
index-restore [--backup-id id] [options]irOrders the server to restore the index from a backup (the latest by default)
index-backups [options]ibsLists the backups kept by the server and shows the state of a running operation

The Docker start script of the server uses ep and generate-lucene Case.

mercury-cmd.sh ep 'my password'
mercury-cmd.sh gl Case --threads 8
mercury-cmd.sh ric 58305
mercury-cmd.sh lc --generate 40 --out /tmp/calibration

Backup and restore of the Lucene index​

The commands index-backup (ib), index-restore (ir) and index-backups (ibs) are only a proxy: they call the REST service of the server, and the server makes the copy and restores the index. They are described, together with the options, the logging in, the choice of the node in a cluster and the way the server works, in the article Backup and restore of the Lucene index.

See also: Backup and restore of the Lucene index, mercury-transfer.