Estou definindo uma arquitetura mestre-escravo e fiz as seguintes etapas até agora:
no mestre:
CREATE USER replicator WITH REPLICATION ENCRYPTED PASSWORD 'replicator';
theowl@postgresql:/etc/postgresql/12/main$ sudo vi pg_hba.conf
host replication replicator 192.168.56.8/24 md5
sudo systemctl restart postgresql
em espera:
theowl@postgresql:/etc/postgresql/12/main$ sudo systemctl stop postgresql
postgres@postgresql:/etc/postgresql/12/main$ ls -ltr
total 0
pg_basebackup -h 192.168.56.7 -U replicator -p 5432 -D /etc/postgresql/12/main/ -Fp -Xs -P -R
postgres@postgresql:/etc/postgresql/12/main$ pg_basebackup -h 192.168.56.7 -U replicator -p 5432 -D /etc/postgresql/12/main/ -Fp -Xs -P -R
Password:
48423/48423 kB (100%), 1/1 tablespace
postgres@postgresql:/etc/postgresql/12/main$ ls -ltr
total 80
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_xact
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_twophase
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_stat_tmp
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_stat
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_snapshots
drwx------ 4 postgres postgres 4096 Mar 12 16:35 pg_multixact
-rw------- 1 postgres postgres 224 Mar 12 16:35 backup_label
drwx------ 3 postgres postgres 4096 Mar 12 16:35 pg_wal
drwx------ 8 postgres postgres 4096 Mar 12 16:35 base
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_subtrans
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_replslot
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_notify
-rw------- 1 postgres postgres 3 Mar 12 16:35 PG_VERSION
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_tblspc
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_serial
drwx------ 4 postgres postgres 4096 Mar 12 16:35 pg_logical
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_dynshmem
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_commit_ts
drwx------ 2 postgres postgres 4096 Mar 12 16:35 global
-rw------- 1 postgres postgres 0 Mar 12 16:35 standby.signal
-rw------- 1 postgres postgres 268 Mar 12 16:35 postgresql.auto.conf
postgres@postgresql:/etc/postgresql/12/main$ cat postgresql.auto.conf
primary_conninfo = 'user=replicator password=replicator host=192.168.56.7 port=5432 sslmode=prefer sslcompression=0 gssencmode=prefer krbsrvname=postgres target_session_attrs=any'
postgres@postgresql:/etc/postgresql/12/main$ source ~/.pgsql_profile
postgres@postgresql:/etc/postgresql/12/main$ pg_ctl -D /etc/postgresql/12/main/ start
***waiting for server to start....postgres: could not access the server configuration file "/etc/postgresql/12/main/postgresql.conf": No such file or directory
stopped waiting
pg_ctl: could not start server
Examine the log output.***
postgres@postgresql:/etc/postgresql/12/main$ cat ~/.pgsql_profile
export PATH=/usr/lib/postgresql/12/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin PAGER=less
Se
data_directory
no masterpostgresql.conf
estiver definido para algum valor não padrão, os arquivos conf não estarão no diretório de dados "real" e não serão copiados pelo pg_basebackup.Se o responsável pelo mestre não for você, você deve pedir uma cópia por outro meio. Ou você pode simplesmente criar o seu próprio.