Streaming replication with tde_heap
This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.
Creating a key and assigning the server key are separate operations. See site errata.
This section outlines how to set up PostgreSQL streaming replication when the pg_tde extension, specifically the tde_heap access method, is enabled on the primary server.
Before you begin, ensure you have followed the pg_tde setup instructions.
You do not need to run CREATE EXTENSION on the standby. It will be replicated automatically.
1. Configure the Primary
Create a principal key
First create a key on the configured global provider using pg_tde_create_key_using_global_key_provider. Then assign it as the server key with pg_tde_set_server_key_using_global_key_provider.
Create the replication role
Create a replication role on the primary:
Configure pg_hba.conf
To allow the replica to connect to the primary server, add the following line in pg_hba.conf:
Ensure that it is placed before the other host rules for replication and then reload the configuration:
2. Configure the Standby
Perform a database backup
Run the base backup from your standby machine to pull the encrypted base backup:
Configure postgresql.conf
After the base backup completes, add the following line to the standby’s postgresql.conf file:
3. Start and validate replication
Assuming that the primary and the standby are running on separate hosts, start the PostgreSQL service:
If you’re using a KMS provider, such as Vault or KMIP, make sure that both the primary and the standby have access to the same key management configuration, and that the paths to the configuration files are identical on both systems.
For example:
- If you configure Vault with a secret path:
/path/to/secret.file, then that file must exist at the same path on both the primary and the standby. - If you use the
keyring_fileprovider, be aware that it stores key material in a local file and it is not designed for shared or concurrent use across multiple servers. It is not recommended in replication setups.
- On primary:
- On standby:
Want to verify that everything is working? After creating an encrypted table on the primary, run the following command on the standby to confirm that the encryption is active and the keys are resolved: