CN117743029A - Group replication cluster self-starting method and device, electronic equipment and storage medium - Google Patents

Group replication cluster self-starting method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117743029A
CN117743029A CN202311757121.6A CN202311757121A CN117743029A CN 117743029 A CN117743029 A CN 117743029A CN 202311757121 A CN202311757121 A CN 202311757121A CN 117743029 A CN117743029 A CN 117743029A
Authority
CN
China
Prior art keywords
node
cluster
target node
target
state
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
CN202311757121.6A
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.)
Nanjing North Road Intelligent Control Technology Co ltd
Original Assignee
Nanjing North Road Intelligent Control Technology 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 Nanjing North Road Intelligent Control Technology Co ltd filed Critical Nanjing North Road Intelligent Control Technology Co ltd
Priority to CN202311757121.6A priority Critical patent/CN117743029A/en
Publication of CN117743029A publication Critical patent/CN117743029A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a group replication cluster self-starting method, a device, electronic equipment and a storage medium. Comprising the following steps: acquiring cluster state data of a target node at fixed time, and determining the online state of the target node based on the cluster state data, wherein the target node is one node in a group replication cluster; when the target node is in an off-line state, connecting other nodes in the group replication cluster through a remote connection command; and determining a target starting instruction based on the online state of the successfully connected node of the target node and the node type of the target node, and executing the target starting instruction. According to the method, the online state of each node is determined according to the cluster state data of each node in the group replication cluster, then the target starting instruction is determined by combining the node type of the target node, the target starting instruction is executed to realize the function of self-starting of the group replication cluster, the problem that the group replication cluster cannot be started automatically is solved, manual intervention is not needed, labor cost is reduced, working efficiency is improved, and data consistency is guaranteed.

Description

Group replication cluster self-starting method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of cluster technologies, and in particular, to a method and apparatus for self-starting a group replication cluster, an electronic device, and a storage medium.
Background
The group replication (MySQL Group Replication, called MGR for short) plug-in is a MySQL server plug-in, can create replication topology with elasticity, high availability and fault tolerance, can well ensure data consistency based on MGR single-master/multi-master group synchronous replication, and also supports automatic switching, and the MGR provides MySQL cluster service with high availability, high expansion and high reliability.
In the application process, a plurality of MySQL examples are often adopted to form a MySQL group replication cluster, the data of any node in the cluster are the same, the read-write of any node can be realized, and the consistency of the data is ensured, however, for the abnormal conditions of power failure, network disconnection and the like of equipment which are deployed in a local area network environment, the group replication cluster cannot realize the function of automatic recovery after the abnormal recovery of the power failure, network disconnection and the like, and the starting of the group replication cluster can be realized only by manual intervention under the condition that the abnormal condition of the group replication cluster is detected manually, the problems that the abnormal condition of the cluster cannot be acquired in time and the group replication cluster cannot be started automatically exist, the manpower resource is consumed, and the working efficiency of the group replication cluster is also low.
Disclosure of Invention
The invention provides a self-starting method, a device, electronic equipment and a storage medium of a group replication cluster, which are used for solving the problem that the group replication cluster cannot be started automatically under the condition of abnormal recovery.
According to an aspect of the present invention, there is provided a group replication cluster self-starting method, including:
acquiring cluster state data of a target node at fixed time, and determining the online state of the target node based on the cluster state data, wherein the target node is one node in a group replication cluster;
when the target node is in an off-line state, connecting other nodes in the group replication cluster through a remote connection command;
and determining a target starting instruction based on the online state of the successfully connected node of the target node and the node type of the target node, and executing the target starting instruction.
Optionally, the method includes periodically acquiring cluster state data of the target node, determining an online state of the target node based on the cluster state data, where the cluster state data is accumulated offline times, and includes:
judging whether the cluster state data of the target node is greater than or equal to a preset threshold value, and if the cluster state data of the target node is greater than or equal to the preset threshold value, determining that the target node is in an off-line state;
And if the cluster state data of the target node is smaller than the preset threshold value, waiting for the next timing processing process.
Optionally, the step of periodically acquiring cluster state data of the target node includes:
the cluster state identification of the target node is obtained at fixed time, and if the cluster state identification of the target node is an online identification, the cluster state data of the target node is set to be zero;
and if the cluster state identification of the target node is not the online identification, adding one to the stored cluster state data of the target node to obtain the cluster state data of the target node.
Optionally, after connecting other nodes in the group replication cluster through the remote connection command, the method includes:
determining whether there is a successfully connected node among other nodes in the group replication cluster;
if no node which is successfully connected exists in other nodes in the group replication cluster, the other nodes in the group replication cluster are connected through a remote connection command according to a preset time interval.
Optionally, the node type includes a boot node and a non-boot node, and the target instruction includes a target node start group copy cluster instruction and a target node join group copy cluster instruction;
determining a target starting instruction based on the online state of the successfully connected node of the target node and the node type of the target node, wherein the target starting instruction comprises the following steps:
Acquiring cluster state data of a successful connection node of a target node, and determining whether the successful connection node in an on-line state exists or not based on the cluster state data of the successful connection node;
if the successful node in the online state exists, the target node is added into the group copy cluster instruction as a target starting instruction.
Optionally, the method further comprises: if the node which is in the online state and is successfully connected does not exist, acquiring the node type of the target node;
if the node type of the target node is the guide node, the target node starting group copy cluster instruction is used as a target starting instruction;
if the node type of the target node is a non-guide node, executing the connection of other nodes in the group copy cluster through the remote connection command.
Optionally, after executing the target start instruction, the method includes:
acquiring cluster state data of a target node, determining the online state of the target node based on the cluster state data, and if the target node is in the online state, successfully starting the target node;
if the target node is in an off-line state, the target node fails to start, and the target start instruction is redetermined.
According to another aspect of the present invention, there is provided a group replication cluster self-starting apparatus, including:
The target node state determining module is used for acquiring cluster state data of the target node at fixed time, determining the on-line state of the target node based on the cluster state data, wherein the target node is one node in the group replication cluster;
the node connection module is used for connecting other nodes in the group replication cluster through a remote connection command under the condition that the target node is in an off-line state;
and the target starting instruction execution module is used for determining a target starting instruction based on the online state of the successfully connected node of the target node and the node type of the target node and executing the target starting instruction.
According to another aspect of the present invention, there is provided an electronic apparatus including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the group replication cluster auto-start method of any one of the embodiments of the invention.
According to another aspect of the present invention, there is provided a computer readable storage medium storing computer instructions for causing a processor to implement a group replication cluster auto-start method of any embodiment of the present invention when executed.
According to the technical scheme, cluster state data of a target node are acquired at fixed time, the online state of the target node is determined based on the cluster state data, and the target node is one node in a group replication cluster; when the target node is in an off-line state, connecting other nodes in the group replication cluster through a remote connection command; and determining a target starting instruction based on the online state of the successfully connected node of the target node and the node type of the target node, and executing the target starting instruction. According to the method, the online state of each node is determined according to the cluster state data of each node in the group replication cluster, then the target starting instruction is determined by combining the node type of the target node, and the target starting instruction is executed to realize the function of self-starting of the group replication cluster, so that the problem that the group replication cluster cannot be self-started is solved, the function of self-starting of the group replication cluster can be realized without manual intervention, the labor cost is reduced, and the working efficiency is improved.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a method for self-starting a group replication cluster according to a first embodiment of the present invention;
FIG. 2 is a flowchart of a method for self-starting a group replication cluster according to a second embodiment of the present invention;
FIG. 3 is a flow chart of a method for self-starting a group replication cluster, to which embodiments of the present invention are applicable;
fig. 4 is a schematic structural diagram of a group replication cluster self-starting device according to a third embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device implementing a group replication cluster self-starting method according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
Fig. 1 is a flowchart of a method for automatically starting up a group replication cluster according to a first embodiment of the present invention, where the method may be performed by a group replication cluster self-starting device, and the group replication cluster self-starting device may be implemented in hardware and/or software, and the group replication cluster self-starting device may be configured in an electronic device such as a computer, a server, or the like. As shown in fig. 1, the method includes:
S110, acquiring cluster state data of a target node at fixed time, and determining the online state of the target node based on the cluster state data, wherein the target node is one node in a group replication cluster.
The group replication cluster is composed of a plurality of MySQL instances, information interaction can be carried out among different instances, data of a plurality of nodes in the group can be consistent strongly through a Paxos protocol, a target node is one node in the group replication cluster, and the target node can be one MySQL instance on the local equipment. The cluster state data may be specifically understood as online state data representing nodes in a replication cluster, so that online states of the nodes can be determined according to the online state data, and exemplary, the cluster state data may be a state identifier of the nodes in the cluster, or may be a variable value and a variable corresponding to the state identifier, or may be a variable value corresponding to the state identifier, which is set in a memory, so as to record the number of times that the accumulation of the nodes is not online in a preset time period, and may be set according to actual needs, which is not limited herein.
Specifically, a timing task is set according to actual needs to obtain cluster state data of the target node, where the cluster state data is data used for representing an online state of the target node, and the set timing housekeeping task may be, for example, starting up the device, or detecting that the network connection is successful, or by setting a preset time interval, which is not limited herein. After the cluster state data of the target node is obtained, whether the cluster state data meets the standard of the online state or not can be judged, if yes, the target node is in the online state, if not, the target node is in the offline state, and if not, the standard of the online state can be exemplified by setting a threshold value of the accumulated number of times of offline of the node, or by setting the identifier of the online state of the node, which is not limited herein, and can be set according to actual requirements.
For example, the obtained state identifier of the target node may be directly used as cluster state data, for example, the state identifier is an online state, which characterizes the target node as being in an online state, that is, if the obtained state identifier of the target node is an online state, the target node may be directly determined to be in an online state. It should be noted that, considering that in the actual situation, a certain time is required for any node to jump from the online state to the offline state or from the offline state to the online state, in order to avoid the situation that the online state of the target node is not accurately determined, the accumulated number of times that the state identifier of the target node is not in the online state, which is continuously obtained through calculation, is adopted as cluster state data, so as to improve the accuracy of determining the online state of the target node.
In this embodiment, under the condition that a system or a device to which the group replication cluster belongs is restarted or normally operates, the cluster state data of the target node is obtained at regular time, and the online state of the target node is determined based on the cluster state data of the target node, so that the online state of the target node can be accurately determined in real time, and further, the self-starting function is timely called according to the online state of the target node, the problem of off-line abnormality of the group replication cluster is timely handled, the working efficiency is improved, and the problems of data loss and inconsistency are avoided.
And S120, connecting other nodes in the group replication cluster through a remote connection command under the condition that the target node is in an offline state.
The remote connection command may be specifically understood as a command that a remote computer operates a server or an SQL server on a remote computer by inputting a command through a command line, and exemplary remote connection commands include, but are not limited to Telnet, rlogin, SSH, determining a reasonable remote connection command according to a system of the device itself and actual requirements, and specifically, in this embodiment, a Telnet command may be used to connect other nodes in a replication cluster.
Specifically, under the condition that the target node is determined to be not online, a remote connection command is automatically called to connect other nodes in the group replication cluster, the network address or domain name, port number and other information of the other nodes in the group replication cluster are connected through the remote connection command, after the command is executed, the node successfully connected with the target node can be determined according to a response result, and if the connection fails, an exemplary prompt message of the connection failure is returned, and if the connection is successful, a message of the connection success is also returned.
On the basis of the above embodiment, after connecting other nodes in the group replication cluster through the remote connection command, it includes: determining whether there is a successfully connected node among other nodes in the group replication cluster; if no node which is successfully connected exists in other nodes in the group replication cluster, the other nodes in the group replication cluster are connected through a remote connection command according to a preset time interval.
Specifically, after the other nodes in the group replication cluster are connected through the remote connection command, whether the nodes with successful connection exist or not can be determined according to the returned connection results with the nodes, if the nodes with successful connection do not exist in the other nodes in the group replication cluster, the remote connection command needs to be called again to connect the other nodes in the group replication cluster after a preset time interval is met.
S130, determining a target starting instruction based on the online state of the successfully connected node of the target node and the node type of the target node, and executing the target starting instruction.
The node type comprises a guide node and a non-guide node, and the target instruction comprises a target node start group copy cluster instruction and a target node join group copy cluster instruction. The bootstrap node may be specifically understood as an initial node of the MySQL group replication cluster, in which data is synchronized by other nodes, and when the group replication cluster is established, one MySQL instance is designated as the bootstrap node, and accordingly, other nodes that are not designated as the bootstrap node are non-bootstrap nodes. The target node active group copy cluster refers to an instruction for starting the group copy cluster, and the target node join group copy cluster instruction refers to an instruction for joining the target node to the group copy cluster.
Specifically, after determining other nodes in the group copy cluster successfully connected with the target node, determining a target start instruction by acquiring the online state of the successfully connected node and the node type of the target node, where the instructions matched by the different online states corresponding to the node types of the different target nodes are different, for example, a mapping relation table between the online state of the successfully connected node, the node type of the target node and the target start instruction may be preset, after determining the online state of the successfully connected node and the node type of the target node, the corresponding target start instruction is matched in the demapping relation table, and then the target start instruction is executed to complete the self-start function of the group copy cluster, so that each node in the group copy cluster can operate normally, and data consistency is ensured.
Optionally, determining the target startup instruction based on the online state of the successfully connected node of the target node and the node type of the target node includes: acquiring cluster state data of a successful connection node of a target node, and determining whether the successful connection node in an on-line state exists or not based on the cluster state data of the successful connection node; if the successful node in the online state exists, the target node is added into the group copy cluster instruction as a target starting instruction.
Specifically, after determining other nodes in the group replication cluster which are successfully connected with the target node, cluster state data of each node which are successfully connected are obtained, whether the node which is in an online state exists in the nodes which are successfully connected is determined according to the cluster state data, if the node which is in the online state exists, the group replication cluster is in an operating state, and the target node is only required to be added into the group replication cluster, so that a group replication cluster instruction is taken as a target starting instruction, the target starting instruction is executed, the target node is automatically added into the group replication cluster, and normal operation of the target node and the group replication cluster is ensured.
Optionally, if there is no successful node in online state, acquiring the node type of the target node; if the node type of the target node is the guide node, the target node starting group copy cluster instruction is used as a target starting instruction; if the node type of the target node is a non-guide node, executing the connection of other nodes in the group copy cluster through the remote connection command.
Specifically, if there is no successful node in online connection, the node type of the target node needs to be further acquired. If the node type of the target node is the guide node, the target node starting group copy cluster instruction is used as a target starting instruction, and the target starting instruction is designated to complete the self-starting of the group copy cluster; if the type of the target node is a non-bootstrap node type, the remote connect command is recalled to connect the process of the other nodes in the group replication cluster.
On the basis of the above embodiment, after executing the target start instruction, it includes: acquiring cluster state data of a target node, determining the online state of the target node based on the cluster state data, and if the target node is in the online state, successfully starting the target node; if the target node is in an off-line state, the target node fails to start, and the target start instruction is redetermined.
Specifically, after the target starting instruction is executed, cluster state data of the target node is obtained to check whether the target node is self-started successfully, if the current cluster state data of the target node meets the standard of the on-line state, the target node is started successfully, otherwise, the target node is started failed. Under the condition that the starting of the target node fails, the process of determining the target node needs to be re-executed so as to re-complete the self-starting method of the group replication cluster until the target node is successfully started, thereby ensuring that all nodes in the group replication cluster work normally and ensuring the data consistency.
In this embodiment, after the execution of the self-starting command, it is checked whether the target node is self-started successfully, and under the condition of failure in starting, the self-starting can be realized again, so that the availability of the self-starting method of the group replication cluster is improved, each node in the group replication cluster is further ensured to be able to normally operate, the data consistency is ensured, and the working efficiency is improved.
According to the technical scheme, the cluster state data of the target node is acquired at fixed time, the on-line state of the target node is determined based on the cluster state data, and the target node is one node in the group replication cluster; when the target node is in an off-line state, connecting other nodes in the group replication cluster through a remote connection command; and determining a target starting instruction based on the online state of the successfully connected node of the target node and the node type of the target node, and executing the target starting instruction. The method and the device have the advantages that the online state of each node is determined according to the cluster state data of each node in the group replication cluster, the target starting instruction is determined by combining the node type of the target node, the target starting instruction is executed to automatically complete the function of self-starting the group replication cluster, the problem that the group replication cluster cannot be started automatically under the condition that equipment is restarted after network disconnection or power failure is solved, the function of self-starting the group replication cluster can be achieved without manual intervention, the labor cost is reduced, the working efficiency is improved, the group replication cluster can quickly enter a normal running state by starting the group replication cluster in time, the risk of data loss caused by untimely starting is avoided, and the data consistency is further ensured.
Example two
Fig. 2 is a flowchart of a group replication cluster self-starting method provided by a second embodiment of the present invention, where the method according to the present embodiment is optimized, and optionally, whether cluster state data of a target node is greater than or equal to a preset threshold is determined, and if the cluster state data of the target node is greater than or equal to the preset threshold, the target node is determined to be in an offline state; and if the cluster state data of the target node is smaller than the preset threshold value, waiting for the next timing processing process. As shown in fig. 2, the method includes:
s210, acquiring cluster state data of the target node at fixed time.
The cluster state data is accumulated off-line times, namely the data which starts to be accumulated by the acquired cluster state identification of the target node as the off-line state, if the acquired cluster state identification of the target node is the on-line identification, the accumulated off-line times are reset to zero, and then the cluster state of the re-recorded target state is identified as the accumulated times of the off-line state.
Specifically, a variable may be set at a preset storage address to store cluster state data of the target node, and the accumulated off-line times of the target node are recorded, and then the cluster state data of the target node is obtained from the variable in the storage address according to a preset time interval, where the preset storage address may be a memory address or a preset database address, and the present invention is not limited herein.
Optionally, the step of periodically acquiring cluster state data of the target node includes: the cluster state identification of the target node is obtained at fixed time, and if the cluster state identification of the target node is an online identification, the cluster state data of the target node is set to be zero; and if the cluster state identification of the target node is not the online identification, adding one to the stored cluster state data of the target node to obtain the cluster state data of the target node.
The cluster state identifier refers to a state identifier of a node in the record MySQL group replication cluster, and it should be noted that a system library (performance_schema database) of each MySQL in the cluster may store performance indexes and state information of the MySQL server, so that the cluster state identifier may be read from the system library, and exemplary, the cluster state identifier may be set to an online state, be used to represent that the corresponding node is in the online state, and may be set to an online state representation online identifier. The stored cluster state data can be specifically understood as a value of a variable set by a preset storage address, and the value can be an initial value of the variable or a value of multiple accumulations of the variable.
Specifically, a variable is set in a memory to record the cluster state data of the target node, that is, record the accumulated off-line times of the target node in a preset time period, the accumulated off-line times can be determined according to the cluster state identification of the target node, the cluster state identification of the target node is obtained according to a preset timing mode, if the obtained cluster state identification of the target node is the on-line identification, the current cluster state data of the target node is set to be zero, and if the cluster state of the target node is the off-line identification, the stored cluster state data of the target node is processed by adding one, the cluster state data of the current target node is updated, and the latest cluster state data of the target node is obtained.
S220, judging whether the cluster state data of the target node is larger than or equal to a preset threshold value.
The preset threshold is a threshold set according to actual requirements, and is used for judging the online state of the target node, and it is required to be noted that a certain time is required in the process of jumping from the non-online state to the online state of the target node, if a certain error exists in judging whether the target node is in the online state or not only by acquiring the cluster state identification of the target node once, a certain threshold needs to be set, and the online state of the target node can be accurately judged under the condition that the cluster state data of the target node meets the set threshold. The magnitude of the threshold value can be set according to actual conditions. The preset threshold is set to 3, for example.
Specifically, a preset threshold value is set according to actual needs, the preset threshold value can be set to be 3, cluster state data of the target node is compared with the preset threshold value, and a judgment result of whether the cluster state data of the target node is greater than or equal to the preset threshold value is determined.
S230, if the cluster state data of the target node is greater than or equal to a preset threshold value, determining that the target node is in an off-line state.
S240, if the cluster state data of the target node is smaller than a preset threshold value, waiting for the next timing processing process.
Specifically, if the cluster state data of the target node is smaller than the preset threshold, triggering the next timing processing process according to the preset time interval, namely acquiring the cluster state data of the target node again according to the timing task.
S250, connecting other nodes in the group replication cluster through a remote connection command under the condition that the target node is in an offline state.
S260, determining a target starting instruction based on the online state of the successfully connected node of the target node and the node type of the target node, and executing the target starting instruction.
In a specific embodiment, there is a system library (performance_schema database) in each MySQL instance in the MySQL group replication cluster, for storing performance index data and status information of the MySQL server, and the replication_group_members table in the system library is a table for storing replication status of the relevant MySQL instance under the MySQL group replication cluster. The module_state field in the table records the current state of the MySQL group member instance, and can represent ONLINE identification through ONLINE, and an ONLINE time variable is customized in the memory in advance and used for recording the accumulated ONLINE time of the local MySQL instance. A flow chart of a group replication cluster self-starting method is shown in fig. 3. And (3) periodically inquiring a field reply_group_members.member_host of an IP address corresponding to the storage target node in an instance table in a MySQL system library performance_schema corresponding to the target node at intervals of 30 seconds, if the field reply_group_members.member_host is matched with the IP address corresponding to the target node, returning a cluster state identification field member_state value of the target node, namely representing the replication state of the target node in a group replication cluster, setting the value of an off-line number variable to be 0 if the cluster state identification field value of the target node is an on-line identification, namely setting cluster state data of the target node to be 0, periodically checking every 30 seconds, returning to inquire the cluster state field value of the target node, and if the cluster state field value is not an on-line state, adjusting the value of the off-line number variable and adding 1 on the basis to obtain the cluster state data of the current target node. And continuously judging whether the cluster state data of the current target node is larger than 3 times, returning to the step of inquiring the module_state field value of the target node if the cluster state data of the current target node is smaller than 3 times, and executing a remote connection command TELNET to connect other nodes in the group replication cluster, namely all other database servers in the group replication cluster if the cluster state data of the target node is larger than 3 times. Further, continuing to judge whether any other node in the group replication cluster can be connected, if any other node in the group replication cluster cannot be connected, waiting for 30 seconds, returning to execute a remote connection command TELNET to connect the other node in the current group replication cluster, if any other node in the group replication cluster can be connected, continuing to judge whether an online-identified MySQL instance exists in the successfully connected node, if the online-identified MySQL instance exists, executing a command for adding the target node into the group replication cluster, then continuing to judge whether the group replication cluster is successful, if the group replication cluster is successful, returning to execute a field for querying an IP address corresponding to the target node in an instance table in a MySQL system library performance_schema corresponding to the target node at intervals of 30 seconds; if the joining of the group replication cluster fails, returning to execute a remote connection command TELNET to connect other nodes in the current group replication cluster; if the MySQL instance of the online identification is not available, continuing to judge whether the target node is a guide node, if the target node is the guide node, executing a target node start group copy cluster command, judging whether the target node start group copy cluster is successful after the command is executed, if the local start group copy cluster is successful, returning to execute the target node according to the time interval of inquiring the cluster state data of the target node of the MySQL instance every 30 seconds, if the target node start group copy cluster fails, returning to execute a remote connection command TELNET to connect other nodes in the current group copy cluster, if the target node is not the guide node, waiting for 30 seconds, and returning to execute the remote connection command TELNET to connect other nodes in the current group copy cluster.
According to the technical scheme of the embodiment, cluster state data of the target node are obtained at fixed time; judging whether the cluster state data of the target node is greater than or equal to a preset threshold value, and if the cluster state data of the target node is greater than or equal to the preset threshold value, determining that the target node is in an off-line state; if the cluster state data of the target node is smaller than a preset threshold value, waiting for the next timing processing process; when the target node is in an off-line state, connecting other nodes in the group replication cluster through a remote connection command; and determining a target starting instruction based on the online state of the successfully connected node of the target node and the node type of the target node, and executing the target starting instruction. The method and the device have the advantages that the online state of each node is determined according to the cluster state data of each node in the group replication cluster, then the target starting instruction is determined by combining the node type of the target node, the target starting instruction is executed to automatically complete the function of self-starting the group replication cluster, the problem that the group replication cluster cannot be started automatically is solved, the function of self-starting the group replication cluster can be realized without manual intervention, the labor cost is reduced, and the working efficiency is improved.
Example III
Fig. 4 is a schematic structural diagram of a group replication cluster self-starting device according to a third embodiment of the present invention. As shown in fig. 4, the apparatus includes:
a target node state determining module 410, configured to periodically obtain cluster state data of a target node, determine an online state of the target node based on the cluster state data, where the target node is one node in a group replication cluster;
a node connection module 420, configured to connect other nodes in the group replication cluster through a remote connection command when the target node is in an offline state;
the target startup instruction execution module 430 is configured to determine a target startup instruction based on the online status of the successfully connected node of the target node and the node type of the target node, and execute the target startup instruction.
According to the technical scheme of the embodiment, the cluster state data of the target node is acquired at fixed time through the target node state determining module, the online state of the target node is determined based on the cluster state data, and the target node is one node in the group replication cluster; the node connection module is used for connecting other nodes in the group replication cluster through a remote connection command under the condition that the target node is in an off-line state; the target starting instruction execution module determines a target starting instruction based on the online state of the successfully connected node of the target node and the node type of the target node, and executes the target starting instruction. The method and the device realize the functions of determining the online state of each node according to the cluster state data of each node in the group replication cluster, determining the target starting instruction by combining the node type of the target node, and executing the target starting instruction to automatically complete the self-starting of the group replication cluster, solve the problem that the group replication cluster cannot be started automatically, avoid manual intervention, reduce labor cost and improve work efficiency.
Based on the above embodiments, optionally, the target node state determining module 410 is specifically configured to: judging whether the cluster state data of the target node is greater than or equal to a preset threshold value, and if the cluster state data of the target node is greater than or equal to the preset threshold value, determining that the target node is in an off-line state;
and if the cluster state data of the target node is smaller than the preset threshold value, waiting for the next timing processing process.
The cluster state identification of the target node is obtained at fixed time, and if the cluster state identification of the target node is an online identification, the cluster state data of the target node is set to be zero;
and if the cluster state identification of the target node is not the online identification, adding one to the stored cluster state data of the target node to obtain the cluster state data of the target node.
Optionally, the node connection module 420 is further configured to:
after connecting other nodes in the group replication cluster through the remote connection command, determining whether a node which is successfully connected exists in the other nodes in the group replication cluster;
if no node which is successfully connected exists in other nodes in the group replication cluster, the other nodes in the group replication cluster are connected through a remote connection command according to a preset time interval.
Optionally, the target startup instruction execution module 430 is specifically configured to: acquiring cluster state data of a successful connection node of a target node, and determining whether the successful connection node in an on-line state exists or not based on the cluster state data of the successful connection node;
if the successful node in the online state exists, the target node is added into the group copy cluster instruction as a target starting instruction.
If the node which is in the online state and is successfully connected does not exist, acquiring the node type of the target node;
if the node type of the target node is the guide node, the target node starting group copy cluster instruction is used as a target starting instruction;
if the node type of the target node is a non-guide node, executing the connection of other nodes in the group copy cluster through the remote connection command.
Optionally, after executing the target start instruction, the apparatus further includes:
the target node start verification module 440 is configured to obtain cluster state data of the target node, determine an online state of the target node based on the cluster state data, and if the target node is in the online state, start the target node successfully;
if the target node is in an off-line state, the target node fails to start, and the target start instruction is redetermined.
The group replication cluster self-starting device provided by the embodiment of the invention can execute the group replication cluster self-starting method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example IV
Fig. 5 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present invention. The electronic device 10 is intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 5, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as the group copy cluster auto-start method.
In some embodiments, the group replication cluster auto-start method may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more of the steps of the group copy cluster self-starting method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the group replication cluster auto-start method in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
The computer program used to implement the group replication cluster auto-start method of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
Example five
The fifth embodiment of the present invention further provides a computer readable storage medium, where computer instructions are stored, where the computer instructions are configured to cause a processor to perform a method for self-starting a group replication cluster, the method includes:
acquiring cluster state data of a target node at fixed time, and determining the online state of the target node based on the cluster state data, wherein the target node is one node in a group replication cluster;
when the target node is in an off-line state, connecting other nodes in the group replication cluster through a remote connection command;
and determining a target starting instruction based on the online state of the successfully connected node of the target node and the node type of the target node, and executing the target starting instruction.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (10)

1. A method for self-starting a group replication cluster, comprising:
acquiring cluster state data of a target node at fixed time, and determining the online state of the target node based on the cluster state data, wherein the target node is one node in the group replication cluster;
connecting other nodes in the group replication cluster through a remote connection command under the condition that the target node is in an off-line state;
and determining a target starting instruction based on the online state of the successfully connected node of the target node and the node type of the target node, and executing the target starting instruction.
2. The method of claim 1, wherein the periodically acquiring cluster state data of a target node, determining an online state of the target node based on the cluster state data, the cluster state data being a cumulative number of times that is not online, comprises:
judging whether the cluster state data of the target node is larger than or equal to a preset threshold value, and if the cluster state data of the target node is larger than or equal to the preset threshold value, determining that the target node is in an off-line state;
and if the cluster state data of the target node is smaller than the preset threshold value, waiting for the next timing processing process.
3. The method of claim 2, wherein the timing acquisition of the cluster state data of the target node comprises:
the cluster state identification of the target node is obtained at fixed time, and if the cluster state identification of the target node is an online identification, the cluster state data of the target node is set to be zero;
and if the cluster state identification of the target node is the off-line identification, adding one to the stored cluster state data of the target node to obtain the cluster state data of the target node.
4. The method of claim 1, comprising, after said connecting other nodes in said set of replicated clusters via a remote connect command:
determining whether there is a successfully connected node among other nodes in the set of replicated clusters;
and if the nodes which are successfully connected do not exist in the other nodes in the group replication cluster, connecting the other nodes in the group replication cluster through the remote connection command according to a preset time interval.
5. The method of claim 1, wherein the node type comprises a booted node and a non-booted node, the target instruction comprising the target node initiating the group copy cluster instruction and the target node joining the group copy cluster instruction;
The determining a target starting instruction based on the online state of the node successfully connected with the target node and the node type of the target node comprises the following steps:
acquiring cluster state data of a successful connection node of the target node, and determining whether the successful connection node in an online state exists or not based on the cluster state data of the successful connection node;
and if the successful node in the online state exists, adding the target node into the group replication cluster instruction as the target starting instruction.
6. The method as recited in claim 5, further comprising:
if the node which is in the online state and is successfully connected does not exist, acquiring the node type of the target node;
if the node type of the target node is the guide node, starting the group copy cluster instruction by the target node as the target starting instruction;
and if the node type of the target node is the non-guide node, executing the connection of other nodes in the group replication cluster through the remote connection command.
7. The method of claim 1, wherein after said executing said target-start instruction, comprising:
Acquiring cluster state data of the target node, determining the online state of the target node based on the cluster state data, and if the target node is in the online state, successfully starting the target node;
if the target node is in an off-line state, the target node fails to start, and the target starting instruction is redetermined.
8. A group replication cluster self-starting device, comprising:
a target node state determining module, configured to obtain cluster state data of a target node at regular time, determine an online state of the target node based on the cluster state data, where the target node is one node in the replication cluster;
the node connection module is used for connecting other nodes in the group replication cluster through a remote connection command under the condition that the target node is in an off-line state;
and the target starting instruction execution module is used for determining a target starting instruction based on the online state of the successfully connected node of the target node and the node type of the target node and executing the target starting instruction.
9. An electronic device, the electronic device comprising:
At least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the group copy cluster self-starting method of any one of claims 1-7.
10. A computer readable storage medium storing computer instructions for causing a processor to implement the group replication cluster auto-start method of any one of claims 1-7 when executed.
CN202311757121.6A 2023-12-20 2023-12-20 Group replication cluster self-starting method and device, electronic equipment and storage medium Pending CN117743029A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311757121.6A CN117743029A (en) 2023-12-20 2023-12-20 Group replication cluster self-starting method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311757121.6A CN117743029A (en) 2023-12-20 2023-12-20 Group replication cluster self-starting method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117743029A true CN117743029A (en) 2024-03-22

Family

ID=90260416

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311757121.6A Pending CN117743029A (en) 2023-12-20 2023-12-20 Group replication cluster self-starting method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117743029A (en)

Similar Documents

Publication Publication Date Title
CN111488233A (en) Method and system for processing bandwidth loss problem of PCIe device
CN106960060B (en) Database cluster management method and device
CN111752488B (en) Management method and device of storage cluster, management node and storage medium
CN102891762A (en) System and method for continuously processing network data
CN113377702A (en) Method and device for starting two-node cluster, electronic equipment and storage medium
CN115934742A (en) Fault processing method, device, equipment and storage medium
CN117743029A (en) Group replication cluster self-starting method and device, electronic equipment and storage medium
CN116521573A (en) Automatic test method, device, equipment and storage medium
CN111090537A (en) Cluster starting method and device, electronic equipment and readable storage medium
CN112799879B (en) Fault processing method, device, equipment and storage medium of node
CN117395263B (en) Data synchronization method, device, equipment and storage medium
CN115174447B (en) Network communication method, device, system, equipment and storage medium
CN116055315B (en) MVB communication configuration method, device, equipment and storage medium
CN117632601A (en) Master-slave machine database switching method, device, equipment and storage medium
CN116668673A (en) Progress monitoring method and device for video recorder, electronic equipment and medium
CN117687989A (en) Data processing method and device, electronic equipment and storage medium
CN118012660A (en) System abnormal starting recovery method, device, equipment and storage medium
CN118132315A (en) Damaged page repairing method, device, equipment and storage medium
CN117609194A (en) Cloud database processing method and device, electronic equipment and storage medium
CN117234779A (en) Exception recovery method, device, equipment and medium for distributed database
CN116881229A (en) Database exercise environment construction method, device, equipment and storage medium
CN117520456A (en) Data synchronization method and device, electronic equipment and storage medium
CN115756855A (en) Cluster switching method, device, terminal and storage medium
CN115237485A (en) Method, device, equipment and medium for managing start of microservice
CN116450411A (en) Method, device, equipment and storage medium for determining replication delay state

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