Get Postgres Tips and Tricks
Subscribe to get advanced Postgres how-tos.
PEM Agent Troubleshooting¶
Restoring a Deleted PEM Agent¶
If an agent has been deleted from the pem.agent
table then you cannot restore it. You will need to use the pemworker utility to re-register the agent.
If an agent has been deleted from PEM Web client but still has an entry in the
pem.agent
table with value of active = f, then you can restore the agent using
the following steps:
Use the following command to check the values of the
id
andactive
fields:pem=# SELECT * FROM pem.agent;
Update the status for the agent to
true
in thepem.agent
table:pem=# UPDATE pem.agent SET active=true WHERE id=<x>;
Where,
x
is the identifier that was displayed in the output of the query used in step 1.Refresh the PEM web client.
The deleted agent will be restored again. However, the servers that were bound to that particular agent might appear to be down. To resolve this issue, you need to modify the PEM agent properties of the server to add the bound agent again; after the successful modification, the servers will be displayed as running properly.
Reconfiguring the PEM Server¶
In certain situations, you may need to uninstall the PEM server, install it again, and reconfigure the PEM server. Use the following commands in the given sequence:
Use the following command to remove the PEM server configuration and uninstall:
/usr/edb/pem/bin/configure-pem-server.sh –un
Use the following command to remove the PEM packages:
yum erase edb-pem-server
Use the following command to drop the
pem
database:DROP DATABASE pem
Move the certificates from
/root/.pem/
to another location:mv /root/.pem/* <new_location>
Move the
agent.cfg
file from/usr/edb/pem/agent/etc/agent.cfg
to another location:mv /usr/edb/pem/agent/etc/agent.cfg <new_location>
Then, use the following command to configure the PEM server again:
/usr/edb/pem/bin/configure-pem-server.sh'
Using the Command Line to Delete a PEM Agent with Down or Unknown Status¶
Using the PEM web interface to delete PEM agents with Down
or Unknown
status may be difficult if the number of such agents is large. In such situations, you might want to use the command line interface to delete Down or Unknown agents.
- Use the following query to delete the agents that are
Down
for more than N number of hours:
UPDATE pem.agent SET active=false WHERE id IN
(SELECT a.id FROM pem.agent
a JOIN pem.agent_heartbeat b ON (b.agent_id=a.id)
WHERE a.id IN
(SELECT agent_id FROM pem.agent_heartbeat WHERE (EXTRACT (HOUR FROM now())-
EXTRACT (HOUR FROM last_heartbeat)) > <N> ));
- Use the following query to delete the agents with an
Unknown
status:
UPDATE pem.agent SET active=false WHERE id IN
(SELECT id FROM pem.agent WHERE id NOT IN
(SELECT agent_id FROM pem.agent_heartbeat));