postgresqlHow do I set up a PostgreSQL HA cluster?
- Install PostgreSQL on all of the nodes in the cluster.
- Create a replication user with appropriate privileges.
CREATE USER replication_user WITH REPLICATION PASSWORD 'replication_password';
- Configure the master node's
postgresql.conf
to enable replication.listen_addresses = '*' wal_level = 'hot_standby' max_wal_senders = 10 wal_keep_segments = 10
- Configure the slave nodes'
postgresql.conf
to enable streaming replication.hot_standby = 'on' wal_level = 'hot_standby' max_wal_senders = 10 wal_keep_segments = 10
- Create the replication slots on the master node.
SELECT * FROM pg_create_physical_replication_slot('slave_1');
- Start the replication from the slave nodes.
pg_basebackup -h master_node -U replication_user -D /var/lib/postgresql/9.6/main --slot=slave_1
- Configure the slave nodes'
recovery.conf
to enable streaming replication.standby_mode = 'on' primary_conninfo = 'host=master_node user=replication_user password=replication_password' primary_slot_name = 'slave_1'
Helpful links
More of Postgresql
- How can I troubleshoot zero damaged pages in PostgreSQL?
- How do I use PostgreSQL ZonedDateTime to store date and time information?
- How do I parse XML data using PostgreSQL?
- How can I use PostgreSQL and ZFS snapshots together?
- How can I set a PostgreSQL interval to zero?
- How can I use PostgreSQL with Zabbix?
- How can I use PostgreSQL on the Yandex Cloud platform?
- How do I use PostgreSQL's XMLTABLE to parse XML data?
- How can Zalando use PostgreSQL to improve its software development?
- How can I use PostgreSQL with YAML?
See more codes...