You can run more than one PEM agent service on a single server. While migrating, running multiple EDB Postgres Enterprise Manager (PEM) agents per database server is standard practice.
Each agent service runs as a separate process with its own configuration file, SSL certificates, and system service. All agents report independently to the same PEM server.
Note
A single PEM agent can already monitor multiple Postgres instances on the same host. Running multiple PEM agents on a single server is necessary only when you need separate agents for independent monitoring contexts or organizational boundaries.
Prerequisites
- The PEM agent package is installed on the host.
- You have root or administrator access on the host.
- The PEM server is accessible from the host.
Linux
Register each additional agent
Each agent instance needs its own configuration directory and SSL certificate directory. Use --config-dir and --cert-path to specify separate directories for each agent.
Create a directory for the additional agent's configuration and certificates:
mkdir -p /etc/edb/pem/agent2/etc mkdir -p /root/.pem/agent2 chmod 700 /root/.pem/agent2
Register the additional agent, specifying the new configuration directory and certificate path:
export PEM_SERVER_PASSWORD=<pem_admin_password> /usr/edb/pem/agent/bin/pemworker --register-agent \ --pem-server <new-pem-server-ip> \ --pem-port 5432 \ --pem-user enterprisedb \ --display-name "agent-host1-2" \ --config-dir /etc/edb/pem/agent2/etc \ --cert-path /root/.pem/agent2
PEM assigns a unique agent ID automatically. The
agent.cfgfile and SSL certificates are created in the directories you specified.Update the log file paths in the new
agent.cfgto avoid conflicts with the default agent:vi /etc/edb/pem/agent2/etc/agent.cfgSet
log_locationandagent_log_locationto unique paths, for example:log_location=/var/log/pem/agent2-worker.log agent_log_location=/var/log/pem/agent2.log
Create a systemd service for each additional agent
The default pemagent service runs the agent using its default configuration directory. To run an additional agent, create a new service unit file that points to the additional agent's configuration.
Copy the default service file:
cp /usr/lib/systemd/system/pemagent.service \ /usr/lib/systemd/system/pemagent2.service
Edit the new service file and update
ExecStartto use the new configuration directory:vi /usr/lib/systemd/system/pemagent2.serviceUpdate the
ExecStartline to pass the-cflag with the path to the newagent.cfg:ExecStart=/usr/edb/pem/agent/bin/pemagent -c /etc/edb/pem/agent2/etc/agent.cfg
Reload the systemd daemon to pick up the new service file:
systemctl daemon-reload
Enable and start the new agent service:
systemctl enable --now pemagent2
Verify that the service is running:
systemctl status pemagent2
Repeat these steps for each additional agent service you want to run on the same host. Use distinct directory paths, log file paths, and service names for each one (for example, agent3, pemagent3.service, and so on).
Windows
Running multiple PEM agent services on a single Windows server isn't supported.
Verify agent registration
After starting each agent service, confirm that all agents are registered and active in the PEM web application.
- In the PEM browser, expand PEM Server Directory > PEM Agents in the Object Explorer.
- Confirm that each agent appears with an Active status.
- Check the agent log files for connection or authentication errors.
You can also use the verify-registration subcommand to validate each agent:
pemworker --verify-registration --config-dir /etc/edb/pem/agent2/etc
See Registering a PEM agent for details on exit codes and additional options.