Creating the Data Directory
Metadb uses local storage in a data directory which is created using the init command:
This creates the data directory and generates a metadb.conf configuration file.
Configuration File Structure
The metadb.conf file in the data directory has the following structure:
[main]
host = host name of the PostgreSQL server
port = port number of the PostgreSQL server
database = database name
superuser = database superuser such as "postgres"
superuser_password = password of superuser
systemuser = database user that is the owner of the database
systemuser_password = password of systemuser
sslmode = should be set to "require" or stronger option
Metadb expects the database name to be metadb or to begin with metadb_; otherwise it logs a warning message.
Example Configuration
Edit the file to add your database connection parameters:
[main]
host = a.b.c
port = 5432
database = metadb
superuser = postgres
superuser_password = zpreCaWS7S79dt82zgvD
systemuser = mdbadmin
systemuser_password = ZHivGie5juxGJZmTObHU
sslmode = require
Metadb assumes that the database, superuser, and systemuser defined in the configuration already exist. Create them before continuing.
Running the Server
Starting the Server
To start the server:
nohup metadb start -D data -l metadb.log &
Memory Limit
The --memlimit option sets a soft memory limit (in GiB):
nohup metadb start -D data -l metadb.log --memlimit 2 &
Additional Options
--port - Set the server port (default: 8550)
--debug - Enable verbose logging
Stopping the Server
To stop the server:
Stopping or restarting the server may delay scheduled data updates or cause them to restart.
Running with systemd
For production deployments, set up Metadb to run with systemd via /etc/systemd/system/metadb.service:
[Unit]
Description=Metadb
After=network.target remote-fs.target
[Service]
Type=simple
User=metadb
ExecStart=/bin/bash -ce "exec /home/metadb/bin/metadb start -D /home/metadb/data -l /home/metadb/metadb.log"
Restart=on-abort
[Install]
WantedBy=multi-user.target
Enable and Start the Service
systemctl enable metadb
systemctl start metadb