CN115168008A - Database dynamic switching method and system - Google Patents

Database dynamic switching method and system Download PDF

Info

Publication number
CN115168008A
CN115168008A CN202210867847.4A CN202210867847A CN115168008A CN 115168008 A CN115168008 A CN 115168008A CN 202210867847 A CN202210867847 A CN 202210867847A CN 115168008 A CN115168008 A CN 115168008A
Authority
CN
China
Prior art keywords
database
new
new database
information
data
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
CN202210867847.4A
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.)
Ping An E Wallet Electronic Commerce Co Ltd
Original Assignee
Ping An E Wallet Electronic Commerce Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An E Wallet Electronic Commerce Co Ltd filed Critical Ping An E Wallet Electronic Commerce Co Ltd
Priority to CN202210867847.4A priority Critical patent/CN115168008A/en
Publication of CN115168008A publication Critical patent/CN115168008A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files

Abstract

The application discloses a method and a system for dynamically switching databases, wherein the method comprises the following steps: analyzing the new database information, and storing the new database configuration information obtained by analysis into a configuration file; and responding to a new database connection instruction, stopping the data processing request receiving function, processing the received data processing request matched with the old database, disconnecting the old database, loading the new database configuration information in the configuration file, connecting the new database, and recovering the data processing request receiving function. When the database is switched, the received data processing request is suspended, the received data processing request matched with the old database is processed, the connection with the old database is disconnected, the new data connection is carried out, the received data processing request is recovered, the system does not need to be restarted, the uncontrollable risk caused by restarting an operation program is avoided, the received data processing request matched with the old database cannot be interrupted during switching, and data loss is avoided.

Description

Database dynamic switching method and system
Technical Field
The invention relates to the technical field of computers, in particular to a method and a system for dynamically switching databases.
Background
With the increase of service systems, more and more data are stored in the database, and the time for querying the data is longer and longer, so that the database needs to be split. After the database is split, some service nodes sometimes need to read the data of the original database, sometimes need to read the data of the split new database, and at this time, need to perform database switching. And with the use of the database, the currently used database is found to be unsuitable and cannot meet some requirements or the currently used database is found to be bad and cannot be used continuously, a new database needs to be replaced, and the database also needs to be switched at the moment.
When the existing method switches databases, the domain name of the old database needs to be switched to the domain name of the new database, then the service system is restarted, domain name resolution is carried out again aiming at the new database, and a new connection is established to the new database. In this process, the following problems may occur:
(1) If the system is restarted for too long, the system may be unavailable for a long time.
(2) When the system is restarted, the connections and requests being used may be interrupted, resulting in data loss.
(3) If frequent database migration and database unavailable scenes occur to perform database switching, the system needs to be restarted frequently, the process is complicated and unsafe, and the system unavailable time can be further prolonged.
Therefore, a database switching method is needed that does not require a system restart and does not cause interruption of the ongoing connection request during switching, resulting in data loss.
Disclosure of Invention
In view of the above, the present invention provides a method and a system for dynamically switching a database, and mainly aims to solve the problem that data loss is caused by interruption of a request being connected due to a system restart when a database is switched at present.
According to an aspect of the present application, there is provided a database dynamic switching method, including:
acquiring new database information, analyzing the new database information, and storing the new database configuration information obtained by analysis into a configuration file;
responding to a new database connection instruction, stopping a data processing request receiving function, processing a received data processing request matched with an old database, disconnecting the old database, loading the new database configuration information in the configuration file, and connecting a new database;
and after the new database is successfully connected, recovering the data processing request receiving function.
Optionally, the step of analyzing the information of the new database and storing the configuration information of the new database obtained by analysis into a configuration file includes:
the data sub-base system analyzes the new database information to obtain configuration information of a plurality of data sub-bases, matches the configuration information corresponding to each data sub-base, fills the matched configuration information of each data sub-base into the configuration file according to a preset format, and sends a new database information synchronization success command to a management platform after filling, wherein the configuration information comprises a domain name, a read-write authority, a protocol type, a user name and a password.
Optionally, the loading the new database configuration information in the configuration file, and connecting the new database includes:
and for each data sub-database, the data sub-database system reads the configuration information of the data sub-database from the configuration file, and the data sub-database is connected based on the domain name, the protocol type, the user name and the password of the data sub-database.
Optionally, the performing connection of the data sub-databases based on the domain name, the protocol type, the user name, and the password of the data sub-databases includes:
inquiring the IP address of the data sub-database according to the domain name of the data sub-database;
generating a connection request corresponding to the protocol type of the data sub-database by using the user name and the password of the data sub-database;
sending the connection request to a server where the IP address is located;
and receiving response information of the connection request, wherein the response information comprises connection success or connection failure.
Optionally, the management platform determines a database sub-system corresponding to the new database according to the corresponding relationship between the new database and the data table and the corresponding relationship between the data table and the database sub-system, and sends the information of the new database to the database sub-system corresponding to the new database.
Optionally, after receiving the new database information synchronization success instruction, the management platform sends the new database connection instruction to the database partitioning system.
Optionally, after receiving the connection request matched with the new database, the data banking system sends information of successful switching of the new database to the management platform.
Optionally, the database sorting system includes a sorting and table sorting component and a sorting and table sorting system.
According to another aspect of the present application, there is provided a dynamic database switching system including a management platform and a database partitioning system, wherein,
the management platform is used for determining a data sub-database system corresponding to the new database and sending the information of the new database to the data sub-database system corresponding to the new database;
the data sub-database system is used for acquiring new database information, analyzing the new database information and storing the new database configuration information obtained by analysis into a configuration file;
responding to a new database connection instruction, stopping a data processing request receiving function, processing a received data processing request matched with an old database, disconnecting the old database, loading the new database configuration information in the configuration file, and connecting a new database;
and after the new database is successfully connected, recovering the data processing request receiving function.
Optionally, the step of analyzing the information of the new database and storing the configuration information of the new database obtained by analysis into a configuration file includes:
the data sub-base system analyzes the new database information to obtain configuration information of a plurality of data sub-bases, matches the configuration information corresponding to each data sub-base, fills the matched configuration information of each data sub-base into the configuration file according to a preset format, and sends a new database information synchronization success command to a management platform after filling, wherein the configuration information comprises a domain name, a read-write authority, a protocol type, a user name and a password.
Optionally, the loading the new database configuration information in the configuration file, and connecting the new database includes:
and for each data sub-library, the data sub-library system reads the configuration information of the data sub-library from the configuration file, and the data sub-library is connected based on the domain name, the protocol type, the user name and the password of the data sub-library.
Optionally, the performing, based on the domain name, the protocol type, the user name, and the password of the data sub-database, the connection of the data sub-database includes:
inquiring the IP address of the data sub-database according to the domain name of the data sub-database;
generating a connection request corresponding to the protocol type of the data sub-database by using the user name and the password of the data sub-database;
sending the connection request to a server where the IP address is located;
and receiving response information of the connection request, wherein the response information comprises connection success or connection failure.
Optionally, the management platform determines a database partitioning system corresponding to the new database according to the corresponding relationship between the new database and the data table and the corresponding relationship between the data table and the database partitioning system, and sends the new database information to the database partitioning system corresponding to the new database.
Optionally, after receiving the new database information synchronization success instruction, the management platform sends the new database connection instruction to the database splitting system.
Optionally, after receiving the connection request matched with the new database, the data banking system sends information of successful switching of the new database to the management platform.
Optionally, the database sorting system includes a sorting and table sorting component and a sorting and table sorting system.
By means of the technical scheme, when the database is switched, the method and the system for dynamically switching the database suspend receiving of data processing requests, process the received data processing requests matched with the old database, disconnect the connection with the old database, read new data configuration information from the configuration file, perform new data connection, recover receiving of the data processing requests after the new database is connected, do not need to restart the system, avoid the uncontrollable risk caused by restarting an operation program, do not interrupt the received data processing requests matched with the old database during switching, and do not cause data loss.
According to the dynamic database switching method and system, the database sub-system simultaneously supports the database sub-table component and the database sub-table system, the appropriate database sub-system is selected according to the requirement, the limitation of a use scene is avoided, and the application range is wider.
The above description is only an overview of the technical solutions of the present invention, and the present invention can be implemented in accordance with the content of the description so as to make the technical means of the present invention more clearly understood, and the above and other objects, features, and advantages of the present invention will be more clearly understood.
Drawings
Various additional advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
fig. 1 shows a flowchart of a dynamic database switching method provided in an embodiment of the present application;
fig. 2 is a schematic structural connection diagram illustrating a database dynamic switching method according to an embodiment of the present application;
fig. 3 is a flowchart illustrating storage of new database configuration information in a dynamic database switching method according to an embodiment of the present application;
fig. 4 shows a flowchart of a data sub-database connection of a method for dynamically switching databases according to an embodiment of the present application;
fig. 5 is a timing diagram illustrating a dynamic database switching method according to an embodiment of the present application;
fig. 6 shows a schematic structural connection diagram of a dynamic database switching system according to an embodiment of the present application.
In the figure: 12-a management platform; 14-a data banking system; 16-old database; 18-new database.
Detailed Description
The invention will be described in detail hereinafter with reference to the drawings and embodiments. It should be noted that the embodiments and features of the embodiments may be combined with each other without conflict.
To further explain the technical means and effects of the present invention adopted to achieve the predetermined object, the following detailed description of the embodiments, structures, features and effects according to the present invention will be made with reference to the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "an embodiment" refers to not necessarily the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
In order to solve the problem that data loss is caused by interruption of a request being connected due to a need of restarting a system when a database is switched at present, an embodiment of the present application provides a database dynamic switching method, as shown in fig. 1, the method includes:
step 102: acquiring new database information, analyzing the new database information, and storing the new database configuration information obtained by analysis into a configuration file;
in the embodiment of the invention, as the data stored in the database is increased and the reading speed of the data is influenced, the database is split into the old database and the new database. And the processing node of the service system sends a processing request to the data sub-database system, the data sub-database system is connected with the corresponding database, reads and writes data in the database, and returns a processing result to the processing node of the service system. Due to the splitting of the database, sometimes a processing request sent by a processing node of a business system is changed from an old matched database to a new matched database to read and write data, and at this time, the database splitting system needs to obtain new database information in advance, store the configuration information of the new database, and send a database information synchronization success instruction to the management platform.
It should be noted that, when the database is split, the processing request of the processing node of the service system is changed from the matching old database to the matching new database, and when the old database has a problem and cannot be used continuously, the processing request of the processing node of the service system is also changed from the matching old database to the matching new database.
The old database and the new database are warehouse databases, and are used for storing a large amount or mass of data in the business operation process, wherein the business operation process includes but is not limited to content of operations such as insurance business, product updating, claim settlement operation and the like, for example, code content and data content corresponding to the operations.
The data stored in the database may be public service data, customer data, etc., and due to the numerous types of data, the database switching method includes, but is not limited to, application scenarios such as public service, financial service, logistics management, etc.
Step 104: responding to a new database connection instruction, stopping a data processing request receiving function, processing a received data processing request matched with an old database, disconnecting the old database, loading the new database configuration information in the configuration file, and connecting a new database;
in an embodiment, as shown in fig. 2, a processing node of a service system B sends a query request to a sub-repository sub-table system, the sub-repository sub-table system receives the query request and responds to the query request, the processing node of the service system B determines that the data sub-repository system is in an online state and can receive a data processing request after receiving response information, the processing node of the service system B sends the data processing request to the sub-repository sub-table system, and the sub-repository sub-table system reads and writes data stored in a database connected to the sub-repository sub-table system according to the data processing request, so that the data processing request is subjected to matching processing. When the processing node of the service system B does not receive the response information, the database-dividing and table-dividing system is determined to be in an off-line state, the database-dividing and table-dividing system cannot receive the data processing request, and the processing node of the service system B sends the data processing request to other database-dividing and table-dividing systems replying the response information. The database and table system is one kind of data database system.
The processing node of the service system A sends a query request to the database and table dividing component, the database and table dividing component responds to the query request after receiving the query request, the processing node of the service system A determines that the database and table dividing system is in an online state and can receive a data processing request after receiving response information, the processing node of the service system A sends the data processing request to the database and table dividing component, and the database and table dividing component reads and writes data stored in a database connected with the database according to the data processing request so that the data processing request is subjected to matching processing. When the processing node of the service system A does not receive the response information, the sub-warehouse sub-table component is determined to be in an off-line state, the sub-warehouse sub-table component cannot receive the data processing request, and the processing node of the service system A sends the data processing request to other sub-warehouse sub-table components for replying the response information. The database and table dividing component is one of database dividing systems.
In an embodiment, the processing node of the service system a determines whether the database partitioning system is in an offline state or an online state by using a liveness detection method, which is not described herein again.
After receiving the new database information synchronization success command, the management platform sends a new database connection command to a data sub-database system, and after receiving the new database connection command, the data sub-database system does not respond to the query request sent by the processing node of the service system, namely, the communication state with the processing node of the service system is an offline state, does not receive the processing request sent by the processing node of the service system, but reads and writes data matched with the processing request from an old database for the received processing request sent by the processing node of the service system, and returns the result matched with the processing request to the processing node of the service system. After the data sub-database system processes the received data processing request matched with the old database, the connection with the old database is disconnected, the configuration information of the new database stored in the configuration file is loaded, and the new database is connected.
Step 106: and after the new database is successfully connected, recovering the data processing request receiving function.
And when the new database is successfully connected, the data sub-database system recovers a data processing request receiving function, namely, the data sub-database system responds to the query request sent by the processing node of the service system, the communication state with the processing node of the service system is an online state, and receives the data processing request matched with the new database.
Compared with the prior art, the method for dynamically switching the databases has the advantages that when the databases are switched, the received data processing requests are stopped, the received data processing requests of the old databases are processed, the connection with the old databases is disconnected, the configuration information of the new databases is read from the configuration file, the connection of the new databases is carried out, the data processing requests are recovered and received after the new databases are connected, the system does not need to be restarted, the uncontrollable risk caused by restarting an operation program is avoided, the received data processing requests of the old databases cannot be interrupted during switching, and data loss is avoided.
In one embodiment, for further limitation and explanation, as shown in fig. 2, the new database includes a plurality of data sub-databases, parsing information of the new database, and storing the parsed configuration information of the new database in a configuration file includes:
step 1022: the data sub-database system analyzes the new database information to obtain configuration information of a plurality of data sub-databases, wherein the configuration information comprises a domain name, a read-write authority, a protocol type, a user name and a password;
step 1024: matching the corresponding configuration information of each data sub-database;
step 1026: filling the matched configuration information of each data sub-database into a configuration file according to a preset format;
step 1028: and after the completion of filling, sending a new database information synchronization success instruction to the management platform.
Specifically, the database comprises a plurality of data sub-databases, the information of the new database comprises information of the data sub-databases, the information is packaged into a data packet according to a preset protocol format, the data packet is called new database information, the new database information is analyzed after the data sub-database system receives the new database information, the analyzed data is configuration information of the data sub-databases, the configuration information comprises a domain name, a read-write authority, a protocol type, a user name and a password, but the configuration information of the data sub-databases is mixed together, so that the configuration information corresponding to each data sub-database is matched according to a preset rule, the configuration information of each matched data sub-database is filled in a configuration file according to a preset format in the configuration file, and a new database information synchronization success instruction is sent to the management platform after the filling is successful.
Compared with the prior art, the dynamic switching method of the database is characterized in that after receiving the information of the new database, the database dividing system analyzes the information of the new database to obtain the configuration information of the new database, stores the configuration information of the new database in the configuration file, provides conditions for dynamic switching of the database, and ensures smooth implementation of dynamic switching of the database.
In one embodiment, loading new database configuration information in the configuration file, and connecting the new database includes:
and for each data sub-database, the data sub-database system reads the configuration information of the data sub-database from the configuration file, and performs connection of the data sub-databases based on the domain name, the protocol type, the user name and the password of the data sub-databases.
Specifically, for one data sub-library, the configuration information of the data sub-library is read from a configuration file, the data sub-libraries are connected based on the domain name, the protocol type, the user name and the password of the data sub-library, after one data sub-library is connected, the configuration information of the other data sub-library is read, the other data sub-library is connected until all the data sub-libraries are successfully connected, the time for connecting each data sub-library is short, the time for connecting all the data sub-libraries is short, the time for not receiving a data processing request is short, and the influence on a system is reduced to the minimum.
In one embodiment, the configuration information of each data sub-library is read simultaneously, and the connection of each data sub-library is performed simultaneously.
In one embodiment, for further definition and explanation, as shown in fig. 3, the connection of the data sub-databases is performed based on the domain name, the protocol type, the user name and the password of the data sub-databases, and includes:
step 1042: inquiring IP addresses of the data sub-databases according to domain names of the data sub-databases;
step 1044: generating a connection request corresponding to the protocol type of the data sub-database by the user name and the password of the data sub-database;
step 1046: sending the connection request to a server where the IP address is located;
step 1048: and receiving response information of the connection request, wherein the response information comprises connection success or connection failure.
Specifically, when each data sub-library is connected, an IP address of the data sub-library is inquired according to a domain name, the protocol type of each data sub-library is different, a connection request corresponding to the protocol type of the data sub-library is generated by the user name and the password of the data sub-library, the connection request is sent to a server where the IP address is located, after the server receives the connection request, the connection request is analyzed to obtain the user name and the password of the data sub-library, the user name and the password are verified, a database connection success instruction is returned to the data sub-library system after verification, a database connection failure instruction is returned to the data sub-library system after verification failure, the data sub-library system searches the reason of the verification failure of the data sub-library, and connection is carried out again after the reason is modified according to the searched reason.
Compared with the prior art, the method for dynamically switching the databases has the advantages that when the databases are switched, the configuration information of each database is read from the configuration file, the connection of each database is carried out, the system does not need to be restarted, only the configured window period is loaded when the single database system is unavailable, and the influence on the whole system is minimized.
In one embodiment, the management platform determines the data sub-database system corresponding to the new database according to the corresponding relation between the new database and the data table and the corresponding relation between the data table and the data sub-database system, and sends the new database information to the data sub-database system corresponding to the new database.
Specifically, the management platform sends the new database information to the database splitting system corresponding to the database information after receiving the new database information according to the routing rule.
The routing rule refers to the corresponding relation between the data table and the data sub-database system and the corresponding relation between the new database and the data table. For example, the new database corresponds to the data table 1, and there are a plurality of database systems corresponding to the data table 1.
In one embodiment, after receiving the new database information synchronization success command, the management platform sends a new database connection command to the database splitting system.
The management platform sends new database information to each corresponding database system, after receiving a new database information synchronization success command of each database system, the management platform firstly sends a new database connection command to the first database system, after receiving the new database connection command, the first database system connects the new databases, and after successfully connecting and receiving a data processing request matched with the new databases, sends a new database switching success command. And the management platform sends a new database connection instruction to the second database system, the second database system performs connection of the new database after receiving the new database connection instruction, and sends a new database switching success instruction after successful connection and receiving a data processing request matched with the new database. The management platform sends new database connection instructions to the database splitting system one by one, and the database splitting system which is not connected with the new database connection instructions continues to process data processing requests matched with old data, so that the problem that the processing requests of the old database cannot be processed during database switching, and data loss is caused is avoided.
In one embodiment, after the data sub-database system receives the data processing request matched with the new database, the data sub-database system sends the information of successful switching of the new database to the management platform.
Specifically, after the database sub-system is successfully connected with the new database, after a processing request matched with the new database is received, the new database is successfully switched, and the information of the successful switching of the new database is sent to the management platform, so that the management platform can continuously send a new database connection instruction to the next database sub-system, the multiple database sub-systems are connected to the new database one by one, and the switching time of the whole new database cluster is basically zero.
In one embodiment, after the data sub-database system receives the data matched with the new database and processes the data, the data in the data sub-database is read and written according to the read-write authority of the data sub-database.
In one embodiment, a data banking system includes a banking and tabulating component and a banking and tabulating system.
Specifically, the database sub-system may be a sub-database sub-table component, or may be a sub-database sub-table system. The database sub-table component is embedded in the service system in an SDK mode, the database sub-table system is an independent system in a proxy mode, is connected with the service system and can provide service for the service system, the database sub-table system simultaneously supports the database sub-table component and the database sub-table system, and the appropriate database sub-table system is selected according to requirements, so that the method is not limited by use scenes and has a wider application range.
In an embodiment, as shown in fig. 5, after receiving the connection information of the new database, the management platform pushes the new database information to a node where a sub-database sub-table component is loaded or a node of a sub-database sub-table system, which is collectively referred to as a sub-database system, according to a routing rule, and the sub-database system parses the received new database information to obtain parsed new database configuration information, stores the new database configuration information in a configuration file, and sends a new database information synchronization success instruction to the management platform after storing.
After receiving the new database information synchronization success command, the management platform issues a reload configuration command to one data sub-library system, and the reload configuration command represents new database connection, so that the data sub-library system which receives the new database connection command can also be called as issuing a new database connection command, and is set to be in an offline state, namely a new processing request of a service system processing node is not received, and the service system processing node sends the new processing request to other data sub-library systems. The data sub-database system reads and writes data from the old database for the received processing request, and returns the result to the processing node of the service system. And after the processing request matched with the old database is processed, the data sub-database system is disconnected from the old database, the configuration information of the new database is read from the configuration file, the configuration information of the new database is loaded, and the connection with the new database is established.
And after the connection with the new database is completed, the data sub-database system is set to be in an online state, receives a new processing request of the service system processing node, and after the new processing request of the service system processing node is received, sends the database switching success information to the management platform. And the management platform issues a reloading configuration command to other data sub-database systems, and the other data sub-database systems repeat the process of setting the offline state, disconnecting the old database and connecting the new database. According to the method and the system, the databases are switched one by one according to the node dimensionality, the system does not need to be restarted in the switching process, the configuration only needs to be reloaded, the system unavailable time of the traditional scheme is greatly reduced, the unavailable time of a single node only has a window period for loading the configuration, and the unavailable time of a cluster is basically 0.
Another embodiment of the present application provides a dynamic database switching system, as shown in fig. 6, which includes a management platform 12 and a database partitioning system 14, wherein,
the management platform 12 is used for determining the data sub-database system 14 corresponding to the new database 18 and sending the new database information to the data sub-database system 14 corresponding to the new database 18;
the database dividing system 14 is used for acquiring new database information, analyzing the new database information, and storing the new database configuration information obtained by analysis into a configuration file;
in response to the new database connection command, the data processing request receiving function is suspended, after the received data processing request matched with the old database 16 is processed, the connection with the old database 16 is disconnected, the new database configuration information in the configuration file is loaded, and the new database 18 is connected;
after the new database 18 is successfully connected, the data processing request receiving function is resumed.
The application provides a database dynamic switching system, compared with the prior art, when the application is switched over, the application suspends the reception of a data processing request, finishes the processing of the received data processing request of an old database, breaks the connection with the old database, reads new data configuration information from a configuration file, performs the connection of new data, recovers the reception of the data processing request after the new database is connected, does not need to restart the system, avoids the uncontrollable risk caused by restarting an operation program, does not interrupt the received data processing request of the old database during switching, and does not cause data loss.
In one embodiment, the new database 18 includes a plurality of data sub-databases, parsing the new database information, and storing the parsed new database configuration information in a configuration file, including:
the data sub-database system analyzes the new database information to obtain configuration information of a plurality of data sub-databases, wherein the configuration information comprises a domain name, a read-write authority, a protocol type, a user name and a password;
matching the corresponding configuration information of each data sub-database;
filling the matched configuration information of each data sub-database into a configuration file according to a preset format;
after completion of the filling, a new database information synchronization success instruction is sent to the management platform 12.
Compared with the prior art, the dynamic database switching system analyzes the information of the new database after receiving the information of the new database to obtain the configuration information of the new database, stores the configuration information of the new database in the configuration file, provides conditions for dynamic switching of the database, and ensures smooth implementation of dynamic switching of the database.
In one embodiment, loading the new database configuration information in the configuration file, and linking the new database 18 includes:
and for each data sub-database, the data sub-database system reads the configuration information of the data sub-database from the configuration file, and performs connection of the data sub-databases based on the domain name, the protocol type, the user name and the password of the data sub-databases.
In one embodiment, the connection of the data banks is performed based on the domain name, the protocol type, the user name and the password of the data banks, and comprises the following steps:
inquiring IP addresses of the data sub-databases according to domain names of the data sub-databases;
generating a connection request corresponding to the protocol type of the data sub-database by the user name and the password of the data sub-database;
sending the connection request to a server where the IP address is located;
and receiving response information of the connection request, wherein the response information comprises connection success or connection failure.
Compared with the prior art, the dynamic switching system for the databases has the advantages that when the databases are switched, the configuration information of each data sub-database is read from the configuration file, the connection of each data sub-database is carried out, the system does not need to be restarted, only the configured window period is loaded when the single data sub-database system is unavailable, and the influence on the system is minimized.
In one embodiment, the management platform 12 determines the database sub-system 14 corresponding to the new database 18 according to the corresponding relationship between the new database 18 and the data table and the corresponding relationship between the data table and the database sub-system 14, and sends the new database information to the database sub-system 14 corresponding to the new database 18.
In one embodiment, after receiving the new database information synchronization success command, the management platform 12 sends a new database connection command to the database splitting system 14.
In one embodiment, the database subsystem 14 sends a new database switch success message to the management platform 12 after receiving the data processing request matching the new database.
In one embodiment, the data banking system 14 reads and writes the data in the data banking according to the read and write authority of the data banking after receiving the data processing request matched with the new database.
In one embodiment, the data banking system 14 includes a banking and tabulation component and a banking and tabulation system.
Compared with the prior art, the dynamic database switching system has the advantages that the database sub-system simultaneously supports the database sub-table component and the database sub-table system, the appropriate database sub-system is selected according to the requirement, the limitation of a use scene is avoided, and the application range is wider.
In one embodiment, after receiving the information of successful switching of the new database sent by one database system 14, the management platform 14 issues a new database connection instruction to the other database systems 14, and the other database systems 14 repeat the above-mentioned setting of the offline state, and after processing the received processing request matching with the old database 16, disconnect the old database 16 and connect the new database 18. The management platform 14 implements the database partitioning system to execute the new database connection one by one in the node dimension by sending new database connection instructions one by one to the database partitioning system, thereby reducing the database unavailability time.
The above embodiments are only exemplary embodiments of the present application, and are not intended to limit the present application, and the protection scope of the present application is defined by the claims. Various modifications and equivalents may be made by those skilled in the art within the spirit and scope of the present application and such modifications and equivalents should also be considered to be within the scope of the present application.

Claims (10)

1. A dynamic database switching method is characterized by comprising the following steps:
acquiring new database information, analyzing the new database information, and storing the new database configuration information obtained by analysis into a configuration file;
responding to a new database connection instruction, stopping a data processing request receiving function, processing a received data processing request matched with an old database, disconnecting the old database, loading the new database configuration information in the configuration file, and connecting a new database;
and after the new database is successfully connected, recovering the data processing request receiving function.
2. The method for dynamically switching databases according to claim 1, wherein the new database includes a plurality of data sub-databases, and the parsing the new database information and storing the parsed new database configuration information in a configuration file includes:
the database dividing system analyzes the new database information to obtain configuration information of a plurality of database dividing systems, matches the configuration information corresponding to each database dividing system, fills the matched configuration information of each database dividing system into the configuration file according to a preset format, and sends a new database information synchronization success instruction to a management platform after filling, wherein the configuration information comprises a domain name, a read-write authority, a protocol type, a user name and a password.
3. The method for dynamically switching databases as claimed in claim 2, wherein the loading the new database configuration information in the configuration file and connecting to a new database comprises:
and for each data sub-database, the data sub-database system reads the configuration information of the data sub-database from the configuration file, and the data sub-database is connected based on the domain name, the protocol type, the user name and the password of the data sub-database.
4. The method for dynamically switching databases according to claim 3, wherein the connecting the databases based on the domain name, the protocol type, the user name and the password of the database includes:
inquiring the IP address of the data sub-database according to the domain name of the data sub-database;
generating a connection request corresponding to the protocol type of the data sub-database by using the user name and the password of the data sub-database;
sending the connection request to a server where the IP address is located;
and receiving response information of the connection request, wherein the response information comprises connection success or connection failure.
5. The method for dynamically switching databases according to claim 2, wherein the management platform determines the database sub-system corresponding to the new database according to the corresponding relationship between the new database and the data table and the corresponding relationship between the data table and the database sub-system, and sends the information of the new database to the database sub-system corresponding to the new database.
6. The dynamic database switching method according to claim 2, wherein the management platform sends the new database connection command to the database partitioning system after receiving the new database information synchronization success command.
7. The dynamic database switching method according to claim 1, wherein the database partitioning system sends a new database switching success message to the management platform after receiving the connection request matched with the new database.
8. The dynamic database switching method according to claim 1, wherein the database partitioning system comprises a database partitioning and table partitioning component and a database partitioning and table partitioning system.
9. A dynamic database switching system is characterized in that the dynamic database switching system comprises a management platform and a database dividing system, wherein,
the management platform is used for determining a data sub-database system corresponding to the new database and sending the information of the new database to the data sub-database system corresponding to the new database;
the data sub-database system is used for acquiring new database information, analyzing the new database information and storing the new database configuration information obtained by analysis into a configuration file;
responding to a new database connection instruction, stopping a data processing request receiving function, processing a received data processing request matched with an old database, disconnecting the old database, loading the new database configuration information in the configuration file, and connecting a new database;
and after the new database is successfully connected, recovering the data processing request receiving function.
10. The system for dynamically switching databases as claimed in claim 9, wherein the new database includes a plurality of data sub-databases, and the parsing the new database information and storing the parsed new database configuration information in a configuration file includes:
the data sub-base system analyzes the new database information to obtain configuration information of a plurality of data sub-bases, matches the configuration information corresponding to each data sub-base, fills the matched configuration information of each data sub-base into a configuration file according to a preset format, and sends a new database information synchronization success instruction to a management platform after filling, wherein the configuration information comprises a domain name, a read-write authority, a protocol type, a user name and a password.
CN202210867847.4A 2022-07-21 2022-07-21 Database dynamic switching method and system Pending CN115168008A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210867847.4A CN115168008A (en) 2022-07-21 2022-07-21 Database dynamic switching method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210867847.4A CN115168008A (en) 2022-07-21 2022-07-21 Database dynamic switching method and system

Publications (1)

Publication Number Publication Date
CN115168008A true CN115168008A (en) 2022-10-11

Family

ID=83496139

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210867847.4A Pending CN115168008A (en) 2022-07-21 2022-07-21 Database dynamic switching method and system

Country Status (1)

Country Link
CN (1) CN115168008A (en)

Similar Documents

Publication Publication Date Title
US7340637B2 (en) Server duplexing method and duplexed server system
CN1988535B (en) Synchronous method, system for file storage and customer terminal
US11385830B2 (en) Data storage method, apparatus and system, and server, control node and medium
CN106815218B (en) Database access method and device and database system
KR100471567B1 (en) Transaction Management Method For Data Synchronous In Dual System Environment
CN106685691A (en) Efficient configuration update method and system of terminal device in Internet of things system
CN107623703B (en) Synchronization method, device and system for Global Transaction Identifier (GTID)
WO2022174735A1 (en) Data processing method and apparatus based on distributed storage, device, and medium
CN112468601B (en) Data synchronization method, access method and system of distributed storage system
JP2019502186A (en) System and method for obtaining, processing and updating global information
CN113067866A (en) Batch file transmission method and device between heterogeneous systems
CN110740155A (en) Request processing method and device in distributed system
CN100505614C (en) System backup and recovery method, and backup and recovery server
WO2016206568A1 (en) Data update method, device, and related system
WO2021082925A1 (en) Transaction processing method and apparatus
CN113535262A (en) Method, device, equipment and storage medium for controlling starting of proxy node
CN115168008A (en) Database dynamic switching method and system
CN111866203B (en) Domain name resolution method and device, readable storage medium and equipment
CN116866363A (en) Distributed file synchronization method, device, equipment and storage medium
US20020184572A1 (en) Method and apparatus for maintaining consistent data
CN113507415B (en) Table item processing method and device
CN111741102B (en) Upgrading method and device for distributed micro-service application
CN115129779A (en) Database synchronization method, device and readable medium
CN111586438B (en) Method, device and system for processing service data
CN107404511A (en) The replacement method and equipment of server in cluster

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