In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "how to use PostgreSQL13 stream-based replication to build a backup server", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use PostgreSQL13 stream-based replication to build a backup server" this article.
The high availability, load balancing and replication characteristics of pg are as follows
The backup server, as the data backup of the primary server, can ensure that the data will not be lost, and can be promoted to continue to provide services to the primary server after the failure of the primary server.
Practical operation 1. Parameter configuration
First configure the postgresql.conf of the host
Vim / usr/local/pgsql/data/postgresql.conflisten_addresses ='* 'wal_level = hot_standbymax_wal_senders = 10max_replication_slots = 10hot_standby = on # is mainly used to prepare the configuration of the library, while the configuration of the main library has no effect on the configuration after wal_keep_size = 1GB # pg13. The parameter full_page_writes = on is required for wal_keep_segmentswal_log_hints = on # pg_rewind before.
Then configure the pg_hba.conf of the host
Vim / usr/local/pgsql/data/pg_hba.confhost replication all 0.0.0.0 trust # add 2, use pg_basebackup to create standby database pg_basebackup-D.. / data1-U postgres-Fp-X stream-R-P-v-p54321-h 127.0.0.1
Explain the common parameters.
Pg_basebackup is used to obtain a basic backup of a running PostgreSQL database cluster.
-D directory
The directory to which the output is written. If necessary, pg_basebackup will create this directory and any parent directories.
-Fp
Write the output as a flat file, using the same layout as the current data directory and tablespace.
-Xstream
The prewritten log is delivered through stream replication when the backup is created. This opens a second connection to the server and starts streaming the prewritten logs in parallel when the backup is run.
-R
-- write-recovery-conf
Set up standby.signal in the output directory (or in the underlying archive when using tar format) and attach connection settings to postgresql.auto.conf to simplify setting up a backup server. The postgresql.auto.conf file records the connection settings, if any, and the replication slot used by pg_basebackup, so that the same settings are used later in the stream copy.
-P
-- progress
Enable progress reporting.
-v
-- verbose
Enabling verbose mode can be understood as outputting backup process data.
3. Start the slave database server echo "port=54322" > > / usr/local/pgsql/data1/postgresql.confpg_ctl-D / usr/local/pgsql/data1 start4, and check
Log in to the host to view the stream replication relationship
Psql-Upostgres-dpostgres-p54321select * from pg_stat_replication
Host inserts data
. / psql-Upostgres-dpostgres-p54321create table T1 (id int, name varchar); insert into T1 values
The data is queried by the slave, and the data synchronization is successful.
Psql-Upostgres-dpostgres-p54322select * from T1
At this point, a simple backup server is set up.
The above is all the contents of the article "how to use PostgreSQL13 to build a backup server based on stream replication". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.