Goal: build a physical standby and prove that primary writes become readable there. Start at the shell prompt. Setup enabled replica WAL and five sender processes on port 5432. as-postgres selects the OS account; -U postgres selects the independent SQL role. pg_basebackup copies the entire cluster into /tmp/standby_data; -R creates standby settings, -X stream includes required WAL, and -c fast requests a prompt checkpoint. Successful backup can print nothing.
Inspect postgresql.auto.conf and standby.signal. primary_conninfo tells the standby where to fetch WAL; the signal file tells it to enter recovery. These are server files, so read them through as-postgres. Keep the provided brace block together: { ... } executes its shell actions as one group, with a single final prompt. A > continuation prompt means the shell is still reading the block; completion requires the final normal shell prompt.
Append port = 5433 to the standby configuration. Both servers share this machine and cannot listen on the same port. This changes the standby's listening port, while its upstream connection still targets primary port 5432.
Start the standby with pg_ctl; -D chooses its data directory, -l saves server messages, and -w waits for startup. Look for server started, then confirm recovery on port 5433. Startup alone does not prove streaming has caught up.
Inspect both ends: primary pg_stat_replication should show the 127.0.0.1 sender as streaming; standby pg_is_in_recovery() should return t. Explicit -p 5433 selects the standby. sync_state = async means a primary commit does not wait for this standby.
Create the separate repl_test fixture and insert 1,000 rows on the primary. Read its count on port 5433; wait for replay if necessary, then expect 1,000. This verifies asynchronous delivery, without promising a fixed delivery time.
Read byte backlog and recent commit acknowledgement times on the primary. pg_wal_lsn_diff returns bytes between positions; the lag intervals describe acknowledgement latency for recent WAL, not a countdown to catch up. A blank interval means NULL, which can occur when idle; it is not a measured zero.