Running the Agent as a service v1.2
For continuous metric streaming and to ensure your database remains visible in your Hybrid Manager (HM) estate, configure the EDB Postgres AI agent (formerly called HM or beacon agent) to run as a service. This allows the EDB Postgres AI agent to start automatically on system startup and restart after any errors.
If you don't set up the agent as a service, it will stream metrics only when you manually run it. Furthermore, your database will disappear from your HM estate 72 hours after the agent stops streaming.
Ensure you've completed agent installation and configuration before setting it up as a service.
Note
Future versions of the agent package may set this up automatically.
This example configures EDB Postgres AI agent to run on an RHEL 9 machine. However, we provide operating system aids so you know when to replace the values.
Environment variables
You must ensure that any environment variables referenced in the agent configuration file are accessible to the service at runtime.
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 system Default 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 Paste the following template into the created
beacon-agent.servicefile 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 settings Placeholder to replace Guidelines User=<user>Provide the name of the system user that will run the agent. WorkingDirectory=</home/user/>Set the working directory to where you stored the .beacondirectory. 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. 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
Your agent is now running as a service. Check on the logs:
journalctl -u beacon-agent.service