Database allocation method, device, system, equipment, medium and product
By establishing a mutually-primary relationship between multiple databases in the payment system and implementing a method of quickly switching to a standby database in the application load balancing server, the problem of long database switching time in the prior art is solved, and the data processing recovery efficiency is improved.
Patent Information
- Application Number
- CN202110632970.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-07
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2041-06-07
AI Technical Summary
In the existing payment system, it takes a long time to switch from the primary database to the standby database, resulting in low efficiency in data processing and recovery process.
By implementing the database allocation method in the application load balancing server, the communication connection between the application load balancing server and the pre-server cluster and the application server cluster is established to establish a mutually-primary relationship between multiple databases. After receiving the downtime database switching instruction, determine the downtime database and its standby database, and forward the pending request to the standby database to realize rapid switching and data processing recovery.
By quickly switching to the standby database, the recovery process efficiency of the payment system data processing is significantly improved and the data processing delay caused by downtime is reduced.
Smart Images

Figure CN113239020B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of data processing technology, and in particular, to a database allocation method, device, system, equipment, medium and product. Background Art
[0002] With the rapid development of e-commerce in recent years, the demand for online consumption has also increased year by year. Users submit agreement payment applications through payment institutions, which initiate agreement payment applications to the China UnionPay or UnionPay platform. The platform accepts and forwards the agreement payment applications to the paying bank. The application server cluster inside the paying bank accesses the database storing the user contract data corresponding to the user to complete the agreement payment related processing. Online consumption requires the bank's payment system to provide basic services to handle the huge transaction data flow during online transactions. At certain times of the year, the bank's payment system database crashes due to the excessive online transaction data flow. Once the bank's payment system database crashes, it will have a great impact on online payments.
[0003] At present, the main way to deal with database failure in payment systems is to set up two databases, primary and backup. Normally, only the primary database is running. When the primary database fails, the backup database can be started to replace the primary database to provide data processing support. However, it currently takes a long time to switch from the primary database to the backup database, resulting in a low efficiency in the recovery process of data processing in the payment system. Summary of the invention
[0004] The present invention provides a database allocation method, device, system, equipment, medium and product, which are used to solve the problem that it takes a long time to switch from a main database to a backup database, resulting in low efficiency of the recovery process of data processing in the payment system.
[0005] A first aspect of an embodiment of the present invention provides a database allocation method, which is applied to an application load balancing server, wherein the application load balancing server is respectively connected to a front-end server cluster and an application server cluster; the application server cluster is connected to a corresponding database in a database cluster, each database in the database cluster is in a master-slave relationship with at least one other database, and the databases in the master-slave relationship store the same user contract data; the method comprises:
[0006] Receive information data;
[0007] If it is determined that the information data is a processing request message sent by the front-end server cluster, the processing request message is forwarded to the corresponding application server cluster according to the processing request message and a preset cluster forwarding strategy, so that the application server cluster accesses the corresponding database to perform corresponding data processing according to the received processing request message;
[0008] If it is determined that the information data is a downtime database switching instruction, the downtime database and a backup database in a master-backup relationship with the downtime database are determined according to the downtime database switching instruction, and when a request message for adjustment processing to be forwarded to the application server cluster corresponding to the downtime database is received, the request message for adjustment processing is forwarded to the application server cluster corresponding to the backup database.
[0009] Optionally, in the method as described above, the processing request message includes a transaction request message; the transaction request message includes user card number information;
[0010] The forwarding of the processing request message to the corresponding application server cluster according to the processing request message and a preset cluster forwarding strategy is specifically used for:
[0011] Determine a random number of preset digits in the user card number information according to the user card number information;
[0012] The transaction request message is forwarded to the corresponding application server cluster according to the random number and a preset cluster forwarding strategy.
[0013] Optionally, in the above method, before forwarding the transaction request message to the corresponding application server cluster according to the random number and the preset cluster forwarding strategy, the method further includes:
[0014] Determine the quotient between the total number of random numbers and the number of application server clusters as a cluster random number interval;
[0015] Sorting the application server clusters, and assigning corresponding random number forwarding intervals to the sorted application server clusters according to the cluster random number intervals and the total number of random numbers;
[0016] The forwarding of the transaction request message to a corresponding application server cluster according to the random number and a preset cluster forwarding strategy includes:
[0017] Determine the random number forwarding interval to which the random number in the transaction request message belongs, and forward the transaction request message to the application server cluster corresponding to the random number forwarding interval.
[0018] Optionally, in the method as described above, determining the downtime database and a standby database in a master-standby relationship with the downtime database according to the downtime database switching instruction includes:
[0019] Determine the corresponding downtime database according to the downtime database switching instruction input by the user;
[0020] A standby database corresponding to the downtime database is determined according to the master-standby relationship between the downtime database and other databases.
[0021] Optionally, in the method described above, the number of databases in a master-slave relationship with the downtime database is greater than or equal to two;
[0022] The method of determining the downtime database and the standby database in a master-standby relationship with the downtime database according to the downtime database switching instruction includes:
[0023] Select a corresponding database from databases that have a master-slave relationship with the downed database according to a preset selection strategy;
[0024] The selected corresponding database is determined as a standby database corresponding to the downtime database.
[0025] Optionally, in the method as described above, after determining the downtime database and the standby database in a master-standby relationship with the downtime database according to the downtime database switching instruction, the method further includes:
[0026] Delete the random number forwarding interval of the downtime database;
[0027] The random number forwarding interval of the standby database in the master-standby relationship with the downtime database is modified to be the sum of the original random number forwarding interval of the downtime database and the original random number forwarding interval of the standby database.
[0028] Optionally, in the method described above, the processing request message is allocated to the target front-end server cluster by the front-end load balancing server according to a preset allocation strategy; the processing request message of the front-end load balancing server is sent by the payment clearing system of the forwarding agency.
[0029] Optionally, in the method as described above, the processing request message includes transaction flow information;
[0030] The target front-end server cluster performs hash calculation on the transaction flow information of the processing request message for the front-end load balancing server to obtain the forwarding allocation value, and determines it according to the forwarding allocation value and the allocation value forwarding interval to which the forwarding allocation value belongs;
[0031] The forwarding allocation value is the last two digits of the corresponding hash value; the allocation value forwarding interval corresponding to each front-end server cluster is allocated to the sorted front-end server cluster by the front-end load balancing server based on the cluster allocation value interval and the total number of the forwarding allocation values; the cluster allocation value interval is determined by the front-end load balancing server taking the quotient between the total number of forwarding allocation values and the number of the front-end server clusters.
[0032] Optionally, in the method described above, the front-end server cluster is communicatively connected to a query database; the processing request message includes a query request message; the query request message includes transaction flow information but does not include user card number information;
[0033] The information received by the application load balancing server and sent by the front-end server cluster includes a query request message and user card number information. The front-end server cluster obtains the corresponding user card number information from the query database based on the transaction flow information in the query request message, and sends the user card number information to the load balancing server.
[0034] A second aspect of an embodiment of the present invention provides a database allocation device, the device is located in an application load balancing server, the application load balancing server is respectively connected to a front-end server cluster and an application server cluster; the application server cluster is connected to a corresponding database in a database cluster, each database in the database cluster is in a master-slave relationship with at least one other database, and the databases in the master-slave relationship store the same user contract data; the device includes:
[0035] A receiving module, used for receiving information data;
[0036] A data processing module, for forwarding the processing request message to a corresponding application server cluster according to the processing request message and a preset cluster forwarding strategy if it is determined that the information data is a processing request message sent by a front-end server cluster, so that the application server cluster accesses a corresponding database to perform corresponding data processing according to the received processing request message;
[0037] A downtime processing module is used to determine the downtime database and a backup database in a master-backup relationship with the downtime database according to the downtime database switching instruction if the information data is determined to be a downtime database switching instruction, and when receiving a request message for adjustment processing to be forwarded to the application server cluster corresponding to the downtime database, forward the request message for adjustment processing to the application server cluster corresponding to the backup database.
[0038] Optionally, in the above device, the processing request message includes a transaction request message; the transaction request message includes user card number information;
[0039] When the data processing module forwards the processing request message to the corresponding application server cluster according to the processing request message and the preset cluster forwarding strategy, it is specifically used to:
[0040] A random number of preset digits in the user card number information is determined according to the user card number information; and the transaction request message is forwarded to a corresponding application server cluster according to the random number and a preset cluster forwarding strategy.
[0041] Optionally, in the above device, the data processing module is further used for:
[0042] Determine the quotient of the total number of random numbers and the number of the application server clusters as the cluster random number interval; sort the application server clusters, and assign corresponding random number forwarding intervals to the sorted application server clusters according to the cluster random number interval and the total number of random numbers;
[0043] When the data processing module forwards the transaction request message to the corresponding application server cluster according to the random number and the preset cluster forwarding strategy, it is specifically used to:
[0044] Determine the random number forwarding interval to which the random number in the transaction request message belongs, and forward the transaction request message to the application server cluster corresponding to the random number forwarding interval.
[0045] Optionally, in the above-mentioned device, when the downtime processing module determines the downtime database and the standby database in a master-standby relationship with the downtime database according to the downtime database switching instruction, it is specifically used to:
[0046] The corresponding downtime database is determined according to the downtime database switching instruction input by the user; and the backup database corresponding to the downtime database is determined according to the master-backup relationship between the downtime database and other databases.
[0047] Optionally, in the device as described above, the number of databases in a master-slave relationship with the downtime database is greater than or equal to two;
[0048] When the downtime processing module determines the downtime database and the standby database in a master-standby relationship with the downtime database according to the downtime database switching instruction, it is specifically used to:
[0049] According to a preset selection strategy, a corresponding database is selected from databases that have a master-slave relationship with the downtime database; and the selected corresponding database is determined as a standby database corresponding to the downtime database.
[0050] Optionally, in the above device, the downtime processing module is further used for:
[0051] Delete the random number forwarding interval of the downtime database; modify the random number forwarding interval of the standby database in the master-standby relationship with the downtime database to the sum of the original random number forwarding interval of the downtime database and the original random number forwarding interval of the standby database.
[0052] Optionally, in the device as described above, the processing request message is allocated to the target front-end server cluster by the front-end load balancing server according to a preset allocation strategy; the processing request message of the front-end load balancing server is sent by the payment clearing system of the forwarding agency.
[0053] Optionally, in the device as described above, the processing request message includes transaction flow information;
[0054] The target front-end server cluster performs hash calculation on the transaction flow information of the processing request message for the front-end load balancing server to obtain the forwarding allocation value, and determines it according to the forwarding allocation value and the allocation value forwarding interval to which the forwarding allocation value belongs;
[0055] The forwarding allocation value is the last two digits of the corresponding hash value; the allocation value forwarding interval corresponding to each front-end server cluster is allocated to the sorted front-end server cluster by the front-end load balancing server based on the cluster allocation value interval and the total number of the forwarding allocation values; the cluster allocation value interval is determined by the front-end load balancing server taking the quotient between the total number of forwarding allocation values and the number of the front-end server clusters.
[0056] Optionally, in the above-mentioned device, the front-end server cluster is communicatively connected with the query database; the processing request message includes a query request message; the query request message includes transaction flow information but does not include user card number information;
[0057] The information received by the application load balancing server and sent by the front-end server cluster includes a query request message and user card number information. The front-end server cluster obtains the corresponding user card number information from the query database based on the transaction flow information in the query request message, and sends the user card number information to the load balancing server.
[0058] A third aspect of an embodiment of the present invention provides a database allocation system, including: a database cluster, an application load balancing server, and a plurality of application server clusters;
[0059] The database cluster includes multiple databases, wherein each database is communicatively connected to a different application server cluster, each database is in a master-backup relationship with at least one other database, and the databases in the master-backup relationship store the same user contract data; the application load balancing server is communicatively connected to the front-end server cluster and the application server cluster respectively.
[0060] Optionally, the system as described above further includes: a front-end server cluster, a query database and a front-end load balancing server;
[0061] The front-end load balancing server is respectively connected to the payment settlement system of the forwarding institution and the front-end server cluster;
[0062] The front-end server cluster is respectively connected to the query database and the application load balancing server for communication.
[0063] A fourth aspect of an embodiment of the present invention provides an electronic device, including: a memory, a processor;
[0064] Memory; Memory for storing instructions executable by the processor;
[0065] The processor is configured to execute the database allocation method described in any one of the first aspects.
[0066] A fifth aspect of an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the database allocation method described in any one of the first aspects.
[0067] A sixth aspect of an embodiment of the present invention provides a computer program product, including a computer program, which, when executed by a processor, implements the database allocation method described in any one of the first aspects.
[0068] A database allocation method, device, system, equipment, medium and product provided in an embodiment of the present invention are applied to an application load balancing server, wherein the application load balancing server is respectively communicated with a front-end server cluster and an application server cluster; the application server cluster is communicated with a corresponding database in a database cluster, each database in the database cluster is in a master-slave relationship with at least one other database, and the databases in the master-slave relationship store the same user contract data; the method comprises: receiving information data; if it is determined that the information data is a processing request message sent by a front-end server cluster, forwarding the processing request message to the corresponding application server cluster according to the processing request message and a preset cluster forwarding strategy, so that the application server cluster accesses the corresponding database to perform corresponding data processing according to the received processing request message; if it is determined that the information data is a downtime database switching instruction, determining the downtime database and the standby database in a master-slave relationship with the downtime database according to the downtime database switching instruction, and when receiving a to-be-adjusted processing request message to be forwarded to the application server cluster corresponding to the downtime database, forwarding the to-be-adjusted processing request message to the application server cluster corresponding to the standby database. The database allocation method of the embodiment of the present invention first receives information data and performs corresponding processing according to the type of information data. If it is determined that the information data is a processing request message sent by the front-end server cluster, the processing request message is forwarded to the corresponding application server cluster according to the processing request message and the preset cluster forwarding strategy, so that the processing request message can be assigned to the corresponding application server cluster and database. If it is determined that the information data is a downtime database switching instruction, the downtime database and the backup database that is in a master-slave relationship with the downtime database are determined according to the downtime database switching instruction. Since the downtime database and the backup database that is in a master-slave relationship with the downtime database are both running databases and store the same user contract data, when a database downtime occurs, it is only necessary to switch the forwarding method of the processing request message to restore the data processing process faster, thereby improving the efficiency of the data processing recovery process. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0070] Figure 1 A scene diagram for implementing the database allocation method of the embodiment of the present invention;
[0071] Figure 2 A schematic diagram of a flow chart of a database allocation method provided in a first embodiment of the present invention;
[0072] Figure 3A schematic diagram of a flow chart of a database allocation method provided in a second embodiment of the present invention;
[0073] Figure 4 A schematic diagram of a payment architecture of a database allocation method provided in a second embodiment of the present invention;
[0074] Figure 5 A schematic diagram of the architecture of a payment system for a database allocation method provided in a second embodiment of the present invention;
[0075] Figure 6 A schematic diagram of a master / slave database of a database allocation method provided in a second embodiment of the present invention;
[0076] Figure 7 A schematic diagram of the structure of a database allocation system provided in a third embodiment of the present invention;
[0077] Figure 8 A schematic diagram of the structure of a database allocation device provided in a fourth embodiment of the present invention;
[0078] Fig. 9 A schematic structural diagram of an electronic device provided in a fifth embodiment of the present invention.
[0079] The above drawings have shown clear embodiments of the present invention, which will be described in more detail below. These drawings and text descriptions are not intended to limit the scope of the present invention in any way, but to illustrate the concept of the present invention for those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0080] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.
[0081] The technical solution of the present invention is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present invention will be described below in conjunction with the accompanying drawings.
[0082] In order to clearly understand the technical solution of the present application, the solution of the prior art is first introduced in detail. The current payment system mostly uses Oracle (Oracle in Chinese) database. Through the synchronization technology in Oracle, the main database and the backup database are established, and the data of both parties are synchronized in real time. Under normal circumstances, the main database provides services. When the main database fails or is abnormal, switch to the backup database. When switching to the backup database, it is necessary to detect the backup database to explore whether the backup database can be used. The overall switching process takes a long time, about 5 minutes. Therefore, it currently takes a long time to switch from the main database to the backup database, resulting in a low efficiency recovery process for data processing in the payment system.
[0083] Therefore, in view of the problem that it takes a long time to switch from the main database to the backup database in the prior art, resulting in a low efficiency of the recovery process of the data processing of the payment system, the inventors found in the research that in order to solve the problem that it takes a long time to switch from the main database to the backup database, resulting in a low efficiency of the recovery process of the data processing of the payment system, multiple databases running simultaneously can be established in a master-slave relationship with each other, so that when a database goes down, the backup databases that are running in a master-slave relationship can be immediately switched, thereby improving the efficiency of the recovery process of the data processing of the payment system. Specifically, first receive information data, and perform corresponding processing according to the type of information data. If it is determined that the information data is a processing request message sent by the front-end server cluster, the processing request message is forwarded to the corresponding application server cluster according to the processing request message and the preset cluster forwarding strategy, so that the processing request message can be assigned to the corresponding application server cluster and database. If it is determined that the information data is a downtime database switching instruction, the downtime database and the backup database that is in a master-slave relationship with the downtime database are determined according to the downtime database switching instruction. Since the downtime database and the backup database in a master-backup relationship with the downtime database are both running databases and store the same user contract data, when a database crash occurs, you only need to switch the forwarding method of the processing request message to restore the data processing process more quickly, thereby improving the efficiency of the data processing recovery process.
[0084] Based on the above creative findings, the inventor proposed the technical solution of the present application.
[0085] The following describes the application scenarios of the database allocation method provided by the embodiment of the present invention. Figure 1As shown, 1 is an electronic device, 2 is a payment and clearing system of a forwarding institution, 3 is a front-end balancing server, 4 is a front-end server cluster, 5 is an application server cluster, and 6 is a database cluster. Among them, the electronic device 1, the front-end balancing server 3, the front-end server cluster 4, the application server cluster 5, and the database cluster 6 are components of the payment system. The electronic device 1 is used as an application load balancing server. The front-end server cluster 4 includes the front-end server cluster a, the front-end server cluster b, and the front-end server cluster c, the application server cluster 5 includes the application server cluster a, the application server cluster b, and the application server cluster c, and the database cluster 6 includes the database a, the database b, and the database c. The network architecture of the application scenario corresponding to the database allocation method provided in the embodiment of the present invention includes: an electronic device 1, a payment and clearing system 2, a front-end balancing server 3, a front-end server cluster 4, an application server cluster 5, and a database cluster 6. At the same time, database a and database b are databases that store the same user contract data and are in a master-slave relationship with each other. The application server cluster a is connected to the database a in communication, the application server b is connected to the database b in communication, and the application server c is connected to the database c in communication. When the payment clearing system receives a processing request message for a user to make an agreement payment, the processing request message is forwarded to the front-end load balancing server 3 in the payment system. The front-end load balancing server 3 sends the processing request message to one of the front-end server clusters in the front-end server cluster 4. Assuming that the processing request message is forwarded to the electronic device 1 by the front-end server cluster a, the electronic device 1 forwards the processing request message to the corresponding application server cluster 5 according to the processing request message and the preset cluster forwarding strategy. Assuming that the processing request message is forwarded to the application server cluster a, the processing request message is accessed by the application server cluster a according to the received processing request message to the database a for corresponding data processing. At this time, if the database a is down, the monitored server or staff sends a downtime database switching instruction to the electronic device 1. The electronic device 1 determines the database a and the database b that is in a master-slave relationship with the database a according to the downtime database switching instruction. The electronic device 1 sends the subsequent processing request message that was originally to be sent to the application server cluster a-database a link to the application server cluster b-database b link, so that the database b replaces the database a for related data processing. Since database b stores the same user contract data, it can directly replace the original data processing function of database a. After the database switch, database a can perform subsequent fault detection, fault handling and other related processing until the fault of database a is resolved, and then the processing request message that belongs to database a can be sent to the application server cluster a-database a link again.
[0086] The embodiments of the present invention are described below in conjunction with the accompanying drawings.
[0087] Figure 2 A schematic diagram of a flow chart of a database allocation method provided in the first embodiment of the present invention is shown in FIG. Figure 2 As shown, in this embodiment, the execution subject of the embodiment of the present invention is a database allocation device, which can be integrated in an electronic device, such as an application load balancing server. It should be noted that the application load balancing server is communicated with the front-end server cluster and the application server cluster respectively. The application server cluster is communicated with the corresponding database in the database cluster, and each database in the database cluster is in a master-backup relationship with at least one other database, and the databases in the master-backup relationship store the same user contract data. The database allocation method provided in this embodiment includes the following steps:
[0088] Step S101, receiving information data.
[0089] In this embodiment, the received information data may be a processing request message sent from a front-end server cluster, or may be a downtime database switching instruction input from a supervision server or a staff member.
[0090] Step S102, if it is determined that the information data is a processing request message sent by the front-end server cluster, the processing request message is forwarded to the corresponding application server cluster according to the processing request message and the preset cluster forwarding strategy, so that the application server cluster accesses the corresponding database according to the received processing request message to perform corresponding data processing.
[0091] In this embodiment, the processing request message is generally sent by the payment clearing system of the forwarding institution to the front-end load balancing server in the payment system, and then the front-end load balancing server distributes the processing request message to the corresponding front-end server cluster according to the preset distribution strategy. Finally, after the front-end server cluster performs pre-processing such as signature verification, sensitive information encryption and decryption, and identity authentication on the processing request message, the verified processing request message is sent to the application load balancing server. After determining that the information data is a processing request message sent by the front-end server cluster, the processing request message can be forwarded to the corresponding application server cluster according to the processing request message and the preset cluster forwarding strategy, and the corresponding database is accessed by the application server cluster according to the received processing request message to perform corresponding data processing.
[0092] Step S103, if it is determined that the information data is a downtime database switching instruction, the downtime database and the backup database that is in a master-backup relationship with the downtime database are determined according to the downtime database switching instruction, and when a request message for adjustment processing to be forwarded to the application server cluster corresponding to the downtime database is received, the request message for adjustment processing is forwarded to the application server cluster corresponding to the backup database.
[0093] In this embodiment, the downtime database switching instruction can be input by a staff member on the application load balancing server, or sent by a supervisory server supervising the operation of the database. Typically, in some scenarios requiring high precision, the downtime database switching instruction is input by a staff member on the application load balancing server.
[0094] User contract data refers to the contract data that the user authorizes the payment system to process the data in the user's account. Only when the user contract data exists in the database can the processing request message corresponding to the user contract data be processed. Assuming that the user contract data corresponding to user a exists in the database, but the user contract data corresponding to user b does not exist, the database can only process the processing request message generated by user a when executing the agreement payment, but cannot process the processing request message generated by user b when executing the agreement payment. Therefore, the existence of the same user contract data is a prerequisite for the databases to be in a master-backup relationship with each other.
[0095] The downtime database switching instruction includes the database identification information corresponding to the downtime, and the database identification information can be used to determine which database is down. At the same time, the downtime database switching instruction can also include the standby database identification information corresponding to the downtime database, that is, the downtime database and the standby database in the master-standby relationship with the downtime database can be determined through the downtime database switching instruction. The master-standby relationship between the downtime database and the standby database in the master-standby relationship with the downtime database can also be pre-stored, and after the downtime database is determined through the database identification information corresponding to the downtime in the downtime database switching instruction, the corresponding standby database is determined according to the master-standby relationship between the downtime database and the standby database in the master-standby relationship with the downtime database.
[0096] When receiving a processing request message to be adjusted to be forwarded to the application server cluster corresponding to the downtime database, the processing request message to be adjusted refers to a processing request message that needs to adjust the forwarding path due to the downtime of the downtime database. Since the processing request message to be adjusted cannot be forwarded to the application server cluster corresponding to the downtime database, it is necessary to forward the processing request message to be adjusted to the application server cluster corresponding to the standby database, so that the application server cluster corresponding to the standby database processes data for the processing request message to be adjusted in conjunction with the standby database.
[0097] A database allocation method provided by an embodiment of the present invention comprises: receiving information data. If it is determined that the information data is a processing request message sent by a front-end server cluster, the processing request message is forwarded to the corresponding application server cluster according to the processing request message and a preset cluster forwarding strategy, so that the application server cluster accesses the corresponding database according to the received processing request message to perform corresponding data processing. If it is determined that the information data is a downtime database switching instruction, the downtime database and the standby database in a master-standby relationship with the downtime database are determined according to the downtime database switching instruction, and when receiving a processing request message to be adjusted to be forwarded to the application server cluster corresponding to the downtime database, the processing request message to be adjusted is forwarded to the application server cluster corresponding to the standby database. The database allocation method of the embodiment of the present invention first receives information data and performs corresponding processing according to the type of information data. If it is determined that the information data is a processing request message sent by a front-end server cluster, the processing request message is forwarded to the corresponding application server cluster according to the processing request message and a preset cluster forwarding strategy, so that the processing request message can be allocated to the corresponding application server cluster and database. If it is determined that the information data is a downtime database switching instruction, the downtime database and the backup database in a master-slave relationship with the downtime database are determined according to the downtime database switching instruction. Since the downtime database and the backup database in a master-slave relationship with the downtime database are both running databases and store the same user contract data, when a database downtime occurs, only the forwarding method of the processing request message needs to be switched to restore the data processing process faster, thereby improving the efficiency of the data processing recovery process.
[0098] Figure 3 A schematic diagram of a flow chart of a database allocation method provided in a second embodiment of the present invention is shown in FIG. Figure 3 As shown, the database allocation method provided in this embodiment is based on the database allocation method provided in the previous embodiment of the present invention, and further refines steps 102 and 103. The database allocation method provided in this embodiment includes the following steps.
[0099] Step S201, receiving information data.
[0100] In this embodiment, the implementation of step 201 is similar to the implementation of step 101 in the previous embodiment of the present invention, and will not be described in detail here.
[0101] It should be noted that the processing request message includes a transaction request message. The transaction request message includes user card number information.
[0102] Step S202: If it is determined that the information data is a processing request message sent by the front-end server cluster, a random number of preset digits in the user card number information is determined according to the user card number information.
[0103] In this embodiment, the user card number information is generally used to identify the user account, such as the card number information in a bank card. Since the user card number information corresponding to the user account is composed of multiple digits, there are several random numbers in the multiple digits. The user card number information can set a random number at the end of the card number or at some digits in the middle, such as setting a random number at the last two digits at the end of the card number. The range of the random number is 00-99.
[0104] Optionally, in this embodiment, before forwarding the transaction request message to the corresponding application server cluster according to the random number and the preset cluster forwarding strategy, the process further includes:
[0105] The quotient between the total number of random numbers and the number of application server clusters is determined as the cluster random number interval.
[0106] The application server clusters are sorted, and corresponding random number forwarding intervals are allocated to the sorted application server clusters according to the cluster random number intervals and the total number of random numbers.
[0107] Forward the transaction request message to the corresponding application server cluster according to the random number and the preset cluster forwarding strategy, including:
[0108] Determine the random number forwarding interval to which the random number in the transaction request message belongs, and forward the transaction request message to the application server cluster corresponding to the random number forwarding interval.
[0109] In this embodiment, the total number of random numbers refers to the total number of digits of the random numbers, for example, the total number of two-digit random numbers is 100, and similarly, if it is a three-digit random number, the total number of random numbers is 1000. Since the payment system processes a large amount of data on a daily basis, it usually requires more application server clusters for data processing.
[0110] The application server clusters correspond to the databases one by one. For example, if the application server clusters include application server cluster a, application server cluster b, and application server cluster c, the databases correspond to database a, database b, and database c. At this time, if the application server clusters are sorted, they can be sorted in the order of application server cluster a, application server cluster b, and application server cluster c.
[0111] Assume that the total number of random numbers is the total number of two-digit random numbers, that is, the total number is 100, and the number of application server clusters is 4, then the cluster random number interval is 25. The random number forwarding intervals are 00-24, 25-49, 50-74, and 75-99 respectively.
[0112] Therefore, after determining the random number in the transaction request message, the random number forwarding interval to which it belongs can be determined. For example, if the random number in the transaction request message is 25, the corresponding random number forwarding interval is 25-49. At this time, the transaction request message can be forwarded to the application server cluster corresponding to the random number forwarding interval.
[0113] By setting random numbers to divide the data processing range of the application server cluster, the overall data processing efficiency of the application server cluster can be improved.
[0114] Step S203, forwarding the transaction request message to the corresponding application server cluster according to the random number and the preset cluster forwarding strategy, so that the application server cluster accesses the corresponding database to perform corresponding data processing according to the received processing request message.
[0115] In this embodiment, the implementation of step 203 is similar to the implementation of step 102 in the previous embodiment of the present invention, and will not be described in detail here.
[0116] Step S204: if it is determined that the information data is a downtime database switching instruction, then the corresponding downtime database is determined according to the downtime database switching instruction input by the user.
[0117] In this embodiment, the implementation of step 204 is similar to the implementation of step 103 in the previous embodiment of the present invention, and will not be described in detail here.
[0118] Optionally, in this embodiment, the number of databases in a master-slave relationship with the downtime database is greater than or equal to two.
[0119] According to the downtime database switch instruction, the downtime database and the standby database in a master-standby relationship with the downtime database are determined, including:
[0120] According to the preset selection strategy, a corresponding database is selected from the databases that have a master-slave relationship with the downed database.
[0121] The selected corresponding database is determined as a standby database corresponding to the downed database.
[0122] In this embodiment, the number of databases in a master-slave relationship with the downtime database is greater than or equal to the number of databases in a master-slave relationship with each other, which refers to 3 or more. This embodiment is mainly aimed at scenarios with a large number of databases. Since the number of databases is large, multiple databases can be set to be in a master-slave relationship with each other, so that when a database crashes, a database with stronger operating functions and less processing data can be selected from multiple backup databases as a replacement database to support the data processing range to which the downtime database belongs. Thereby reducing the problem of reduced data processing efficiency caused by database crashes. At this time, if the number of databases is 4, the number of databases in a master-slave relationship with the downtime database can be two or three. The preset selection strategy can be to randomly select a backup database, or to select according to the current data processing pressure, which is not limited in this embodiment.
[0123] Optionally, in this embodiment, after determining the downtime database and the standby database in a master-standby relationship with the downtime database according to the downtime database switching instruction, the method further includes:
[0124] Delete the random number forwarding interval of the downtime database.
[0125] Modify the random number forwarding interval of the standby database in the active-standby relationship between the downtime database and the original random number forwarding interval of the standby database to be the sum of the original random number forwarding interval of the downtime database and the original random number forwarding interval of the standby database.
[0126] In this embodiment, since the downtime database cannot perform tasks related to data processing, it is necessary to forward the processing request message originally forwarded to the downtime database to the corresponding standby database. Therefore, it is necessary to transfer the random number forwarding interval of the downtime database to the standby database, so that the random number forwarding interval of the standby database is the sum of the original random number forwarding interval of the downtime database and the original random number forwarding interval of the standby database. For example, if the original random number forwarding interval of the downtime database is 00-24, and the random number forwarding interval of the standby database is 25-49, then the random number forwarding interval of the merged standby database is 00-49.
[0127] Optionally, in this embodiment, the processing request message is distributed to the target front-end server cluster by the front-end load balancing server according to a preset distribution strategy. The processing request message of the front-end load balancing server is sent by the payment settlement system of the forwarding institution.
[0128] In this embodiment, the processing request message is sent by the payment settlement system of the forwarding organization to the front-end load balancing server, and then distributed to the corresponding front-end server cluster, ie, the target front-end server cluster, via the front-end load balancing server.
[0129] Optionally, in this embodiment, the processing request message includes transaction flow information.
[0130] The target front-end server cluster performs hash calculation on the transaction flow information of the processing request message for the front-end load balancing server to obtain the forwarding allocation value, and determines it according to the forwarding allocation value and the allocation value forwarding interval to which the forwarding allocation value belongs.
[0131] The forwarding allocation value is the last two digits of the corresponding hash value. The forwarding interval of the allocation value corresponding to each front-end server cluster is allocated to the sorted front-end server cluster by the front-end load balancing server based on the cluster allocation value interval and the total number of forwarding allocation values. The cluster allocation value interval is determined by the front-end load balancing server dividing the total number of forwarding allocation values by the number of front-end server clusters.
[0132] In this embodiment, when the user performs related operations of the agreement payment, corresponding transaction flow information will be generated. The corresponding hash value can be obtained by hashing the transaction flow information, and the last two digits of the hash value are taken as the forwarding allocation value. The allocation strategy for the front-end server cluster is similar to the distribution strategy for the application server cluster. The total number of forwarding allocation values is 100, that is, 100 numbers from 00-99. Assuming that the number of front-end server clusters is 4, the cluster allocation value interval is 25, that is, the allocation value forwarding intervals are 00-24, 25-49, 50-74, and 75-99 respectively.
[0133] Optionally, in this embodiment, the front-end server cluster is connected to the query database in communication. The processing request message includes the query request message. The query request message includes transaction flow information but does not include user card number information.
[0134] The information sent by the front-end server cluster and received by the application load balancing server includes a query request message and user card number information. The front-end server cluster obtains the corresponding user card number information from the query database based on the transaction flow information in the query request message, and sends the user card number information to the load balancing server.
[0135] In this embodiment, the query database stores the user card number information and transaction flow information in the transaction request message. When processing the transaction request message, the front-end server cluster will store the user card number information and transaction flow information in the transaction request message into the query database. When processing the query request message, since the query request message does not contain the user card number information, the transaction flow information in the query request message is the same as the transaction flow information in the transaction request message. Therefore, the front-end server cluster can query the corresponding user card number information in the query database according to the transaction flow information in the query request message, so as to facilitate the application load balancing server to determine which application server cluster the query message is distributed to according to the user card number information.
[0136] Step S205 , determining a standby database corresponding to the downtime database according to the master-standby relationship between the downtime database and other databases.
[0137] In this embodiment, the master-slave relationship between the downtime database and other databases may be stored in the application load balancing server, or may be carried in the downtime database switching instruction, which is not limited in this embodiment.
[0138] Step S206 , when receiving the processing request message to be forwarded to the application server cluster corresponding to the downtime database, forward the processing request message to be forwarded to the application server cluster corresponding to the standby database.
[0139] In this embodiment, the implementation of step 206 is similar to the implementation of step 103 in the previous embodiment of the present invention, and will not be described in detail here.
[0140] A database allocation method provided by an embodiment of the present invention uses the random number of user card number information as a distribution strategy for distributing processing request messages, so that when a database crashes, the random number forwarding interval of the crashed database can be deleted, and the random number forwarding interval of the standby database in a master-standby relationship with the crashed database can be modified to the sum of the original random number forwarding interval of the crashed database and the original random number forwarding interval of the standby database, and the processing request message originally processed by the crashed database can be transferred to the corresponding standby database for processing. Therefore, the data processing process can be restored faster by simply switching the forwarding method of the processing request message, thereby improving the efficiency of the data processing recovery process.
[0141] In order to explain the method of this embodiment in more detail, the processing flow of a certain processing request message and the processing process when the database crashes will be explained in detail below.
[0142] See also Figure 4-Figure 6 In order to more conveniently view the process of the method, the names of the various components in the three figures are abbreviated. The front-end load balancing server is abbreviated as front-end load balancing, the front-end server cluster is abbreviated as front-end cluster, the application load balancing server is abbreviated as application load balancing, and the application server cluster is abbreviated as application cluster. The main database of this embodiment adopts the Oracle database. At the same time, the non-operating standby databases ADG standby database 1-ADG standby database 4 corresponding to each database are added. Redis, RAC1, RAC2, RAC3, and RAC4 are all databases. The query database adopts the Redis database.
[0143] like Figure 4As shown in the figure, the architecture of the agreement payment mainly consists of three parts: payment institution, China UnionPay / NetsUnionPay platform, and paying bank. After the user completes an agreement payment, the payment institution sends a processing request message to China UnionPay / NetsUnionPay according to the message specification of the China UnionPay / NetsUnionPay platform, and then the China UnionPay / NetsUnionPay platform forwards the processing request message to the paying bank. The paying bank performs internal payment processing for the agreement payment, and after completing the processing, it feeds back the transaction receipt message to the China UnionPay / NetsUnionPay platform, so that the China UnionPay / NetsUnionPay platform forwards the transaction receipt message back to the payment institution. Each payment-related processing request message initiated by the user has unique transaction flow information as an identifier.
[0144] like Figure 5 As shown in the figure, the architecture of the payment system of this embodiment is mainly divided into two modules. Module 1 is the front cluster module. The front load balancing server is used to receive the processing request message forwarded from China UnionPay. The front cluster module completes the message pre-processing such as signature verification, encryption and decryption of sensitive information, and caches the user card number information and transaction flow information in the processing request message into the Redis database. So that when the subsequent query request message comes in, it can be found to which server cluster / database shard the transaction request message in the original processing request message is sent.
[0145] Table 1 Allocation value forwarding interval table corresponding to the front cluster module
[0146]
[0147] As shown in Table 1, after receiving the processing request message forwarded from NetsUnion / UnionPay, the front-end load balancing server performs hash calculation on the transaction serial number, and takes the last two digits of the calculated value as the forwarding allocation value. In this embodiment, four databases are used, and four front-end server clusters are also used, namely, front-end server clusters 1-4. Therefore, the allocation value forwarding interval is shown in Table 1. The database shard record routing relationship table is selected according to these two digits.
[0148] Module 2 is the core application module, which includes multiple application server clusters. In this embodiment, there are 4 application server clusters, namely application server clusters 1-4. The business logic of all online transactions such as signing, payment, refund, payment, and inquiry are processed in this module. The application load balancing server selects the database and application server cluster according to the two random numbers in the user card number information. This system assumes that the last two digits of the user card number information such as the bank card are random numbers. The application load balancing server takes out the user card number information from the message after pre-processing, and sends it to the corresponding application server cluster according to the last two digits of the card number, so as to process the request message, and store the data processed by the request message in the corresponding database. Here, the last two digits of the card number are random numbers, and it is not required to be the last two digits, as long as they are two random numbers in the card number. Please see Table 2 for the diversion rules.
[0149] Table 2 Random number forwarding interval table corresponding to the application server cluster
[0150] Last two digits of card number 00-24 25-49 50-74 75-99 Application Server Cluster 1 2 3 4 Database RAC number 1 2 3 4
[0151] The server cluster and database RAC in Table 1 and Table 2 can be horizontally adjusted and expanded as needed.
[0152] In order to achieve high availability, we set up a "replica library" for each master library. When the master library fails, the processing request message is sent to the replica library for acceptance. The existing four master libraries exist in a pairwise backup form, as shown in Table 3. For example, the replica library of database RAC1 is database RAC2. When a failure occurs, the processing request message is first sent to database RAC2. Database RAC2, as a replica library, accepts both RAC1 and its own processing request messages.
[0153] The same table structure as that in the main database is established in the replica database, and the same user contract data is stored, so that it can handle business in both the main database and the replica database at the same time.
[0154] Table 3 Main library and replica library correspondence table
[0155] Primary database RAC RAC1 RAC2 RAC3 RAC4 Replica RAC RAC2 RAC1 RAC4 RAC3
[0156] like Figure 6 As shown in the figure, the prerequisite for the replica database to accept the business traffic of the main database is that the replica database has the user contract data of the main database. Therefore, when signing and terminating a contract, we send the contract data to Kafka and synchronize it to the replica database at the same time as the main database is landed. The synchronization of contract data is a prerequisite for high-availability switching. And each main database can set up an additional standby database ADG standby database that is not normally running.
[0157] The emergency operation after the database crashes requires the conversion of the random number forwarding interval from Table 2 to Table 4. In fact, it is only necessary to replace the script on the load balancing server. After the switch, the RAC1 database and the corresponding application server cluster 1 no longer accept processing request messages, and the fault can be repaired. At the same time, the processing request messages on the RAC1 database are taken over by the RAC2 database.
[0158] Table 4 Random number forwarding interval table corresponding to the application server cluster
[0159] Last two digits of card number 00-24 25-49 Application Server Cluster 2 2 Database RAC number 2 2
[0160] Figure 7 A schematic diagram of the structure of a database distribution system provided in the third embodiment of the present invention is shown in FIG. Figure 7 As shown, this embodiment also provides a database allocation system, including: a database cluster, an application load balancing server 1 and multiple application server clusters 5.
[0161] The database cluster 6 includes multiple databases, each of which is connected to a different application server cluster, each database is in a master-slave relationship with at least one other database, and the databases in the master-slave relationship store the same user contract data. The application load balancing server 1 is connected to the front-end server cluster and the application server cluster 5 respectively.
[0162] Optionally, this embodiment also includes: a front-end server cluster, a query database and a front-end load balancing server.
[0163] The front-end load balancing server is respectively connected to the payment settlement system of the forwarding institution and the front-end server cluster communication.
[0164] The front-end server cluster is respectively connected to the query database and the application load balancing server for communication.
[0165] The database allocation system provided in this embodiment can be executed Figure 2-Figure 6 The technical solution of the method embodiment shown in the figure has the same implementation principle and technical effect as Figure 2-Figure 6 The method embodiments shown are similar and will not be described in detail here.
[0166] Figure 8 A schematic diagram of the structure of a database allocation device provided in a fourth embodiment of the present invention is shown in FIG. Figure 8As shown, in this embodiment, the database allocation device 300 is located in the application load balancing server, and the application load balancing server is respectively connected to the front-end server cluster and the application server cluster. The application server cluster is connected to the corresponding database in the database cluster, and each database in the database cluster is in a master-slave relationship with at least one other database, and the databases in the master-slave relationship store the same user contract data. The database allocation device 300 includes:
[0167] The receiving module 301 is used to receive information data.
[0168] The data processing module 302 is used to forward the processing request message to the corresponding application server cluster according to the processing request message and the preset cluster forwarding strategy if it is determined that the information data is a processing request message sent by the front-end server cluster, so that the application server cluster accesses the corresponding database according to the received processing request message to perform corresponding data processing.
[0169] The downtime processing module 303 is used to determine the downtime database and the backup database in a master-backup relationship with the downtime database according to the downtime database switching instruction if the information data is determined to be a downtime database switching instruction, and when receiving the to-be-adjusted processing request message to be forwarded to the application server cluster corresponding to the downtime database, forward the to-be-adjusted processing request message to the application server cluster corresponding to the backup database.
[0170] The database allocation device provided in this embodiment can execute Figure 2 The technical solution of the method embodiment shown in the figure has the same implementation principle and technical effect as Figure 2 The method embodiments shown are similar and will not be described in detail here.
[0171] Meanwhile, the database allocation device provided by the present invention further refines the database allocation device 300 based on the database allocation device provided by the previous embodiment.
[0172] Optionally, in this embodiment, the processing request message includes a transaction request message. The transaction request message includes user card number information.
[0173] When the data processing module 302 forwards the processing request message to the corresponding application server cluster according to the processing request message and the preset cluster forwarding strategy, it is specifically used to:
[0174] Determine a random number of preset digits in the user card number information according to the user card number information. Forward the transaction request message to the corresponding application server cluster according to the random number and the preset cluster forwarding strategy.
[0175] Optionally, in this embodiment, the data processing module 302 is further used to:
[0176] The quotient between the total number of random numbers and the number of application server clusters is determined as the cluster random number interval. The application server clusters are sorted, and the sorted application server clusters are assigned corresponding random number forwarding intervals according to the cluster random number interval and the total number of random numbers.
[0177] When forwarding the transaction request message to the corresponding application server cluster according to the random number and the preset cluster forwarding strategy, the data processing module 302 is specifically used to:
[0178] Determine the random number forwarding interval to which the random number in the transaction request message belongs, and forward the transaction request message to the application server cluster corresponding to the random number forwarding interval.
[0179] Optionally, in this embodiment, when the downtime processing module 303 determines the downtime database and the standby database in a master-standby relationship with the downtime database according to the downtime database switching instruction, it is specifically used to:
[0180] The corresponding downtime database is determined according to the downtime database switching instruction input by the user. The standby database corresponding to the downtime database is determined according to the master-slave relationship between the downtime database and other databases.
[0181] Optionally, in this embodiment, the number of databases in a master-slave relationship with the downtime database is greater than or equal to two.
[0182] When the downtime processing module 303 determines the downtime database and the standby database in a master-standby relationship with the downtime database according to the downtime database switching instruction, it is specifically used to:
[0183] According to a preset selection strategy, a corresponding database is selected from databases that have a master-slave relationship with the downtime database, and the selected corresponding database is determined as a standby database corresponding to the downtime database.
[0184] Optionally, in this embodiment, the downtime processing module 303 is further used to:
[0185] Delete the random number forwarding interval of the downtime database. Modify the random number forwarding interval of the standby database in the active / standby relationship with the downtime database to the sum of the original random number forwarding interval of the downtime database and the original random number forwarding interval of the standby database.
[0186] Optionally, in this embodiment, the processing request message is distributed to the target front-end server cluster by the front-end load balancing server according to a preset distribution strategy. The processing request message of the front-end load balancing server is sent by the payment settlement system of the forwarding institution.
[0187] Optionally, in this embodiment, the processing request message includes transaction flow information.
[0188] The target front-end server cluster performs hash calculation on the transaction flow information of the processing request message for the front-end load balancing server to obtain the forwarding allocation value, and determines it according to the forwarding allocation value and the allocation value forwarding interval to which the forwarding allocation value belongs.
[0189] The forwarding allocation value is the last two digits of the corresponding hash value. The forwarding interval of the allocation value corresponding to each front-end server cluster is allocated to the sorted front-end server cluster by the front-end load balancing server based on the cluster allocation value interval and the total number of forwarding allocation values. The cluster allocation value interval is determined by the front-end load balancing server dividing the total number of forwarding allocation values by the number of front-end server clusters.
[0190] Optionally, in this embodiment, the front-end server cluster is connected to the query database in communication. The processing request message includes the query request message. The query request message includes transaction flow information but does not include user card number information.
[0191] The information sent by the front-end server cluster and received by the application load balancing server includes a query request message and user card number information. The front-end server cluster obtains the corresponding user card number information from the query database based on the transaction flow information in the query request message, and sends the user card number information to the load balancing server.
[0192] The database allocation device provided in this embodiment can execute Figure 2-Figure 6 The technical solution of the method embodiment shown in the figure has the same implementation principle and technical effect as Figure 2-Figure 6 The method embodiments shown are similar and will not be described in detail here.
[0193] According to an embodiment of the present invention, the present invention also provides an electronic device, a computer-readable storage medium and a computer program product.
[0194] like Fig. 9 As shown, Fig. 9 1 is a schematic diagram of the structure of an electronic device provided by the fifth embodiment of the present invention. The electronic device is intended to be various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.
[0195] like Fig. 9 As shown, the electronic device includes: a processor 401 and a memory 402. The various components are connected to each other using different buses and can be installed on a common mainboard or in other ways as required. The processor can process instructions executed in the electronic device.
[0196] The memory 402 is a non-transient computer-readable storage medium provided by the present invention. The memory stores instructions executable by at least one processor to enable at least one processor to perform the database allocation method provided by the present invention. The non-transient computer-readable storage medium of the present invention stores computer instructions, which are used to enable a computer to perform the database allocation method provided by the present invention.
[0197] The memory 402 is a non-transient computer-readable storage medium that can be used to store non-transient software programs, non-transient computer executable programs and modules, such as program instructions / modules corresponding to the database allocation method in the embodiment of the present invention (for example, the attached Figure 8 The processor 401 executes various functional applications of the server and database allocation by running the non-transient software programs, instructions and modules stored in the memory 402, that is, the database allocation method in the above method embodiment is implemented.
[0198] At the same time, this embodiment also provides a computer product. When the instructions in the computer product are executed by the processor of the electronic device, the electronic device can execute the database allocation method of the above-mentioned embodiments 1 to 2.
[0199] Those skilled in the art will readily appreciate other implementations of the embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses, or adaptations of the embodiments of the present invention that follow the general principles of the embodiments of the present invention and include common knowledge or customary technical means in the art that are not disclosed in the embodiments of the present invention. The specification and examples are to be regarded as exemplary only, and the true scope and spirit of the embodiments of the present invention are indicated by the following claims.
[0200] It should be understood that the embodiments of the present invention are not limited to the precise structures described above and shown in the drawings, and various modifications and changes may be made without departing from the scope thereof. The scope of the embodiments of the present invention is limited only by the appended claims.
Claims
1. A database allocation method, characterized in that: Applied to an application load balancing server, the application load balancing server is respectively connected to a front-end server cluster and an application server cluster; the application server cluster is connected to a corresponding database in a database cluster, each database in the database cluster is in a master-slave relationship with at least one other database, and the databases in the master-slave relationship store the same user contract data; the method comprises: Receive information data; If it is determined that the information data is a processing request message sent by the front-end server cluster, the processing request message is forwarded to the corresponding application server cluster according to the processing request message and a preset cluster forwarding strategy, so that the application server cluster accesses the corresponding database to perform corresponding data processing according to the received processing request message; If it is determined that the information data is a downtime database switching instruction, then the downtime database and a standby database in a master-standby relationship with the downtime database are determined according to the downtime database switching instruction, and when a request message for processing to be adjusted is received and is to be forwarded to an application server cluster corresponding to the downtime database, the request message for processing to be adjusted is forwarded to the application server cluster corresponding to the standby database; The processing request message includes a transaction request message; the transaction request message includes user card number information; The forwarding of the processing request message to the corresponding application server cluster according to the processing request message and a preset cluster forwarding strategy is specifically used for: Determine a random number of preset digits in the user card number information according to the user card number information; Forwarding the transaction request message to a corresponding application server cluster according to the random number and a preset cluster forwarding strategy; Before forwarding the transaction request message to the corresponding application server cluster according to the random number and the preset cluster forwarding strategy, the method further includes: Determine the quotient between the total number of random numbers and the number of application server clusters as a cluster random number interval; Sorting the application server clusters, and sequentially allocating corresponding random number forwarding intervals to the sorted application server clusters according to the cluster random number intervals and the total number of random numbers; the number of the random number forwarding intervals is the same as the number of the application server clusters; The forwarding of the transaction request message to a corresponding application server cluster according to the random number and a preset cluster forwarding strategy includes: Determine the random number forwarding interval to which the random number in the transaction request message belongs, and forward the transaction request message to the application server cluster corresponding to the random number forwarding interval.
2. The method according to claim 1, characterized in that The method of determining the downtime database and the standby database in a master-standby relationship with the downtime database according to the downtime database switching instruction includes: Determine the corresponding downtime database according to the downtime database switching instruction input by the user; A standby database corresponding to the downtime database is determined according to the master-standby relationship between the downtime database and other databases.
3. The method according to claim 2, characterized in that The number of databases in a master-slave relationship with the downtime database is greater than or equal to two; The method of determining the downtime database and the standby database in a master-standby relationship with the downtime database according to the downtime database switching instruction includes: Select a corresponding database from databases that have a master-slave relationship with the downed database according to a preset selection strategy; The selected corresponding database is determined as a standby database corresponding to the downtime database.
4. The method according to claim 2 or 3, characterized in that: After determining the downtime database and the standby database in a master-standby relationship with the downtime database according to the downtime database switching instruction, the method further includes: Delete the random number forwarding interval of the downtime database; The random number forwarding interval of the standby database in the master-standby relationship with the downtime database is modified to be the sum of the original random number forwarding interval of the downtime database and the original random number forwarding interval of the standby database.
5. The method according to claim 2, characterized in that: The processing request message is distributed to the target front-end server cluster by the front-end load balancing server according to a preset distribution strategy; the processing request message of the front-end load balancing server is sent by the payment settlement system of the forwarding institution.
6. The method according to claim 5, characterized in that The processing request message includes transaction flow information; The target front-end server cluster performs hash calculation on the transaction flow information of the processing request message for the front-end load balancing server to obtain the forwarding allocation value, and determines it according to the forwarding allocation value and the allocation value forwarding interval to which the forwarding allocation value belongs; The forwarding allocation value is the last two digits of the corresponding hash value; the allocation value forwarding interval corresponding to each front-end server cluster is allocated to the sorted front-end server cluster by the front-end load balancing server based on the cluster allocation value interval and the total number of the forwarding allocation values; the cluster allocation value interval is determined by the front-end load balancing server taking the quotient between the total number of forwarding allocation values and the number of the front-end server clusters.
7. The method according to claim 5, characterized in that The front-end server cluster is in communication connection with the query database; the processing request message includes a query request message; the query request message includes transaction flow information but does not include user card number information; The information received by the application load balancing server and sent by the front-end server cluster includes a query request message and user card number information. The front-end server cluster obtains the corresponding user card number information from the query database based on the transaction flow information in the query request message, and sends the user card number information to the load balancing server.
8. A database allocation device, characterized in that: The device is located in an application load balancing server, and the application load balancing server is respectively connected to the front-end server cluster and the application server cluster; the application server cluster is connected to the corresponding database in the database cluster, and each database in the database cluster is in a master-slave relationship with at least one other database, and the databases in the master-slave relationship store the same user contract data; the device includes: A receiving module, used for receiving information data; A data processing module, for forwarding the processing request message to a corresponding application server cluster according to the processing request message and a preset cluster forwarding strategy if it is determined that the information data is a processing request message sent by a front-end server cluster, so that the application server cluster accesses a corresponding database to perform corresponding data processing according to the received processing request message; A downtime processing module, for determining the downtime database and a standby database in a master-standby relationship with the downtime database according to the downtime database switching instruction if the information data is determined to be a downtime database switching instruction, and forwarding the to-be-adjusted processing request message to the application server cluster corresponding to the standby database when receiving a to-be-adjusted processing request message to be forwarded to the application server cluster corresponding to the downtime database; The processing request message includes a transaction request message; the transaction request message includes user card number information; When the data processing module forwards the processing request message to the corresponding application server cluster according to the processing request message and the preset cluster forwarding strategy, it is specifically used to: Determine a random number of preset digits in the user card number information according to the user card number information; forward the transaction request message to the corresponding application server cluster according to the random number and the preset cluster forwarding strategy; The data processing module is also used for: Determine the quotient between the total number of random numbers and the number of application server clusters as the cluster random number interval; Sorting each application server cluster, and sequentially allocating corresponding random number forwarding intervals to the sorted application server clusters according to the cluster random number intervals and the total number of random numbers; the number of the random number forwarding intervals is the same as the number of the application server clusters; When the data processing module forwards the transaction request message to the corresponding application server cluster according to the random number and the preset cluster forwarding strategy, it is specifically used to: Determine the random number forwarding interval to which the random number in the transaction request message belongs, and forward the transaction request message to the application server cluster corresponding to the random number forwarding interval.
9. A database distribution system, characterized in that: include: Database clusters, application load balancing servers, and multiple application server clusters; The database cluster includes multiple databases, wherein each database is communicatively connected to a different application server cluster, each database is in a master-slave relationship with at least one other database, and the databases in the master-slave relationship store the same user contract data; the application load balancing server is communicatively connected to the front-end server cluster and the application server cluster respectively; It also includes: front-end server cluster, query database and front-end load balancing server; The front-end load balancing server is respectively connected to the payment settlement system of the forwarding institution and the front-end server cluster; The front-end server cluster is respectively connected to the query database and the application load balancing server for communication.
10. An electronic device, characterized in that: include: Memory, processor; Memory; a memory for storing instructions executable by the processor; The processor is configured to execute the database allocation method according to any one of claims 1 to 7.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the database allocation method according to any one of claims 1 to 7.
12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the database allocation method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Service processing system and service processing method
CN111131451A