CN112835649A - Method for constructing postgresql with high availability - Google Patents
Method for constructing postgresql with high availability Download PDFInfo
- Publication number
- CN112835649A CN112835649A CN202110215186.2A CN202110215186A CN112835649A CN 112835649 A CN112835649 A CN 112835649A CN 202110215186 A CN202110215186 A CN 202110215186A CN 112835649 A CN112835649 A CN 112835649A
- Authority
- CN
- China
- Prior art keywords
- vip
- postgresql
- slave node
- original
- master node
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 14
- 238000013515 script Methods 0.000 claims abstract description 15
- 230000009471 action Effects 0.000 claims abstract description 5
- 230000009286 beneficial effect Effects 0.000 abstract description 2
- 238000010276 construction Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44505—Configuring for program initiating, e.g. using registry, configuration files
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44568—Immediately runnable code
Abstract
The invention provides a method for constructing postgresql with high availability, which comprises the following steps: s1, storing vip and ip addresses of two hosts in the two high-availability hosts through files; s2, script definition, wherein when the slave node receives the switching action, the slave node accesses the original master node through the vip to obtain the ip address of the original master node, then stops the vip of the original master node through the ip access, starts the vip at the original slave node, and changes the role of the master node into the original slave node; s3, the repmgr tool is responsible for notifying the slave node to execute the script. The invention has the beneficial effects that: the invention is realized based on a repmgr tool, adds flexible functions of main-standby switching, fault switching and the like, and has flexible and stable platform, simple configuration and higher performance.
Description
Technical Field
The invention belongs to the technical field of information, and particularly relates to a method for constructing postgresql with high availability.
Background
The technical scheme of the invention is based on a repmgr open source framework, a complete solution of postgresql high-availability architecture is realized, a similar solution is based on pgpool-II, the operation configuration is too complex, the performance defect is obvious, and the necessary vip fault switching and transferring function is lacked.
Disclosure of Invention
In view of this, the present invention aims to provide a method for constructing postgresql with high availability, so as to add flexible functions of active/standby switching, fault switching, etc., and the platform is flexible and stable, and has simple configuration and high performance.
In order to achieve the purpose, the technical scheme of the invention is realized as follows:
a method of constructing postgresql high availability comprising the steps of:
s1, storing vip and ip addresses of two hosts in the two high-availability hosts through files;
s2, script definition, wherein when the slave node receives the switching action, the slave node accesses the original master node through the vip to obtain the ip address of the original master node, then stops the vip of the original master node through the ip access, starts the vip at the original slave node, and changes the role of the master node into the original slave node;
s3, the repmgr tool is responsible for notifying the slave node to execute the script.
Further, primary and standby allocation of postgresql is realized based on the repmgr, and role registration is realized by configuring a primary register and a standby register command.
Further, automatic transfer of vip when postgresql is switched is achieved through the script.
Compared with the prior art, the method for constructing the postgresql with high availability has the following beneficial effects:
(1) the method for constructing the postgresql high availability, which is disclosed by the invention, has the advantages of complete function, simplicity in construction and easiness in understanding and operation.
(2) The method for constructing postgresql with high availability, provided by the invention, has flexible and multipurpose functions and more flexible control by using scripts
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate an embodiment of the invention and, together with the description, serve to explain the invention and not to limit the invention. In the drawings:
fig. 1 is a schematic diagram of a method for constructing postgresql with high availability according to an embodiment of the present invention.
Detailed Description
It should be noted that the embodiments and features of the embodiments may be combined with each other without conflict.
The present invention will be described in detail below with reference to the embodiments with reference to the attached drawings.
As shown in fig. 1, a method of constructing postgresql high availability includes the steps of:
s1, storing vip and ip addresses of two hosts in the two high-availability hosts through files;
s2, script definition, wherein when the slave node receives the switching action, the slave node accesses the original master node through the vip to obtain the ip address of the original master node, then stops the vip of the original master node through the ip access, starts the vip at the original slave node, and changes the role of the master node into the original slave node;
s3, the repmgr tool is responsible for notifying the slave node to execute the script.
The primary and standby allocation of postgresql is realized based on the repmgr, and the role registration is realized by configuring a primary register command and a standby register command.
The automatic transfer of vip when the postgresql is switched is achieved through the script.
The primary and standby allocation of postgresql is realized based on the repmgr, and the role registration is realized by configuring a primary register command and a standby register command. The invention mainly utilizes the script to realize the automatic transfer of vip when postgresql is switched, and as shown in fig. 1, the operation is as follows:
in the two high-availability hosts, vip and ip addresses of the two hosts are stored through files.
And defining a script, wherein when the slave node receives the switching action, the slave node accesses the original master node through the vip to obtain the ip address of the original master node, then stops the vip of the original master node through the ip access, starts the vip at the original slave node, and changes the role of the master node into the original slave node.
The repmgr tool is responsible for notifying the slave node of executing the script.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.
Claims (3)
1. A method for constructing postgresql with high availability, comprising the steps of:
s1, storing vip and ip addresses of two hosts in the two high-availability hosts through files;
s2, script definition, wherein when the slave node receives the switching action, the slave node accesses the original master node through the vip to obtain the ip address of the original master node, then stops the vip of the original master node through the ip access, starts the vip at the original slave node, and changes the role of the master node into the original slave node;
s3, the repmgr tool is responsible for notifying the slave node to execute the script.
2. The method of claim 1, wherein the postgresql is constructed by: the primary and standby allocation of postgresql is realized based on the repmgr, and the role registration is realized by configuring a primary register command and a standby register command.
3. The method of claim 1, wherein the postgresql is constructed by: the automatic transfer of vip when the postgresql is switched is achieved through the script.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110215186.2A CN112835649A (en) | 2021-02-24 | 2021-02-24 | Method for constructing postgresql with high availability |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110215186.2A CN112835649A (en) | 2021-02-24 | 2021-02-24 | Method for constructing postgresql with high availability |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112835649A true CN112835649A (en) | 2021-05-25 |
Family
ID=75933568
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110215186.2A Pending CN112835649A (en) | 2021-02-24 | 2021-02-24 | Method for constructing postgresql with high availability |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112835649A (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105224637A (en) * | 2015-09-24 | 2016-01-06 | 珠海许继芝电网自动化有限公司 | A kind of based on PostgreSQL database active and standby/the comprehensive method of cluster application |
CN111200532A (en) * | 2020-01-02 | 2020-05-26 | 广州虎牙科技有限公司 | Method, device, equipment and medium for master-slave switching of database cluster node |
CN111813856A (en) * | 2020-07-01 | 2020-10-23 | 浪潮云信息技术股份公司 | PostgreSQL high-availability implementation method |
-
2021
- 2021-02-24 CN CN202110215186.2A patent/CN112835649A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105224637A (en) * | 2015-09-24 | 2016-01-06 | 珠海许继芝电网自动化有限公司 | A kind of based on PostgreSQL database active and standby/the comprehensive method of cluster application |
CN111200532A (en) * | 2020-01-02 | 2020-05-26 | 广州虎牙科技有限公司 | Method, device, equipment and medium for master-slave switching of database cluster node |
CN111813856A (en) * | 2020-07-01 | 2020-10-23 | 浪潮云信息技术股份公司 | PostgreSQL high-availability implementation method |
Non-Patent Citations (2)
Title |
---|
炼狱腾蛇: ""监控系列讲座(二十一)postgresql+repmgr高可用"", 《知乎》 * |
逆玄: ""Postgresql主备同步流复制及主备切换、IP漂移"", 《CSDN》 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9513970B2 (en) | Optimizing handling of virtual machine mobility in data center environments | |
KR101099822B1 (en) | Redundant routing capabilities for a network node cluster | |
CN103078927A (en) | Key-value data distributed caching system and method thereof | |
CN110365750A (en) | Service registration system and method | |
CN106126318A (en) | The dynamic migration method of virtual machine in a kind of Openstack cloud platform | |
CN102917384B (en) | Hot backup method of coordinators in Zigbee network | |
EP2843906A1 (en) | Method, apparatus, and system for data transmission | |
CN108616376B (en) | FC network system fault dynamic reconstruction method | |
CN110535676A (en) | Implementation method, device, equipment and the storage medium of SMF dynamic disaster recovery | |
CN107493180B (en) | Upgrading method and device of virtual switch | |
JP7299416B2 (en) | Information processing method and related network equipment | |
JP4927784B2 (en) | Network relay device and network relay system | |
CN101959271A (en) | Method, device and system for configuring transmit diversities | |
CN102663017A (en) | Implementation system and implementation method for enhancing availability of MySQL database | |
TWI770701B (en) | Hardware-based save-and-restore controller | |
CN103577125A (en) | Cross controller group mirror image writing method and device applied to high-end disk array | |
CN112866035A (en) | Method for switching specified slave node into master node of redis service on cloud platform | |
CN112835649A (en) | Method for constructing postgresql with high availability | |
WO2016180081A1 (en) | Configuration information synchronization method, primary device and standby device | |
CN104243304A (en) | Data processing method, device and system of locally-connected topological structure | |
CN102917036A (en) | Memcached-based distributed cache data synchronization realization method | |
CN100546250C (en) | A kind of management method of check points in cluster | |
CN109951388A (en) | Route non-interrupted method and master control borad | |
CN107231449A (en) | A kind of ARP request retransmission method, device and WLAN communication systems | |
CN104022898A (en) | Switch configuration management method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20210525 |