SeisComP3

Table Of Contents

Previous topic

scconfig

Next topic

scdispatch

This Page

scdb

Populates a SQL database from XML files or messages.

Description

A major component of the SeisComP3 system is the database. Almost all applications have only read access to the database, but all the processing results and objects have to be written into the database. This was the task of scdb. In very first versions of SeisComP3 scdb was the only component that had write access to the database. Its task is to connect to scmaster and populate the database with all received notifier messages. Although it worked it introduced race conditions caused by the latency of the database backend since all other clients received the message at the same time. Accessing the database immediately at this point in time did not guarantuee that the object was written already.

In consequence, the scmaster itself gained write access to the database and forwards messages to all clients after they are written to database.

scdb by definition does not check existing objects in the database. It only generates INSERT/UPDATE/DELETE statements based on the data used and sends these statements to the database. E.g. if scdb receives a message to insert a new object into the database and this object exists already, the database will raise an error because scdb hasn't checked it.

Online mode

Now scdb can be used to maintain a backup or archive the database that is not part of the realtime processing. When running scdb as database write daemon it can inform a client about the database connection to use. A client sends a DatabaseRequest message and scdb sends back a DatabaseResponse message containing the database connection parameters.

For that it connects to a messaging server and writes all received messages to a configured database, e.g. a backup database.

scdb -H server -o mysql://sysop:sysop@db-server/seiscomp3

In the above example scdb connects to "server" and writes all messages to the output database. The database connection it received from the messaging server during the handshake is reported to client requesting a database address. To overwrite the read-only database, just override the applications database address:

scdb -H server -d mysql://sysop:sysop@db-server/seiscomp3 \
               -o mysql://writer:12345@db-server/seiscomp3

Offline mode

Another important task of scdb is to populate the database with any SeisComP3 datamodel content. In combination with scxmldump it can be used to copy events from one database to another.

For that it does not connect to a messaging server but reads data from XML files and writes it to the database.

Warning

When reading XML files the output database address is not passed with -o but -d. The applications database address is used.

scdb -i data.xml -d mysql://sysop:sysop@db-server/seiscomp3

Configuration

etc/defaults/global.cfg
etc/defaults/scdb.cfg
etc/global.cfg
etc/scdb.cfg
~/.seiscomp3/global.cfg
~/.seiscomp3/scdb.cfg

scdb inherits global options.

connection.requestGroup

Type: string

Defines the group on scmaster to subscribe for database requests.

connection.provideGroup

Type: string

Defines the group on scmaster to send database response messages to.

output.type

Type: string

Defines the output database connection type.

output.parameters

Type: string

Defines the output database connection parameters.

Command-line

Generic

-h, --help

show help message.

-V, --version

show version information

--config-file arg

Use alternative configuration file. When this option is used the loading of all stages is disabled. Only the given configuration file is parsed and used. To use another name for the configuration create a symbolic link of the application or copy it, eg scautopick -> scautopick2.

--plugins arg

Load given plugins.

-D, --daemon

Run as daemon. This means the application will fork itself and doesn't need to be started with &.

--auto-shutdown arg

Enable/disable self-shutdown because a master module shutdown. This only works when messaging is enabled and the master module sends a shutdown message (enabled with --start-stop-msg for the master module).

--shutdown-master-module arg

Sets the name of the master-module used for auto-shutdown. This is the application name of the module actually started. If symlinks are used then it is the name of the symlinked application.

--shutdown-master-username arg

Sets the name of the master-username of the messaging used for auto-shutdown. If "shutdown-master-module" is given as well this parameter is ignored.

Verbosity

--verbosity arg

Verbosity level [0..4]. 0:quiet, 1:error, 2:warning, 3:info, 4:debug

-v, --v

Increase verbosity level (may be repeated, eg. -vv)

-q, --quiet

Quiet mode: no logging output

--component arg

Limits the logging to a certain component. This option can be given more than once.

-s, --syslog

Use syslog logging back end. The output usually goes to /var/lib/messages.

-l, --lockfile arg

Path to lock file.

--console arg

Send log output to stdout.

--debug

Debug mode: --verbosity=4 --console=1

--log-file arg

Use alternative log file.

Messaging

-u, --user arg

Overrides configuration parameter connection.username.

-H, --host arg

Overrides configuration parameter connection.server.

-t, --timeout arg

Overrides configuration parameter connection.timeout.

-g, --primary-group arg

Overrides configuration parameter connection.primaryGroup.

-S, --subscribe-group arg

A group to subscribe to. This option can be given more than once.

--encoding arg

Overrides configuration parameter connection.encoding.

--start-stop-msg arg

Sets sending of a start- and a stop message.

--m, --mode arg

scdb can either process a XML file and write it to the database or collecting messages from scmaster. If connected to scmaster the mode defines what objects are handled: none (no objects at all), notifier (notifier only) or all (all objects whereas non-notifier objects are INSERTED into the database).

Database

--db-driver-list

List all supported database drivers.

-d, --database arg

The database connection string, format: service://user:pwd@host/database. "service" is the name of the database driver which can be queried with "--db-driver-list".

--config-module arg

The configmodule to use.

--inventory-db arg

Load the inventory database from a given XML file.

--config-db arg

Load the configuration database from a given XML file.

--o, --output arg

If connected to scmaster this flag defines the database connection to use for writing. The configured application database connection (as received from scmaster) is reported to clients as part of a database response messages.

Import

-i, --input arg

Defines the import XML file to be written to database.

-b, --batchsize arg

Batch size of a database transactions [0..1000]. By default all INSERT/UPDATE/DELETE statements are executed in one single transaction.