CN109614390A - Data base read-write separation method, device, service system, equipment and medium - Google Patents
Data base read-write separation method, device, service system, equipment and medium Download PDFInfo
- Publication number
- CN109614390A CN109614390A CN201811492169.8A CN201811492169A CN109614390A CN 109614390 A CN109614390 A CN 109614390A CN 201811492169 A CN201811492169 A CN 201811492169A CN 109614390 A CN109614390 A CN 109614390A
- Authority
- CN
- China
- Prior art keywords
- database
- database server
- operation instruction
- sending
- main
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000926 separation method Methods 0.000 title claims abstract description 34
- 238000012545 processing Methods 0.000 claims description 14
- 238000004590 computer program Methods 0.000 claims description 13
- 238000000034 method Methods 0.000 claims description 13
- 238000012790 confirmation Methods 0.000 claims description 12
- 238000011022 operating instruction Methods 0.000 abstract 8
- 210000004556 brain Anatomy 0.000 description 8
- 238000010586 diagram Methods 0.000 description 7
- 230000006870 function Effects 0.000 description 5
- 230000000694 effects Effects 0.000 description 3
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 125000004432 carbon atom Chemical group C* 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5083—Techniques for rebalancing the load in a distributed system
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Data base read-write separation method, device, service system, equipment and medium provided by the invention, belong to field of cloud calculation.The data base read-write separation method comprises determining that action type corresponding to received database operating instruction;The database operating instruction is sent to and is used to execute the database operating instruction with the matched database server of the action type, the database server.In the present invention, by determining action type corresponding to received database operating instruction;The database operating instruction is sent to and the matched database server of the action type, the database server is for executing the database operating instruction, the database operating instruction of same type will be sent to different database servers to realize, so that database server executes the database operating instruction received by itself, to realize that operation shunts, and then largely alleviate the load of database server cluster.
Description
Technical Field
The invention relates to the field of cloud computing, in particular to a database read-write separation method, a database read-write separation device, a database read-write separation service system, database read-write separation equipment and a database read-write separation medium.
Background
Due to the rapid development of cloud computing, the service volume of users is continuously increased, and the requirements on the reliability and performance of services are higher and higher. In an actual production environment, reading and writing of a redis (i.e., a Key-Value database) are in the same redis server, which cannot meet actual requirements. In order to separate read and write, the mainstream technology in the industry at present realizes high availability of a cluster based on keepalived, and realizes main read and write operations. When the master node fails, one of the slave nodes is selected by voting, and the vip is automatically switched to the slave node. The read-write operation of the user is distributed to a new main node, however, only one node bears the read-write operation under the actual normal condition, and the shunt of the read-write operation is not really realized.
Disclosure of Invention
In view of this, embodiments of the present invention provide a database read/write separation method, apparatus, service system, device, and medium.
In order to achieve the above purpose, the embodiment of the present invention adopts the following technical solutions:
in a first aspect, a method for separating read from write of a database provided in an embodiment of the present invention includes: determining an operation type corresponding to the received database operation instruction; and sending the database operation instruction to a database server matched with the operation type, wherein the database server is used for executing the database operation instruction. In the embodiment of the invention, the operation type corresponding to the received database operation instruction is determined; and sending the database operation instruction to a database server matched with the operation type, wherein the database server is used for executing the database operation instruction, so that the database operation instruction of the same type is sent to different database servers, the database server executes the received database operation instruction, the operation shunting is realized, and the load of a database server cluster is further reduced to a greater extent.
With reference to the first aspect, an embodiment of the present invention provides a first possible implementation manner of the first aspect, where sending the database operation instruction to a database server matched with the operation type includes: acquiring a database server cluster corresponding to the database operation instruction; determining whether the state information corresponding to the database server cluster meets a preset rule; and if so, sending the database operation instruction to a database server matched with the operation type in the database server cluster. In the embodiment of the invention, the identification information carried by the database operation instruction is quickly matched to the target database server cluster without being matched with the database servers in the database server cluster one by one, so that the time for inquiring the database server cluster can be reduced, and the use efficiency is improved. And further, when a preset rule is met, the database operation instruction is sent to a database server matched with the operation type in the database server cluster.
With reference to the first possible implementation manner of the first aspect, an embodiment of the present invention provides a second possible implementation manner of the first aspect, where determining whether state information corresponding to the database server cluster meets a preset rule includes: determining the main and standby states respectively corresponding to a plurality of database servers in the database server cluster; if the main and standby states corresponding to at least two database servers in the plurality of database servers are main states, state information corresponding to the database server cluster is represented not to meet a preset rule. In the embodiment of the invention, when the preset rule is not satisfied, the current database server cluster is judged to have a fault (namely, the database server cluster has split brain), and data is not written into the database server in the database server cluster. And then when the database server cluster has split brain (namely when there are at least two database servers in the master state), forbidding data writing to realize the technical effect of protecting the safety of data, thereby overcoming the technical problem that the consistency of data can be broken when two masters write data simultaneously under the condition that the cluster has split brain in the prior art.
With reference to the second possible implementation manner of the first aspect, an embodiment of the present invention provides a third possible implementation manner of the first aspect, where sending the database operation instruction to a database server matched with the operation type includes: determining whether the operation type matches a first type; if so, sending the database operation instruction to the database server corresponding to the main/standby state as the main state; or, determining whether the operation type matches a second type; and if so, sending the database operation instruction to the database server corresponding to the master/standby state as the standby state. In the embodiment of the present invention, the different types of database operation instructions are sent to the database servers in different active/standby states, so as to implement operation shunting, that is, a first type of database operation instruction is executed on the database server corresponding to the active state, and a second type of database operation instruction is executed on the database server corresponding to the standby state. Therefore, the processing pressure of the database server can be effectively reduced, and the load of the database server cluster is greatly reduced.
With reference to the second possible implementation manner of the first aspect, an embodiment of the present invention provides a fourth possible implementation manner of the first aspect, where the determining the active/standby states respectively corresponding to the multiple databases in the database server cluster includes: sending a master/slave status confirmation request to each database server in the database server cluster; and receiving the main/standby state corresponding to the database server returned by each database server according to the main/standby state confirmation request. In the embodiment of the invention, the master/standby state of each database server in the database server cluster is confirmed by sending the master/standby state confirmation request, so that the condition that the database operation instruction is sent to the database server cluster with a fault is effectively avoided, and the data processing efficiency is improved.
With reference to the second possible implementation manner of the first aspect, an embodiment of the present invention provides a fifth possible implementation manner of the first aspect, where sending the database operation instruction to a database server matched with the operation type includes: determining whether the operation type is a write operation; if so, sending the database operation instruction to the database server corresponding to the main/standby state as the main state; or, determining whether the operation type is a read operation; and if so, sending the database operation instruction to the database server corresponding to the master/standby state as the standby state. In the embodiment of the invention, the database operation instruction of the write operation is sent to the database server corresponding to the main state, and the database operation instruction of the read operation is sent to the database server corresponding to the main standby state, so that the read-write operation is shunted, that is, the data is written by the database server in the main state, the data is read by the database servers corresponding to the standby states, and the load of a database server cluster is further reduced to a greater extent.
In a second aspect, an embodiment of the present invention provides a database read-write separation apparatus, including: the processing module is used for determining the operation type corresponding to the received database operation instruction; and the sending module is used for sending the database operation instruction to a database server matched with the operation type, and the database server is used for executing the database operation instruction.
In a third aspect, a service system provided in an embodiment of the present invention includes at least one load balancer and a plurality of database servers; the load balancer is used for determining an operation type corresponding to the received database operation instruction; sending the database operation instruction to a database server matched with the operation type; the plurality of database servers are used for executing the database operation instructions received by the plurality of database servers.
In a fourth aspect, a terminal device provided in an embodiment of the present invention includes: a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the database read-write separation method according to any one of the first aspect when executing the computer program.
In a fifth aspect, an embodiment of the present invention provides a storage medium, where the storage medium is configured to store instructions, and when the instructions are executed on a computer, the instructions cause the computer to perform the database read-write separation method according to any one of the first aspect.
Additional features and advantages of the disclosure will be set forth in the description which follows, or in part may be learned by the practice of the above-described techniques of the disclosure, or may be learned by practice of the disclosure.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
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 database read-write separation method according to a first embodiment of the present invention;
fig. 2 is a functional block diagram of a database read-write separation apparatus according to a second embodiment of the present invention;
fig. 3 is a schematic diagram of a service system according to a third embodiment of the present invention;
FIG. 4 is a schematic diagram of another service system shown in FIG. 3;
fig. 5 is a schematic diagram of a terminal device according to a fourth embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, 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 some, but not all, embodiments of the present invention. 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. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. 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.
Some embodiments of the invention are described in detail below with reference to the accompanying drawings. The embodiments described below and the features of the embodiments can be combined with each other without conflict.
First embodiment
The present embodiment provides a database read/write separation method, it should be noted that the steps shown in the flowchart of the drawings may be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in an order different from that shown. The present embodiment will be described in detail below.
Fig. 1 is a flowchart of a database read-write separation method according to an embodiment of the present invention. The specific process shown in FIG. 1 will be described in detail below.
Step S101, determining the operation type corresponding to the received database operation instruction.
Optionally, the operation types include a first type and a second type.
Optionally, the first type is used to characterize write operations, i.e., operations that write data to the database server. The second type is used for characterizing a read operation, namely an operation for reading data from the database server according to the database operation instruction.
Alternatively, the database server may be a redis server.
Optionally, the database operation instruction is initiated by a user through a terminal device (such as a computer or a server).
Optionally, determining the operation type corresponding to the received database operation instruction includes: receiving a database operation instruction sent by a user, and determining an operation type corresponding to the database operation instruction.
And step S102, sending the database operation instruction to a database server matched with the operation type, wherein the database server is used for executing the database operation instruction.
Optionally, the number of database servers is at least two.
As an implementation scenario, when a plurality of database servers form a database server cluster, step S102 includes: acquiring a database server cluster corresponding to the database operation instruction; determining whether the state information corresponding to the database server cluster meets a preset rule; and if so, sending the database operation instruction to a database server matched with the operation type in the database server cluster. And if not, deleting the database operation instruction.
Optionally, the database server cluster matched with the identification information may be queried through the identification information used for characterizing the database server cluster and carried by the database operation instruction.
Alternatively, the number of database server clusters may be plural.
For example, if there are a plurality of database server clusters currently, the plurality of database server clusters are G1, G2, and G3, respectively, and the identification information carried by the database operation command is G1, the database server cluster corresponding to the database operation command is G1 by querying the identification information.
In the embodiment of the invention, the identification information carried by the database operation instruction is quickly matched to the target database server cluster without being matched with the database servers in the database server cluster one by one, so that the time for inquiring the database server cluster can be reduced, and the use efficiency is improved.
Optionally, the determining whether the state information corresponding to the database server cluster meets a preset rule includes: determining the main and standby states respectively corresponding to a plurality of database servers in the database server cluster; if the main and standby states corresponding to at least two database servers in the plurality of database servers are main states, state information corresponding to the database server cluster is represented not to meet a preset rule.
When at least two database servers in the database server cluster are in the main state, the preset rule is not met.
Optionally, when the preset rule is not satisfied, it is determined that the current database server cluster fails (i.e., a database server cluster has a split brain), and data is not written into the database servers in the database server cluster. And then when the database server cluster has split brain (namely when there are at least two database servers in the master state), forbidding data writing to realize the technical effect of protecting the safety of data, thereby overcoming the technical problem that the consistency of data can be broken when two masters write data simultaneously under the condition that the cluster has split brain in the prior art.
Optionally, the determining the active/standby states respectively corresponding to the multiple databases in the database server cluster includes: sending a master/slave status confirmation request to each database server in the database server cluster; and receiving the main/standby state corresponding to the database server returned by each database server according to the main/standby state confirmation request.
Optionally, the active/standby state confirmation request may be sent in real time, or may be sent when receiving an operation instruction of the database. The master-slave state confirmation request is used for confirming master-slave state information of each database server in the database server cluster corresponding to the database operation instruction.
In the embodiment of the invention, the master/standby state of each database server in the database server cluster is confirmed by sending the master/standby state confirmation request, so that the condition that the database operation instruction is sent to the database server cluster with a fault is effectively avoided, and the data processing efficiency is improved.
As an implementation scenario, when a database server in a database server cluster in a current master state fails, a database server in a standby state in the database server cluster elects a new master database server through automatic election.
Optionally, a weight value corresponding to each database server in the standby state is obtained, the database server in the standby state with the largest weight value is obtained, and the database server in the standby state with the largest weight value is used as a new master database server. The weight setting may be set according to a Central Processing Unit (CPU) of the database server in the standby state and/or a bandwidth.
Of course, in actual use, the new master database server may be selected in other ways. Here, the number of the carbon atoms is not particularly limited.
In the embodiment of the invention, the master-slave state information of each database server in the database server cluster is determined, so that the technical effect of protecting the data safety can be effectively avoided by prohibiting data writing when the database server cluster has a split brain (namely when at least two database servers in master states exist), and the technical problem that the consistency of the data can be broken when the two master-slave data are written simultaneously when the cluster has the split brain in the prior art is further solved.
Optionally, the sending the database operation instruction to the database server matched with the operation type includes: determining whether the operation type matches a first type; if so, sending the database operation instruction to the database server corresponding to the main/standby state as the main state; or, determining whether the operation type matches a second type; and if so, sending the database operation instruction to the database server corresponding to the master/standby state as the standby state.
In the embodiment of the present invention, the different types of database operation instructions are sent to the database servers in different active/standby states, so as to implement operation shunting, that is, a first type of database operation instruction is executed on the database server corresponding to the active state, and a second type of database operation instruction is executed on the database server corresponding to the standby state. Therefore, the processing pressure of the database server can be effectively reduced, and the load of the database server cluster is greatly reduced.
Optionally, the sending the database operation instruction to the database server matched with the operation type includes: determining whether the operation type is a write operation; if so, sending the database operation instruction to the database server corresponding to the main/standby state as the main state; or, determining whether the operation type is a read operation; and if so, sending the database operation instruction to the database server corresponding to the master/standby state as the standby state.
The write operation refers to an operation of writing data. The read operation is an operation of reading data from the database server.
In the embodiment of the invention, the database operation instruction of the write operation is sent to the database server corresponding to the main state, and the database operation instruction of the read operation is sent to the database server corresponding to the main standby state, so that the read-write operation is shunted, that is, the data is written by the database server in the main state, the data is read by the database servers corresponding to the standby states, and the load of a database server cluster is further reduced to a greater extent.
The database read-write separation method provided by the embodiment of the invention determines the operation type corresponding to the received database operation instruction; and sending the database operation instruction to a database server matched with the operation type, wherein the database server is used for executing the database operation instruction, so that the database operation instruction of the same type is sent to different database servers, the database server executes the received database operation instruction, the operation shunting is realized, and the load of a database server cluster is further reduced to a greater extent.
Second embodiment
Fig. 2 shows a database read-write separation apparatus that uses the database read-write separation method shown in the first embodiment in a one-to-one correspondence, corresponding to the database read-write separation method in the first embodiment. As shown in fig. 2, the database read-write separation apparatus 200 includes a processing module 210 and a sending module 220. The implementation functions of the processing module 210 and the sending module 220 correspond to the corresponding steps in the first embodiment one to one, and for avoiding repeated descriptions, detailed descriptions are not needed in this embodiment.
The processing module 210 is configured to determine an operation type corresponding to the received database operation instruction.
A sending module 220, configured to send the database operation instruction to a database server matched with the operation type, where the database server is configured to execute the database operation instruction.
Optionally, the sending module 220 is further configured to obtain a database server cluster corresponding to the database operation instruction; determining whether the state information corresponding to the database server cluster meets a preset rule; and if so, sending the database operation instruction to a database server matched with the operation type in the database server cluster.
Optionally, the determining whether the state information corresponding to the database server cluster meets a preset rule includes: determining the main and standby states respectively corresponding to a plurality of database servers in the database server cluster; if the main and standby states corresponding to at least two database servers in the plurality of database servers are main states, state information corresponding to the database server cluster is represented not to meet a preset rule.
Optionally, the sending the database operation instruction to the database server matched with the operation type includes: determining whether the operation type matches a first type; if so, sending the database operation instruction to the database server corresponding to the main/standby state as the main state; or, determining whether the operation type matches a second type; and if so, sending the database operation instruction to the database server corresponding to the master/standby state as the standby state.
Optionally, the determining the active/standby states respectively corresponding to the multiple databases in the database server cluster includes: sending a master/slave status confirmation request to each database server in the database server cluster; and receiving the main/standby state corresponding to the database server returned by each database server according to the main/standby state confirmation request.
Optionally, the sending the database operation instruction to the database server matched with the operation type includes: determining whether the operation type is a write operation; if so, sending the database operation instruction to the database server corresponding to the main/standby state as the main state; or, determining whether the operation type is a read operation; and if so, sending the database operation instruction to the database server corresponding to the master/standby state as the standby state.
Third embodiment
As shown in fig. 3, a schematic diagram of a service system 300 is shown. Service system 300 includes at least one load balancer 310 and a plurality of database servers 320.
Optionally, the at least one load balancer 310 is configured to determine an operation type corresponding to the received database operation instruction; and sending the database operation instruction to the database server 320 matched with the operation type.
Optionally, at least one load balancer 310 is configured to perform the database read/write separation method as in the first embodiment, and details are not repeated here to avoid repetition.
The plurality of database servers 320 are configured to execute the database operation instructions received by themselves.
As an implementation scenario, the load balancers 310 form a load balancer cluster, and as shown in fig. 4, the load balancer cluster includes a main load balancer (i.e., a load balancer with a main standby state) and two load balancers with main standby states. In the initial state, the primary load balancer is configured to execute the database read/write separation method in the first embodiment, and when the primary load balancer fails, a new primary load balancer is determined by determining weights of two load balancers in the primary and standby states, and at this time, the new primary load balancer continues to execute the database read/write separation method in the first embodiment, thereby effectively improving the effectiveness and high availability of database read/write separation of the service system 300. And further, even if the current main load balancer breaks down, a new main load balancer can be determined to realize database read-write separation, and further, the service processing capacity and stability of the service system 300 are improved.
As an implementation scenario, the main load balancer is associated with a floating IP (Internet Protocol) address, so that the user can access the service system 300 through the floating IP address. When the main load balancer has a fault, the floating IP address is automatically associated with the new main load balancer (for example, by acquiring the main/standby state information of the load balancer, determining the main/standby state of the load balancer through the main/standby state information, and associating the floating IP address with the load balancer in the main state when the main/standby state of the load balancer is in the main state), and further, when the main load balancer is out of order, the user can still access the service system 300 through the floating IP address, and now the floating IP address of the service system 300 does not need to be strongly bound to the master node of the database server 320, further, the technical problems that when a database server cluster breaks down, floating IP addresses can not be switched simultaneously with a main database server under special conditions and abnormal service conditions occur in the prior art are solved.
Optionally, the obtaining manner of the active/standby state information of the load balancer may refer to the active/standby state obtaining manner of the database server in the first embodiment. Here, the description is omitted.
Fourth embodiment
As shown in fig. 5, a schematic diagram of a terminal device 400 is shown. The terminal device 400 includes a memory 402, a processor 404, and a computer program 403 stored in the memory 402 and capable of running on the processor 404, where the computer program 403 implements the database read-write separation method in the first embodiment when executed by the processor 404, and details are not repeated here to avoid repetition. Alternatively, the computer program 403, when executed by the processor 404, implements the functions of the modules/units in the database read-write separation apparatus according to the second embodiment, and is not described herein again to avoid repetition.
Illustratively, the computer program 403 may be partitioned into one or more modules/units, which are stored in the memory 402 and executed by the processor 404 to implement the present invention. One or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program 403 in the terminal device 400. For example, the computer program 403 may be divided into the processing module 210 and the sending module 220 in the second embodiment, and specific functions of the modules are as described in the first embodiment or the second embodiment, which are not described herein again.
The Memory 402 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Read-Only Memory (EPROM), an electrically Erasable Read-Only Memory (EEPROM), and the like. The memory 402 is used for storing a program, and the processor 404 executes the program after receiving an execution instruction, and the method defined by the flow disclosed in any of the foregoing embodiments of the present invention may be applied to the processor 404, or implemented by the processor 404.
The processor 404 may be an integrated circuit chip having signal processing capabilities. The processor 404 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Optionally, the terminal device 400 is a load balancer.
It is understood that the structure shown in fig. 5 is only a schematic structural diagram of the terminal device 400, and the terminal device 400 may further include more or less components than those shown in fig. 5. The components shown in fig. 5 may be implemented in hardware, software, or a combination thereof.
Fifth embodiment
An embodiment of the present invention further provides a storage medium, where the storage medium is used to store an instruction, and when the instruction runs on a computer, the computer program is executed by a processor to implement the database read-write separation method in the first embodiment, and details are not repeated here in order to avoid repetition. Alternatively, the computer program, when executed by the processor, implements the functions of the modules/units in the database read-write separation apparatus according to the second embodiment, and is not described herein again to avoid repetition.
From the above description of the embodiments, it is clear to those skilled in the art that the present invention can be implemented by hardware, or by software plus a necessary general hardware platform, and based on such understanding, the technical solution of the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a usb disk, a removable hard disk, etc.), and includes several instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the method of the various implementation scenarios of the present invention.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
Claims (10)
1. A method for separating read and write of a database is characterized by comprising the following steps:
determining an operation type corresponding to the received database operation instruction;
and sending the database operation instruction to a database server matched with the operation type, wherein the database server is used for executing the database operation instruction.
2. The method of claim 1, wherein sending the database operation instruction to a database server matched with the operation type comprises:
acquiring a database server cluster corresponding to the database operation instruction;
determining whether the state information corresponding to the database server cluster meets a preset rule;
and if so, sending the database operation instruction to a database server matched with the operation type in the database server cluster.
3. The method of claim 2, wherein the determining whether the state information corresponding to the database server cluster meets a preset rule comprises:
determining the main and standby states respectively corresponding to a plurality of database servers in the database server cluster;
if the main and standby states corresponding to at least two database servers in the plurality of database servers are main states, state information corresponding to the database server cluster is represented not to meet a preset rule.
4. The method of claim 3, wherein sending the database operation instruction to a database server matching the operation type comprises:
determining whether the operation type matches a first type;
if so, sending the database operation instruction to the database server corresponding to the main/standby state as the main state; or,
determining whether the operation type matches a second type;
and if so, sending the database operation instruction to the database server corresponding to the master/standby state as the standby state.
5. The method of claim 3, wherein the determining the active/standby states respectively corresponding to the plurality of databases in the database server cluster comprises:
sending a master/slave status confirmation request to each database server in the database server cluster;
and receiving the main/standby state corresponding to the database server returned by each database server according to the main/standby state confirmation request.
6. The method of claim 3, wherein sending the database operation instruction to a database server matching the operation type comprises:
determining whether the operation type is a write operation;
if so, sending the database operation instruction to the database server corresponding to the main/standby state as the main state; or,
determining whether the operation type is a read operation;
and if so, sending the database operation instruction to the database server corresponding to the master/standby state as the standby state.
7. A database read-write separation apparatus, comprising:
the processing module is used for determining the operation type corresponding to the received database operation instruction;
and the sending module is used for sending the database operation instruction to a database server matched with the operation type, and the database server is used for executing the database operation instruction.
8. A service system comprising at least one load balancer and a plurality of database servers; wherein,
the at least one load balancer is used for determining an operation type corresponding to the received database operation instruction; sending the database operation instruction to a database server matched with the operation type;
the plurality of database servers are used for executing the database operation instructions received by the plurality of database servers.
9. A terminal device, comprising: memory, processor and computer program stored in the memory and executable on the processor, the processor implementing the steps of the database read-write separation method according to any one of claims 1 to 6 when executing the computer program.
10. A storage medium for storing instructions which, when run on a computer, cause the computer to perform a database read-write separation method according to any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811492169.8A CN109614390A (en) | 2018-12-06 | 2018-12-06 | Data base read-write separation method, device, service system, equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811492169.8A CN109614390A (en) | 2018-12-06 | 2018-12-06 | Data base read-write separation method, device, service system, equipment and medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109614390A true CN109614390A (en) | 2019-04-12 |
Family
ID=66008333
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811492169.8A Pending CN109614390A (en) | 2018-12-06 | 2018-12-06 | Data base read-write separation method, device, service system, equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109614390A (en) |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110297867A (en) * | 2019-06-28 | 2019-10-01 | 浪潮云信息技术有限公司 | Data-base cluster operation method and system based on domestic CPU and distributed container cluster |
CN110427353A (en) * | 2019-06-27 | 2019-11-08 | 华迪计算机集团有限公司 | The method and device of database server cluster read and write abruption setting |
CN111078802A (en) * | 2019-12-31 | 2020-04-28 | 叮当快药科技集团有限公司 | Database reading and writing method and related device |
CN112100208A (en) * | 2020-09-08 | 2020-12-18 | 北京金山云网络技术有限公司 | Operation request forwarding method and device |
CN112115202A (en) * | 2020-09-18 | 2020-12-22 | 北京人大金仓信息技术股份有限公司 | Task distribution method and device in cluster environment |
CN112235332A (en) * | 2019-07-15 | 2021-01-15 | 北京京东尚科信息技术有限公司 | Read-write switching method and device for cluster |
CN112506962A (en) * | 2020-11-10 | 2021-03-16 | 中软国际科技服务南京有限公司 | High-performance database read-write separation method |
CN113204592A (en) * | 2021-05-20 | 2021-08-03 | 远景智能国际私人投资有限公司 | Data processing method, system and device under scene of Internet of things and storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104780115A (en) * | 2014-01-14 | 2015-07-15 | 上海盛大网络发展有限公司 | Load balancing method and load balancing system in cloud computing environment |
CN105553701A (en) * | 2015-12-11 | 2016-05-04 | 国网青海省电力公司 | Distribution network adjustment and control system and control method thereof |
CN106850759A (en) * | 2016-12-31 | 2017-06-13 | 广州勤加缘科技实业有限公司 | MySQL database clustering methods and its processing system |
CN107508694A (en) * | 2016-06-14 | 2017-12-22 | 中兴通讯股份有限公司 | Node administration method and node device in a kind of cluster |
CN108763572A (en) * | 2018-06-06 | 2018-11-06 | 湖南蚁坊软件股份有限公司 | A kind of method and apparatus for realizing Apache Solr read and write abruptions |
-
2018
- 2018-12-06 CN CN201811492169.8A patent/CN109614390A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104780115A (en) * | 2014-01-14 | 2015-07-15 | 上海盛大网络发展有限公司 | Load balancing method and load balancing system in cloud computing environment |
CN105553701A (en) * | 2015-12-11 | 2016-05-04 | 国网青海省电力公司 | Distribution network adjustment and control system and control method thereof |
CN107508694A (en) * | 2016-06-14 | 2017-12-22 | 中兴通讯股份有限公司 | Node administration method and node device in a kind of cluster |
CN106850759A (en) * | 2016-12-31 | 2017-06-13 | 广州勤加缘科技实业有限公司 | MySQL database clustering methods and its processing system |
CN108763572A (en) * | 2018-06-06 | 2018-11-06 | 湖南蚁坊软件股份有限公司 | A kind of method and apparatus for realizing Apache Solr read and write abruptions |
Non-Patent Citations (2)
Title |
---|
匿名: "split-brain 脑裂问题(Keepalived)", 《博客园URL: HTTPS://WWW.CNBLOGS.COM/KEVINGRACE/P/7205846.HTML》 * |
匿名: "数据库水平切分的实现原理解析——分库,分表,主从,集群,负载均衡器", 《博客园URL:HTTPS://WWW.CNBLOGS.COM/ZHONGXINWANG/P/4262650.HTML》 * |
Cited By (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110427353A (en) * | 2019-06-27 | 2019-11-08 | 华迪计算机集团有限公司 | The method and device of database server cluster read and write abruption setting |
CN110427353B (en) * | 2019-06-27 | 2022-07-26 | 华迪计算机集团有限公司 | Method and device for separately setting reading and writing of database server cluster |
CN110297867A (en) * | 2019-06-28 | 2019-10-01 | 浪潮云信息技术有限公司 | Data-base cluster operation method and system based on domestic CPU and distributed container cluster |
CN110297867B (en) * | 2019-06-28 | 2021-08-17 | 浪潮软件集团有限公司 | Database cluster operation method and system based on domestic CPU and distributed container cluster |
CN112235332A (en) * | 2019-07-15 | 2021-01-15 | 北京京东尚科信息技术有限公司 | Read-write switching method and device for cluster |
CN112235332B (en) * | 2019-07-15 | 2024-01-16 | 北京京东尚科信息技术有限公司 | Method and device for switching reading and writing of clusters |
CN111078802A (en) * | 2019-12-31 | 2020-04-28 | 叮当快药科技集团有限公司 | Database reading and writing method and related device |
CN112100208A (en) * | 2020-09-08 | 2020-12-18 | 北京金山云网络技术有限公司 | Operation request forwarding method and device |
CN112115202A (en) * | 2020-09-18 | 2020-12-22 | 北京人大金仓信息技术股份有限公司 | Task distribution method and device in cluster environment |
CN112506962A (en) * | 2020-11-10 | 2021-03-16 | 中软国际科技服务南京有限公司 | High-performance database read-write separation method |
CN113204592A (en) * | 2021-05-20 | 2021-08-03 | 远景智能国际私人投资有限公司 | Data processing method, system and device under scene of Internet of things and storage medium |
CN113204592B (en) * | 2021-05-20 | 2023-07-21 | 远景智能国际私人投资有限公司 | Data processing method, system and device in Internet of things scene and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109614390A (en) | Data base read-write separation method, device, service system, equipment and medium | |
US10642704B2 (en) | Storage controller failover system | |
US11586673B2 (en) | Data writing and reading method and apparatus, and cloud storage system | |
CN107943421B (en) | Partition division method and device based on distributed storage system | |
CN112597153B (en) | Block chain-based data storage method, device and storage medium | |
EP3767470B1 (en) | Central processing unit cpu hot-remove method and apparatus, and central processing unit cpu hot-add method and apparatus | |
CN104504147B (en) | A kind of resource coordination method of data-base cluster, apparatus and system | |
CN109873714B (en) | Cloud computing node configuration updating method and terminal equipment | |
CN107181636B (en) | Health check method and device in load balancing system | |
CN105701099A (en) | Method and device used for executing task in distributed environment, and distributed task execution system | |
CN114168071B (en) | Distributed cluster capacity expansion method, distributed cluster capacity expansion device and medium | |
CN106570091B (en) | Method for enhancing high availability of distributed cluster file system | |
CN110275772B (en) | Data processing method and related equipment thereof | |
CN115033551A (en) | Database migration method and device, electronic equipment and storage medium | |
CN111046004B (en) | Data file storage method, device, equipment and storage medium | |
US11301436B2 (en) | File storage method and storage apparatus | |
CN111614701B (en) | Distributed cluster and container state switching method and device | |
CN105373451B (en) | The method and device that a kind of virtual machine is placed | |
CN107294781B (en) | Method and system for cluster configuration node failover | |
CN112181829B (en) | User distribution method, device, terminal and medium for AB experiment | |
CN113986846A (en) | Data processing method, system, device and storage medium | |
CN114443415A (en) | Acquisition automatic balancing method, task distributor and system for Prometheus | |
CN113051143A (en) | Detection method, device, equipment and storage medium for service load balancing server | |
CN111885159A (en) | Data acquisition method and device, electronic equipment and storage medium | |
CN111198649A (en) | Disk selection method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20190412 |