Skip to content

Commit

Permalink
Merge pull request #6079 from EnterpriseDB/docs/edits_to_pem_pr5950
Browse files Browse the repository at this point in the history
Edits to PEM with PgBouncer-customer issue PR5950
  • Loading branch information
gvasquezvargas authored Sep 24, 2024
2 parents a7cb721 + cf9fe7a commit e85021d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ You must configure PgBouncer to work with the PEM database server.

## Prerequisites

- If you are running EDB Postgres Advanced Server, you have installed [EDB PgBouncer](/pgbouncer/latest/installing).
- If you're running EDB Postgres Advanced Server, install [EDB PgBouncer](/pgbouncer/latest/installing).

Or

- If you are running EDB Postgres Extended Server or PostgreSQL, you have installed community [PgBouncer](https://www.pgbouncer.org/install.html).
- If you're running EDB Postgres Extended Server or PostgreSQL, install community [PgBouncer](https://www.pgbouncer.org/install.html).

### EDB PgBouncer and PgBouncer installation considerations

The name and location of the directories and files in the configuration steps, as well as the user, depend on whether you installed the community version of PgBouncer or EDB PgBouncer. If you have installed community PgBouncer (whether you install it from the community repo or the EDB repo), replace the names of the files and directories in the worked example with the values for PgBouncer.
The name and location of the directories and files in the configuration steps, as well as the user, depend on whether you installed the community version of PgBouncer or EDB PgBouncer. If you installed community PgBouncer (whether you install it from the community repo or the EDB repo), replace the names of the files and directories in the worked example with the values for PgBouncer.

| Name | PgBouncer | EDB PgBouncer |
|---------------------|---------------------------|------------------------------------|
Expand All @@ -33,9 +31,9 @@ The name and location of the directories and files in the configuration steps, a

## Configuring PgBouncer

This example configures EDB PgBouncer with the `enterprisedb` system user.
This example configures EDB PgBouncer with the enterprisedb system user.

If you are running community PgBouncer, replace the names of the directories, files and user as explained in [Location of PgBouncer directories](#edb-pgbouncer-and-pgbouncer-installation-considerations) .
If you're running community PgBouncer, replace the names of the directories, files, and user as explained in [Location of PgBouncer directories](#edb-pgbouncer-and-pgbouncer-installation-considerations).

1. Open a terminal window and navigate to the PgBouncer directory.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ redirects:

## Prerequisites

You have [installed the PEM agent](../../installing_pem_agent/).
[Install the PEM agent](../../installing_pem_agent/).

!!!note
Do not configure PEM agents with `enable_smtp`, `enable_snmp`, or `enable_webhook` set to `true` in the `agent.cfg` file to connect through PgBouncer. SNMP, SMTP, and Webhook spoolers use the LISTEN/NOTIFY mechanism provided by Postgres to send notifications asynchronously. Since PgBouncer doesn’t support the LISTEN/NOTIFY mechanism in transaction mode, connecting the agent to PgBouncer can cause notifications to be delayed or not delivered at all. Instead, connect the PEM agent directly to the PEM backend database.
Don't configure PEM agents with `enable_smtp`, `enable_snmp`, or `enable_webhook` set to `true` in the `agent.cfg` file to connect through PgBouncer. SNMP, SMTP, and Webhook spoolers use the LISTEN/NOTIFY mechanism provided by Postgres to send notifications asynchronously. Since PgBouncer doesn’t support the LISTEN/NOTIFY mechanism in transaction mode, connecting the agent to PgBouncer can cause notifications to be delayed or not delivered at all. Instead, connect the PEM agent directly to the PEM backend database.
!!!

Now you can choose to [configure a new PEM agent](#configuring-a-new-pem-agent) or [use an existing PEM agent](#configuring-an-existing-pem-agent) for PgBouncer.

## Configuring a new PEM agent

After installing the PEM agent, configure it to work with a particular PEM database server. Use the following command:
After installing the PEM agent, configure it to work with a particular PEM database server:

```shell
PGSSLMODE=require PEM_SERVER_PASSWORD=pem_admin1_password \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ navigation:
You can use PgBouncer as a connection pooler for limiting the number of connections from the PEM agent to the Postgres Enterprise Manager (PEM) server on non-Windows machines:

- [PEM server and agent connection management mechanism](pem_server_pem_agent_connection_management_mechanism) provides an introduction of the PgBouncer-PEM infrastructure.
- [Preparing the PEM Database Server](preparing_the_pem_database_server) provides information about preparing the PEM database server to be used with PgBouncer.
- [Preparing the PEM database server](preparing_the_pem_database_server) provides information about preparing the PEM database server to be used with PgBouncer.
- [Configuring PgBouncer](configuring_pgBouncer) provides detailed information about configuring PgBouncer to allow it to work with the PEM database server.
- [Configuring the PEM agent](configuring_the_pem_agent) provides detailed information about configuring a PEM agent to connect to PgBouncer.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ For example, a user agent with ID 1 connects to the PEM database server as agent

## With PgBouncer

In a PgBouncer-enabled environment, PEM agents cannot connect to the PEM database server directly. PEM agents must use a proxy user that you configure specifically for the connection to PgBouncer. In the example, the proxy user handling all PEM agent connections is called `pem_agent_user1`.
In a PgBouncer-enabled environment, PEM agents can't connect to the PEM database server directly. PEM agents must use a proxy user that you configure specifically for the connection to PgBouncer. In the example, the proxy user handling all PEM agent connections is called `pem_agent_user1`.

Once the PEM agents connect to PgBouncer using SSL, PgBouncer is responsible for managing connection requests to the PEM database server. PgBouncer uses the rules you have configured for connection pooling to manage the incoming connection requests, for example, by respecting the established maximum number of active connections.
Once the PEM agents connect to PgBouncer using SSL, PgBouncer is responsible for managing connection requests to the PEM database server. PgBouncer uses the rules you configured for connection pooling to manage the incoming connection requests, for example, by respecting the established maximum number of active connections.

![Connecting to pgBouncer.](../../images/pem_with_pgbouncer.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ redirects:
- /pem/latest/pem_online_help/09_toc_pem_configure_pgbouncer/02_pem_pgbouncer_preparing_dbserver/
---

You must configure dedicated users and create an SSL key and certificate on the PEM database server to enable connection pooling for PEM with PgBouncer.
To enable connection pooling for PEM with PgBouncer, you must configure dedicated users and create an SSL key and certificate on the PEM database server.

This example shows how to prepare the PEM database server with the `enterprisedb` user on a RHEL-based operating system with EDB Postgres Advanced Server version 16. The location of your data, the configuration and key files, and the user you employ to perform the configuration may differ depending on your OS and Postgres distribution.
This example shows how to prepare the PEM database server with the enterprisedb user on a RHEL-based operating system with EDB Postgres Advanced Server version 16. The location of your data, the configuration and key files, and the user you use to perform the configuration may differ depending on your OS and Postgres distribution.

## Prerequisites

- You are connected to the `pem` database of the PEM database server.
- Connect to the `pem` database of the PEM database server.

- You are connected as `enterprisedb` or `postgres` user. The user depends on your Postgres distribution.
- Connect as the enterprisedb or postgres user based on your Postgres distribution.

| Postgres distribution | User |
|------------------------------|--------------|
Expand All @@ -40,7 +40,7 @@ This example shows how to prepare the PEM database server with the `enterprisedb
GRANT ROLE
```

1. Create a user named pem_admin1 (not a superuser) with `pem_admin` and `pem_agent_pool` role membership. This user is used to register the agent to the PEM server and manage access to the PEM database.
1. Create a user named pem_admin1 (not a superuser) with pem_admin and pem_agent_pool role membership. This user registers the agent to the PEM server and manages access to the PEM database.

```sql
CREATE ROLE pem_admin1 PASSWORD 'ANY_PASSWORD' LOGIN CREATEROLE;
Expand Down Expand Up @@ -117,15 +117,15 @@ This example shows how to prepare the PEM database server with the `enterprisedb
pem_agent_pool pem_agent_pool pgbouncer
```

1. Restart the Postgres service. Replace the `<postgres_service>` placeholder with the name of the Postgres instance systemd service name:
1. Restart the Postgres service. Replace `<postgres_service>` with the name of the Postgres instance systemd service name:

```shell
systemctl restart <postgres_service>
```

## Creating the SSL key and certificate for PgBouncer-PEM authentication

Create a key and certificate for the `pem_agent_pool` group role. Then, move the files to the PgBouncer instance to allow authentication between the PEM database server and PgBouncer.
Create a key and certificate for the pem_agent_pool group role. Then, move the files to the PgBouncer instance to allow authentication between the PEM database server and PgBouncer.

This example runs EDB Postgres Advanced Server on RHEL. When setting your environment variables, choose the correct directories according to your operating system and Postgres distribution.

Expand Down Expand Up @@ -175,7 +175,7 @@ This example runs EDB Postgres Advanced Server on RHEL. When setting your enviro
openssl genrsa -out pem_agent_pool.key 4096
```

1. Create a certificate-signing request (CSR). Replace the `-subj` attributes in `<...>` as required. Ensure the Common Name (CN) is set to the `pem_agent_pool` group role name:
1. Create a certificate-signing request (CSR). Replace the `-subj` attributes in `<...>` as required. Ensure the common name (CN) is set to the pem_agent_pool group role name:

```shell
openssl req -new -key pem_agent_pool.key -out pem_agent_pool.csr -subj '/C=<COUNTRY>/ST=<STATE>/L=<LOCATION>/O=<ORGANISATION>/CN=pem_agent_pool'
Expand Down

1 comment on commit e85021d

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.