create role repl login replication encrypted password '123456';
主库上配置从库采用repl账号
vim /var/lib/pgsql/11/data/pg_hba.conf
#只需要台添加下面两行,repl是用来做备份的用户,后面的192.168.2.0/24是该网段内的IP地址
host replication repl 192.168.2.0/24 md5
host all repl 192.168.2.0/24 trust
vim /var/lib/pgsql/11/data/postgresql.conf
listen_addresses = '*' # what IP address(es) to listen on;
port = 5432 # (change requires restart)
max_connections = 512 # (change requires restart)
shared_buffers = 128MB # min 128kB
dynamic_shared_memory_type = posix # the default is the first option
wal_level = replica # minimal, replica, or logical
#archive_mode = on # enables archiving; off, on, or always
#archive_command = 'cp %p /var/lib/pgsql/11/data/pg_archive/%f' # command to use to archive a logfile segment
max_wal_senders = 10 # max number of walsender processes
wal_keep_segments = 10240 # in logfile segments, 16MB each; 0 disables
wal_sender_timeout = 60s # in milliseconds; 0 disables
log_directory = 'log' # directory where log files are written
vim /var/lib/pgsql/11/data/postgresql.conf
listen_addresses = '*' # what IP address(es) to listen on;
port = 5432 # (change requires restart)
max_connections = 1000 # (change requires restart)
shared_buffers = 128MB # min 128kB
dynamic_shared_memory_type = posix # the default is the first option
wal_level = replica # minimal, replica, or logical
#archive_mode = on # enables archiving; off, on, or always
#archive_command = 'cp %p /var/lib/pgsql/12/data/pg_archive/%f' # command to use to archive a logfile segment
wal_sender_timeout = 60s # in milliseconds; 0 disables
hot_standby = on # "on" allows queries during recovery
max_standby_streaming_delay = 30s # max delay before canceling queries
wal_receiver_status_interval = 10s # send replies at least this often
hot_standby_feedback = on # send info from standby to prevent
log_directory = 'log' # directory where log files are written