forked from postgres/postgres
-
Notifications
You must be signed in to change notification settings - Fork 11
Create replication.md quick walkthrough for pg_tde #319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
72406c5
updated replication.md
Andriciuc dd248f4
Update replication.md
Andriciuc 6d1f228
small fixes to text
Andriciuc 486a1b0
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc 449a781
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc e672241
Updated replication.md
Andriciuc 55e2a57
Merge branch 'DOCS-create-replication.md' of https://github.com/perco…
Andriciuc d995bf3
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc 6bf49ad
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc 9e04c3d
updated replication.md with proper information
Andriciuc 288fbe4
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc f27ba4d
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc 7a94559
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc 1451d7a
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc 02333be
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc 5edfd88
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc c736a0d
Update replication.md
Andriciuc 2652ab2
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc f704afa
Update replication.md
Andriciuc be718a5
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc 6bca4af
Update replication.md
Andriciuc 963c6bc
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc 6e24fb9
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc d6863a4
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc 0572b97
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc 81f82f7
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc 15bd921
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc aea50a2
Update replication.md
Andriciuc f37eecf
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc ef2540d
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc 3c7e6f3
Update replication.md
Andriciuc 3af26a7
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc 9716803
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc 24af28d
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc ed3ef1a
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc b8fa9f2
Merge branch 'TDE_REL_17_STABLE' into DOCS-create-replication.md
Andriciuc d15fff3
Merge branch 'release-17.5.2' into DOCS-create-replication.md
Andriciuc a9fb88e
Merge branch 'release-17.5.2' into DOCS-create-replication.md
Andriciuc 6ef6038
Merge branch 'release-17.5.2' into DOCS-create-replication.md
Andriciuc b877cef
Merge branch 'release-17.5.2' into DOCS-create-replication.md
Andriciuc 23189d7
updated based on latest feedback
Andriciuc 817d133
Merge branch 'release-17.5.2' into DOCS-create-replication.md
Andriciuc e1bd244
Merge branch 'release-17.5.2' into DOCS-create-replication.md
Andriciuc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,103 @@ | ||
# Replication | ||
# Streaming Replication with tde_heap | ||
|
||
<!-- To add information on Replication affecting pg_tde for customers and how it interacts with it | ||
Also, don't forget to add it to TOC> | ||
This section outlines how to set up PostgreSQL streaming replication when the `pg_tde` extension, specifically the [`tde_heap`](index/table-access-method.md) access method, is enabled on the primary server. | ||
|
||
Before you begin, ensure you have followed the [`pg_tde` setup instructions](setup.md). | ||
|
||
!!! note | ||
You do **not** need to run `CREATE EXTENSION` on the standby. It will be replicated automatically. | ||
|
||
## 1. Configure the Primary | ||
|
||
### Create a principal key | ||
|
||
Use the [`pg_tde_set_server_key_using_global_key_provider`](functions.md#pg_tde_set_server_key_using_global_key_provider) function to create a principal key. | ||
|
||
### Create the replication role | ||
|
||
Create a replication role on the primary: | ||
|
||
```sql | ||
CREATE ROLE example_replicator WITH REPLICATION LOGIN PASSWORD 'example_password'; | ||
``` | ||
|
||
### Configure pg_hba.conf | ||
|
||
To allow the replica to connect to the primary server, add the following line in `pg_hba.conf`: | ||
|
||
```conf | ||
host replication example_replicator standby_ip/32 scram-sha-256 | ||
``` | ||
|
||
Ensure that it is placed before the other host rules for replication and then **reload** the configuration: | ||
|
||
```sql | ||
SELECT pg_reload_conf(); | ||
``` | ||
|
||
## 2. Configure the Standby | ||
Andriciuc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Perform a database backup | ||
|
||
Run the base backup from your standby machine to pull the encrypted base backup: | ||
|
||
```bash | ||
export PGPASSWORD='example_password' | ||
pg_basebackup \ | ||
-h primary_ip \ | ||
-D /var/lib/pgsql/data \ | ||
-U example_replicator \ | ||
--wal-method=stream \ | ||
--slot=tde_slot \ | ||
Andriciuc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
-C \ | ||
-c fast \ | ||
-v -P | ||
``` | ||
|
||
### Configure postgresql.conf | ||
|
||
After the base backup completes, add the following line to the standby's `postgresql.conf` file: | ||
|
||
```ini | ||
shared_preload_libraries = 'pg_tde' | ||
``` | ||
|
||
## 3. Start and validate replication | ||
|
||
Assuming that the primary and the standby are running on separate hosts, start the PostgreSQL service: | ||
|
||
```bash | ||
sudo systemctl start postgresql | ||
Andriciuc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
!!! warning "Key management consistency **required** for replication" | ||
|
||
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_file` provider, 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: | ||
|
||
```sql | ||
SELECT client_addr, state | ||
FROM pg_stat_replication; | ||
``` | ||
|
||
* On standby: | ||
|
||
```sql | ||
SELECT | ||
pg_is_in_recovery() AS in_recovery, | ||
pg_last_wal_receive_lsn() AS receive_lsn, | ||
pg_last_wal_replay_lsn() AS replay_lsn; | ||
``` | ||
|
||
!!! tip | ||
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: | ||
|
||
```sql | ||
SELECT pg_tde_is_encrypted('your_encrypted_table'); | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.