CN115757635A - Database cluster flow distribution method, device, equipment and storage medium - Google Patents

Database cluster flow distribution method, device, equipment and storage medium Download PDF

Info

Publication number
CN115757635A
CN115757635A CN202211505030.9A CN202211505030A CN115757635A CN 115757635 A CN115757635 A CN 115757635A CN 202211505030 A CN202211505030 A CN 202211505030A CN 115757635 A CN115757635 A CN 115757635A
Authority
CN
China
Prior art keywords
node
weight
traffic
read
initial
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
CN202211505030.9A
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.)
Shanghai Pudong Development Bank Co Ltd
Original Assignee
Shanghai Pudong Development Bank 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 Shanghai Pudong Development Bank Co Ltd filed Critical Shanghai Pudong Development Bank Co Ltd
Priority to CN202211505030.9A priority Critical patent/CN115757635A/en
Publication of CN115757635A publication Critical patent/CN115757635A/en
Pending legal-status Critical Current

Links

Images

Landscapes

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

Abstract

The invention discloses a method, a device, equipment and a storage medium for distributing the flow of a database cluster. The method comprises the following steps: the database cluster comprises a main node, a standby node and at least one read-only node; acquiring initial flow weights of the main node, the standby node and the at least one read-only node; the initial flow weight of the standby node is a set value; when the main node fails, the standby node is switched to a new main node; determining the target flow weight of the new main node according to the initial flow weight of the main node; and controlling the database cluster to read data according to the target flow weight of the new main node and the initial flow weight of the at least one read-only node. By the technical scheme of the invention, when the fault transfer occurs, the new main node, the read-only node and the original main node after the fault recovery are automatically adjusted to be automatically distributed to the read-write flow.

Description

Database cluster flow distribution method, device, equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of databases, in particular to a method, a device, equipment and a storage medium for allocating the flow of a database cluster.
Background
With the development of database technology, the use of the open source database is very extensive, and the MySQL database plays a significant role in many open source databases.
The read-write separation of the MySQL database is usually implemented by a database proxy, which is a network middleware located in a network between the business system and the database. However, when the failover occurs, the standby node is upgraded to the new master node, the weight of the new master node is still the weight during initialization, the read traffic cannot be borne, automatic allocation of the read traffic after the failover cannot be achieved, and the read-only node bears all the read traffic, so that the load is increased rapidly, and the performance bottleneck occurs.
Disclosure of Invention
The invention provides a method, a device, equipment and a storage medium for distributing traffic of a database cluster, which are used for automatically adjusting a new main node, a read-only node and an original main node after fault recovery to automatically distribute read-write traffic when fault transfer occurs.
According to an aspect of the present invention, a method for allocating traffic of a database cluster is provided, where the database cluster includes a master node, a standby node, and at least one read-only node; the method comprises the following steps:
acquiring initial flow weights of the main node, the standby node and the at least one read-only node; the initial flow weight of the standby node is a set value;
when the main node fails, the standby node is switched to a new main node;
determining the target flow weight of the new main node according to the initial flow weight of the main node;
and controlling the database cluster to read data according to the target flow weight of the new master node and the initial flow weight of the at least one read-only node.
Optionally, determining the target traffic weight of the new master node according to the initial traffic weight of the master node includes:
determining a flow weight range according to the initial flow weight of the main node;
and selecting a traffic weight from the traffic weight range to determine the traffic weight as the target traffic weight of the new master node.
Optionally, determining a traffic weight range according to the initial traffic weight of the master node includes:
acquiring a set weight offset;
determining a flow weight range according to the initial flow weight of the main node and the offset; wherein the traffic weight range is centered on an initial traffic weight of the master node.
Optionally, controlling the database cluster to perform data reading according to the target traffic weight of the new master node and the initial traffic weight of the at least one read-only node, including:
determining a traffic distribution proportion between the new main node and the at least one read-only node according to the target traffic weight of the new main node and the initial traffic weight of the at least one read-only node;
and controlling the database cluster to read data according to the flow distribution proportion.
Optionally, after controlling the database cluster to perform data reading according to the target traffic weight of the new master node and the initial traffic weight of the at least one read-only node, the method further includes:
and if the main node is repaired due to the fault, switching the main node into a new standby node, and adjusting the flow weight of the new standby node to be a set value.
According to another aspect of the present invention, there is provided a traffic distribution apparatus for a database cluster, wherein the database cluster is configured with a master node, a standby node and at least one read-only node; the device comprises:
an initial traffic weight obtaining module, configured to obtain initial traffic weights of the master node, the standby node, and the at least one read-only node; the initial flow weight of the standby node is a set value;
the master node switching module is used for switching the standby node to a new master node when the master node fails;
the target flow weight determining module is used for determining the target flow weight of the new main node according to the initial flow weight of the main node;
and the data reading module is used for controlling the database cluster to read data according to the target flow weight of the new master node and the initial flow weight of the at least one read-only node.
Optionally, the target traffic weight determining module includes:
a traffic weight range determining unit, configured to determine a traffic weight range according to the initial traffic weight of the master node;
and the target traffic weight determining unit is used for selecting a traffic weight from the traffic weight range and determining the traffic weight as the target traffic weight of the new main node.
Optionally, the flow weight range determining unit is specifically configured to:
acquiring a set weight offset;
determining a flow weight range according to the initial flow weight of the main node and the offset; wherein the traffic weight range is centered on an initial traffic weight of the master node.
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 content of the first and second substances,
the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to enable the at least one processor to perform a method of database cluster traffic allocation according to any of the embodiments of the present 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 method for database cluster traffic allocation according to any of the embodiments of the present invention when the computer instructions are executed.
The invention obtains the initial flow weight of the main node, the standby node and the at least one read-only node; the initial flow weight of the standby node is a set value; when the main node fails, the standby node is switched to a new main node; determining the target flow weight of the new main node according to the initial flow weight of the main node; and controlling the database cluster to read data according to the target flow weight of the new master node and the initial flow weight of the at least one read-only node. By the technical scheme of the invention, when the fault transfer occurs, the new main node, the read-only node and the original main node after the fault recovery are automatically adjusted to be automatically distributed to the read-write flow.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a flowchart of a method for allocating traffic of a database cluster according to an embodiment of the present invention;
fig. 2 is a diagram illustrating an example of traffic weight assignment before failover according to an embodiment of the present invention;
fig. 3 is a diagram illustrating an example of traffic weight assignment after failover according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a traffic distribution apparatus of a database cluster according to a second embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device according to a third embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or 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 one
Fig. 1 is a flowchart of a method for allocating traffic of a database cluster according to an embodiment of the present invention, where this embodiment is applicable to a case of allocating traffic to nodes in the database cluster, and the method may be executed by a traffic allocation apparatus of the database cluster, where the apparatus may be implemented in a form of software and/or hardware, and optionally, implemented by an electronic device, where the electronic device may be a mobile terminal, a PC end, a server, or the like. The method specifically comprises the following steps:
and 110, acquiring initial flow weights of the main node, the standby node and the at least one read-only node.
The database cluster in this embodiment may include a master node, a standby node, and at least one read-only node. There may be a plurality of read-only nodes. The initial traffic weight of the standby node may be a set value. Multiple nodes may be included in a database cluster to handle tasks of the database, such as write tasks and read tasks. For example, the database cluster in this embodiment may be a MySQL cluster. The read-write separation of the MySQL database is usually implemented by a database proxy, which is a network middleware located in a network between the business system and the database.
In this embodiment, a plurality of slave nodes in a database cluster may be divided into a standby node and a read-only node, where the standby node is mainly used for disaster recovery as the master node, and the read-only node may mainly share a task of reading traffic. The database cluster in this embodiment may include a master node, a standby node, and at least one read-only node. The initial traffic weight may be pre-configured. In this embodiment, the initial traffic weight may be a weight of read traffic initially assumed by each node configured in the database proxy. In this embodiment, the initial traffic weight of the standby node may be a set value, and the set value may be 0. The initial flow rate in this embodiment may be configured by a technician according to actual needs. For example, assuming that a database cluster is a framework of 1 master node, 1 standby node and 2 read-only nodes, an initial traffic weight of read traffic of the master node is 50, an initial traffic weight of read traffic of the standby node is 0,2 read-only nodes, and the initial traffic weights of the read traffic of the standby node are 25 respectively, that is, the master node bears 50% of the read traffic, the standby node bears 0% of the read traffic, and the 2 read-only nodes bear 25% of the read traffic respectively. In this embodiment, the initial traffic weights of the master node, the standby node, and the at least one read-only node may be obtained.
Fig. 2 is an exemplary diagram of a traffic weight assignment situation before failover in this embodiment. Wherein, the number of the read-only nodes can be 2; the initial traffic weight of the master node is 50, the initial traffic weight of the standby node is 0, and the initial weights of the two read-only nodes are 25 respectively. In this embodiment, the database high availability component may be an editor, and the database proxy component may be a proxysql, where the editor component manages a MySQL cluster (which may include a master node, a standby node, and a read-only node), and configures information of the proxysql proxy node in the editor node.
And step 120, when the main node fails, switching the standby node to a new main node.
In this embodiment, when the master node fails, the standby node may be switched to a new master node. If the master node does not fail, the traffic can be read according to the pre-configured initial traffic weight.
And step 130, determining the target traffic weight of the new main node according to the initial traffic weight of the main node.
Wherein the target traffic weight item may be a traffic weight of the new master node. The target traffic weight may be determined based on the initial traffic weight of the primary node. In this embodiment, the new target traffic weight of the master node may be determined according to the initial traffic weight of the master node.
In this embodiment, optionally, the determining the target traffic weight of the new master node according to the initial traffic weight of the master node includes: determining a flow weight range according to the initial flow weight of the main node; and selecting a traffic weight from the traffic weight range to determine the traffic weight as the target traffic weight of the new master node.
The traffic weight range may be less than or equal to the initial traffic weight, or the traffic weight range is determined according to the initial traffic weight of the master node and the set weight offset, or may be set according to actual requirements. The target traffic weight of the new master node may be determined by selecting a traffic weight from a range of traffic weights.
In this embodiment, the weight range may be determined according to the initial traffic weight of the master node, for example, if the initial traffic weight of the master node is 50, the traffic weight range may be 0 to 50, and the target traffic weight of the new master node may be one traffic weight selected from 0 to 50, may be 40, or may be 30, and may be selected according to an actual situation.
In this embodiment, a traffic weight range may be determined according to the initial traffic weight of the master node, and then a traffic weight is selected from the determined traffic weight range and determined as a target traffic weight of the new master node. By means of the setting, the target traffic weight of the new main node can be determined, and therefore the situation that after the fault transfer, the new main node does not bear read traffic and forwards all the read traffic to the read-only node, so that the load of the read-only node is increased, and even the read-only node is unavailable is avoided.
In this embodiment, optionally, determining the traffic weight range according to the initial traffic weight of the master node includes: acquiring a set weight offset; determining a flow weight range according to the initial flow weight of the main node and the offset; wherein the traffic weight range is centered on an initial traffic weight of the master node.
The weight offset may be preset, for example, the set weight offset may be ± 10, and may be set according to a time requirement. In this embodiment, the traffic weight range may be determined according to the initial traffic weight and the offset of the master node. The traffic weight range may be centered on the primary traffic weight of the primary node. It is understood that, in this embodiment, the range of subtracting the set offset amount or adding the set offset amount may be taken as the flow weight range with the initial flow weight as the center. For example, if the primary node has an initial traffic weight of 50 and the set weight offset may be ± 10, the traffic weight range may be 40-60.
In this embodiment, the set weight offset may be obtained, and the weight range may be determined by centering on the initial traffic weight of the master node and the offset. Through such setting in this embodiment, the traffic weight range can be determined, a traffic weight is selected from the determined traffic weight range to be determined as the target traffic weight of the new master node, and the method and the device are more flexible and convenient.
Fig. 3 is an exemplary diagram of a traffic weight assignment situation after failover in this embodiment. The number of the read-only nodes can be 2, and the target traffic weight of the new master node is selected to be 50; in this embodiment, the reading of the primary master node weight in proxysql may be implemented in the hook function after the editor failover, and the read traffic weight of the new master node is adjusted to 50, and the read traffic weight of the primary master node is adjusted to 0 when the new master node is applied to the new master node. In this embodiment, after the Orchester monitors that the master node fails and performs failover, the logic of the new master node weight of proxysql may be modified based on the preset configuration automatically called by the Orchester mechanism. The flow weight adjustment configured after the failover is respectively as follows: the target flow weight of the new main node can be 50, the original main node is repaired to be used as a standby node, and the flow weight is 0; the traffic weights of the two read-only nodes are 25 respectively.
In this embodiment, if the original master node is repaired and then joins the cluster in the role of the standby node, since the read traffic weight has been modified to 0, the read traffic of the standby node is not assumed after rejoining the cluster, thereby avoiding the situation of data inconsistency caused by long-time departure from the cluster and reducing the business impact.
And 140, controlling the database cluster to read data according to the target flow weight of the new master node and the initial flow weight of the at least one read-only node.
In this embodiment, the database cluster may be controlled to read data according to the new target traffic weight of the master node and the initial traffic weight of the at least one read-only node.
In this embodiment, optionally, controlling the database cluster to perform data reading according to the target traffic weight of the new master node and the initial traffic weight of the at least one read-only node includes: determining a traffic distribution proportion between the new main node and the at least one read-only node according to the target traffic weight of the new main node and the initial traffic weight of the at least one read-only node; and controlling the database cluster to read data according to the flow distribution proportion.
The traffic distribution ratio between the new master node and the at least one read-only node may be determined according to the target traffic weight of the new master node and the initial traffic weight of the at least one read-only node. For example, if there is one read-only node, the target traffic weight of the new master node is 50, and the weight of the read-only node is 50, then the traffic allocation proportion between the new master node and the read-only node is 1:1; if there are two read-only nodes, the target traffic weight of the new master node is 50, and the weights of the two read-only nodes are 25, then the traffic allocation proportion between the new master node and the two read-only nodes is 2. In this embodiment, the database cluster may be controlled to read data according to the flow distribution ratio.
In this embodiment, the traffic distribution ratio between the new master node and the at least one read-only node may be determined according to the target traffic weight of the new master node and the initial traffic weight of the at least one read-only node, and then the database cluster is controlled to perform data reading according to the traffic distribution ratio. Through the setting, the data reading can be automatically carried out according to the automatically distributed flow distribution proportion of the new main node and the read-only node to the read-write flow, so that the data reading consistency is ensured, and the stable operation of a service system is maintained.
In this embodiment, optionally, after controlling the database cluster to perform data reading according to the target traffic weight of the new master node and the initial traffic weight of the at least one read-only node, the method further includes: and if the main node is repaired, switching the main node into a new standby node, and adjusting the flow weight of the new standby node to a set value.
The setting value can be preset and can be set according to actual requirements. The set value in the present embodiment may be 0. In this embodiment, if the master node fails, the master node may be switched to a new standby node, and the traffic weight of the new standby node is adjusted to a set value. Through the arrangement, after the main node is repaired, the original main node is switched to a new standby node, so that disaster tolerance can be conveniently carried out when the new main node fails next time, and the operation is more convenient; the situation that the read flow is sent to the node after the original main node is recovered due to failure and is added into the cluster as the standby node can also be avoided.
The invention obtains the initial flow weight of the main node, the standby node and the at least one read-only node; the initial flow weight of the standby node is a set value; when the main node fails, the standby node is switched to a new main node; determining the target traffic weight of the new main node according to the initial traffic weight of the main node; and controlling the database cluster to read data according to the target flow weight of the new master node and the initial flow weight of the at least one read-only node. By the technical scheme of the invention, when the fault transfer occurs, the new main node, the read-only node and the original main node after the fault recovery are automatically adjusted to be automatically distributed to the read-write flow.
Example two
Fig. 4 is a schematic structural diagram of a traffic distribution apparatus for a database cluster according to a second embodiment of the present invention, where the apparatus is capable of executing a traffic distribution method for a database cluster according to any embodiment of the present invention, and has corresponding functional modules and beneficial effects of the execution method. As shown in fig. 4, the database cluster is configured with a master node, a standby node and at least one read-only node; the device comprises:
an initial traffic weight obtaining module 410, configured to obtain initial traffic weights of the master node, the standby node, and the at least one read-only node; and the initial flow weight of the standby node is a set value.
The master node switching module 420 is configured to switch the standby node to a new master node when the master node fails.
And a target traffic weight determining module 430, configured to determine a target traffic weight of the new host node according to the initial traffic weight of the host node.
A data reading module 440, configured to control the database cluster to read data according to the target traffic weight of the new master node and the initial traffic weight of the at least one read-only node.
Optionally, the target traffic weight determining module includes:
a traffic weight range determining unit, configured to determine a traffic weight range according to the initial traffic weight of the master node;
and the target traffic weight determining unit is used for selecting a traffic weight from the traffic weight range and determining the selected traffic weight as the target traffic weight of the new main node.
Optionally, the flow weight range determining unit is specifically configured to:
acquiring a set weight offset;
determining a flow weight range according to the initial flow weight of the main node and the offset; wherein the traffic weight range is centered on an initial traffic weight of the master node.
Optionally, the data reading module 440 has a module for:
determining a traffic distribution proportion between the new main node and the at least one read-only node according to the target traffic weight of the new main node and the initial traffic weight of the at least one read-only node;
and controlling the database cluster to read data according to the flow distribution proportion.
Optionally, the apparatus further includes:
and the node switching module is used for switching the main node into a new standby node and adjusting the flow weight of the new standby node to a set value if the main node is repaired due to a fault after controlling the database cluster to read data according to the target flow weight of the new main node and the initial flow weight of the at least one read-only node.
The device can execute the methods provided by all the embodiments of the invention, and has corresponding functional modules and beneficial effects for executing the methods. For details not described in detail in this embodiment, reference may be made to the methods provided in all the foregoing embodiments of the present invention.
EXAMPLE III
Fig. 5 is a schematic structural diagram of an electronic device according to a third 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. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, 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 communicatively connected to the at least one processor 11, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, and the like, wherein the memory stores a computer program executable by the at least one processor, and the processor 11 can perform various suitable actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from a storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data necessary for the operation of the electronic apparatus 10 can 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 the bus 14.
A number of 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, or the like; 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, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, or the like. The processor 11 performs the various methods and processes described above, such as the traffic distribution method of a database cluster.
In some embodiments, the traffic distribution method of a database cluster 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 the RAM 13 and executed by the processor 11, one or more steps of the above described method of traffic allocation for a database cluster may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the traffic allocation method of the database cluster by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), system on a 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 that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for implementing the methods 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 performed. A computer program can execute entirely on a 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.
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. A 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 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) by 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 can 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, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end 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 back-end, 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. A client and server are generally 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 host and VPS service are overcome.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present invention may be executed in parallel, sequentially, or in different orders, and are not limited herein as long as the desired results of the technical solution of the present invention can be achieved.
The above-described embodiments should not be construed as limiting the scope of the invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. The flow distribution method of the database cluster is characterized in that the database cluster comprises a main node, a standby node and at least one read-only node; the method comprises the following steps:
acquiring initial flow weights of the main node, the standby node and the at least one read-only node; the initial flow weight of the standby node is a set value;
when the main node fails, switching the standby node to a new main node;
determining the target flow weight of the new main node according to the initial flow weight of the main node;
and controlling the database cluster to read data according to the target flow weight of the new main node and the initial flow weight of the at least one read-only node.
2. The method of claim 1, wherein determining the target traffic weight for the new master node based on the initial traffic weight for the master node comprises:
determining a flow weight range according to the initial flow weight of the main node;
and selecting a traffic weight from the traffic weight range to determine the traffic weight as the target traffic weight of the new master node.
3. The method of claim 2, wherein determining a traffic weight range based on the initial traffic weight of the master node comprises:
acquiring a set weight offset;
determining a flow weight range according to the initial flow weight of the main node and the offset; wherein the traffic weight range is centered on an initial traffic weight of the master node.
4. The method of claim 1, wherein controlling the database cluster for data reading according to the target traffic weight of the new master node and the initial traffic weight of the at least one read-only node comprises:
determining a traffic distribution proportion between the new main node and the at least one read-only node according to the target traffic weight of the new main node and the initial traffic weight of the at least one read-only node;
and controlling the database cluster to read data according to the flow distribution proportion.
5. The method of claim 1, further comprising, after controlling the database cluster to perform data reading according to the target traffic weight of the new master node and the initial traffic weight of the at least one read-only node:
and if the main node is repaired, switching the main node into a new standby node, and adjusting the flow weight of the new standby node to a set value.
6. The flow distribution device of the database cluster is characterized in that the database cluster is arranged in a main node, a standby node and at least one read-only node; the device comprises:
an initial traffic weight obtaining module, configured to obtain initial traffic weights of the master node, the standby node, and the at least one read-only node; the initial flow weight of the standby node is a set value;
the master node switching module is used for switching the standby node to a new master node when the master node fails;
the target flow weight determining module is used for determining the target flow weight of the new main node according to the initial flow weight of the main node;
and the data reading module is used for controlling the database cluster to read data according to the target flow weight of the new master node and the initial flow weight of the at least one read-only node.
7. The apparatus of claim 6, wherein the target traffic weight determination module comprises:
a traffic weight range determining unit, configured to determine a traffic weight range according to the initial traffic weight of the master node;
and the target traffic weight determining unit is used for selecting a traffic weight from the traffic weight range and determining the selected traffic weight as the target traffic weight of the new main node.
8. The apparatus according to claim 7, wherein the traffic weight range determining unit is specifically configured to:
acquiring a set weight offset;
determining a flow weight range according to the initial flow weight of the main node and the offset; wherein the traffic weight range is centered on an initial traffic weight of the master node.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the method of database cluster traffic allocation of any of claims 1-5.
10. A computer-readable storage medium, having stored thereon computer instructions for causing a processor, when executed, to implement the method of database cluster traffic allocation of any of claims 1-5.
CN202211505030.9A 2022-11-28 2022-11-28 Database cluster flow distribution method, device, equipment and storage medium Pending CN115757635A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211505030.9A CN115757635A (en) 2022-11-28 2022-11-28 Database cluster flow distribution method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211505030.9A CN115757635A (en) 2022-11-28 2022-11-28 Database cluster flow distribution method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115757635A true CN115757635A (en) 2023-03-07

Family

ID=85339650

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211505030.9A Pending CN115757635A (en) 2022-11-28 2022-11-28 Database cluster flow distribution method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115757635A (en)

Similar Documents

Publication Publication Date Title
CN113986478A (en) Resource migration strategy determination method and device
CN114911598A (en) Task scheduling method, device, equipment and storage medium
WO2022199204A1 (en) Method and apparatus for determining resources
CN115964153A (en) Asynchronous task processing method, device, equipment and storage medium
CN115580645A (en) Service switching method and device, electronic equipment and storage medium
CN113608765A (en) Data processing method, device, equipment and storage medium
CN112887407B (en) Job flow control method and device for distributed cluster
CN113590329A (en) Resource processing method and device
CN115757635A (en) Database cluster flow distribution method, device, equipment and storage medium
CN113641688B (en) Node updating method, related device and computer program product
CN113360689B (en) Image retrieval system, method, related device and computer program product
CN115599438A (en) Method, device, equipment and medium for constructing application program publishing package
CN114070889A (en) Configuration method, traffic forwarding method, device, storage medium, and program product
CN112799879A (en) Node fault processing method, device, equipment and storage medium
CN113596172B (en) Method and device for updating nodes in distributed cluster
US20230080300A1 (en) Critical workload management in container-based computing environment
CN115913954A (en) Cluster management information interaction method, device, equipment and storage medium
CN115186032A (en) Database expansion method and device, electronic equipment and storage medium
CN115617454A (en) Containerization service deployment method, device, equipment and storage medium
CN117298599A (en) Game version scheduling method, system, equipment and storage medium
CN115617616A (en) Operation monitoring method, device and equipment of server FRU and storage medium
CN115658650A (en) Data migration method, device, equipment and storage medium
CN114356505A (en) Method, apparatus, device, medium and product for scheduling groups of containers
CN118041915A (en) Flow control method, device, equipment and storage medium
CN115934246A (en) Virtual machine creating method, device, equipment and medium

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