In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you what the PostgreSQL high availability Patroni and learning methods are. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Recently, there are many ways to learn POSTGRESQL, but there are also many pits, and you can't fall on PGPOOL-II. At the same time, you can't fall on PGPOOL-II. At the same time, you find a problem during your study, that is, most of the time you don't ask for a careful solution to your knowledge, and many posts on the Internet are installed and OK. If you install to do it, in fact, the installation is not successful or the problem cannot be solved.
In a different way to learn, do not waste time in some should know, but pull posts from the Internet to do, and then confused learning method, changed to, down-to-earth to do a related knowledge carding and hierarchical learning.
This time we are learning Patroni, the highly available method of postgresql.
Patroni itself is not a software, but a template to build a highly available postgresql solution through python. The software itself can be supported by other distributed software (zookeeper, etcd, etc.) and install patroni according to the different modules you choose.
The data synchronization method used by Patroni itself is the stream replication mode of postgresql. By default, we still use asynchronous mode. There will be a parameter in Patroni.
Maximum_lag_on_failover, by setting, ensures that the master-slave transfer will not occur when the slave database is out of sync with more than a certain amount of data in the master database.
In the patroni settings, there are three ways, 1 dynamic settings, 2 local settings 3 environment settings, some of which must be consistent between the master and slave libraries, these values are not valid in the local configuration file.
The following values must be saved and set in the dynamic settings
Max_connections:
Max_locks_per_transaction:
Max_worker_processes:
Max_prepared_transactions
Wal_level:hot_standby
Wal_log_hints: on
Track_commit_timestamp: off
And there are some values that need to be roughly the same, the main reason is that the master and slave may switch, and if the new master's machine cannot adjust its own state after the switch, it will affect the normal use of the database.
Max_wal_sender
Max_replicaiton_slots:
Wal_keep_segments:
meanwhile,
Listen_address
Port
Cluster_name
Host_standby
Parameters are passed to pt_ctl dynamically (pt_ctl is the initiator of patroni)
And these parameters are passed higher than the setting of alter system.
Specifically, how does patroni do it and in what order does it read the configuration?
1 Node first checks whether there is postgresql.base.conf (usually defaults to the data directory of the installed postgresql) or sets custom_conf
2 if custom_conf sets the same parameters, then custom_conf is the main configuration, and other configurations will be ignored.
3. If custom_conf is not set, it will be dominated by postgresql.base.conf. If it does not already exist, change postgresql.conf to postgresql.base.conf.
4 dynamic options will take effect without rereading, but will take effect after the application is written.
Summary: the order in which parameter files are applied
1 postgresql.base.conf
2 postgresql.conf
3 postgresql.auto.conf
4 run-time parameter
Changes in dynamic files and configuration changes in DCS will save the relevant configurations in the disk file of patroni.dynamic.
Patroni is configured in the YAML way, so this requires that the rigor of the configuration file, such as one more space and one less indentation, is not allowed.
There are many items in the configuration file, and the values here are concerned about the configuration of global and etcd.
1 Global Settin
Name cluster name the machines in the cluster must be unique, and each machine has its own name
The area path where namespace stores configuration information (please keep the default)
Name of the scope cluster
2 configuration of log
Level sets the level of the log
Format sets the level of logs. The default setting is asctime levelname message
Dateformat sets the time format
The directory to which dir writes to the program log must exist and be written by the patroni user and can be set by you. The application will keep logs for 4 25MB by default.
The number of logs to be retained by file_num
The size of the file_size patroni.log
Loggers: defines the allowable log level
Boot configuration:
DCS: in the global configuration of a cluster, changing parameters needs to be changed in DCS or heard of API.
The description of loop_wait cycle hibernation defaults to 10 seconds
Ttl: TTL acquires the pilot lock. It can be thought of as the length of time before starting the automatic failover process. Default value: 30
Retry_timeout: how long after the loss of contact between the distributed program and the POSTGRESQL does not trigger the switch.
Maximum_lag_on_failover: the byte gap between the slave library and the master library that can be switched between master and slave.
Time tolerance of master_start_timeout master library in failover, loop_wait + master_start_timeout+loop_wait
Synchronous_mode turns on this mode and selects the slave library closest to the master library as the new master library.
Synchronous_mode_strict: turning on this mode will prevent the master from writing data if it is found that there is no slave library that replicates data with the master.
The above content is PostgreSQL high availability Patroni and what are the learning methods? have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are 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.