Skip to main content

Starting and Stopping on Linux

DBmarlin Agent Process​

The DBmarlin agent runs as a Tomcat process. The agent process can be started via a single command agent-start.sh and stopped via agent-stop.sh.

info

The agent-start.sh, agent-stop.sh and agent-status.sh scripts must be run as a dbmarlin user account or other non-root user account with access to the DBmarlin install directory.

Starting DBmarlin agent process​

The 3 ENV variable must first be set before starting the agent.

export DBMARLIN_AGENT_NAME="My first remote agent"
export DBMARLIN_ARCHIVER_URL=http://dbmarlin-service:9090/archiver
export DBMARLIN_API_KEY=aGVsbG86d29ybGQ=

These could be set using one of these methods;

  1. Linux service (preferred) - See systemd startup for Linux below.
  2. User .profile or similar for the dbmarlin user to export the 3 variables.
  3. Create your own wrapper script to export the 3 variable before calling ./agent-start.sh

The agent process (tomcat) can be started with a single agent-start.sh command.

cd /opt/dbmarlin
./agent-start.sh

Checking the status of DBmarlin agent process​

Check the status of the DBmarlin agent processes with the agent-status.sh command.

cd /opt/dbmarlin
./agent-status.sh

DBmarlin agent (Running)

Stopping the DBmarlin agent process​

The agent process (tomcat) can be stopped with a single agent-stop.sh command.

cd /opt/dbmarlin
./agent-stop.sh

systemd startup for Linux​

Systemd is a modern SysV-style init and rc replacement for Linux systems which makes use of many modern Linux kernel features. It provides a system and service manager that runs as PID 1 and starts the rest of the system. Systemd is what is responsible for controlling how services are started, stopped, restarted and otherwise managed on modern Linux distributions.

info

The standard Systemd Service unit files that come with the Linux system or installed by third party applications usually run as root or system user account.

Installing systemd unit files for DBmarlin​

  1. Login as the root user.

  2. Create new file dbmarlin-agent.service under /etc/systemd/system with contents like below. Be sure to customize the 3 Environment variable to your own settings and also amend the paths below if you aren't using /opt/dbmarlin/ as the base for your DBmarlin installation.

    [Unit]
    Description=DBmarlin Agent Application Service
    After=syslog.target network-online.target remote-fs.target nss-lookup.target
    Wants=network-online.target

    [Service]
    Environment="DBMARLIN_AGENT_NAME=dbmarlin-remote-agent"
    Environment="DBMARLIN_ARCHIVER_URL=http://172.30.0.155:9090/archiver"
    Environment="DBMARLIN_API_KEY=dXNlcjpwYXNzd29yZA=="
    Type=forking
    PIDFile=/opt/dbmarlin/tomcat/bin/catalina.pid
    ExecStartPre=/usr/bin/rm -f /opt/dbmarlin/tomcat/bin/catalina.pid
    ExecStart=/opt/dbmarlin/agent-start.sh
    ExecStop=/opt/dbmarlin/agent-stop.sh
    ExecStopPost=/bin/rm -f /opt/dbmarlin/tomcat/bin/catalina.pid
    PrivateTmp=true
    User=dbmarlin
    Group=dbmarlin
    Restart=always
    RestartSec=30

    [Install]
    WantedBy=multi-user.target
  3. Reload the services.

    systemctl daemon-reload
  4. systemctl list-unit-files | grep dbmarlin - you should see them listed but disabled which means they won't automatically start on a machine reboot but can be started and stopped manually via systemctl

    systemctl list-unit-files | grep dbmarlin
    dbmarlin-agent.service disabled
  5. systemctl start - to start the services

    systemctl start dbmarlin-agent
  6. systemctl status - to get the current status of the services

    systemctl status dbmarlin-agent
  7. systemctl stop - to stop the services

    systemctl stop dbmarlin-agent
  8. Enable the service to make the service automatically restarts on reboot

    systemctl enable dbmarlin-agent

For more on systemd see https://www.redhat.com/sysadmin/getting-started-systemctl