CN115617917A - Method, device, system and equipment for controlling multiple activities of database cluster - Google Patents

Method, device, system and equipment for controlling multiple activities of database cluster Download PDF

Info

Publication number
CN115617917A
CN115617917A CN202211618872.5A CN202211618872A CN115617917A CN 115617917 A CN115617917 A CN 115617917A CN 202211618872 A CN202211618872 A CN 202211618872A CN 115617917 A CN115617917 A CN 115617917A
Authority
CN
China
Prior art keywords
node
cluster
database
nodes
normal service
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.)
Granted
Application number
CN202211618872.5A
Other languages
Chinese (zh)
Other versions
CN115617917B (en
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.)
China Xian Satellite Control Center
Original Assignee
China Xian Satellite Control Center
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 China Xian Satellite Control Center filed Critical China Xian Satellite Control Center
Priority to CN202211618872.5A priority Critical patent/CN115617917B/en
Publication of CN115617917A publication Critical patent/CN115617917A/en
Application granted granted Critical
Publication of CN115617917B publication Critical patent/CN115617917B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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
    • 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

Landscapes

  • Engineering & Computer Science (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)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a database cluster multi-activity control method, which comprises the following steps: 1. acquiring database states of all nodes in a cluster; 2. judging the states of all nodes; 3. processing an abnormal node; 4. judging and processing the database cluster fragmentation of the normal service nodes; 5. and controlling the normal service nodes after the splitting judgment and treatment according to the cluster state and the node state. The method of the invention has simple steps, and solves the problems of automatic starting, restarting and recovery of the database on the nodes in a cluster starting mode and a cluster adding mode in the process of controlling the node database according to the cluster state and the node state.

Description

Method, device, system and equipment for controlling multiple activities of database cluster
Technical Field
The invention belongs to the technical field of database cluster control, and particularly relates to a database cluster multi-activity control method.
Background
Galera Cluster is a multi-homed Cluster of MariaDB (MySQL) that keeps all the nodes of MariaDB synchronized, galera provides synchronized replication for MariaDB, so it can guarantee HA, and it currently supports only XtraDB/InnodB storage engines and can only be used under Linux. Galera Cluster possesses the following properties: in a real multi-master architecture, any node can read and write; synchronous replication is carried out, no delay exists among nodes, and data loss cannot be caused when the nodes are down; closely coupling, all nodes keep the same state, and no different data exists among the nodes; no master-slave switching operation or VIP use is required; no downtime during Failover; automatic node configuration, without manual backup of the current database and copying to a new node; support an InNODB storage engine; the application is transparent, and the application does not need to be changed or is changed very little; no separate read and write is required.
Although gallera cluster is one of the best clustering schemes of MariaDB (MySQL), there are still some disadvantages in deployment usage:
the method for starting the MariaDB (MySQL) cluster is different from the method for adding the MariaDB (MySQL), the starting method is difficult to automate, and the use barrier exists for users lacking professional operation and maintenance personnel;
if the network failure occurs in the MariaDB (MySQL) cluster and the MariaDB (MySQL) cluster is recovered, the MariaDB (MySQL) cluster can be split, the splitting is not easy to be detected for a user, the data of the MariaDB (MySQL) cluster is not consistent easily, and the recovery is difficult;
the MariaDB (MySQL) cluster which is started normally can not be started normally due to restart of an operating system, power failure and the like.
Disclosure of Invention
The technical problem to be solved by the present invention is to provide a method, an apparatus, a system and a device for controlling multiple activities of a database cluster, which are designed reasonably, and solve the problems of automatic starting, restarting and recovering of a database on a node in a manner of starting a cluster and a manner of joining a cluster in the process of controlling a node database according to a cluster state and a node state.
In a first aspect of the embodiments of the present invention, a method for controlling multiple activities of a database cluster is provided, where the cluster includes multiple nodes served by a database, and the method includes the following steps:
step one, acquiring the database states of all nodes in a cluster: wherein the parameters of the database state include: the method comprises the following steps of (1) connecting state, database cluster available cluster size, cluster state identification, cluster configuration identification, node cluster role, node connecting cluster state, node ready state and all node addresses connected to a node;
judging the states of all nodes, acquiring nodes and abnormal nodes which can normally provide database services in a database cluster, and acquiring the number of the nodes which can normally provide the database services; wherein, the node which normally provides database service to the outside is marked as a normal service node;
step three, processing abnormal nodes: closing the abnormal node database;
step four, judging and processing the database cluster split of the normal service nodes;
and step five, controlling the normal service nodes after the crack judgment and treatment according to the cluster state and the node state.
The above database cluster multi-activity control method is characterized in that: step one, acquiring the database state of any node in a cluster, specifically comprising the following steps:
initializing the database state of a node to be acquired; a connection node database, wherein the connection node database process needs to set timeout times;
if the node connection state is normal, inquiring the size of the available cluster of the database cluster, the cluster state identifier, the cluster configuration identifier, the node cluster role, the node connection cluster state, the node ready state and all the node addresses connected to the node to obtain the parameters of the database state.
In the above method for controlling multiple database cluster activities, the states of all nodes are determined in step two, and the specific process is as follows:
step 201, recording each node in the database cluster as the 1 st node in sequence
Figure 165210DEST_PATH_IMAGE001
A node, an a-th node; wherein,
Figure 950763DEST_PATH_IMAGE001
and A are positive integers, and
Figure 875994DEST_PATH_IMAGE002
Figure 100302DEST_PATH_IMAGE001
is shown as
Figure 365061DEST_PATH_IMAGE001
Definition numbers of the nodes;
step 202, judging
Figure 649412DEST_PATH_IMAGE001
The connection state of the individual nodes, if
Figure 61939DEST_PATH_IMAGE001
If the connection status of each node is normal, executing step 203 to step 205; wherein, the normal connection state means successful connection;
step 203, determining
Figure 260576DEST_PATH_IMAGE001
Individual node cluster role, second
Figure 442159DEST_PATH_IMAGE001
Individual node connected cluster state
Figure 897411DEST_PATH_IMAGE001
Three parameter states of ready state of each node, if all three parameters are normal, execute step 204; if any of the parameters is not normal, go to step 205; the node cluster role is normal, namely the value is 'Primary', the node connection cluster state is normal, namely the value is 'ON', and the node ready state is 'ON';
step 204, second
Figure 734917DEST_PATH_IMAGE001
The individual node is a node which normally provides database service to the outside and will be the first node
Figure 301028DEST_PATH_IMAGE001
Recording each node as a normal service node, and adding 1 to the number of the normal service nodes; wherein, the initial value of the number of the normal service nodes is zero;
step 205, no
Figure 337117DEST_PATH_IMAGE001
The node whose individual node can not normally provide database service to the outside will be
Figure 963270DEST_PATH_IMAGE001
Recording each node as an abnormal node;
and 206, repeating the steps 202 to 205 for multiple times, finishing the judgment of the A-th node, acquiring a normal service node and an abnormal node, and acquiring the total number B of the normal service nodes.
In the second step, in the process of judging from the 1 st node to the A st node, the 1 st node meeting the conditions of the step 202 and the step 203 is taken as a master node, and the number of the master node, the configuration identifier of the master node cluster, the role of the master node cluster and all the node addresses connected to the master node in the master node are obtained; all node addresses in the master node connected to the master node are recorded as a list of connected master node addresses.
The method for controlling the multiple activities of the database cluster comprises the following steps of judging and processing the database cluster splitting performance of normal service nodes, wherein the specific process comprises the following steps:
step 401, recording the plurality of normal service nodes as the first
Figure 288072DEST_PATH_IMAGE003
A normal service node, the first
Figure 392295DEST_PATH_IMAGE004
A normal service node, the first
Figure 548469DEST_PATH_IMAGE005
A normal service node; wherein,
Figure 283207DEST_PATH_IMAGE003
Figure 892043DEST_PATH_IMAGE006
and
Figure 65536DEST_PATH_IMAGE007
numbers which are positive integers and whose values are from 1 to A;
step 402, for the second step
Figure 518295DEST_PATH_IMAGE004
The normal service node judges the specific process as follows:
step 4021, judging whether the address list of the connection master node contains the second node
Figure 486251DEST_PATH_IMAGE008
If not, executing step 4022; if it contains, then executeStep 4023;
step 4022, closing the normal service node;
step 4023, determining whether the cluster configuration identifier of the normal service node is equal to the cluster configuration identifier of the master node, if not, executing step 4022, and if so, executing step 4024;
step 4024, judging whether the normal service node is the master node, if yes, returning; otherwise, go to step 4025;
step 4025, judging whether the size of the available cluster of the database cluster viewed from the normal service node is equal to B, if not, executing step 4022; if yes, returning;
step 403, repeat step 402 multiple times to complete the first step
Figure 582383DEST_PATH_IMAGE009
Judging the normal service nodes, acquiring the normal service nodes after judgment and processing, and recording the normal service nodes after judgment and processing as normal service nodes to be judged; wherein, the number of the normal service nodes to be judged is denoted as B'.
In the above method for controlling multiple activities of a database cluster, the normal service nodes judged and processed in the fourth step are controlled according to the number of the normal service nodes and the distributed locks in the fifth step, and the specific process is as follows:
step 501, judging whether the number B' of the normal service nodes to be judged is 0, if not, executing step 502; if 0, go to step 504;
step 502, judging whether a certain normal service node to be judged is started, if not, executing step 503, and if so, returning;
step 503, starting the command of adding the normal service node to be judged into the database server cluster, and returning; when a command for joining a server database cluster is started, the value of a parameter "safe _ to _ bootstrap" in a gram file under a database data directory needs to be set to 0, and a database server process is directly started;
step 504: judging whether a distributed lock exists or not, and if not, executing step 505; if so, perform step 506; the distributed lock judges the existence by using a mode of storing key value pairs in Redis, and can directly judge whether corresponding keys exist in the Redis;
step 505: locking, go to step 507;
step 506: judging whether the lock owner is a certain normal service node to be judged, if so, executing the step 507, otherwise, returning;
step 507: and starting the cluster command of the database server of the normal service node to be judged.
In a second aspect of the embodiments of the present invention, there is provided a database cluster multi-activity control apparatus, which is applied to database cluster multi-activity control, and the apparatus can implement any one of the database cluster multi-activity control methods, including:
the state collection unit is used for acquiring the database states of all nodes in the cluster;
the state judging unit is used for judging the states of all the nodes;
a node exception handling unit;
the database cluster splitting performance judging and processing unit is used for judging and processing the splitting performance of the database cluster;
the control unit is used for controlling the normal service nodes after the splitting judgment and treatment according to the cluster state and the node state;
the database closing unit is used for closing the node database;
the third aspect of the embodiment of the invention provides a database cluster multi-activity control system, which comprises not less than three nodes, wherein each node can run MySQL or MariaDB supporting a Galera plug-in and a database controller; a network for communicating the nodes; distributed caching;
the data managed by each node database of the system should be independent, rather than shared; the system can comprise independent data nodes and also can comprise non-independent data nodes; the distributed cache can be the same as or different from the nodes for operating the database; the database controller comprises the database cluster multi-activity control device as claimed in claim 7, wherein the database cluster multi-activity control device is a process running in a service mode, and the service is managed in a service or system.
In a fourth aspect of the embodiments of the present invention, there is provided a computer apparatus, including a memory, a processor, and computer program instructions stored in the memory and capable of being executed on the processor, the computer program instructions implementing the database cluster multi-activity control method according to any one of claims 1 to 6 or the database cluster multi-activity control device according to claim 7.
In a fifth aspect of embodiments of the present invention, there is provided a computer-readable storage medium storing computer program instructions, which are executable on a processor, and cause the processor to implement any one of the database cluster multi-activity control methods or the database cluster multi-activity control apparatus described above.
In summary, in the process of controlling the database of the node according to the cluster state and the local state, the present invention solves the problems of automatic starting, restarting, recovering, etc. of the database on the node in a manner of starting the cluster and a manner of adding the cluster, and solves the problem of cluster splitting through judgment and processing of database cluster splitting.
The technical solution of the present invention is further described in detail by the accompanying drawings and embodiments.
Drawings
FIG. 1 is a block diagram of the process flow of the present invention.
FIG. 2 is a database cluster multi-activity control apparatus according to the present invention.
FIG. 3 is a database cluster multi-activity control system of the present invention.
Detailed Description
Example 1
As shown in fig. 1, a database cluster multi-activity control method, the cluster comprising a plurality of nodes served by a database, the method comprising the steps of:
step one, acquiring the database states of all nodes in a cluster: wherein the parameters of the database state include: the method comprises the following steps of (1) connecting state, database cluster available cluster size, cluster state identification, cluster configuration identification, node cluster role, node connecting cluster state, node ready state and all node addresses connected to a node;
judging the states of all nodes, acquiring nodes and abnormal nodes which can normally provide database services in a database cluster, and acquiring the number of the nodes which can normally provide the database services; wherein, the node which normally provides database service to the outside is marked as a normal service node;
step three, processing the abnormal node: closing the abnormal node database;
step four, judging and processing the database cluster crack of the normal service node;
and step five, controlling the normal service nodes after the crack judgment and treatment according to the cluster state and the node state.
In this embodiment, the step one of obtaining the database state of any node in the cluster includes the following specific processes:
initializing the state of a database of a node to be acquired; a connection node database, wherein the process of connecting the node database needs to set overtime times;
if the node connection state is normal, inquiring the size of the available cluster of the database cluster, the cluster state identifier, the cluster configuration identifier, the node cluster role, the node connection cluster state, the node ready state and all the node addresses connected to the node to obtain the parameters of the database state.
In this embodiment, the state of all nodes is determined in step two, and the specific process is as follows:
step 201, recording each node in the database cluster as the 1 st node in sequence
Figure 28407DEST_PATH_IMAGE010
A node, an a-th node; wherein,
Figure 96857DEST_PATH_IMAGE010
and A are positive integers, and
Figure 235715DEST_PATH_IMAGE011
Figure 819143DEST_PATH_IMAGE010
is shown as
Figure 6542DEST_PATH_IMAGE010
Definition number of each node;
step 202, determining
Figure 991815DEST_PATH_IMAGE010
The connection state of the individual nodes, if
Figure 301574DEST_PATH_IMAGE010
If the connection status of each node is normal, executing step 203 to step 205; wherein, the normal connection state means successful connection;
step 203, determining
Figure 309981DEST_PATH_IMAGE010
Individual node cluster role, second
Figure 363388DEST_PATH_IMAGE010
Individual node connected cluster state
Figure 203168DEST_PATH_IMAGE010
Three parameter states of ready state of each node, if all three parameters are normal, execute step 204; if any of the parameters is not normal, go to step 205; the node cluster role is normal, namely the value is 'Primary', the node connection cluster state is normal, namely the value is 'ON', and the node ready state is 'ON';
step 204, second
Figure 683828DEST_PATH_IMAGE010
The individual node is a node which normally provides database service to the outside and will be the first node
Figure 412487DEST_PATH_IMAGE010
The node is recorded as normalThe number of the service nodes is 1; wherein the initial value of the number of the normal service nodes is zero;
step 205, item I
Figure 269585DEST_PATH_IMAGE010
The node whose individual node can not normally provide the database service to the outside will be the first node
Figure 963871DEST_PATH_IMAGE010
Recording each node as an abnormal node;
and 206, repeating the steps 202 to 205 for multiple times, finishing the judgment of the A-th node, acquiring a normal service node and an abnormal node, and acquiring the total number B of the normal service nodes.
In this embodiment, in the process of determining the 1 st node to the a th node in step two, the 1 st node satisfying the conditions of step 202 and step 203 is recorded as a master node, and a master node number, a master node cluster configuration identifier, a master node cluster role, and all node addresses connected to the master node in the master node are obtained; all node addresses in the master node connected to the master node are recorded as a list of connected master node addresses.
In this embodiment, the database cluster splitting performance determination and processing are performed on the normal service nodes in step four, and the specific process is as follows:
step 401, recording the plurality of normal service nodes as the first
Figure 553115DEST_PATH_IMAGE012
A normal service node, the first
Figure 598432DEST_PATH_IMAGE013
A normal service node, the first
Figure 993641DEST_PATH_IMAGE014
A normal service node; wherein,
Figure 480117DEST_PATH_IMAGE012
Figure 568159DEST_PATH_IMAGE013
and
Figure 835192DEST_PATH_IMAGE014
numbers which are positive integers and whose values are from 1 to A;
step 402, for the second step
Figure 768513DEST_PATH_IMAGE013
The normal service node judges the specific process as follows:
step 4021, judging whether the address list of the connection main node contains the second node
Figure 375075DEST_PATH_IMAGE013
If not, executing step 4022; if yes, executing step 4023;
step 4022, closing the normal service node;
step 4023, determining whether the cluster configuration identifier of the normal service node is equal to the cluster configuration identifier of the master node, if not, executing step 4022, and if so, executing step 4024;
step 4024, judging whether the normal service node is the master node, if yes, returning; otherwise, go to step 4025;
step 4025, judging whether the size of the available cluster of the database cluster viewed from the normal service node is equal to B, if not, executing step 4022; if yes, returning;
step 403, repeat step 402 multiple times to complete the first step
Figure 634018DEST_PATH_IMAGE009
Judging the normal service nodes, acquiring the normal service nodes after judgment and processing, and recording the normal service nodes after judgment and processing as normal service nodes to be judged; wherein, the number of the normal service nodes to be judged is denoted as B'.
In this embodiment, in the fifth step, the normal service nodes judged and processed in the fourth step are controlled according to the number of the normal service nodes and the distributed locks, and the specific process is as follows:
step 501, judging whether the number B' of the normal service nodes to be judged is 0, if not, executing step 502; if 0, go to step 504;
step 502, judging whether a certain normal service node to be judged is started, if not, executing step 503, and if so, returning;
step 503, starting the command of adding the normal service node to be judged into the database server cluster, and returning; when a command of adding a server database cluster is started, the value of a parameter "safe _ to _ bootstrap" in a flag file under a database data directory needs to be set to 0, and a database server process is directly started;
step 504: judging whether a distributed lock exists, if not, executing step 505; if so, perform step 506; the distributed lock judges the existence by using a mode of storing key value pairs in Redis, and can directly judge whether corresponding keys exist in the Redis;
step 505: locking, execute step 507;
step 506: judging whether the lock owner is a certain normal service node to be judged, if so, executing the step 507, otherwise, returning;
step 507: and starting the cluster command of the database server of the normal service node to be judged.
In this embodiment, the database includes MySQL or maridb supporting the Galera plug-in;
the nodes comprise industrial personal computers, servers or PC machines.
In this embodiment, the method includes acquiring a database cluster available cluster size, a cluster state identifier, a cluster configuration identifier, a node cluster role, a node connection cluster state, a node ready state, and address information of all nodes connected to the node, and includes the following specific processes:
the corresponding values are obtained from a table "performance _ schema _ session _ status", wherein the database cluster available cluster size, cluster state identifier, cluster configuration identifier, node cluster role, node connection cluster state, node ready state, and all node addresses connected to the node are the values of the second column of the row where the first column value in the table is "wsrep _ cluster _ size", "wsrep _ cluster _ state _ uuid", "wsrep _ cluster _ conf _ id", "wsrep _ cluster _ status", "wsrep _ connected", "wsrep _ ready", "wsrep _ communication _ addresses", respectively.
In this embodiment, any parameter in step 203 is abnormal, that is, the node cluster angular color value is not "Primary", the node connection cluster state value is not "ON", or the node ready state value is not "ON".
Example 2
As shown in fig. 2, a database cluster multi-activity control apparatus can implement the database cluster multi-activity control method described in embodiment 1, and includes:
a state collection unit 401, configured to obtain database states of all nodes in a cluster;
a state judgment unit 402 for judging the states of all nodes;
a node exception handling unit 403;
the splitting performance judging and processing unit (404) is used for judging and processing the splitting performance of the database cluster;
the control unit 405 controls the normal service nodes subjected to the crack judgment and treatment according to the cluster state and the node state;
a database closing unit 406, configured to close the node database;
in this embodiment, since the apparatus embodiment is the same as the method embodiment, the description is simple, and the related points are described with reference to the method embodiment, and the following apparatus embodiments are merely exemplary.
In this embodiment, the state collection unit 401 includes a state initialization unit, configured to initialize a database state of a node; the database connection unit is used for connecting a database and setting overtime times during connection; and the database query unit is used for querying the cluster size, the cluster state identifier, the cluster configuration identifier, the cluster role of the node, the node connection cluster state, the node ready state and all node addresses connected to the node.
In this embodiment, the state determining unit 402 includes:
the state processing unit is used for judging the states of all the nodes according to the following steps: the method comprises the following steps that a connection state, a node cluster role, a node connection cluster state and a node ready state are adopted, and if four parameters are normal, the node is considered to be a node capable of providing database service to the outside;
the main node judging unit is used for taking a first node which can normally provide database service to the outside in the cluster as a main node and recording a main node number, a main node cluster configuration identifier and all node addresses connected to the main node in the main node;
and the normal service node number calculating unit is used for acquiring the number of the normal service nodes.
In this embodiment, the node exception handling unit 403 is configured to determine whether a certain node is abnormal, where the determining method is as follows: the node connection state is normal, but one of the cluster role of the node, the node connection cluster state and the node ready state is abnormal, and the database closing unit is triggered to work when the node connection state is abnormal.
In this embodiment, the splitting property determining and processing unit 404 includes:
the address judging unit is used for judging whether all node addresses connected to the main node contain the node address under the condition that a certain node connection state, a node cluster role, a node connection cluster state and a node ready state are normal, and if not, the address judging unit triggers the database closing unit to work;
the cluster configuration identifier judging unit is used for judging whether the node cluster configuration identifier is equal to the main node cluster configuration identifier or not, and if not, triggering the database closing unit to work;
and the available cluster size judging unit is used for judging whether the available cluster size of the database cluster checked in the node state is equal to the number B of nodes which can normally provide database services for the database cluster when the node is not the master node, and if not, the available cluster size judging unit triggers the database closing unit to work.
In this embodiment, the controlling unit (405) including a certain node controlling unit includes:
a starting cluster unit for modifying the node configuration parameters to enable starting the database server cluster at the node, and executing the database server starting command with the cluster parameters attached at the node;
a join cluster unit for modifying the node configuration parameters to enable joining a database server cluster at the node where the database server startup command is executed;
the node number judging unit is used for judging whether the database cluster B' is 0 or not, and if the database of the node is not started and is larger than 0, the node is triggered to join the cluster unit to work;
the lock acquiring unit is used for judging whether a distributed lock exists or not;
a locking unit for locking;
and the lock owner judging unit is used for judging whether the lock owner is the node or not, and if the lock owner is the node and the number of the nodes capable of normally providing the database service by the database cluster is 0, triggering the node to start the cluster unit to work.
Example 3
As shown in fig. 3, a database cluster multi-activity control system includes three MariaDB database service nodes: node 1, node 2, node 3, three data nodes: the data nodes 1, 2, 3 and 4 run Redis service, and the network switch. The three MariaDB database service nodes respectively run a MariaDB database service and a database controller, and the database controller comprises the database cluster multi-active control device described in the embodiment 2.
In this embodiment, the data managed by each node database of the system should be independent, and must be independent in specific implementation;
in this embodiment, the present invention includes independent data nodes, and may also include dependent data nodes in specific implementation;
in this embodiment, the distributed cache of the system uses Redis, and on an independent node, in specific implementation, the distributed cache can be the same as a node for running the database;
in this embodiment, the database controller includes a database cluster multi-activity control device that supports embodiment 2, and is a process that operates in a service manner, where the service management manner is systemd, and may also be service when implemented specifically.
Example 4
A computer apparatus comprising a memory, a processor, and computer program instructions stored on the memory and operable on the processor to implement the database cluster multi-activity control method of embodiment 1 or the database cluster multi-activity control apparatus of claim 7.
Example 5
A computer readable storage medium storing computer program instructions executable on a processor, the computer program instructions causing the processor to implement the database cluster multi-activity control method described in embodiment 1 or the database cluster multi-activity control apparatus described in embodiment 2.
According to embodiments of the application, the processes and embodiments described above with reference to the embodiment figures and the flow charts may be implemented as computer software components. All or a portion of the present application may be implemented as part of a computer program product, such as computer program instructions, which when executed by a computer, may invoke or provide a method or apparatus in accordance with the present application through the operation of the computer.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
It will be evident to those skilled in the art that the application is not limited to the details of the foregoing illustrative embodiments, and that the present application may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The embodiments are therefore to be considered in all respects as illustrative and not restrictive. The scope of the application is defined by the appended claims, rather than the description above, and all changes that come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein.

Claims (10)

1. A database cluster multi-activity control method, wherein the cluster comprises a plurality of nodes served by a database, the method comprising the steps of:
step one, acquiring the database states of all nodes in a cluster: wherein the parameters of the database state include: the method comprises the following steps of (1) connecting state, database cluster available cluster size, cluster state identification, cluster configuration identification, node cluster role, node connecting cluster state, node ready state and all node addresses connected to a node;
judging the states of all nodes, acquiring nodes and abnormal nodes which can normally provide database services in a database cluster, and acquiring the number of the nodes which can normally provide the database services; wherein, the node which normally provides database service to the outside is marked as a normal service node;
step three, processing the abnormal node: closing the abnormal node database;
step four, judging and processing the database cluster crack of the normal service node;
and step five, controlling the normal service nodes after the judgment and treatment of the splitting property according to the cluster state and the node state.
2. A database cluster multi-activity control method according to claim 1, characterized in that: step one, acquiring the database state of any node in a cluster, specifically comprising the following steps:
initializing the database state of a node to be acquired; a connection node database, wherein the connection node database process needs to set timeout times;
and if the node connection state is normal, inquiring the size of the available cluster of the database cluster, the cluster state identifier, the cluster configuration identifier, the node cluster role, the node connection cluster state, the node ready state and all the node addresses connected to the node to obtain the parameters of the database state.
3. A database cluster multi-activity control method according to claim 1, characterized in that: judging the states of all nodes in the second step, wherein the specific process is as follows:
step 201, recording each node in the database cluster as the 1 st node in turn
Figure 275751DEST_PATH_IMAGE001
A node, an a-th node; wherein,
Figure 480467DEST_PATH_IMAGE001
and A are positive integers, and
Figure 679368DEST_PATH_IMAGE002
Figure 82667DEST_PATH_IMAGE001
denotes the first
Figure 279293DEST_PATH_IMAGE001
Definition number of each node;
step 202, judging
Figure 33623DEST_PATH_IMAGE001
The connection state of the individual nodes, if
Figure 770634DEST_PATH_IMAGE001
If the connection status of each node is normal, executing step 203 to step 205; wherein, the normal connection state means successful connection;
step 203, judge
Figure 730238DEST_PATH_IMAGE001
Individual node cluster role, second
Figure 160082DEST_PATH_IMAGE001
Individual node connected cluster state
Figure 136128DEST_PATH_IMAGE001
Three parameter states of ready state of each node, if all three parameters are normal, execute step 204; if any of the parameters is not normal, go to step 205; the node cluster role is normal, namely the value is 'Primary', the node connection cluster state is normal, namely the value is 'ON', and the node ready state is 'ON';
step 204, step I
Figure 614514DEST_PATH_IMAGE001
The individual node is a node which normally provides database service to the outside and will be the first node
Figure 257985DEST_PATH_IMAGE001
Recording each node as a normal service node, and adding 1 to the number of the normal service nodes; wherein, the initial value of the number of the normal service nodes is zero;
step 205, no
Figure 593152DEST_PATH_IMAGE001
The node whose individual node can not normally provide database service to the outside will be
Figure 259756DEST_PATH_IMAGE001
Recording each node as an abnormal node;
and 206, repeating the steps 202 to 205 for multiple times, finishing the judgment of the A-th node, acquiring a normal service node and an abnormal node, and acquiring the total number B of the normal service nodes.
4. A database cluster multi-activity control method according to claim 3, characterized in that: in the process from the 1 st node to the A st node, marking the 1 st node meeting the conditions of the step 202 and the step 203 as a master node, and acquiring a master node number, a master node cluster configuration identifier, a master node cluster role and all node addresses connected to the master node in the master node; all node addresses in the master node connected to the master node are recorded as a list of connected master node addresses.
5. A database cluster multi-activity control method according to claim 4, characterized in that: and in the fourth step, judging and processing the database cluster fragmentation of the normal service nodes, wherein the specific process is as follows:
step 401, recording the plurality of normal service nodes as the first
Figure 338571DEST_PATH_IMAGE003
A normal service node, the first
Figure 836548DEST_PATH_IMAGE004
A normal service node, the first
Figure 342616DEST_PATH_IMAGE005
A normal service node; wherein,
Figure 496517DEST_PATH_IMAGE003
Figure 379022DEST_PATH_IMAGE004
and
Figure 731506DEST_PATH_IMAGE005
numbers which are positive integers and whose values are from 1 to A;
step 402, for the second step
Figure 110273DEST_PATH_IMAGE004
The normal service nodes are judged, and the specific process is as follows:
step 4021, judging whether the address list of the connection master node contains the second node
Figure 548207DEST_PATH_IMAGE004
If not, executing step 4022; if yes, executing step 4023;
step 4022, closing the normal service node;
step 4023, determining whether the cluster configuration identifier of the normal service node is equal to the cluster configuration identifier of the master node, if not, executing step 4022, and if so, executing step 4024;
step 4024, judging whether the normal service node is the master node, if yes, returning; otherwise, go to step 4025;
step 4025, judging whether the size of the available cluster of the database cluster viewed from the normal service node is equal to B, if not, executing step 4022; if yes, returning;
step 403, repeat step 402 multiple times to complete the second step
Figure 968824DEST_PATH_IMAGE005
Judging the normal service nodes, acquiring the normal service nodes after judgment and processing, and recording the normal service nodes after judgment and processing as normal service nodes to be judged; wherein, the number of the normal service nodes to be judged is denoted as B'.
6. A database cluster multi-activity control method according to claim 1, characterized in that: and step five, controlling the normal service nodes judged and processed in the step four according to the number of the normal service nodes and the distributed locks, wherein the specific process is as follows:
step 501, judging whether the number B' of the normal service nodes to be judged is 0, if not, executing step 502; if 0, go to step 504;
step 502, judging whether a certain normal service node to be judged is started, if not, executing step 503, and if so, returning;
step 503, starting the command of adding the normal service node to be judged into the database server cluster, and returning; when a command for joining a server database cluster is started, the value of a parameter "safe _ to _ bootstrap" in a gram file under a database data directory needs to be set to 0, and a database server process is directly started;
step 504: judging whether a distributed lock exists, if not, executing step 505; if so, perform step 506; the distributed lock judges the existence by using a mode of storing key value pairs in Redis, and can directly judge whether corresponding keys exist in the Redis;
step 505: locking, go to step 507;
step 506: judging whether the lock owner is a certain normal service node to be judged, if so, executing the step 507, otherwise, returning;
step 507: and starting the cluster command of the database server of the normal service node to be judged.
7. A database cluster multi-activity control device, applied to database cluster multi-activity control, wherein the device can implement the database cluster multi-activity control method of any one of claims 1 to 6, and comprises:
the state collection unit (401) is used for acquiring the database states of all the nodes in the cluster;
a state judgment unit (402) for judging the states of all nodes;
a node exception handling unit (403);
the splitting performance judging and processing unit (404) is used for judging and processing the splitting performance of the database cluster;
the control unit (405) controls the normal service nodes after the splitting judgment and treatment according to the cluster state and the node state;
and a database closing unit (406) for closing the node database.
8. A database cluster multi-activity control system is characterized in that: the system comprises at least three nodes, wherein each node can run MySQL or MariaDB supporting the Galera plug-in and a database controller; a network for communicating the nodes; distributed caching;
the data managed by each node database of the system should be independent, rather than shared; the system can comprise independent data nodes and also can comprise non-independent data nodes; the distributed cache can be the same as or different from the nodes for operating the database; the database controller comprises the database cluster multi-activity control device as claimed in claim 7, wherein the database cluster multi-activity control device is a process running in a service mode, and the service is managed by a service or a system.
9. A computer device, characterized by: comprising a memory, a processor, and computer program instructions stored on the memory and executable on the processor, said computer program instructions implementing the database cluster multi-activity control method of any one of claims 1 to 6.
10. A computer-readable storage medium characterized by: the computer readable storage medium stores computer program instructions executable on a processor, the computer program instructions causing the processor to implement the database cluster multi-activity control method of any of claims 1-6.
CN202211618872.5A 2022-12-16 2022-12-16 Method, device, system and equipment for controlling multiple activities of database cluster Active CN115617917B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211618872.5A CN115617917B (en) 2022-12-16 2022-12-16 Method, device, system and equipment for controlling multiple activities of database cluster

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211618872.5A CN115617917B (en) 2022-12-16 2022-12-16 Method, device, system and equipment for controlling multiple activities of database cluster

Publications (2)

Publication Number Publication Date
CN115617917A true CN115617917A (en) 2023-01-17
CN115617917B CN115617917B (en) 2023-03-10

Family

ID=84880444

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211618872.5A Active CN115617917B (en) 2022-12-16 2022-12-16 Method, device, system and equipment for controlling multiple activities of database cluster

Country Status (1)

Country Link
CN (1) CN115617917B (en)

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110131193A1 (en) * 2009-12-01 2011-06-02 Sybase, Inc. On Demand Locking of Retained Resources in a Distributed Shared Disk Cluster Environment
CN102308559A (en) * 2011-07-26 2012-01-04 华为技术有限公司 Voting arbitration method and apparatus for cluster computer system
CN103970580A (en) * 2014-05-05 2014-08-06 华中科技大学 Data flow compilation optimization method oriented to multi-core cluster
WO2016177130A1 (en) * 2015-05-07 2016-11-10 中兴通讯股份有限公司 Method and device for selecting communication node
CN109542659A (en) * 2018-11-14 2019-03-29 深圳前海微众银行股份有限公司 Using more activating methods, equipment, data center's cluster and readable storage medium storing program for executing
CN109639794A (en) * 2018-12-10 2019-04-16 杭州数梦工场科技有限公司 A kind of stateful cluster recovery method, apparatus, equipment and readable storage medium storing program for executing
CN110073301A (en) * 2017-08-02 2019-07-30 强力物联网投资组合2016有限公司 The detection method and system under data collection environment in industrial Internet of Things with large data sets
JP2019153055A (en) * 2018-03-02 2019-09-12 富士通株式会社 Cluster system, information processing apparatus, cluster monitoring method, and cluster monitoring program
WO2019216975A1 (en) * 2018-05-07 2019-11-14 Strong Force Iot Portfolio 2016, Llc Methods and systems for data collection, learning, and streaming of machine signals for analytics and maintenance using the industrial internet of things
CN111427689A (en) * 2020-03-24 2020-07-17 苏州科达科技股份有限公司 Cluster keep-alive method and device and storage medium
CN113742073A (en) * 2021-09-06 2021-12-03 中国西安卫星测控中心 LSB interface-based cluster control method
CN113961402A (en) * 2021-09-27 2022-01-21 广东浪潮智慧计算技术有限公司 Management method, device, equipment and medium for virtualization cluster

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110131193A1 (en) * 2009-12-01 2011-06-02 Sybase, Inc. On Demand Locking of Retained Resources in a Distributed Shared Disk Cluster Environment
CN102308559A (en) * 2011-07-26 2012-01-04 华为技术有限公司 Voting arbitration method and apparatus for cluster computer system
CN103970580A (en) * 2014-05-05 2014-08-06 华中科技大学 Data flow compilation optimization method oriented to multi-core cluster
WO2016177130A1 (en) * 2015-05-07 2016-11-10 中兴通讯股份有限公司 Method and device for selecting communication node
CN110073301A (en) * 2017-08-02 2019-07-30 强力物联网投资组合2016有限公司 The detection method and system under data collection environment in industrial Internet of Things with large data sets
JP2019153055A (en) * 2018-03-02 2019-09-12 富士通株式会社 Cluster system, information processing apparatus, cluster monitoring method, and cluster monitoring program
WO2019216975A1 (en) * 2018-05-07 2019-11-14 Strong Force Iot Portfolio 2016, Llc Methods and systems for data collection, learning, and streaming of machine signals for analytics and maintenance using the industrial internet of things
CN109542659A (en) * 2018-11-14 2019-03-29 深圳前海微众银行股份有限公司 Using more activating methods, equipment, data center's cluster and readable storage medium storing program for executing
CN109639794A (en) * 2018-12-10 2019-04-16 杭州数梦工场科技有限公司 A kind of stateful cluster recovery method, apparatus, equipment and readable storage medium storing program for executing
CN111427689A (en) * 2020-03-24 2020-07-17 苏州科达科技股份有限公司 Cluster keep-alive method and device and storage medium
CN113742073A (en) * 2021-09-06 2021-12-03 中国西安卫星测控中心 LSB interface-based cluster control method
CN113961402A (en) * 2021-09-27 2022-01-21 广东浪潮智慧计算技术有限公司 Management method, device, equipment and medium for virtualization cluster

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
SARE GORGBANDI: "Detection of Anomalous Cluster Heads and Nodes in Wireless Sensor Networks" *
潘吉飞;黄德才;: "区块链技术对人工智能的影响" *

Also Published As

Publication number Publication date
CN115617917B (en) 2023-03-10

Similar Documents

Publication Publication Date Title
CN106331098B (en) Server cluster system
TW523656B (en) Method and apparatus for building and managing multi-clustered computer systems
US7356531B1 (en) Network file system record lock recovery in a highly available environment
CN112506702B (en) Disaster recovery method, device, equipment and storage medium for data center
US20080082863A1 (en) System and Method for Maintaining Functionality During Component Failures
JP2009205687A (en) Multiple device management method and system
CN107666493B (en) Database configuration method and equipment thereof
US10048983B2 (en) Systems and methods for enlisting single phase commit resources in a two phase commit transaction
CN110635941A (en) Database node cluster fault migration method and device
US10346085B1 (en) Distributed restore anywhere for directory services
US20160050113A1 (en) Methods for managing storage virtual machine configuration changes in a distributed storage system and devices thereof
JP2008176749A (en) Id lending device, id lending program, and id lending method
CN118018463A (en) Fault processing method, device, equipment and readable storage medium
CN115617917B (en) Method, device, system and equipment for controlling multiple activities of database cluster
CN107623581B (en) Service list generation method, device and system, and acquisition and reporting method and device
CN116319280A (en) Method for electing master and slave nodes based on kubernetes distributed lock
CN112702206B (en) Main and standby cluster deployment method and system
CN112749045B (en) Database cluster switching method, device, storage medium and apparatus
CN113672346A (en) Method for realizing multi-MGR service deployment based on look
JPH07114495A (en) Multiplexing file managing system
CN114915545B (en) Application scheduling deployment management method based on DHCP network cluster
JP4160171B2 (en) Branch store backup system, center side server, branch store server, branch store backup method, and recording medium
WO2024061219A1 (en) Information updating method, apparatus and device, storage medium, and program product
CN112667449B (en) Cluster management method and device
JP2006202220A (en) Program for causing computer to execute processing of confirming consistency of handover information, and method thereof

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
GR01 Patent grant
GR01 Patent grant