CN109471902A - A kind of database switching method, device, equipment and system - Google Patents

A kind of database switching method, device, equipment and system Download PDF

Info

Publication number
CN109471902A
CN109471902A CN201710806380.1A CN201710806380A CN109471902A CN 109471902 A CN109471902 A CN 109471902A CN 201710806380 A CN201710806380 A CN 201710806380A CN 109471902 A CN109471902 A CN 109471902A
Authority
CN
China
Prior art keywords
database
state information
middleware
connection state
operation requests
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201710806380.1A
Other languages
Chinese (zh)
Inventor
吴旭冬
黄大鹏
侯宏元
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Cloud Computing Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201710806380.1A priority Critical patent/CN109471902A/en
Publication of CN109471902A publication Critical patent/CN109471902A/en
Pending legal-status Critical Current

Links

Landscapes

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

Abstract

The application provides a kind of database switching method, device, equipment and system, this method comprises: receiving the switching request that first database is sent;Connection state information is got from the first database, and the connection state information is sent to the second database, so that connection state information described in second database purchase;Operation requests corresponding with the first database are sent to second database, so that second database root is handled the operation requests according to the connection state information.Pass through the technical solution of the application, connection state information can be kept constant in database handoff procedure, that is the connection state information that the second database uses is identical as the connection state information that first database uses, it, being capable of significantly more efficient realization database connection holding function to promote the success rate of database switching.

Description

A kind of database switching method, device, equipment and system
Technical field
This application involves Internet technical field more particularly to a kind of database switching method, device, equipment and systems.
Background technique
With the rapid development of internet, the middleware Technology of database has obtained extensively in distributed data base system Using.Middleware is the relay device between application server and database, and can be separately connected application server and Database.When application server needs to access database, then application server needs to establish a communication connection with middleware 1, and middleware needs and Database one communication connection 2.
When application server is needed using SQL (Structured Query Language, structured query language) sentence When operating to the data in database, SQL statement can be sent to middleware by communication connection 1, middleware passes through logical The SQL statement is sent to database by letter connection 2.Database executes the SQL statement received, and is answered by middleware to this The implementing result of the SQL statement is returned with server.
But if database breaks down, the communication connection 2 between middleware and database is interrupted, in this way, needle Application server is sent to the SQL statement of database, and middleware can not be sent to database by communication connection 2, lead to nothing Method handles these SQL statements, and has an impact to business experience.
Summary of the invention
The application provides a kind of database switching method, is applied to middleware, which comprises
Receive the switching request that first database is sent;
Connection state information is got from the first database, and the connection state information is sent to the second data Library, so that connection state information described in second database purchase;
Operation requests corresponding with the first database are sent to second database, so that second data Library is handled the operation requests according to the connection state information.
The application provides a kind of database switching device, is applied to middleware, and described device includes:
Receiving module, for receiving the switching request of first database transmission;
Module is obtained, for getting connection state information from the first database;
Sending module, for the connection state information to be sent to the second database, so that the second database purchase institute State connection state information;Operation requests corresponding with the first database are sent to second database, so that second Database root is handled the operation requests according to the connection state information.
The application provides a kind of middleware equipment, and the middleware equipment includes:
Receiver, for receiving the switching request of first database transmission;
Processor, for getting connection state information from the first database;
Transmitter, for the connection state information to be sent to the second database, so that described in the second database purchase Connection state information;Operation requests corresponding with the first database are sent to second database, so that described Two database roots are handled the operation requests according to the connection state information.
The application provides a kind of database switching system, the system comprises:
First database, for sending switching request to middleware;
Middleware, the switching request sent for receiving the first database, gets company from the first database Status information is connect, and the connection state information is sent to the second database;
Second database, for storing the connection state information received;
Middleware is also used to the corresponding operation requests of the first database being sent to second database;
Second database is also used to handle the operation requests according to the connection state information.
Based on the above-mentioned technical proposal, in the embodiment of the present application, when needing to be switched to the second database from first database, Middleware can get connection state information from first database, and connection state information is sent to the second database, with Make the second database purchase connection state information, and operation requests are handled according to the connection state information.In this way, can To keep connection state information constant in database handoff procedure, i.e. the connection state information and first that the second database uses The connection state information that database uses is identical, so that the success rate of database switching is promoted, it being capable of significantly more efficient realization number It is connected according to library and keeps function.
Detailed description of the invention
It, below will be to the application in order to clearly illustrate the embodiment of the present application or technical solution in the prior art Embodiment or attached drawing needed to be used in the description of the prior art be briefly described, it should be apparent that, it is described below Attached drawing is only some embodiments as described in this application, for those of ordinary skill in the art, can also be according to this Shen Please these attached drawings of embodiment obtain other attached drawings.
Fig. 1 is the application scenarios schematic diagram in a kind of embodiment of the application;
Fig. 2 is the flow chart of the database switching method in a kind of embodiment of the application;
Fig. 3 is the structure chart of the database switching device in a kind of embodiment of the application.
Specific embodiment
In the term that the embodiment of the present application uses merely for the sake of for the purpose of describing particular embodiments, rather than limit this Shen Please.The "an" of singular used in the application and claims, " described " and "the" are also intended to including most shapes Formula, unless context clearly shows that other meanings.It is also understood that term "and/or" used herein refers to comprising one A or multiple associated any or all of project listed may combine.
It will be appreciated that though various letters may be described using term first, second, third, etc. in the embodiment of the present application Breath, but these information should not necessarily be limited by these terms.These terms are only used to for same type of information being distinguished from each other out.For example, In the case where not departing from the application range, the first information can also be referred to as the second information, and similarly, the second information can also be with The referred to as first information.Depending on context, in addition, used word " if " can be construed to " ... when " or " when ... " or " in response to determination ".
It is proposed a kind of database switching method in the embodiment of the present application, this method can be applied to include application server, The system of middleware and database, middleware are the relay devices between application server and database, are referred to as Middleware equipment, middleware can be separately connected application server and database.In one example, application server, centre Part and database can be deployed in the same equipment.In another example, application server, middleware and database can also be with It is deployed in different equipment, as application server, middleware and database are deployed in independent equipment.It is shown in Figure 1, be The application scenarios schematic diagram of the embodiment of the present application, the quantity of application server can be one or more, the quantity of middleware It can be one, the quantity of database can be two or more, with no restrictions to this quantity.
In one example, middleware is the relay device between application server and database, middleware encapsulation There is processing method relevant to the operating system of application server, communication protocol etc., so as to provide unification for database Interface, so that application server haves no need to change database after the configuration of the bottoms such as replacement operation system and communication protocol Program code, and enhance the portability of database.
Middleware can also manage the connection of database, mitigate the burden of database.Specifically, if not using middleware, It when application server accesses database every time, is required to connect with Database one, when extensive application server is visited parallel It when asking database, needs largely to connect with Database simultaneously, is the behaviour for expending time and system resource due to establishing connection Make, and the parallel processing capability of database is limited, therefore, application server substantially reduces the access efficiency of database.It is intermediate Part can be connect with Database multiple free time in advance, and these connections are kept and managed, when application server is logical Cross Middleware Request access database when, the application server first with middleware establishes connection, then, middleware from database Idle connection is selected in the connection of foundation, and application server is distributed into free time connection and is used, and application servers is waited to use After, middleware recycles the connection, to improve application server to the access efficiency of database.
Wherein, above-mentioned database includes but is not limited to MySQL (My Structured Query Language, i.e. relationship Type data base management system) database, the connection between above-mentioned middleware and database can include but is not limited to JDBC (connection of Java Database Connectivity, java database).Certainly, above-mentioned MySQL and JDBC is the application One example, with no restrictions to this database, connection.
In one example, the database before switching can be known as first database, the database after switching is known as Second database.Before database switching, middleware asks operation after the operation requests for receiving application server transmission It asks and is sent to first database, first database executes the operation requests, returns to the operation to application server by middleware The implementing result of request.After database switching, middleware will be grasped after the operation requests for receiving application server transmission Make request and be sent to the second database, the second database executes the operation requests, and being returned by middleware to application server should The implementing result of operation requests.
Wherein, for the process flow before database switching, then: when application server needs to access database, answering It needs to establish with middleware communication connection (subsequent to be known as connection 1) with server, and middleware needs and database (the i.e. first number According to library) establish communication connection (subsequent to be known as connection 2).In application server using operation requests to the data in first database When being operated, then the operation requests are sent to middleware by connection 1 by application server, and middleware is receiving the operation After request, which can be sent to by first database by connection 2.First database is asked receiving the operation After asking, the operation requests are executed, and return to the implementing result of the operation requests to the application server by middleware.
Wherein, for the process flow after database switching, then: being established and led to middleware due to application server Letter connection (connect 1) therefore can not resettle connection between application server and middleware, middleware also need and Second Database communication connection (subsequent to be known as connection 3).In application server using operation requests in the second database Data when being operated, then the operation requests are sent to middleware by connection 1 by application server, and middleware is receiving After the operation requests, which is sent to by the second database by connection 3.Second database is receiving the operation After request, the operation requests are executed, and return to the implementing result of the operation requests to the application server by middleware.
In order to realize above-mentioned database handoff procedure, a kind of database switching method, the party are proposed in the embodiment of the present application Method can be applied to middleware, shown in Figure 2, for the flow chart of the database switching method.
Step 201, the switching request that first database is sent is received.
In one example, first database is executing operation requests, during returning to implementing result, if this first number Database service is no longer provided according to library, and (such as first database causes no longer to provide database clothes restarting, due to exception Business), then first database can send switching request to middleware, which indicates that this first database no longer provides number It is serviced according to library, middleware is needed to carry out database switching.
Wherein, middleware is after the switching request for receiving first database transmission, so that it may the after determining switching Two databases, and connect with the second Database.And it is directed to that " middleware determines the second database after switching, and with second The process of Database connection ", can include but is not limited to such as under type:
The information of the second database after switching can be carried in mode one, above-mentioned switching request is (such as the second database Mark, IP address etc.), middleware can parse the information of the second database from the switching request, and in middleware and Connection is established between two databases.Mode two, middleware are that first database selects the second database after switching (such as from first In other databases except database randomly choose a database, with no restrictions to this selection mode), and middleware with Connection is established between second database.
Wherein, middleware can also judge first database after the switching request for receiving first database transmission In whether there is untreated completion operation requests;If it is, continuing to keep the connection between middleware and first database; If it is not, then the connection between middleware and first database can be disconnected.
For example, within a certain period of time, application server sends operation requests 1- operation requests 3, middleware to middleware After receiving these operation requests, these operation requests are sent to first database.First database is receiving operation After requesting 1- operation requests 3, operation requests 1 are first carried out, after the completion of the execution of operation requests 1, are then taken by middleware to application The implementing result for device return operation requests 1 of being engaged in.Then, first database executes operation requests 2, executes completion to operation requests 2 Afterwards, then the implementing result of operation requests 2 is returned to application server by middleware.Then, first database executes operation and asks 3 are asked, after the completion of the execution of operation requests 3, then returns to the implementing result of operation requests 3 to application server by middleware.
Wherein, above-mentioned " operation requests of untreated completion " refer to: the operation requests that have not carried out have been executed but have not been returned The operation requests of implementing result.For example, if first database is currently executing operation requests 2, but do not returned to middleware also The implementing result of operation requests 2 is returned, then there are the operation requests of untreated completion, i.e. aforesaid operations request 2 in first database It is the operation requests of untreated completion with operation requests 3.
In order to realize the above process, middleware can also count the operation requests quantity sent to first database, with And the implementing result quantity that first database returns.If operation requests quantity is identical as implementing result quantity, illustrate the first number According to the operation requests that untreated completion is not present in library;If operation requests quantity is greater than implementing result quantity, illustrate the first number According in library there are the operation requests of untreated completion, and the difference between operation requests quantity and implementing result quantity, that is, The quantity of the operation requests of untreated completion.
In conclusion when, there are when the operation requests of untreated completion, keeping middleware by continuing in first database Connection between first database enables first database that the implementing result of operation requests is sent to middleware, keeps away The implementing result for exempting from operation requests is lost.Moreover, when the operation requests of untreated completion being not present in first database, It just will disconnect the connection between middleware and first database.
Step 202, connection state information is got from first database, and the connection state information of first database is sent out The second database is given, so that connection state information described in the second database purchase.
In one example, before disconnecting the connection between middleware and first database, middleware can be from first Database gets connection state information.For the process of " getting connection state information from first database ", may include But be not limited to such as under type: middleware sends connection status request message to first database;Then, middleware can receive The response message for the connection status request message that one database returns, and can be parsed from the response message The connection state information of first database.
Wherein, middleware and first database can arrange the format of connection status request message, response message, disappear to this Format is ceased with no restrictions, as long as connection status request message is for requesting connection state information, response message for carrying connection Status information.Based on this, middleware can send connection status request message to first database, and first database exists After receiving this connection status request message, know this connection status request message for requesting the connection of first database Therefore the connection state information of first database is added in response message by status information, and response message is sent to Between part.Middleware is after receiving this response message, so that it may the connection of first database is parsed from the response message Status information.
In one example, above-mentioned connection state information may include: that connection status variable (is referred to as ambient condition Variable, link variable, state variable etc.), the assignment of connection status variable.Wherein, this connection state information is application service The information that device and first database are negotiated, first database can execute the behaviour of application server according to this connection state information It requests, and returns to implementing result to middleware.
In practical applications, variable may include global variable and local variable, global variable using two symbols as Beginning, user can only access, can not assignment, and local variable is defined by user oneself, and life cycle is only in a batch processing Interior effective, local variable, can when to local variable assignments by user oneself definition and assignment using a symbol as beginning To use select or set.Above-mentioned connection status variable can be local variable, naturally it is also possible to and it is global variable, it is right The type of this connection status variable is with no restrictions.
Wherein, global variable can include but is not limited to :@@IDENTITY, indicate that return is finally inserted capable identity column Train value.@@ERROR indicates the error code for returning to the Transact-SQL sentence finally executed, is then zero without mistake.@@ ROWCOUNT, indicates to return the line number that is influenced by a upper sentence, any not return to capable sentence and set 0 for this variable.@@ DBTS indicates the timestamp value for returning to current database.@@SERVERNAME indicates the title for returning to local server.@@ LANGID indicates to return to currently used Language ID value.And so on, with no restrictions to this global variable.
Wherein, local variable (i.e. connection status variable) is by user oneself definition and assignment (the i.e. tax of connection status variable Value), select or set can be used when to local variable assignments, above-mentioned local variable and assignment also just constitute connection Status information.For example, set@name=Zhang San, indicates that local variable is " name ", the assignment of local variable is " Zhang San ".Example again Such as, set@abc=123 indicates that local variable is " abc ", and the assignment of local variable is " 123 ".In another example set@names= Utf8 indicates that local variable is " names ", and the assignment of local variable is " utf8 ".In another example set@autocommit=1, table Show that local variable is " autocommit ", the assignment of local variable is " 1 ".And so on, with no restrictions to this local variable.
In one example, middleware is after getting connection state information from first database, so that it may pass through centre The connection state information of first database is sent to the second database by the connection between part and the second database.Second data Library can store the connection state information of first database after receiving the connection state information of first database, and rear During continuous, the connection state information of first database is used.
Step 203, operation requests corresponding with first database are sent to the second database, so that the second database root The operation requests are handled according to the connection state information of the first database.
In one example, for " operation requests corresponding with first database are sent to the second database by middleware " Process, can include but is not limited to such as under type: mode one, middleware receiving application server transmission with first number After the corresponding operation requests in library, the operation requests received are sent to the second database.Mode two, middleware are among this Part inquires operation requests that are corresponding with first database but being also not issued to first database, and the operation that will be inquired Request is sent to the second database.
For mode one, after middleware is connect with the second Database, when application server uses operation requests pair When data in database are operated, which can be sent to middleware by application server, and middleware is connecing After receiving the operation requests, the operation requests are no longer sent to first database, but pass through middleware and the second database Between connection, which is sent to the second database.
For mode two, within a certain period of time, application server sends operation requests 1- operation requests 5 to middleware, Middleware first sends out each operation requests in these operation requests of local cache, and successively after receiving these operation requests Give first database.For example, operation requests 1 are first sent to first database by middleware, then operation requests 2 are sent to Then operation requests 3 are sent to first database by first database, operation requests 4 are then sent to first database, so Operation requests 5 are sent to first database afterwards.But, it is assumed that after operation requests 3 are sent to first database by middleware, Before operation requests 4 are sent to first database by middleware, middleware receives the switching request of first database transmission, In this way, operation requests 4 and operation requests 5 are just no longer sent to first database by middleware.But in middleware and the second number After establishing connection according to library, middleware can inquire corresponding with first database from this middleware but also be not issued to first The operation requests 4 and operation requests 5 of database, and the operation requests 4 inquired and operation requests 5 can be sent to the second number According to library, without being destined to first database.
In one example, the second database can go out the first data after receiving operation requests from local search The connection state information in library, and the operation requests are handled according to the connection state information of first database, and can lead to Cross the implementing result that middleware returns to operation requests to the application server.
In conclusion in the embodiment of the present application, by the way that the connection state information of first database is sent to the second data Both library handles the second database to operation requests according to the connection state information of first database, i.e., Connection state information is identical, avoids mistake occur to the implementing result of operation requests.
For example, middleware by the connection state information of first database (set@name=Zhang San, set@abc=123, Set@names=utf8, set@autocommit=1) be sent to the second database after, the second database can use these companies Status information is connect to handle operation requests.For example, being directed to " get abc " this operation requests, the second database can benefit The operation requests are handled with connection state information " set@abc=123 ", and implementing result is " 123 ", therefore passed through Between part to application server return implementing result " 123 ", still, if the second database does not store connection state information " set@abc=123 ", it is NULL that will lead to, which can not handle " get abc " this operation requests or implementing result, is then led Implementing result is caused mistake occur.
In another example for " get autocommit " this operation requests, the second database can use the connection shape State information " set@autocommit=1 " handles the operation requests, and implementing result is " 1 ", therefore, the second database Implementing result " 1 " is returned to application server by middleware, still, if the second database does not store connection state information " set@autocommit=1 " will lead to that " get autocommit " this operation requests or implementing result can not be handled For NULL, then implementing result is caused mistake occur.
In the above-described embodiments, operation requests can include but is not limited to SQL statement.Wherein, the SQL statement can be Data query language sentence, data manipulation language sentence, Data Definition Language sentence, data control language sentence, issued transaction Language statement, pointer control language statement etc., it is without limitation.
Based on the above-mentioned technical proposal, in the embodiment of the present application, when needing to be switched to the second database from first database, Middleware can get connection state information from first database, and connection state information is sent to the second database, with Make the second database purchase connection state information, and operation requests are handled according to the connection state information.In this way, can To keep connection state information constant in database handoff procedure, i.e. the connection state information and first that the second database uses The connection state information that database uses is identical, so that the success rate of database switching is promoted, it being capable of significantly more efficient realization number It is connected according to library and keeps function.
Based on similarly applying conceiving with the above method, the embodiment of the present application also provides a kind of database switching device, should Database switching device can be applied to middleware (being referred to as middleware equipment), as shown in figure 3, proposed for the application The structure chart of database switching device, the database switching device include:
Receiving module 301, for receiving the switching request of first database transmission;
Module 302 is obtained, for getting connection state information from the first database;
Sending module 303, for the connection state information to be sent to the second database, so that the second database purchase The connection state information;Operation requests corresponding with the first database are sent to second database, so that the Two database roots are handled the operation requests according to the connection state information.
In one example, the database switching device further includes (not regarding out in figure):
Connection management module, for after getting connection state information, judging whether deposit in the first database In the operation requests of untreated completion;If it is, keeping the connection between the middleware and the first database;If It is no, then disconnect the connection between the middleware and the first database;
The connection management module, is also used to before the connection state information is sent to the second database, from institute The information of the second database after parsing switching in switching request is stated, and between the middleware and second database Establish connection;Alternatively, for the second database after first database selection switching, and in the middleware and described second Connection is established between database.
In one example, the acquisition module 302, specifically for getting connection status from the first database During information, connection status request message can be sent to the first database;Then, the first database is received The response message for the connection status request message returned;Then, described first is parsed from the response message The connection state information of database.
The sending module 303, specifically for will operation requests corresponding with the first database be sent to it is described During second database, after the operation requests corresponding with the first database for receiving application server transmission, The operation requests received are sent to second database;And/or
It inquires corresponding with the first database from the middleware but is also not issued to the first database The operation requests inquired are sent to second database by operation requests.
In one example, the operation requests include: structured query language SQL statement;
The connection state information includes: the assignment of connection status variable, the connection status variable.
Based on similarly applying conceiving with the above method, the embodiment of the present application also provides a kind of middleware equipment, it is described in Between part equipment include: receiver, processor and transmitter;Wherein, receiver, the switching for receiving first database transmission are asked It asks;Processor, for getting connection state information from the first database;Transmitter, for believing the connection status Breath is sent to the second database, so that connection state information described in the second database purchase;It will be corresponding with the first database Operation requests be sent to second database so that second database root is according to the connection state information to the behaviour Make request to be handled.
Based on similarly applying conceiving with the above method, a kind of machine readable storage Jie is also provided in the embodiment of the present application Matter, the machine readable storage medium can be applied to middleware equipment, several meters are stored on the machine readable storage medium The instruction of calculation machine, the computer instruction, which is performed, to be handled as follows:
Receive the switching request that first database is sent;Connection state information is got from the first database;And The connection state information is sent to the second database, so that connection state information described in the second database purchase;Will with institute It states the corresponding operation requests of first database and is sent to second database, so that second database root is according to the connection Status information handles the operation requests.
Based on similarly applying conceiving with the above method, the embodiment of the present application also provides a kind of database switching system, institute The system of stating includes initiating the first database of switching request, middleware, the second database being switched;
The first database, for sending switching request to the middleware;
The middleware, the switching request sent for receiving the first database, obtains from the first database The second database is sent to connection state information, and by the connection state information;
Second database, for storing the connection state information received;
The middleware is also used to the corresponding operation requests of the first database being sent to the second database;
Second database is also used to handle the operation requests according to the connection state information.
In one example, during the middleware gets connection state information from the first database, The middleware is also used to send connection status request message to the first database;The first database is received to return The response message for the connection status request message;The company of the first database is parsed from the response message Connect status information.
System, device, module or the unit that above-described embodiment illustrates can specifically realize by computer chip or entity, Or it is realized by the product with certain function.A kind of typically to realize that equipment is computer, the concrete form of computer can To be personal computer, laptop computer, cellular phone, camera phone, smart phone, personal digital assistant, media play In device, navigation equipment, E-mail receiver/send equipment, game console, tablet computer, wearable device or these equipment The combination of any several equipment.
For convenience of description, it is divided into various units when description apparatus above with function to describe respectively.Certainly, implementing this The function of each unit can be realized in the same or multiple software and or hardware when application.
It should be understood by those skilled in the art that, embodiments herein can provide as method, system or computer program Product.Therefore, complete hardware embodiment, complete software embodiment or reality combining software and hardware aspects can be used in the application Apply the form of example.Moreover, it wherein includes computer usable program code that the embodiment of the present application, which can be used in one or more, The computer implemented in computer-usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) The form of program product.
The application is referring to method, the process of equipment (system) and computer program product according to the embodiment of the present application Figure and/or block diagram describe.It is generally understood that being realized by computer program instructions each in flowchart and/or the block diagram The combination of process and/or box in process and/or box and flowchart and/or the block diagram.It can provide these computer journeys Sequence instruct to general purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices processor with A machine is generated, so that the instruction generation executed by computer or the processor of other programmable data processing devices is used for Realize the dress for the function of specifying in one or more flows of the flowchart and/or one or more blocks of the block diagram It sets.
Moreover, these computer program instructions also can store be able to guide computer or other programmable datas processing set In standby computer-readable memory operate in a specific manner, so that instruction stored in the computer readable memory generates Manufacture including command device, the command device are realized in one process of flow chart or multiple processes and/or block diagram one The function of being specified in a box or multiple boxes.
These computer program instructions can also be loaded into computer or other programmable data processing devices, so that counting Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer Or the instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram The step of function of being specified in one box or multiple boxes.
The above description is only an example of the present application, is not intended to limit this application.For those skilled in the art For, various changes and changes are possible in this application.All any modifications made within the spirit and principles of the present application are equal Replacement, improvement etc., should be included within the scope of the claims of this application.

Claims (10)

1. a kind of database switching method, which is characterized in that be applied to middleware, which comprises
Receive the switching request that first database is sent;
Connection state information is got from the first database, and the connection state information is sent to the second database, So that connection state information described in second database purchase;
Operation requests corresponding with the first database are sent to second database, so that second database root The operation requests are handled according to the connection state information.
2. the method according to claim 1, wherein
It is described get connection state information from the first database after, the method also includes:
Judge the operation requests that whether there is untreated completion in the first database;
If it is, keeping the connection between the middleware and the first database;
If it is not, then disconnecting the connection between the middleware and the first database.
3. the method according to claim 1, wherein
It is described the connection state information is sent to the second database before, the method also includes:
The information of the second database after parsing switching in the switching request, and in the middleware and second number According to establishing connection between library;Alternatively, for the first database selection switching after the second database, and the middleware with Connection is established between second database.
4. the method according to claim 1, wherein
The process that connection state information is got from the first database, specifically includes:
Connection status request message is sent to the first database;
Receive the response message for the connection status request message that the first database returns;
The connection state information of the first database is parsed from the response message.
5. the method according to claim 1, wherein described will operation requests corresponding with the first database It is sent to the process of second database, is specifically included:
After the operation requests corresponding with the first database for receiving application server transmission, the operation received is asked It asks and is sent to second database;And/or
Operation that is corresponding with the first database but being also not issued to the first database is inquired from the middleware The operation requests inquired are sent to second database by request.
6. method described according to claim 1 or 2 or 5, which is characterized in that
The operation requests include: structured query language SQL statement.
7. the method according to claim 1, wherein
The connection state information includes: the assignment of connection status variable, the connection status variable.
8. a kind of database switching device, which is characterized in that be applied to middleware, described device includes:
Receiving module, for receiving the switching request of first database transmission;
Module is obtained, for getting connection state information from the first database;
Sending module, for the connection state information to be sent to the second database, so as to connect described in the second database purchase Connect status information;Operation requests corresponding with the first database are sent to second database, so that the second data Library is handled the operation requests according to the connection state information.
9. a kind of middleware equipment, which is characterized in that the middleware equipment includes:
Receiver, for receiving the switching request of first database transmission;
Processor, for getting connection state information from the first database;
Transmitter, for the connection state information to be sent to the second database, so as to be connected described in the second database purchase Status information;Operation requests corresponding with the first database are sent to second database, so that second number The operation requests are handled according to the connection state information according to library.
10. a kind of database switching system, which is characterized in that the system comprises:
First database, for sending switching request to middleware;
Middleware, the switching request sent for receiving the first database, gets connection shape from the first database State information, and the connection state information is sent to the second database;
Second database, for storing the connection state information received;
Middleware is also used to the corresponding operation requests of the first database being sent to second database;
Second database is also used to handle the operation requests according to the connection state information.
CN201710806380.1A 2017-09-08 2017-09-08 A kind of database switching method, device, equipment and system Pending CN109471902A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710806380.1A CN109471902A (en) 2017-09-08 2017-09-08 A kind of database switching method, device, equipment and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710806380.1A CN109471902A (en) 2017-09-08 2017-09-08 A kind of database switching method, device, equipment and system

Publications (1)

Publication Number Publication Date
CN109471902A true CN109471902A (en) 2019-03-15

Family

ID=65657966

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710806380.1A Pending CN109471902A (en) 2017-09-08 2017-09-08 A kind of database switching method, device, equipment and system

Country Status (1)

Country Link
CN (1) CN109471902A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112541006A (en) * 2019-09-23 2021-03-23 拉扎斯网络科技(上海)有限公司 Database command request processing method and device, electronic equipment and storage medium
CN114253620A (en) * 2021-12-27 2022-03-29 中国建设银行股份有限公司 Host system switching method and device, electronic equipment and computer storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101207512A (en) * 2006-12-22 2008-06-25 中兴通讯股份有限公司 Method for switching and redundancy backup of database system
CN104579791A (en) * 2015-01-26 2015-04-29 浪潮电子信息产业股份有限公司 Method for achieving automatic K-DB main and standby disaster recovery cluster switching
CN105373563A (en) * 2014-08-28 2016-03-02 北京奇虎科技有限公司 Database switching method and apparatus
US9619542B2 (en) * 2013-04-06 2017-04-11 Citrix Systems, Inc. Systems and methods for application-state distributed replication table hunting
CN106815097A (en) * 2017-01-18 2017-06-09 北京许继电气有限公司 Database disaster tolerance system and method
US20170177658A1 (en) * 2015-12-18 2017-06-22 Sap Se Table replication in a database environment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101207512A (en) * 2006-12-22 2008-06-25 中兴通讯股份有限公司 Method for switching and redundancy backup of database system
US9619542B2 (en) * 2013-04-06 2017-04-11 Citrix Systems, Inc. Systems and methods for application-state distributed replication table hunting
CN105373563A (en) * 2014-08-28 2016-03-02 北京奇虎科技有限公司 Database switching method and apparatus
CN104579791A (en) * 2015-01-26 2015-04-29 浪潮电子信息产业股份有限公司 Method for achieving automatic K-DB main and standby disaster recovery cluster switching
US20170177658A1 (en) * 2015-12-18 2017-06-22 Sap Se Table replication in a database environment
CN106815097A (en) * 2017-01-18 2017-06-09 北京许继电气有限公司 Database disaster tolerance system and method

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112541006A (en) * 2019-09-23 2021-03-23 拉扎斯网络科技(上海)有限公司 Database command request processing method and device, electronic equipment and storage medium
CN112541006B (en) * 2019-09-23 2023-01-06 拉扎斯网络科技(上海)有限公司 Database command request processing method and device, electronic equipment and storage medium
CN114253620A (en) * 2021-12-27 2022-03-29 中国建设银行股份有限公司 Host system switching method and device, electronic equipment and computer storage medium

Similar Documents

Publication Publication Date Title
US11412024B2 (en) Method and apparatus for determining access path of content delivery network
US10204114B2 (en) Replicating data across data centers
CN102299954B (en) For the context-specific network resource addressing system and method for Distributed Services
CN103377652B (en) A kind of method, device and equipment for carrying out speech recognition
CN109639636A (en) Business datum forwarding, business data processing method, device and electronic equipment
CN104581785B (en) wireless network test method, test device and mobile terminal
CN107798108A (en) A kind of asynchronous task querying method and equipment
CN108141724A (en) For the virtual user identification module of mobile communication equipment
CN110019444A (en) A kind of operation requests processing method, device, equipment and system
CN109582458A (en) Resource information loading method, device, storage medium and processor
CN109471902A (en) A kind of database switching method, device, equipment and system
WO2012021143A1 (en) Method and system for providing a stateful experience while accessing content using a global textsite platform
CN110928895B (en) Data query and data table establishment method, device and equipment
CN105577707B (en) A kind of remote invocation method and equipment
CN110070379A (en) A kind of method for message transmission, device and server
CN103701681A (en) Information processing method and electronic equipment
US8818324B1 (en) Location capability provisioning
CN110737662A (en) data analysis method, device, server and computer storage medium
CN110245192A (en) Identity information querying method and system
CN110417919A (en) A kind of flow abduction method and device
CN109684196A (en) A kind of test method and device
CN114401382A (en) Machine scheduling method and device and electronic equipment
CN113449086B (en) Dialogue management method, device and storage medium
CN105704686B (en) A kind of instant communication method based on short message, apparatus and system
CN111506644B (en) Application data processing method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right

Effective date of registration: 20210907

Address after: Room 508, floor 5, building 4, No. 699, Wangshang Road, Changhe street, Binjiang District, Hangzhou City, Zhejiang Province

Applicant after: Alibaba (China) Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Applicant before: ALIBABA GROUP HOLDING Ltd.

TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20211119

Address after: No.12 Zhuantang science and technology economic block, Xihu District, Hangzhou City, Zhejiang Province

Applicant after: Aliyun Computing Co.,Ltd.

Address before: 310052 room 508, 5th floor, building 4, No. 699 Wangshang Road, Changhe street, Binjiang District, Hangzhou City, Zhejiang Province

Applicant before: Alibaba (China) Co.,Ltd.

TA01 Transfer of patent application right