Running the EDB Postgres AI agent as a service Innovation Release

For continuous metric streaming and to ensure your database remains visible in your Hybrid Manager (HM) estate, configure the agent to run as a service. Running as a service allows it to start on system startup and restart after any errors.

If you don't set up the agent as a service, it streams metrics only when you manually run it. Also, your database will disappear from your HM estate 72 hours after the agent stops streaming.

Before setting the agent up as a service, install and configure it.

Note

Future versions of the agent package may set this up automatically.

This example configures the EDB Postgres AI agent to run on an RHEL 9 machine. Operating system aids help you to know when to replace the values.

Environment variables

Make sure that any environment variables referenced in the agent configuration file are accessible to the service at runtime.

  1. Create a file using your text editor of choice. This example command uses the vi editor.

    sudo vi /usr/lib/systemd/system/beacon-agent.service

    Other default system directories on AWS EC2 instances are:

    Operating systemDefault system directory
    RHEL/usr/lib/systemd/system/beacon-agent.service
    Rocky Linux/usr/lib/systemd/system/beacon-agent.service
    AlmaLinux/usr/lib/systemd/system/beacon-agent.service
    Ubuntu/etc/systemd/system/beacon-agent.service
    Debian/lib/systemd/system/beacon-agent.service
  2. Paste the following template into the new beacon-agent.service file and replace the information in placeholders < >.

    # TEMPLATE
    
    [Unit]
    Description=Agent
    
    After=network.target
    
    [Service]
    Type=simple
    
    User=<user>
    
    WorkingDirectory=</home/user/>
    Environment="PATH=</path/to/Oracle/db/binary>:</Oracle/user/binaries>:</system/binaries>" # e.g. /u01/app/oracle/product/19.0.0/dbhome_1/bin:/home/oracle/.local/bin:/home/oracle/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
    Environment="ORACLE_HOME=</path/to/Oracle/db/binary>" # e.g. /u01/app/oracle/product/19.0.0/dbhome_1
    
    ExecStart=</usr/local/bin/beacon-agent>
    
    Restart=on-failure
    RestartSec=60
    
    [Install]
    WantedBy=multi-user.target
    Service settingsPlaceholder to replaceGuidelines
    User=<user>Provide the name of the system user which will run the Agent.
    WorkingDirectory=</home/user/>Set the working directory to where you stored the .beacon directory. The path depends on the operating system.
    Environment="PATH=</path/to/Oracle/db/binary>:</Oracle/user/binaries>:</system/binaries>"Set to all user and system directories that contain Oracle-related executables to ensure the Agent can use sqlplus for schema extraction during runtime.
    Environment="ORACLE_HOME=</path/to/Oracle/db/binary>"Set to the directory of the Oracle database executables to enable sqlplus to extract schemas.
    ExecStart=</usr/local/bin/beacon-agent>Provide the path to the directory where the Agent was installed. The path depends on the operating system.
  3. Run the following commands to reload, enable, and start your new service. These commands apply to all mentioned operating systems:

    sudo systemctl daemon-reload
    sudo systemctl enable beacon-agent.service
    sudo systemctl start beacon-agent.service
  4. Your agent is now running as a service. Check the logs:

    journalctl -u beacon-agent.service