CN115604286A - Method, device, equipment and storage medium for synchronizing master and standby state information of nodes - Google Patents

Method, device, equipment and storage medium for synchronizing master and standby state information of nodes Download PDF

Info

Publication number
CN115604286A
CN115604286A CN202211158267.4A CN202211158267A CN115604286A CN 115604286 A CN115604286 A CN 115604286A CN 202211158267 A CN202211158267 A CN 202211158267A CN 115604286 A CN115604286 A CN 115604286A
Authority
CN
China
Prior art keywords
state information
node
standby state
main
cluster monitoring
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
Application number
CN202211158267.4A
Other languages
Chinese (zh)
Inventor
叶宗刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
New H3C Technologies Co Ltd
Original Assignee
New H3C Technologies Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by New H3C Technologies Co Ltd filed Critical New H3C Technologies Co Ltd
Priority to CN202211158267.4A priority Critical patent/CN115604286A/en
Publication of CN115604286A publication Critical patent/CN115604286A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/275Synchronous replication
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • H04L41/0654Management of faults, events, alarms or notifications using network fault recovery
    • H04L41/0663Performing the actions predefined by failover planning, e.g. switching to standby network elements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0803Configuration setting
    • H04L41/084Configuration by using pre-existing information, e.g. using templates or copying from other elements
    • H04L41/0846Configuration by using pre-existing information, e.g. using templates or copying from other elements based on copy from other elements

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Hardware Redundancy (AREA)

Abstract

The invention provides a method, a device, equipment and a storage medium for synchronizing master and standby state information of nodes, wherein the method comprises the following steps: acquiring first main/standby state information from a cluster monitoring node and acquiring second main/standby state information from a coordination node; the first main/standby state information represents main/standby state information of a target node maintained by the cluster monitoring node, and the second main/standby state information represents main/standby state information of the target node currently recorded by the coordination node; comparing the first main/standby state information with the second main/standby state information to determine a comparison result; and if the comparison result is that the first main/standby state information is different from the second main/standby state information, updating the second main/standby state information by using the first main/standby state information. The invention can provide the synchronization function of the master and standby state information of the nodes for the distributed database, and ensure the unification of the master and standby state information of the nodes in the distributed database so as to ensure the normal processing of the distributed database to the service.

Description

Method, device, equipment and storage medium for synchronizing master and standby state information of nodes
Technical Field
The invention relates to the technical field of distributed storage, in particular to a method, a device, equipment and a storage medium for synchronizing active and standby state information of nodes.
Background
Currently, a large number of target nodes are often deployed in a distributed database, and the target nodes may have a master node and a standby node for failover. Taking PostgreSQL as an example, postgreSQL (PG for short) belongs to an open-source relational database, is used for facing transactions, and can be deployed in a single machine or in a clustered manner. The open source component, cis, belongs to an extension plug-in of postgreSQL, and is used for extending a relational database postgreSQL into a distributed database, wherein target nodes in the distributed database comprise a coordination node and a working node, so that query parallelization among a plurality of target nodes (servers) and second-level response on a large data set are realized. The open source component pg _ auto _ failover is used for achieving postgresQL automatic failover, namely that the main node is switched to the standby node or the standby node is switched to the main node. The pg _ auto _ failover is specifically a middleware for realizing a postgreSQL high availability state, and maintains a cluster high availability state through redundant monitoring nodes and a custom monitoring threshold. However, in the prior art, the open source component citris cannot acquire the active-standby state of the node maintained by the open source component pg _ auto _ failover, which affects the normal use of the open source component citris. Therefore, the conventional distributed database is prone to the problem that the master and standby state information of the nodes among different open-source components are not synchronous.
Disclosure of Invention
In order to solve the problem that the master and standby state information of the nodes among different open source components of the distributed database is not synchronous, the invention provides a method, a device, equipment and a storage medium for synchronizing the master and standby state information of the nodes, and provides a function of synchronizing the master and standby state information of the nodes for the distributed database.
In order to achieve the above technical object, the present invention can provide a method for synchronizing master/standby state information of nodes, which is applied to a synchronization control process, and comprises:
acquiring first main/standby state information from a cluster monitoring node and acquiring second main/standby state information from a coordination node; the first main/standby state information represents main/standby state information of a target node maintained by the cluster monitoring node, the second main/standby state information represents main/standby state information of the target node currently recorded by the coordination node, and the target node comprises a working node and/or the coordination node;
comparing the first main/standby state information with the second main/standby state information to determine a comparison result;
and if the comparison result shows that the first main/standby state information is different from the second main/standby state information, updating the second main/standby state information by using the first main/standby state information.
The method and the device can acquire first main/standby state information from the cluster monitoring node and second main/standby state information from the coordination node, judge that the primary/standby state information of the nodes of the distributed database is not synchronous by comparing the first main/standby state information with the second main/standby state information, and achieve the purpose of synchronizing the primary/standby state information of the nodes of the distributed database by updating the second main/standby state information through the first main/standby state information. Therefore, the invention provides a function of synchronizing the master and standby state information of the nodes for the distributed database, and ensures the unification of the master and standby state information of the nodes in the distributed database so as to ensure the normal processing of the distributed database to the service. Therefore, when the problem that the active component status cannot acquire the active-standby state of the node (i.e., the first active-standby state information) maintained by the active component pg _ auto _ failover is encountered, the invention can automatically update the active-standby state information of the node (i.e., the second active-standby state information) recorded by the active component status, and effectively solve the problem that the conventional distributed database is easy to have the asynchronous state of the active-standby state information of the nodes between different active components.
In an implementation manner of the present invention, acquiring first active/standby state information from a cluster monitoring node and acquiring second active/standby state information from a coordination node includes:
starting a timing task, wherein the timing task runs at a fixed time interval;
and accessing the cluster monitoring node and the coordination node according to a fixed time interval so as to read the first main/standby state information from the cluster monitoring node and the second main/standby state information from the coordination node.
Based on the improved technical scheme, the cluster monitoring nodes and the coordination nodes can be respectively accessed according to the fixed time interval, and the influence of the process for realizing the synchronization of the main state information and the standby state information of the nodes on the performance of the distributed database is avoided on the premise of realizing the accurate main state information provided for the synchronization of the node states by the mode of accessing the nodes at the fixed time interval, so that the robustness and the reliability of the distributed database are improved.
In an implementation manner of the present invention, accessing a cluster monitoring node and a coordinating node includes:
performing access verification on the cluster monitoring node through a first login name and a first password read from a user configuration file, and logging in a state base in the cluster monitoring node after the verification is passed, wherein first main and standby state information is stored in the state base;
and performing access verification on the coordination node through a second login name and a second password read from the user configuration file, and logging in a metadatabase in the coordination node after the verification is passed, wherein second main/standby state information is stored in the metadatabase.
Based on the improved technical scheme, the access security of the coordination node and the cluster monitoring node is improved in the mode, and unsafe access behaviors to the coordination node and the cluster monitoring node are reduced to the greatest extent.
In an implementation manner of the present invention, reading first active/standby state information from a cluster monitoring node and reading second active/standby state information from a coordinating node includes:
inquiring a first main node list from a state base in a cluster monitoring node, and taking the first main node list as first main/standby state information;
and querying a second main node list from a metadata base in the coordination node, and taking the second main node list as second main/standby state information.
Based on the improved technical scheme, the embodiment of the invention can respectively determine the master node maintained by the pg _ auto _ failover and the master node identified by the status in the above manner, thereby providing an accurate and comprehensive node state information basis for whether to update the master node identified by the status subsequently.
In an implementation manner of the present invention, acquiring first active/standby state information from a cluster monitoring node and acquiring second active/standby state information from a coordination node includes: acquiring first main and standby state information from a state library of the cluster monitoring node corresponding to the open source component pg _ auto _ failover, and acquiring second main and standby state information from a metadata library of the coordination node corresponding to the open source component status; the open source component cis is used for expanding a database PostgreSQL used for deploying the coordination nodes and the working nodes into a distributed database.
In an implementation manner of the present invention, updating the second main/standby state information through the first main/standby state information includes:
modifying the second main node list according to the first main node list;
alternatively, the second master node list is replaced by the first master node list.
In an implementation manner of the present invention, the method for synchronizing the master/standby state information of the nodes further includes:
and if the comparison result is that the first main/standby state information is the same as the second main/standby state information, returning to the step of acquiring the first main/standby state information from the cluster monitoring node.
In an implementation manner of the present invention, before acquiring the first active/standby state information from the cluster monitoring node, the method further includes:
testing whether the cluster monitoring node and the coordination node can be connected or not;
according to the fact that the cluster monitoring node and the coordination node can be connected, the step of obtaining first main/standby state information from the cluster monitoring node is allowed to be started;
and sending out error reporting information according to the condition that at least one of the cluster monitoring node and the coordination node cannot be connected, and ending.
Based on the improved technical scheme, the method also avoids executing the flow of the scheme under the condition that the cluster monitoring node or the coordination node can not be connected, and ensures that the synchronous flow of the method is always effectively executed; the problem that the subsequent synchronization process is invalid under the condition that the nodes are not connectable is avoided.
In order to achieve the above technical object, the present invention provides a device for synchronizing master/standby state information of nodes, which is applied to a synchronization control process, and comprises:
the information acquisition module is used for acquiring first main/standby state information from the cluster monitoring node and acquiring second main/standby state information from the coordination node; the first main/standby state information represents main/standby state information of a target node maintained by the cluster monitoring node, the second main/standby state information represents main/standby state information of the target node currently recorded by the coordination node, and the target node comprises a working node and/or the coordination node;
the information comparison module is used for comparing the first main/standby state information with the second main/standby state information to determine a comparison result;
and the information updating module is used for updating the second main/standby state information by using the first main/standby state information according to the comparison result that the first main/standby state information is different from the second main/standby state information.
In an implementation manner of the invention, the information acquisition module comprises a task starting unit and a node access unit;
the task starting unit is used for starting a timing task, and the timing task runs at a fixed time interval;
and the node access unit is used for accessing the cluster monitoring node and the coordination node according to a fixed time interval so as to read the first main/standby state information from the cluster monitoring node and the second main/standby state information from the coordination node.
In an implementation manner of the present invention, the node access unit is configured to perform access verification on the cluster monitoring node through a first login name and a first password read from a user configuration file, and log in a state library in the cluster monitoring node after the verification is passed, where first master/slave state information is stored in the state library;
and the node access unit is used for performing access verification on the coordination node through a second login name and a second password read from the user configuration file, and logging in a metadata database in the coordination node after the verification is passed, wherein second main/standby state information is stored in the metadata database.
In an implementation manner of the present invention, the node access unit is configured to query a first master node list from a state base in the cluster monitoring node, and use the first master node list as first master/slave state information;
and the node access unit is used for inquiring a second main node list from a metadata base in the coordination node and taking the second main node list as second main/standby state information.
In an implementation manner of the present invention, the information updating module is configured to modify the second host node list according to the first host node list; or, the information updating module is used for replacing the second main node list by the first main node list.
In an implementation manner of the present invention, the apparatus for synchronizing the master/standby state information of the nodes further includes:
and the continuous monitoring module is used for notifying the information acquisition module to acquire the first main/standby state information from the cluster monitoring node again according to the comparison result that the first main/standby state information is the same as the second main/standby state information.
In an implementation manner of the present invention, a device for synchronizing active/standby state information of nodes further includes:
the connection testing module is used for testing whether the cluster monitoring node and the coordination node can be connected or not;
the connection testing module is used for allowing the step of acquiring first main/standby state information from the cluster monitoring node to be started according to the fact that the cluster monitoring node and the coordination node can be connected; or the connection testing module is used for sending error reporting information according to the fact that at least one node in the cluster monitoring node and the coordination node cannot be connected.
To achieve the above technical object, the present invention can also provide a computer device, which includes a memory and a processor, wherein the memory stores computer readable instructions, and when the computer readable instructions are executed by the processor, the processor executes the steps of the method for synchronizing the master/standby state information of the nodes according to any embodiment of the present invention.
To achieve the above technical object, the present invention may further provide a storage medium storing computer readable instructions, which when executed by one or more processors, cause the one or more processors to perform the steps of the method for synchronizing the master/standby state information of the nodes in any embodiment of the present invention.
Drawings
Fig. 1 is a flowchart illustrating a method for synchronizing master/standby state information of nodes in one or more embodiments of the present invention.
Fig. 2 is a flowchart illustrating a method for starting to perform synchronization of master/standby state information of nodes based on a timing task in one or more embodiments of the present invention.
FIG. 3 is a flow diagram illustrating an access cluster monitoring node and a coordinating node in one or more embodiments of the invention.
Fig. 4 is a schematic flow chart illustrating a process of reading first active-standby information from a cluster monitoring node and reading second active-standby state information from a coordinating node in one or more embodiments of the present invention.
Fig. 5 is a schematic flowchart illustrating synchronization of active/standby state information of nodes applied to a database PostgreSQL in one or more embodiments of the present invention.
Fig. 6 is a flowchart illustrating a specific implementation of a method for synchronizing active/standby node status information in one or more embodiments of the present invention.
FIG. 7 illustrates a schematic diagram of the overall architecture of a distributed database in one or more embodiments of the invention.
Fig. 8 is a schematic diagram illustrating a device for synchronizing primary/standby node status information in one or more embodiments of the present invention.
FIG. 9 is a schematic diagram that illustrates the internal structure of a computing device in one or more embodiments of the invention.
Detailed Description
In the related art, pg _ auto _ failover can implement automatic failover of a database PostgreSQL, thereby ensuring high availability of a cluster. However, both pg _ auto _ failover and status are open-source components, which are not adapted to each other, and meanwhile, a PostgreSQL cluster using pg _ auto _ failover middleware and status extension plug-in is used, and after a coordinating node and/or a working node triggers failover, the active-standby state of a node maintained by pg _ auto _ failover in the prior art is not updated to status. At least one embodiment of the present invention may provide a method for synchronizing active/standby state information of nodes, where the method includes, but is not limited to, the following steps: acquiring first main/standby state information from a cluster monitoring node and acquiring second main/standby state information from a coordination node; the first master-slave state information represents master-slave state information of a target node maintained by the cluster monitoring node, the second master-slave state information represents master-slave state information of the target node currently recorded by the coordination node, and the target node comprises a working node and/or the coordination node. And comparing the first main/standby state information with the second main/standby state information to determine a comparison result. And if the comparison result shows that the first main/standby state information is different from the second main/standby state information, updating the second main/standby state information by using the first main/standby state information. The method and the device can acquire first main/standby state information from the cluster monitoring node and second main/standby state information from the coordination node, judge that the main/standby state information of the nodes in the distributed database is not synchronous by comparing the first main/standby state information with the second main/standby state information, and achieve the purpose of synchronizing the main/standby state information of the nodes in the distributed database by updating the second main/standby state information through the first main/standby state information. Therefore, the invention provides a function of synchronizing the master and standby state information of the nodes for the distributed database, and ensures the unification of the master and standby state information of the nodes in the distributed database so as to ensure the normal processing of the distributed database to the service. Therefore, when the problem that the active-standby state of the node maintained by the active component citus cannot be acquired by the active component pg _ auto _ fail is encountered, that is, the problem that the first active-standby state information maintained by the pg _ auto _ fail cannot be known by the citus, the embodiment of the invention realizes automatic updating of the node active-standby state information recorded by the active component citus in advance, and effectively solves the problem that the conventional distributed database is easy to have unsynchronized node active-standby state information among different active components.
As shown in fig. 1, at least one embodiment of the present invention can provide a method for synchronizing active/standby state information of nodes, which is applied to a synchronization control process, and the method includes, but is not limited to, the following steps S100 to S300.
Step S100, acquiring first main/standby state information from a cluster monitoring node and acquiring second main/standby state information from a coordination node; the first active-standby state information indicates active-standby state information of a target node maintained by a cluster monitoring node, in this embodiment, the first active-standby state information is specifically active-standby state information of a target node maintained by an open source component pg _ auto _ failover corresponding to the cluster monitoring node, the second active-standby state information indicates active-standby state information of a target node currently recorded by a coordination node, and in this embodiment, the first active-standby state information is specifically active-standby state information of a target node currently recorded by an open source component cis corresponding to the coordination node. The target node may include, but is not limited to, a worker node and/or a coordinator node.
As shown in fig. 5, in this embodiment, the first active-standby state information is acquired from the cluster monitoring node, and the second active-standby state information is acquired from the coordination node, including but not limited to step S101. Step S101, acquiring first main and standby state information from a state base of a cluster monitoring node corresponding to an open source component pg _ auto _ failure, and acquiring second main and standby state information from a metadata base of a coordination node corresponding to an open source component status; the open source component cis is used for expanding a database PostgreSQL used for deploying the coordination nodes and the working nodes into a distributed database. Referring to fig. 7, in the embodiment of the present invention, a cluster monitoring node is a Monitor, a coordinating node is a Coordinator, and a working node is a Worker, where the working node may be multiple, for example, working nodes 1 to n in the drawing, where n represents the number of the working nodes; for the coordination node and any working node, both master and slave mechanisms are adopted, for example, the coordination node includes a coordination master node (coordination node) and a coordination slave node (coordination slave), the working node 1 includes a working master node 1 (worker node 1) and a working slave node 1 (worker slave 1), and the working node n includes a working master node n (worker node n) and a working slave node n (worker slave n). The coordination node and the working node related to the embodiment of the invention are in communication connection with the cluster monitoring node, and the cluster monitoring node is connected with the coordination node.
Step S200, comparing the first main/standby state information with the second main/standby state information to determine a comparison result. And judging whether the first main/standby state information is the same as the second main/standby state information by comparing the first main/standby state information with the second main/standby state information.
Step S300, if the comparison result is that the first main/standby state information is different from the second main/standby state information, the second main/standby state information is updated by using the first main/standby state information, so that the second main/standby state information is synchronous with the first main/standby state information. Compared with the mode that the master/standby state of the node maintained by pg _ auto _ fail is not updated to status in the prior art, the invention provides a method for repairing the abnormal high-availability state of the cluster using status and pg _ auto _ fail simultaneously.
As shown in fig. 2, in one or more optional embodiments of the present invention, the obtaining the first active-standby state information from the cluster monitoring node and the obtaining the second active-standby state information from the coordinating node include, but are not limited to, the following steps S110 to S120.
Step S110, starting a timing task, wherein the timing task runs according to a fixed time interval. In specific implementation, after a user starts a process (i.e., a synchronization control process related to the present invention), a task is initiated at a fixed time interval in the process by using a timing scheduling manner, where the fixed time interval is set to 1 minute to 5 minutes, and is specifically determined according to a service tolerance, for example, 3 minutes, that is, a process of synchronizing master and slave state information of a node is executed every 3 minutes. Of course, in an alternative embodiment of the present invention, automatic start of the timing task may also be set, for example, the timing task is automatically started every 3 minutes, and a process of synchronizing the master/standby state information of the nodes is executed once after the timing task is started.
Step S120, according to a fixed time interval, accessing the cluster monitoring node and the coordination node to read the first main/standby state information from the cluster monitoring node and the second main/standby state information from the coordination node. It can be seen that the embodiment of the present invention can access the cluster monitoring node and the coordination node respectively according to the fixed time interval based on the start of the timing task, and the node access mode based on the fixed time interval, and on the premise of providing accurate master/slave state information for node state synchronization, the present invention can also avoid the influence of the process for realizing the synchronization of the master/slave state information of the nodes on the performance of the distributed database, and improve the robustness and reliability of the present invention.
As shown in fig. 3, in one or more alternative embodiments of the present invention, the cluster monitoring node and the coordinating node are accessed, including but not limited to the following steps S121 to S121.
Step S121, performing access verification on the cluster monitoring node through the first login name and the first password read from the user configuration file, and logging in a state library in the cluster monitoring node after the verification is passed, wherein first master/slave state information is stored in the state library. In this embodiment, access verification is performed on the cluster monitoring node first, but access verification may also be performed on the coordination node first in alternative embodiments of the present invention, or access verification may be performed on the cluster monitoring node and the coordination node at the same time.
And step S122, performing access verification on the coordination node through the second login name and the second password read from the user configuration file, and logging in a metadata database in the coordination node after the verification is passed, wherein second main/standby state information is stored in the metadata database. The embodiment of the invention uses a psql (postgreSQL) command line to remotely carry out login verification in a client mode, stops the synchronous process if the user cannot log in, and continues the following process if the user successfully logs in to indicate that normal connection can be realized. The invention can improve the access security of the coordinating node and the cluster monitoring node through the mode and reduce the unsafe access behavior of the coordinating node and the cluster monitoring node to the maximum extent.
As shown in fig. 4, in one or more alternative embodiments of the present invention, the reading of the first active-standby state information from the cluster monitoring node and the reading of the second active-standby state information from the coordinating node include, but are not limited to, steps S123 to S124.
Step S123, a first master node list is queried from a state library in the cluster monitoring node, and the first master node list is used as the first master/slave state information. The state library in the cluster monitoring node is a state library of an open source component pg _ auto _ failover. In the embodiment, a psql client is used in a timing task in a process to log in a state library of an open source component pg _ auto _ failover of a Monitor node so as to query master nodes of a coordination node and a working node and determine a first master node list.
Step S124, a second master node list is queried from the metadata base in the coordinating node, and the second master node list is used as second master/slave state information. The metadata base in the coordination node is specifically a metadata base of the open source component status. In the embodiment, a metadata base of an open source component status of a Coordinator node is logged in by using a psql client in a timing task in a process, so as to query main nodes of a coordinating node and a working node identified by the status, and determine a second main node list.
The embodiment of the invention can respectively determine the master node maintained by the pg _ auto _ failover and the master node identified by the status, thereby providing accurate and comprehensive node state information basis for whether the master node identified by the status is updated subsequently.
In one or more optional embodiments of the present invention, the updating of the second main/standby state information according to the first main/standby state information includes, but is not limited to, step S310.
Step S310, modify the second master node list according to the first master node list, or replace the second master node list with the first master node list. Based on the above manner, the master node identified by the status is guaranteed to be the master node elected by pg _ auto _ failover. The mode of modifying the second main node list in the embodiment of the invention can pertinently modify the nodes with changed main/standby states, and the mode of directly replacing the second main node list in the embodiment of the invention can improve the speed and accuracy of updating the main/standby state information.
The method for synchronizing the master/standby state information of the nodes in one or more optional embodiments of the present invention further includes: and if the comparison result is that the first main/standby state information is the same as the second main/standby state information, returning to the step of acquiring the first main/standby state information from the cluster monitoring node.
The embodiment of the invention ensures that the pg _ auto _ failover middleware is adapted to maintain the high availability state of the cluster on the basis of satisfying the distributed data good experience brought by the users using the cities, thereby ensuring the health of the cluster and ensuring the normal use of the service.
As shown in fig. 6 and in combination with fig. 7, before acquiring the first active/standby state information from the cluster monitoring node, at least one embodiment of the present invention further includes: testing whether the cluster monitoring node and the coordination node can be connected; according to the fact that the cluster monitoring node and the coordination node can be connected, the step of obtaining first main/standby state information from the cluster monitoring node is allowed to be started; and sending error report information according to the condition that at least one node in the cluster monitoring node and the coordination node can not be connected, namely directly reporting errors, and finishing. Therefore, the embodiment of the invention also avoids executing the flow of the scheme under the condition that the cluster monitoring node or the coordination node can not be connected, and ensures that the synchronous flow is always effectively executed in the embodiment of the invention; the problem that the subsequent synchronization process is invalid under the condition that the nodes are not connectable is avoided.
As shown in fig. 8, based on the same inventive technical concept, the method for synchronizing the primary/standby state information of the nodes according to the embodiment of the present invention can also provide a device for synchronizing the primary/standby state information of the nodes, which is applied to a synchronization control process.
The device for synchronizing the active/standby state information of the node in this embodiment may include, but is not limited to, an information acquisition module, an information comparison module, and an information update module.
The information acquisition module is used for acquiring first main/standby state information from the cluster monitoring node and acquiring second main/standby state information from the coordination node; the first master-slave state information represents master-slave state information of a target node maintained by the cluster monitoring node, the second master-slave state information represents master-slave state information of the target node currently recorded by the coordination node, and the target node comprises a working node and/or the coordination node.
And the information comparison module is used for comparing the first main/standby state information with the second main/standby state information to determine a comparison result.
And the information updating module is used for updating the second main/standby state information by using the first main/standby state information according to the comparison result that the first main/standby state information is different from the second main/standby state information.
In one or more optional embodiments of the present invention, the information obtaining module includes a task starting unit and a node accessing unit.
And the task starting unit is used for starting the timing task, and the timing task runs according to a fixed time interval.
And the node access unit is used for accessing the cluster monitoring node and the coordination node according to a fixed time interval so as to read the first main/standby state information from the cluster monitoring node and the second main/standby state information from the coordination node.
In one or more optional embodiments of the present invention, the node access unit is configured to perform access verification on the cluster monitoring node through a first login name and a first password read from the user configuration file, and log in a state library in the cluster monitoring node after the verification is passed, where first active/standby state information is stored in the state library.
And the node access unit is used for performing access verification on the coordination node through a second login name and a second password read from the user configuration file, and logging in a metadata database in the coordination node after the verification is passed, wherein second main/standby state information is stored in the metadata database.
In one or more optional embodiments of the present invention, the node access unit is configured to query a first master node list from a state library in the cluster monitoring node, and use the first master node list as the first master/slave state information.
And the node access unit is used for inquiring the second main node list from the metadata database in the coordination node, and taking the second main node list as second main/standby state information.
In one or more optional embodiments of the present invention, the information updating module is configured to modify the second master node list according to the first master node list; or, the information updating module is used for replacing the second main node list by the first main node list.
In one or more optional embodiments of the present invention, the apparatus for synchronizing active/standby state information of nodes further includes: and the continuous monitoring module is used for notifying the information acquisition module to acquire the first main/standby state information from the cluster monitoring node again according to the comparison result that the first main/standby state information is the same as the second main/standby state information.
The device for synchronizing the active/standby node state information in one or more optional embodiments of the present invention further includes:
and the connection testing module is used for testing whether the cluster monitoring node and the coordination node can be connected or not.
The connection testing module is used for allowing the step of acquiring first main/standby state information from the cluster monitoring node to be started according to the fact that the cluster monitoring node and the coordination node can be connected; or the connection testing module is used for sending error reporting information according to the fact that at least one node in the cluster monitoring node and the coordination node cannot be connected.
As shown in fig. 9, based on the same inventive technical concept, one or more embodiments of the present invention can further provide a computer device, where the computer device includes a memory and a processor, and the memory stores computer readable instructions, and when the computer readable instructions are executed by the processor, the processor is enabled to execute the steps of the method for synchronizing active/standby state information of nodes in any embodiment of the present invention.
As shown in fig. 9, based on the same inventive technical concept, one or more embodiments of the present invention can further provide a storage medium storing computer readable instructions, where the computer readable instructions, when executed by one or more processors, enable the one or more processors to perform the steps of the method for synchronizing the active/standby state information of the nodes in any embodiment of the present invention.
The logic and/or steps represented in the flowcharts or otherwise described herein, such as an ordered listing of executable instructions that can be considered to implement logical functions, can be embodied in any computer-readable storage medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For the purposes of this description, a "computer-readable storage medium" can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection (electronic device) having one or more wires, a portable computer cartridge (magnetic device), a Random Access Memory (RAM), a Read-Only Memory (ROM), an Erasable Programmable Read-Only Memory (EPROM, flash Memory), an optical fiber device, and a portable Compact Disc Read-Only Memory (CDROM). Further, the computer readable storage medium could even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, via for instance optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner if necessary, and then stored in a computer memory.
It should be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic Gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic Gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
In the description herein, references to the description of the term "the present embodiment," "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.
Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of the present invention, "a plurality" means at least two, e.g., two, three, etc., unless explicitly specified otherwise.
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 and simplifications made in the spirit of the present invention are intended to be included in the scope of the present invention.

Claims (10)

1. A method for synchronizing master and standby state information of nodes is characterized in that the method is applied to a synchronous control process; the method comprises the following steps:
acquiring first main/standby state information from a cluster monitoring node and acquiring second main/standby state information from a coordination node; the first active-standby state information represents active-standby state information of a target node maintained by the cluster monitoring node, the second active-standby state information represents active-standby state information of the target node currently recorded by the coordination node, and the target node comprises a working node and/or the coordination node;
comparing the first main/standby state information with the second main/standby state information to determine a comparison result;
and if the comparison result is that the first main/standby state information is different from the second main/standby state information, updating the second main/standby state information by using the first main/standby state information.
2. The method for synchronizing the active-standby state information of the nodes according to claim 1, wherein the acquiring a first active-standby state information from the cluster monitoring node and a second active-standby state information from the coordinating node comprises:
starting a timing task, wherein the timing task runs at a fixed time interval;
and accessing the cluster monitoring node and the coordination node according to the fixed time interval so as to read the first main/standby state information from the cluster monitoring node and read the second main/standby state information from the coordination node.
3. The method according to claim 2, wherein the accessing the cluster monitoring node and the coordinating node comprises:
performing access verification on the cluster monitoring node through a first login name and a first password read from a user configuration file, and logging in a state base in the cluster monitoring node after the verification is passed, wherein the first main/standby state information is stored in the state base;
and performing access verification on the coordination node through a second login name and a second password read from the user configuration file, and logging in a metadata database in the coordination node after the verification is passed, wherein the metadata database stores second main/standby state information.
4. The method according to claim 3, wherein the reading the first active-standby state information from the cluster monitoring node and the reading the second active-standby state information from the coordinating node includes:
querying a first main node list from a state base in the cluster monitoring node, and taking the first main node list as first main/standby state information;
and querying a second main node list from a metadata base in the coordination node, and taking the second main node list as second main/standby state information.
5. The method for synchronizing the active-standby state information of the nodes according to any one of claims 1 to 4, wherein the step of acquiring the first active-standby state information from the cluster monitoring node and the second active-standby state information from the coordinating node comprises:
acquiring first main and standby state information from a state library of the cluster monitoring node corresponding to the open source component pg _ auto _ failover, and acquiring second main and standby state information from a metadata library of the coordination node corresponding to the open source component status;
wherein the open source component, cis, is configured to extend a database PostgreSQL for deploying the coordinating node and the working node into a distributed database.
6. A device for synchronizing master and standby node state information is characterized in that the device is applied to a synchronous control process; the device comprises:
the information acquisition module is used for acquiring first main/standby state information from the cluster monitoring node and acquiring second main/standby state information from the coordination node; the first main/standby state information represents main/standby state information of a target node maintained by the cluster monitoring node, the second main/standby state information represents main/standby state information of the target node currently recorded by the coordination node, and the target node comprises a working node and/or the coordination node;
the information comparison module is used for comparing the first main/standby state information with the second main/standby state information to determine a comparison result;
and the information updating module is used for updating the second main/standby state information by using the first main/standby state information according to the comparison result that the first main/standby state information is different from the second main/standby state information.
7. The device for synchronizing the master-standby state information of the nodes according to claim 6, wherein the information acquisition module comprises a task starting unit and a node access unit;
the task starting unit is used for starting a timing task, and the timing task runs at a fixed time interval;
the node accessing unit is configured to access the cluster monitoring node and the coordination node according to the fixed time interval, so as to read the first active/standby state information from the cluster monitoring node and read the second active/standby state information from the coordination node.
8. The apparatus for synchronizing master/standby node status information according to claim 7,
the node access unit is used for performing access verification on the cluster monitoring node through a first login name and a first password read from a user configuration file, and logging in a state library in the cluster monitoring node after the verification is passed, wherein the state library stores the first main/standby state information;
and the node access unit is used for performing access verification on the coordination node through a second login name and a second password read from a user configuration file, and logging in a metadata database in the coordination node after the verification is passed, wherein the metadata database stores second main/standby state information.
9. A computer device comprising a memory and a processor, the memory having stored therein computer-readable instructions which, when executed by the processor, cause the processor to perform the steps of the method of synchronizing master and slave state information of nodes according to any of claims 1 to 5.
10. A storage medium having computer-readable instructions stored thereon, which, when executed by one or more processors, cause the one or more processors to perform the steps of the method for master/slave state information synchronization of nodes according to any of claims 1 to 5.
CN202211158267.4A 2022-09-22 2022-09-22 Method, device, equipment and storage medium for synchronizing master and standby state information of nodes Pending CN115604286A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211158267.4A CN115604286A (en) 2022-09-22 2022-09-22 Method, device, equipment and storage medium for synchronizing master and standby state information of nodes

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211158267.4A CN115604286A (en) 2022-09-22 2022-09-22 Method, device, equipment and storage medium for synchronizing master and standby state information of nodes

Publications (1)

Publication Number Publication Date
CN115604286A true CN115604286A (en) 2023-01-13

Family

ID=84844732

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211158267.4A Pending CN115604286A (en) 2022-09-22 2022-09-22 Method, device, equipment and storage medium for synchronizing master and standby state information of nodes

Country Status (1)

Country Link
CN (1) CN115604286A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117521423A (en) * 2024-01-05 2024-02-06 山东鑫林纸制品有限公司 Intelligent prediction method and device for machine speed of corrugated paper processing and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117521423A (en) * 2024-01-05 2024-02-06 山东鑫林纸制品有限公司 Intelligent prediction method and device for machine speed of corrugated paper processing and storage medium
CN117521423B (en) * 2024-01-05 2024-04-05 山东鑫林纸制品有限公司 Intelligent prediction method and device for machine speed of corrugated paper processing and storage medium

Similar Documents

Publication Publication Date Title
US8301600B1 (en) Failover recovery in a distributed data store
WO2017177941A1 (en) Active/standby database switching method and apparatus
CN108710673B (en) Method, system, computer device and storage medium for realizing high availability of database
CN110399267B (en) PCIE (peripheral component interface express) equipment monitoring method, system and equipment of server and readable storage medium
CN109933632B (en) Data migration method, device and equipment for database
CN108319617B (en) Method and device for determining master-slave difference of database and switching control method and device
CN114466027B (en) Cloud primary database service providing method, system, equipment and medium
CN115486052A (en) Data storage method, system and storage medium
CN111880956A (en) Data synchronization method and device
CN115604286A (en) Method, device, equipment and storage medium for synchronizing master and standby state information of nodes
US20100205164A1 (en) Maintaining Data Integrity
US10860411B2 (en) Automatically detecting time-of-fault bugs in cloud systems
CN109144788B (en) Method, device and system for reconstructing OSD
CN112433875A (en) Middleware-based database operation method and device and terminal equipment
CN111367885A (en) Database management system, database management method, storage medium, and electronic device
CN110362428A (en) The on-line automatic method and system for restoring database block
CN111669452A (en) High-availability method and device based on multi-master DNS (Domain name System) architecture
CN112799922A (en) Log management method, electronic equipment and storage device
CN115905270B (en) Method and device for determining active data nodes in database and storage medium
CN113806140B (en) Method for restarting redis cluster based on management platform
CN117873596A (en) Configuration file synchronization method, distributed server cluster and storage medium
CN110647427A (en) Main and standby system based on storage sharing and implementation method thereof
CN117194117A (en) Dual-machine hot standby data synchronization method, device, system and storage medium
CN117971393A (en) Method and device for executing jobs under single cluster in distributed scene
CN115269696A (en) Data processing method, unified data processor and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication