CN105956143B - Data bank access method and database broker node - Google Patents
Data bank access method and database broker node Download PDFInfo
- Publication number
- CN105956143B CN105956143B CN201610313378.6A CN201610313378A CN105956143B CN 105956143 B CN105956143 B CN 105956143B CN 201610313378 A CN201610313378 A CN 201610313378A CN 105956143 B CN105956143 B CN 105956143B
- Authority
- CN
- China
- Prior art keywords
- database
- access request
- proxy node
- user terminal
- time period
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 32
- 238000012795 verification Methods 0.000 claims description 24
- 238000012545 processing Methods 0.000 claims description 13
- 238000004458 analytical method Methods 0.000 claims description 3
- 230000004044 response Effects 0.000 description 5
- 230000005540 biological transmission Effects 0.000 description 4
- 238000010586 diagram Methods 0.000 description 3
- OTZZZISTDGMMMX-UHFFFAOYSA-N 2-(3,5-dimethylpyrazol-1-yl)-n,n-bis[2-(3,5-dimethylpyrazol-1-yl)ethyl]ethanamine Chemical compound N1=C(C)C=C(C)N1CCN(CCN1C(=CC(C)=N1)C)CCN1C(C)=CC(C)=N1 OTZZZISTDGMMMX-UHFFFAOYSA-N 0.000 description 2
- 241001441724 Tetraodontidae Species 0.000 description 2
- 238000013523 data management Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000001960 triggered effect Effects 0.000 description 2
- 230000000007 visual effect Effects 0.000 description 2
- 239000002699 waste material Substances 0.000 description 2
- 238000011161 development Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000008569 process Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a kind of data bank access methods, are applied to database broker node, provide agency service by database broker node for multiple database servers of rear end.For any database server of rear end, if database broker node receives the database access request for being directed toward the database server within the high load capacity period of the database server, the type for the SQL statement that the database access request carries is determined first, if the SQL statement carried is DQL sentence, directly acquires and send the business datum of the SQL statement direction to the source user terminal of database access request;If the SQL statement carried is DML statement, when waiting except the high load capacity period for reaching the database server, database access request is sent to database server and is executed.The invention also discloses a kind of database broker nodes.The present invention can be improved the stability of database server work.
Description
Technology neighborhood
The invention relates to the technical field of internet, in particular to a database access method and a database proxy node.
Background
With the rapid development of internet technology, various specialized comprehensive user center websites in the form of personalized operation, rich content and active interaction have come into play, such as various recently emerging e-commerce websites and microblog websites. The user center websites provide content support through the database server at the back end, when a large number of access requests are concurrent in a short period, the database server often cannot execute all the access requests in time due to performance limitation, so that response delay is caused, even the database server is down to stop service, and the problem of low working stability exists.
Disclosure of Invention
The invention mainly aims to provide a database access method and a database proxy node, aiming at improving the working stability of a database server.
In order to achieve the above object, the present invention provides a database access method, including the steps of:
step A, when a database access request sent by a user terminal is received, a database proxy node judges whether the database access request is currently located in a high-load time period of a database server corresponding to the database access request, if not, the step B is executed, and if yes, the step C is executed;
b, the database proxy node forwards the database access request to the database server for execution;
step C, the database agent node analyzes the SQL sentences carried by the database access request, wherein if the SQL sentences are DQL sentences, the step D is executed, and if the SQL sentences are DML sentences, the step B is executed when the SQL sentences reach the time outside the high-load time period of the database server;
and step D, the database agent node acquires the currently stored business data pointed by the SQL statement and sends the acquired business data to the user terminal.
Optionally, before the step of sending the obtained service data to the user terminal, the method further includes:
and when the stored service data is failed to be acquired, the database proxy node acquires and stores the service data pointed by the SQL statement based on other database proxy nodes, and the step of transmitting the acquired service data to the user terminal is carried out.
Optionally, before the step of determining whether the current database proxy node is located within the high-load time period of the database server corresponding to the database access request, the method further includes:
when a database access request sent by a user terminal is received, the database proxy node carries out verification operation on the user terminal;
and when the verification is passed, executing the step that the database proxy node judges whether the database proxy node is currently located in the high-load time period of the database server corresponding to the database access request.
Optionally, the step of sending the obtained service data to the user terminal includes:
and the database proxy node encrypts the acquired service data by using a preset secret key and sends the encrypted service data to the user terminal so that the user terminal can decrypt the service data based on the corresponding secret key.
Optionally, the database access method further includes:
and the database proxy node updates the stored high-load time period information of each database server.
In addition, to achieve the above object, the present invention also provides a database proxy node, including:
the system comprises a judging module, a database access module and a database processing module, wherein the judging module is used for judging whether the database access request sent by a user terminal is currently located in a high-load time period of a database server corresponding to the database access request;
the sending module is used for forwarding the database access request to the database server for execution when the database access request is currently located outside the high-load time period of the database server;
the analysis module is used for analyzing SQL sentences carried by the database access request when the current database access request is located within a high-load time period of the database server;
the sending module is further configured to, when the SQL statement is a DQL statement, obtain currently stored service data pointed by the SQL statement, and send the obtained service data to the user terminal; and
and when the SQL statement is a DML statement and the high load time period of the database server is reached, forwarding the database access request to the database server for execution.
Optionally, the sending module is further configured to, when the stored service data fails to be obtained, obtain and store the service data pointed by the SQL statement based on other database proxy nodes.
Optionally, the database proxy node further includes:
the verification module is used for performing verification operation on the user terminal when receiving a database access request sent by the user terminal;
the judging module is further used for judging whether the current database access request is located within the high-load time period of the database server corresponding to the database access request when the verification is passed.
Optionally, the sending module is further configured to encrypt the obtained service data using a preset key, and send the encrypted service data to the user terminal, so that the user terminal decrypts the service data based on the corresponding key.
Optionally, the database proxy node further includes:
and the updating module is used for updating the stored high-load time period information of each database server.
The database access method provided by the invention is applied to database proxy nodes, and provides proxy service for a plurality of database servers at the back end through the database proxy nodes. For any database server at the back end, if a database proxy node receives a database access request pointing to the database server within a high-load time period of the database server, firstly determining the type of an SQL (structured query language) statement carried by the database access request, and if the carried SQL statement is an DQL statement, directly acquiring and sending service data pointed by the SQL statement to a source user terminal of the database access request; and if the carried SQL statement is the DML statement, sending the database access request to the database server for execution when the carried SQL statement is beyond the high-load time period of the database server. Compared with the prior art, the method and the device can share part of pressure for the database server when the database server works at high load, and achieve the purpose of improving the working stability of the database server.
Drawings
FIG. 1 is a schematic flow chart of a first embodiment of a database access method according to the present invention;
FIG. 2 is a diagram showing an exemplary database topology according to a first embodiment of the database access method of the present invention;
fig. 3 is a functional block diagram of a database proxy node according to a first embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The present invention provides a database access method, and referring to fig. 1, in a first embodiment of the database access method of the present invention, the database access method includes:
step S10, when receiving a database access request sent by a user terminal, a database proxy node judges whether the database proxy node is currently located in a high-load time period of a database server corresponding to the database access request, if not, the step S20 is executed, and if yes, the step S30 is executed;
referring to fig. 2, which is an exemplary diagram of a database topology structure applied to the database access method of the present invention, as shown in fig. 2, a database proxy node provides a proxy service for a plurality of database servers at a back end, and for any database server at the back end, if the database proxy node receives a database access request directed to the database server within a high-load time period of the database server, first determine a type of an SQL (Structured Query Language) statement carried by the database access request, and then execute different operations according to the type of the parsed SQL statement, so as to reduce a working pressure of the database server and improve a working stability of the database server.
Specifically, in the embodiment of the present invention, the user terminal provides a visual operation interface based on the database server, such as a web interface provided by a browser; when a user terminal receives a URL (uniform resource locator) input by a user based on an address bar of a browser, or click operation triggered by a hyperlink address displayed by the browser, or other types of operation, a database access request carrying a corresponding URL (or an IP (Internet protocol) address) and an SQL (structured query language) statement is generated and sent to a database proxy node to request service data corresponding to the URL or the hyperlink address; when receiving a database access request sent by a user terminal, the database proxy node firstly judges whether the database proxy node is currently located in a high-load time period of a database server corresponding to the database access request.
It should be noted that the database proxy node also stores high-load time period information of each database server of its proxy, which is used to describe a time period in which each database server may be under high load. The high-load time period information can be manually input by a manager with authority, or can be obtained by counting according to the recorded real-time workload of each database server and sent to the database proxy node. When receiving a database access request sent by a user terminal, a database proxy node directly judges whether the current system time is in a high-load time period of a database server corresponding to the database access request, and if so, the database proxy node determines that the database server is in a high-load working state.
In another embodiment, before the step S10, the method further includes:
a database routing device receives an original database access request sent by the user terminal, wherein the original database access request carries an original URL (uniform resource locator) requested by the user terminal, and a domain name corresponding to the original URL is an original domain name requested by the user terminal; and the database routing equipment returns a redirection response message to the user terminal, and the domain name corresponding to the URL carried by the redirection response message comprises the node identification of the database proxy node selected by the database routing equipment for the user terminal, so that the user terminal sends a database access request to the database proxy node, and the database proxy node provides proxy service.
For example, the URL carried in a database access request sent by a user terminal to a database proxy node is https:// www.XXX.com/news/a. html, wherein, the content corresponding to www.XXX.com is provided by a background database server, proxy service is provided through the database proxy node, a database routing device selects a database proxy node for the user terminal according to a predetermined policy, and if the node identifier of the selected database proxy node is C1, a new URL is constructed as https:// C1/www.XXX.com/news/a. html. And the user terminal sends a database access request to the new URL to request the service data corresponding to the page.
Step S20, the database proxy node forwards the database access request to the database server for execution;
it is easily understood that when the database server is located outside the high load time period of the database server, that is, the database server is not operating at high load, the database server can normally provide the data service, and obviously, the database proxy node does not need to provide the proxy service. Therefore, in the embodiment of the present invention, when determining that the current location is outside the high-load time period of the database server corresponding to the database access request, the database proxy node directly forwards the received database access request to the database server for execution.
Specifically, when executing a received database access request, the database server parses out an SQL statement carried by the database access request, where the SQL statement includes a DQL (Data Query Language) statement and a DML (Data management Language) statement. When the analyzed SQL statement is the DQL statement, the user is indicated to inquire the data in the database; when the parsed SQL statement is a DML statement, it indicates that the user wants to perform operations on the data in the database, including inserting data, modifying data, deleting data, and the like.
For example, when the parsed SQL statement is a DQL statement, the database server obtains the stored service data pointed by the SQL statement, and returns the obtained service data to the source user terminal of the database access request received by the database server; for another example, when the parsed SQL statement is a DML statement, the database server performs a corresponding operation based on the parsed SQL statement, and returns a result of the operation to the user terminal, where the result at least includes information about whether the operation is successful.
Step S30, the database agent node analyzes the SQL statement carried by the database access request, wherein if the SQL statement is the DQL statement, the step S40 is executed, and if the SQL statement is the DML statement, the step S20 is executed when the SQL statement reaches the time outside the high-load time period of the database server;
step S40, the database proxy node acquires the currently stored service data pointed by the SQL statement, and sends the acquired service data to the user terminal.
As will be appreciated by those skilled in the art, the delay of a database server in responding to a database access request will increase significantly in the case of high-load operation, and as the received database access requests continue to grow, the processing resources of the database server will be depleted, and a downtime service may occur. Therefore, in the embodiment of the present invention, when the current location is within the high load time period of the database server corresponding to the database access request, the database proxy node proxies the database server to provide the service.
Specifically, when determining that the current database proxy node is located within a high-load time period of a database server corresponding to the database access request, the database proxy node firstly analyzes an SQL statement carried by the received database access request, and judges whether the analyzed SQL statement is a DQL statement; wherein,
when the analyzed SQL statement is the DQL statement, the database proxy node acquires the currently stored service data pointed by the SQL statement, and directly sends the acquired service data to the user terminal for presentation to the user;
and when the analyzed SQL statement is the DQL statement, the database proxy node sends the received database access request to the database server for execution when waiting for the database proxy node to reach the time outside the high-load time period of the database server.
It should be noted that, in other embodiments, the database proxy node further deletes the stored service data that has not been accessed within the preset time period. The preset time period may be set according to actual needs, for example, the preset time period is set to 24 hours in this embodiment, and it can be understood by those skilled in the art that by periodically deleting service data that has not been accessed for a long time, the utilization rate of the storage space of the database proxy node can be improved, so as to better provide proxy services.
In the database access method provided by this embodiment, a database proxy node provides a proxy service for a plurality of database servers at a back end, and for any database server at the back end, if the database proxy node receives a database access request directed to the database server within a high-load time period of the database server, the type of an SQL statement carried in the database access request is first determined, and if the carried SQL statement is a DQL statement, service data directed by the SQL statement is directly acquired and sent to a source user terminal of the database access request; and if the carried SQL statement is the DML statement, sending the database access request to the database server for execution when the carried SQL statement is beyond the high-load time period of the database server. Compared with the prior art, the method and the device can share part of pressure for the database server when the database server works at high load, and achieve the purpose of improving the working stability of the database server.
Further, based on the first embodiment, a second embodiment of the database access method of the present invention is provided, and in this embodiment, before the step of sending the obtained service data to the user terminal, the method further includes:
and when the stored service data is failed to be acquired, the database proxy node acquires and stores the service data pointed by the SQL statement based on other database proxy nodes, and the step of transmitting the acquired service data to the user terminal is carried out.
It should be noted that the difference between this embodiment and the first embodiment is that the processing operation when the database proxy node fails to acquire the stored service data is added in this embodiment, and only this difference is described below, and other embodiments may refer to the first embodiment, and are not described herein again.
Based on the foregoing description, those skilled in the art will appreciate that the delay of the database server in responding to the database access request will increase significantly in the case of high-load operation, and as the received database access request continues to grow, the processing resources of the database server will be depleted, and a downtime out of service may occur. Therefore, in the embodiment of the present invention, when the database proxy node fails to acquire the stored service data, the database proxy node acquires and stores the service data pointed by the database access request based on other database proxy nodes, and the following description specifically describes that the database proxy node is a first proxy node, and the other database proxy nodes are second proxy nodes:
when the first proxy node fails to acquire the stored service data, the received database access request is forwarded to a second proxy node, wherein the first proxy node adds identification information for describing the passing of the user terminal verification in the database access request so as to avoid the second proxy node from performing secondary verification to cause unnecessary processing resource waste; when receiving a database access request forwarded by a first proxy node, a second proxy node identifies the identification information carried by the database access request, directly acquires stored service data pointed by the database access request and returns the service data to the first proxy node; and when receiving the service data returned by the second proxy node, the first proxy node stores the received service data as the service data pointed by the database access request, and simultaneously, encrypts the service data by using the updated public key and returns the encrypted service data to the user terminal.
In the embodiment, when the database proxy node does not store the service data pointed by the database access request received by the database proxy node, proxy service is provided based on other database proxy nodes, so that the user terminal can be ensured to normally obtain data service.
Further, based on the first embodiment, a third embodiment of the database access method according to the present invention is provided, where in this embodiment, before step S10, the method further includes:
when a database access request sent by a user terminal is received, the database proxy node carries out verification operation on the user terminal;
when the verification is passed, the flow proceeds to step S10.
It should be noted that the difference between this embodiment and the first embodiment is that the present embodiment adds an authentication operation to the user terminal on the basis of the first embodiment, and only this difference is described below, and other embodiments may refer to the first embodiment, and are not described herein again.
In the embodiment of the present invention, when receiving a database access request sent by a user terminal, the database proxy node first verifies the identity of the user terminal based on the received database access request, for example, the database access request sent by the user terminal also carries a user name and a corresponding password that are pre-input by the user based on the user terminal, and when receiving the database access request sent by the user terminal, the database proxy node verifies the identity of the user terminal according to the user name and the password carried by the database access request, so as to determine whether the corresponding user is an authorized user. After the verification is passed, it is determined whether the current time is within the high-load time period of the database server corresponding to the database access request, so as to start the processing flow of the proxy service.
This embodiment is through verifying user terminal, can promote the security of storage data.
Further, based on any one of the foregoing embodiments, a fourth embodiment of the database access method of the present invention is provided, and in this embodiment, the step of sending the obtained service data to the user terminal includes:
and the database proxy node encrypts the acquired service data by using a preset secret key and sends the encrypted service data to the user terminal so that the user terminal can decrypt the service data based on the corresponding secret key.
It should be noted that the difference between this embodiment and the first embodiment is that a specific description of sending the service data is added in this embodiment, and only this difference is described below, and other embodiments can be referred to separately, and are not described herein again.
As will be understood by those skilled in the art, data is easily stolen by illegal persons during transmission in the network, resulting in leakage of user data. Therefore, in this embodiment, when the database proxy node sends the obtained service data, the preset key is obtained first, and the obtained service data is encrypted by using the key, where the encryption may be performed by using an asymmetric encryption algorithm such as an RSA algorithm or an Elgamal algorithm, or may be performed by using a symmetric encryption algorithm such as a DES algorithm, a 3DES algorithm, a TDEA algorithm, a Blowfish algorithm, an RC5 algorithm, or an IDEA algorithm.
For example, when the database proxy node encrypts the acquired service data by using the RSA algorithm based on the public key issued by the user terminal in advance, the user terminal needs to decrypt the service data by using the RSA algorithm based on the private key corresponding to the public key; for another example, when the database proxy node encrypts the acquired service data by using the DES algorithm using the key agreed in advance with the user terminal, the user terminal needs to decrypt the service data by using the DES algorithm based on the same key.
The embodiment can realize the safety of data transmission by encrypting the transmitted service data.
Further, based on any one of the foregoing embodiments, a fifth embodiment of the database access method according to the present invention is provided, in this embodiment, the database access method further includes:
and the database proxy node updates the stored high-load time period information of each database server.
It should be noted that the difference between this embodiment and any of the foregoing embodiments is that the update operation of the high-load time period information of the database server is added in this embodiment, and only this difference is described below, and other embodiments may be referred to separately, and are not described herein again.
In the embodiment of the present invention, three ways of updating the high load time period information are provided:
firstly, when a database agent node receives an update instruction of a manager with a preset authority, the database agent node updates high-load time period information of a corresponding database server according to the received update instruction;
secondly, when receiving the high-load time period information sent by the database server, the database proxy node updates the stored high-load time period information corresponding to the database server into the received high-load time period information;
and thirdly, the database proxy node sends the updating request to each database server at regular time, and when receiving the high-load time period information returned by each database server based on the received updating request, the high-load time period information corresponding to each data server is respectively updated to the received corresponding high-load time period information.
In this embodiment, the stored high-load time period information of each database server is updated, so that the database proxy node can better provide proxy service, and the working stability of the database server is further improved.
The present invention also provides a database proxy node, and referring to fig. 3, in a first embodiment of the database proxy node of the present invention, the database proxy node includes:
the system comprises a judging module 10, a database server and a database server, wherein the judging module is used for judging whether a database access request sent by a user terminal is currently located in a high-load time period of the database server corresponding to the database access request;
as shown in fig. 2, a database proxy node provides proxy services for a plurality of database servers at a back end, and for any database server at the back end, if the database proxy node receives a database access request directed to the database server within a high-load time period of the database server, first determine a type of an SQL (Structured Query Language) statement carried by the database access request, and then execute different operations according to the type of the parsed SQL statement, so as to reduce a working pressure of the database server and improve a working stability of the database server.
Specifically, in the embodiment of the present invention, the user terminal provides a visual operation interface based on the database server, such as a web interface provided by a browser; when a user terminal receives a URL (uniform resource locator) input by a user based on an address bar of a browser, or click operation triggered by a hyperlink address displayed by the browser, or other types of operation, a database access request carrying a corresponding URL (or an IP (Internet protocol) address) and an SQL (structured query language) statement is generated and sent to a database proxy node to request service data corresponding to the URL or the hyperlink address; when receiving a database access request sent by a user terminal, the database proxy node firstly judges whether the database proxy node is currently located in a high-load time period of a database server corresponding to the database access request.
It should be noted that the database proxy node also stores high-load time period information of each database server of its proxy, which is used to describe a time period in which each database server may be under high load. The high-load time period information can be manually input by a manager with authority, or can be obtained by counting according to the recorded real-time workload of each database server and sent to the database proxy node. When receiving a database access request sent by a user terminal, the determining module 10 directly determines whether the current system time is in a high-load time period of a database server corresponding to the database access request, and if so, determines that the database server is in a high-load working state.
It should be noted that, in other embodiments, before providing the proxy service, the database proxy node further includes:
a database routing device receives an original database access request sent by the user terminal, wherein the original database access request carries an original URL (uniform resource locator) requested by the user terminal, and a domain name corresponding to the original URL is an original domain name requested by the user terminal; and the database routing equipment returns a redirection response message to the user terminal, and the domain name corresponding to the URL carried by the redirection response message comprises the node identification of the database proxy node selected by the database routing equipment for the user terminal, so that the user terminal sends a database access request to the database proxy node, and the database proxy node provides proxy service.
For example, the URL carried in a database access request sent by a user terminal to a database proxy node is https:// www.XXX.com/news/a. html, wherein, the content corresponding to www.XXX.com is provided by a background database server, proxy service is provided through the database proxy node, a database routing device selects a database proxy node for the user terminal according to a predetermined policy, and if the node identifier of the selected database proxy node is C1, a new URL is constructed as https:// C1/www.XXX.com/news/a. html. And the user terminal sends a database access request to the new URL to request the service data corresponding to the page.
A sending module 20, configured to forward the database access request to the database server for execution when the database access request is currently located outside the high-load time period of the database server;
it is easily understood that when the database server is located outside the high load time period of the database server, that is, the database server is not operating at high load, the database server can normally provide the data service, and obviously, the database proxy node does not need to provide the proxy service. Therefore, in the embodiment of the present invention, when the determining module 10 determines that the current time is outside the high-load time period of the database server corresponding to the database access request, the sending module 20 directly forwards the received database access request to the database server for execution.
Specifically, when executing a received database access request, the database server parses out an SQL statement carried by the database access request, where the SQL statement includes a DQL (Data Query Language) statement and a DML (Data management Language) statement. When the analyzed SQL statement is the DQL statement, the user is indicated to inquire the data in the database; when the parsed SQL statement is a DML statement, it indicates that the user wants to perform operations on the data in the database, including inserting data, modifying data, deleting data, and the like.
For example, when the parsed SQL statement is a DQL statement, the database server obtains the stored service data pointed by the SQL statement, and returns the obtained service data to the source user terminal of the database access request received by the database server; for another example, when the parsed SQL statement is a DML statement, the database server performs a corresponding operation based on the parsed SQL statement, and returns a result of the operation to the user terminal, where the result at least includes information about whether the operation is successful.
The analysis module 30 is configured to analyze an SQL statement carried by the database access request when the current SQL statement is located within a high-load time period of the database server;
the sending module 20 is further configured to, when the SQL statement is a DQL statement, obtain currently stored service data pointed by the SQL statement, and send the obtained service data to the user terminal; and
and when the SQL statement is a DML statement and the high load time period of the database server is reached, forwarding the database access request to the database server for execution.
As will be appreciated by those skilled in the art, the delay of a database server in responding to a database access request will increase significantly in the case of high-load operation, and as the received database access requests continue to grow, the processing resources of the database server will be depleted, and a downtime service may occur. Therefore, in the embodiment of the present invention, when the current location is within the high load time period of the database server corresponding to the database access request, the database proxy node proxies the database server to provide the service.
Specifically, when the determining module 10 determines that the current location is within the high-load time period of the database server corresponding to the database access request, the parsing module 30 first parses out the SQL statement carried by the received database access request, and determines whether the parsed SQL statement is a DQL statement; wherein,
when the parsed SQL statement is a DQL statement, the sending module 20 obtains currently stored service data pointed by the SQL statement, and directly sends the obtained service data to the user terminal for the user terminal to present;
when the parsed SQL statement is the DQL statement, the sending module 20 sends the received database access request to the database server to execute when waiting for the SQL statement to reach outside the high load time period of the database server.
It should be noted that, in other embodiments, the database proxy node further includes a deleting module, configured to delete the stored service data that is not accessed within the preset time period. The preset time period may be set according to actual needs, for example, the preset time period is set to 24 hours in this embodiment, and it can be understood by those skilled in the art that by periodically deleting service data that has not been accessed for a long time, the utilization rate of the storage space of the database proxy node can be improved, so as to better provide proxy services.
The database proxy node provided in this embodiment provides proxy services for a plurality of database servers at a back end, and for any database server at the back end, if the database proxy node receives a database access request directed to the database server within a high-load time period of the database server, first determines a type of an SQL statement carried by the database access request, and if the carried SQL statement is a DQL statement, directly obtains and sends service data directed by the SQL statement to a source user terminal of the database access request; and if the carried SQL statement is the DML statement, sending the database access request to the database server for execution when the carried SQL statement is beyond the high-load time period of the database server. Compared with the prior art, the method and the device can share part of pressure for the database server when the database server works at high load, and achieve the purpose of improving the working stability of the database server.
Further, based on the first embodiment, a second embodiment of the database proxy node of the present invention is provided, and in this embodiment, the sending module 20 is further configured to, when the stored service data fails to be obtained, obtain and store the service data pointed by the SQL statement based on other database proxy nodes.
It should be noted that the difference between this embodiment and the first embodiment is that the processing operation when the database proxy node fails to acquire the stored service data is added in this embodiment, and only this difference is described below, and details of the other steps are not described again.
Based on the foregoing description, those skilled in the art will appreciate that the delay of the database server in responding to the database access request will increase significantly in the case of high-load operation, and as the received database access request continues to grow, the processing resources of the database server will be depleted, and a downtime out of service may occur. Therefore, in the embodiment of the present invention, when the sending module 20 fails to acquire and store the stored service data, the service data pointed by the database access request is acquired and stored based on other database proxy nodes, and the following specific description is made with the database proxy node where the sending module 20 is located as a first proxy node and the other database proxy nodes as second proxy nodes:
when the stored service data is failed to be acquired, the first proxy node (sending module 20) forwards the received database access request to the second proxy node, wherein the first proxy node adds identification information for describing the passing of the user terminal verification in the database access request, so as to avoid the second proxy node from performing secondary verification, which causes unnecessary processing resource waste; when receiving a database access request forwarded by a first proxy node, a second proxy node identifies the identification information carried by the database access request, directly acquires stored service data pointed by the database access request and returns the service data to the first proxy node; and when receiving the service data returned by the second proxy node, the first proxy node stores the received service data as the service data pointed by the database access request and returns the service data to the user terminal.
In the embodiment, when the database proxy node does not store the service data pointed by the database access request received by the database proxy node, proxy service is provided based on other database proxy nodes, so that the user terminal can be ensured to normally obtain data service.
Further, based on the first embodiment, a third embodiment of the database proxy node of the present invention is provided, in this embodiment, the database proxy node further includes:
the verification module is used for performing verification operation on the user terminal when receiving a database access request sent by the user terminal;
the determining module 10 is further configured to determine whether the current time period is within a high-load time period of the database server corresponding to the database access request when the verification is passed.
It should be noted that the difference between this embodiment and the first embodiment is that, in this embodiment, an authentication operation for the user terminal is added on the basis of the first embodiment, and only this difference is described below, and the rest is not described again.
In the embodiment of the invention, when a database access request sent by a user terminal is received, firstly, an authentication module authenticates the identity of the user terminal based on the received database access request, for example, the database access request sent by the user terminal also carries a user name and a corresponding password which are pre-input by the user based on the user terminal, and when the database access request sent by the user terminal is received, a database proxy node authenticates the identity of the user terminal according to the user name and the password carried by the database access request so as to determine whether the corresponding user is an authorized user. After the verification is passed, the verification module transmits the received database access request to the determination module 10 for update processing, so as to start the processing flow of the proxy service.
This embodiment is through verifying user terminal, can promote the security of storage data.
Further, based on any one of the foregoing embodiments, a fourth embodiment of the database proxy node of the present invention is provided, and in this embodiment, the sending module 20 is further configured to encrypt the obtained service data using a preset key, and send the encrypted service data to the user terminal, so that the user terminal decrypts the service data based on the corresponding key.
It should be noted that the difference between this embodiment and the first embodiment is that a specific description of sending the service data is added in this embodiment, and only this difference is described below, and other embodiments can be referred to separately, and are not described herein again.
As will be understood by those skilled in the art, data is easily stolen by illegal persons during transmission in the network, resulting in leakage of user data. Therefore, in this embodiment, when sending the obtained service data, the sending module 20 first obtains the preset key, and encrypts the obtained service data by using the key, where the encryption may be performed by using an asymmetric encryption algorithm such as an RSA algorithm or an Elgamal algorithm, or may be performed by using a symmetric encryption algorithm such as a DES algorithm, a 3DES algorithm, a TDEA algorithm, a Blowfish algorithm, an RC5 algorithm, or an IDEA algorithm.
For example, when the sending module 20 encrypts the obtained service data by using the RSA algorithm based on the public key issued by the user terminal in advance, the user terminal needs to decrypt the service data by using the RSA algorithm based on the private key corresponding to the public key; for another example, when the sending module 20 encrypts the acquired service data by using the DES algorithm using the key agreed in advance with the user terminal, the user terminal needs to decrypt the service data by using the DES algorithm based on the same key.
The embodiment can realize the safety of data transmission by encrypting the transmitted service data.
Further, based on any one of the foregoing embodiments, a fifth embodiment of the database proxy node of the present invention is provided, in this embodiment, the database proxy node further includes:
and the updating module is used for updating the stored high-load time period information of each database server.
It should be noted that the difference between this embodiment and any of the foregoing embodiments is that the update operation of the high-load time period information of the database server is added in this embodiment, and only this difference is described below, and other embodiments may be referred to separately, and are not described herein again.
In the embodiment of the present invention, three ways of updating the high load time period information are provided:
firstly, when an updating instruction of a manager with a preset authority is received by an updating module, updating high-load time period information of a corresponding database server according to the received updating instruction;
when receiving the high-load time period information sent by the database server, the updating module updates the stored high-load time period information corresponding to the database server into the received high-load time period information;
and thirdly, the updating module sends updating requests to the database servers at regular time, and when receiving the high-load time period information returned by the database servers based on the received updating requests, the high-load time period information corresponding to the database servers is respectively updated to the received corresponding high-load time period information.
In this embodiment, the stored high-load time period information of each database server is updated, so that the database proxy node can better provide proxy service, and the working stability of the database server is further improved.
The above description is only for the preferred embodiment of the present invention and is not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related arts, are included in the scope of the present invention.
Claims (6)
1. A database access method, comprising the steps of:
step A, when a database access request sent by a user terminal is received, a database proxy node judges whether the database access request is currently located in a high-load time period of a database server corresponding to the database access request, if not, the step B is executed, and if yes, the step C is executed;
b, the database proxy node forwards the database access request to the database server for execution;
step C, the database agent node analyzes the SQL sentences carried by the database access request, wherein if the SQL sentences are DQL sentences, the step D is executed, and if the SQL sentences are DML sentences, the step B is executed when the SQL sentences reach the time outside the high-load time period of the database server;
step D, the database proxy node acquires and stores the business data pointed by the currently stored SQL statement, and sends the acquired business data to the user terminal when the acquisition of the stored business data fails, wherein the database proxy node is a first proxy node, the other database proxy nodes are second proxy nodes, and the first proxy node forwards a database access request received by the first proxy node to the second proxy node when the acquisition of the stored business data fails, and identification information used for describing the verification passing of the user terminal is added in the database access request by the first proxy node;
and the database proxy node updates the stored high-load time period information of each database server, wherein the database proxy node sends an update request to each database server at regular time, and when receiving the high-load time period information returned by each database server based on the received update request, the high-load time period information corresponding to each data server is respectively updated to the received corresponding high-load time period information.
2. The database access method according to claim 1, wherein the step of the database proxy node determining whether the database proxy node is currently located in the high-load time period of the database server corresponding to the database access request further comprises:
when a database access request sent by a user terminal is received, the database proxy node carries out verification operation on the user terminal;
and when the verification is passed, executing the step that the database proxy node judges whether the database proxy node is currently located in the high-load time period of the database server corresponding to the database access request.
3. The database access method according to any one of claims 1 or 2, wherein the step of sending the acquired service data to the user terminal comprises:
and the database proxy node encrypts the acquired service data by using a preset secret key and sends the encrypted service data to the user terminal so that the user terminal can decrypt the service data based on the corresponding secret key.
4. A database proxy node, the database proxy node comprising:
the system comprises a judging module, a database access module and a database processing module, wherein the judging module is used for judging whether the database access request sent by a user terminal is currently located in a high-load time period of a database server corresponding to the database access request;
the sending module is used for forwarding the database access request to the database server for execution when the database access request is currently located outside the high-load time period of the database server;
the analysis module is used for analyzing SQL sentences carried by the database access request when the current database access request is located within a high-load time period of the database server;
the sending module is further configured to, when the SQL statement is a DQL statement, obtain currently stored service data pointed by the SQL statement, and send the obtained service data to the user terminal; and
when the SQL statement is a DML statement and reaches the outside of the high-load time period of the database server, forwarding the database access request to the database server for execution;
the sending module is further used for acquiring and storing the business data pointed by the SQL statement based on other database proxy nodes when the acquisition of the stored business data fails, the database proxy nodes are first proxy nodes, the other database proxy nodes are second proxy nodes, and the first proxy nodes forward the received database access requests to the second proxy nodes when the acquisition of the stored business data fails, wherein identification information used for describing the passing of the verification of the user terminal is added in the database access requests by the first proxy nodes;
and the updating module is used for updating the stored high-load time period information of each database server by the database proxy node, wherein the database proxy node sends an updating request to each database server at regular time, and when receiving the high-load time period information returned by each database server based on the received updating request, the high-load time period information corresponding to each data server is respectively updated into the received corresponding high-load time period information.
5. The database proxy node of claim 4, further comprising:
the verification module is used for performing verification operation on the user terminal when receiving a database access request sent by the user terminal;
the judging module is further used for judging whether the current database access request is located within the high-load time period of the database server corresponding to the database access request when the verification is passed.
6. The database proxy node according to any one of claims 4 or 5, wherein the sending module is further configured to encrypt the obtained service data using a preset key, and send the encrypted service data to the user terminal, so that the user terminal decrypts the service data based on the corresponding key.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610313378.6A CN105956143B (en) | 2016-05-11 | 2016-05-11 | Data bank access method and database broker node |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610313378.6A CN105956143B (en) | 2016-05-11 | 2016-05-11 | Data bank access method and database broker node |
Publications (2)
Publication Number | Publication Date |
---|---|
CN105956143A CN105956143A (en) | 2016-09-21 |
CN105956143B true CN105956143B (en) | 2019-07-26 |
Family
ID=56912618
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610313378.6A Active CN105956143B (en) | 2016-05-11 | 2016-05-11 | Data bank access method and database broker node |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105956143B (en) |
Families Citing this family (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107222493A (en) * | 2017-06-26 | 2017-09-29 | 浪潮软件股份有限公司 | ORACLE-JDBC data transmission channel encryption compression system and method |
CN110457944B (en) * | 2019-08-02 | 2023-08-25 | 爱友智信息科技(苏州)有限公司 | Data sharing method and system |
CN110661786B (en) * | 2019-09-04 | 2021-10-08 | 杭州利项科技有限公司 | User data system based on chain relation |
CN111949451A (en) * | 2020-08-17 | 2020-11-17 | 广东睿江云计算股份有限公司 | Database operation backup method and system |
CN112162996A (en) * | 2020-09-23 | 2021-01-01 | 金现代信息产业股份有限公司 | Database access method and system for in-station graph editor |
CN112181948B (en) * | 2020-09-30 | 2024-02-02 | 中国工商银行股份有限公司 | Processing method and device of database operation statement, electronic equipment and medium |
CN112632625A (en) * | 2020-12-31 | 2021-04-09 | 深圳昂楷科技有限公司 | Database security gateway system, data processing method and electronic equipment |
CN113778998A (en) * | 2021-09-28 | 2021-12-10 | 北京安华金和科技有限公司 | Database proxy fault prevention processing method and device |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101916298A (en) * | 2010-08-31 | 2010-12-15 | 深圳市赫迪威信息技术有限公司 | Database operation method, apparatus and system |
CN103095691A (en) * | 2012-12-31 | 2013-05-08 | 清华大学 | Method of controlling access to Internet of things nodes |
CN103139278A (en) * | 2011-12-05 | 2013-06-05 | 北京网康科技有限公司 | Network resource pre-fetching and cache accelerating method and device thereof |
CN103365979A (en) * | 2013-07-03 | 2013-10-23 | 交通银行股份有限公司 | Long-distance double-center online processing method and system based on open database |
CN105183751A (en) * | 2015-07-13 | 2015-12-23 | 深信服网络科技(深圳)有限公司 | Database access method and database access device |
-
2016
- 2016-05-11 CN CN201610313378.6A patent/CN105956143B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101916298A (en) * | 2010-08-31 | 2010-12-15 | 深圳市赫迪威信息技术有限公司 | Database operation method, apparatus and system |
CN103139278A (en) * | 2011-12-05 | 2013-06-05 | 北京网康科技有限公司 | Network resource pre-fetching and cache accelerating method and device thereof |
CN103095691A (en) * | 2012-12-31 | 2013-05-08 | 清华大学 | Method of controlling access to Internet of things nodes |
CN103365979A (en) * | 2013-07-03 | 2013-10-23 | 交通银行股份有限公司 | Long-distance double-center online processing method and system based on open database |
CN105183751A (en) * | 2015-07-13 | 2015-12-23 | 深信服网络科技(深圳)有限公司 | Database access method and database access device |
Also Published As
Publication number | Publication date |
---|---|
CN105956143A (en) | 2016-09-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105956143B (en) | Data bank access method and database broker node | |
US10270758B2 (en) | Login method, server, and login system | |
JP5978759B2 (en) | Service request apparatus, service providing system, service request method, and service request program | |
EP3537689B1 (en) | Using credentials stored in different directories to access a common endpoint | |
US8302169B1 (en) | Privacy enhancements for server-side cookies | |
US8898765B2 (en) | Signing off from multiple domains accessible using single sign-on | |
KR100615793B1 (en) | Method and apparatus for serving content from a semi-trusted server | |
US7454421B2 (en) | Database access control method, database access controller, agent processing server, database access control program, and medium recording the program | |
KR101302135B1 (en) | Method and apparetus for encoding/decoding partial of data | |
CN111314491B (en) | Cross-tenant data interaction method and device, server cluster and medium | |
CN110166577B (en) | Distributed application group session processing system and method | |
CN111428225A (en) | Data interaction method and device, computer equipment and storage medium | |
WO2009107219A1 (en) | Authentication device, authentication method, and authentication program with the method mounted thereon | |
WO2020019478A1 (en) | Communication data encryption method and apparatus | |
US9398075B2 (en) | Communication system, communication apparatus, communication method, and storage medium | |
CN107463848B (en) | Application-oriented ciphertext search method, device, proxy server and system | |
WO2020019477A1 (en) | Communication data encryption method and apparatus | |
CN104702575B (en) | A kind of account management method, management platform and system | |
CN111488604A (en) | Data desensitization system and data desensitization method | |
CN112653671A (en) | Network communication method, device, equipment and medium for client and server | |
CN112560003A (en) | User authority management method and device | |
CN113329242A (en) | Resource management method and device | |
CN112491955A (en) | Method and system for realizing data exchange of iframe system based on proxy server | |
JP2010272951A (en) | Method and server for managing distribution of shared key | |
CN116346486A (en) | Combined login method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
CB02 | Change of applicant information |
Address after: 518057 Shenzhen Software Park, Nanshan District high tech Industrial Park, Guangdong, China,, 6 401-402 Applicant after: Yongxing Shenzhen Polytron Technologies Inc Address before: 518057 Shenzhen Software Park, Nanshan District high tech Industrial Park, Guangdong, China,, 6 401-402 Applicant before: Shenzhen Longrise Technology Co., Ltd. |
|
COR | Change of bibliographic data | ||
GR01 | Patent grant | ||
GR01 | Patent grant |