replication is running
This commit is contained in:
parent
83c9ee3283
commit
66c20020fc
1 changed files with 12 additions and 3 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
## Note: This file wont setup the replication by itself
|
||||||
|
## Once deploy follow those instruction to run the streaming replication
|
||||||
|
## Execute on each slave (replace major version an ip addr accordingly):
|
||||||
|
# 1. sudo systemctl stop postgresql.service
|
||||||
|
# 2. sudo rm -r /var/lib/postgresql/17
|
||||||
|
# 3. pg_basebackup -h 172.19.1.2 -U replication -p 5432 -D /var/lib/postgresql/17 -P -Xs
|
||||||
|
# 4. sudo systemctl restart postgresql.service
|
||||||
|
|
||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -45,7 +53,7 @@ in
|
||||||
++ lib.optionals (builtins.elem myName mapping.db.slaves) [
|
++ lib.optionals (builtins.elem myName mapping.db.slaves) [
|
||||||
"host replication replication ${masterIP}/32 md5"
|
"host replication replication ${masterIP}/32 md5"
|
||||||
]));
|
]));
|
||||||
ensureUsers = [{
|
ensureUsers = lib.mkIf (myName == mapping.db.master) [{
|
||||||
name = "replication";
|
name = "replication";
|
||||||
ensureClauses.replication = true;
|
ensureClauses.replication = true;
|
||||||
}];
|
}];
|
||||||
|
@ -58,12 +66,13 @@ in
|
||||||
log_disconnections = true;
|
log_disconnections = true;
|
||||||
} // lib.optionalAttrs (myName == mapping.db.master) {
|
} // lib.optionalAttrs (myName == mapping.db.master) {
|
||||||
wal_level = "logical";
|
wal_level = "logical";
|
||||||
wal_sender_timeout = 10;
|
wal_sender_timeout = "60s";
|
||||||
max_wal_senders = 16;
|
max_wal_senders = 16;
|
||||||
wal_keep_size = 1000; # In MB
|
wal_keep_size = 1000; # In MB
|
||||||
} // lib.optionalAttrs (builtins.elem myName mapping.db.slaves) {
|
} // lib.optionalAttrs (builtins.elem myName mapping.db.slaves) {
|
||||||
wal_level = "logical";
|
wal_level = "logical";
|
||||||
wal_receiver_timeout = 10;
|
wal_receiver_timeout = "60s";
|
||||||
|
max_wal_senders = 16;
|
||||||
primary_conninfo = "host=${masterIP} port=5432 user=replication";
|
primary_conninfo = "host=${masterIP} port=5432 user=replication";
|
||||||
hot_standby = "on";
|
hot_standby = "on";
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue