CN114925052A - Method, device, equipment and computer readable medium for restarting database - Google Patents
Method, device, equipment and computer readable medium for restarting database Download PDFInfo
- Publication number
- CN114925052A CN114925052A CN202210542893.7A CN202210542893A CN114925052A CN 114925052 A CN114925052 A CN 114925052A CN 202210542893 A CN202210542893 A CN 202210542893A CN 114925052 A CN114925052 A CN 114925052A
- Authority
- CN
- China
- Prior art keywords
- database
- library
- standby
- restarting
- master
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
- G06F16/215—Improving data quality; Data cleansing, e.g. de-duplication, removing invalid entries or correcting typographical errors
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/25—Integrating or interfacing systems involving database management systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/28—Databases characterised by their database models, e.g. relational or object models
- G06F16/284—Relational databases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/547—Remote procedure calls [RPC]; Web services
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/54—Indexing scheme relating to G06F9/54
- G06F2209/544—Remote
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Software Systems (AREA)
- Quality & Reliability (AREA)
- Computing Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a method, a device, equipment and a computer readable medium for restarting a database, and relates to the technical field of computers. One embodiment of the method comprises: stopping and restarting the database backup in response to the remote procedure call request; under the condition that the data in the database main library and the data in the database standby library are consistent, transferring a data request from the database main library to the database standby library; switching the database main library into a new database standby library and switching the database standby library into a new database main library; and restarting the database to prepare the database newly. This embodiment enables the database to shorten the unavailability time period.
Description
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a computer-readable medium for restarting a database.
Background
MySQL is a relational database management system that maintains data in different tables instead of putting all the data in one large repository, which increases speed and flexibility. The SQL language used by MySQL is the most common standardized language for accessing databases.
Currently, the restart scheme of the cloud database MySQL is to deploy an Agent service and a MySQL service in a container. And then the management and control system calls a Remote Procedure Call (RPC) interface exposed by the Agent service to respectively restart the master library and the standby library.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art: MySQL database restart schemes often result in database unavailability for long periods of time.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method, an apparatus, a device, and a computer-readable medium for restarting a database, which can shorten an unavailable duration of the database.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a method of restarting a database, including:
stopping and restarting the database backup in response to the remote procedure call request;
under the condition that the data in the database main library and the data in the database standby library are consistent, transferring a data request from the database main library to the database standby library;
switching the database main library into a new database standby library and switching the database standby library into a new database main library;
and restarting the database to prepare the database newly.
The data in the database main library and the database standby library are consistent, and the method comprises the following steps:
accelerating the writing speed of the database standby library;
setting the database master library as read-only when the delay time of the database master library and the database standby library is less than or equal to a preset delay threshold;
and determining that the data in the database main library and the data in the database standby library are consistent based on the site information of the database main library and the site information of the database standby library.
The transferring the data request from the database master library to the database standby library comprises:
in load balancing, the IP of the database main library is deleted, and the IP of the database standby library is configured in the load balancing, so that the data request is transferred from the database main library to the database standby library.
The step of switching the database master library into a new database backup library comprises the following steps:
cleaning the synchronous information in the database standby database;
connecting the database master library, and adding replication information for the database master library to switch the database master library into a new database standby library;
the step of switching the database standby library into a new database main library comprises the following steps:
and opening the read-only of the database standby library, resetting a disk write strategy, and switching the database standby library into a new database main library.
Before stopping and restarting the database backup in response to the remote procedure call request, the method further comprises:
and the master-slave delay of the database master library and the database slave library is less than a preset restart threshold value.
The method further comprises the following steps:
and if the master-slave delay of the database master library and the database slave library is greater than or equal to a preset restart threshold, forcibly restarting the database master library and the database slave library.
Before switching the database master library into the new database backup library and switching the database backup library into the new database master library, the method further comprises the following steps:
and supporting delayed switching, and detecting that the current time is consistent with the specified switching time.
According to a second aspect of the embodiments of the present invention, there is provided an apparatus for restarting a database, including:
the response module is used for responding to the remote procedure call request, and stopping and restarting the database standby library;
the transfer module is used for transferring the data request from the database main library to the database standby library under the condition that the data in the database main library and the data in the database standby library are consistent;
the switching module is used for switching the database main library into a new database standby library and switching the database standby library into a new database main library;
and the restarting module is used for restarting the new standby database of the database.
According to a third aspect of the embodiments of the present invention, there is provided an electronic device that restarts a database, including:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method as described above.
According to a fourth aspect of embodiments of the present invention, there is provided a computer readable medium, on which a computer program is stored, which when executed by a processor, implements the method as described above.
One embodiment of the above invention has the following advantages or benefits: stopping and restarting the database backup in response to the remote procedure call request; under the condition that the data in the database main library and the data in the database standby library are consistent, transferring a data request from the database main library to the database standby library; switching the database main library into a new database standby library and switching the database standby library into a new database main library; and restarting the new database. Under the condition that the data of the database main library and the data of the database standby library are consistent, the database main library and the database standby library are exchanged, so that the occupied time for restarting the database is reduced, and the unavailable time of the database can be shortened.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic main flow diagram of a method of restarting a database according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a forced restart database according to an embodiment of the present invention;
FIG. 3 is a schematic flow chart illustrating a process of determining data consistency between a primary database and a secondary database according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a transfer data request according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a process for switching a database master library to a database backup library according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of a handoff database according to an embodiment of the present invention;
FIG. 7 is a schematic flow diagram of restarting a database according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of the main structure of an apparatus for restarting a database according to an embodiment of the present invention;
FIG. 9 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
fig. 10 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Currently, MySQL database restart schemes often result in database unavailability for long periods of time. Such as: the direct restart, each restart can lead to the service being unavailable for a long time, the influence duration is more than 2 minutes on average, and the user experience is poor.
In order to solve the technical problem that the MySQL database is unavailable for a long time, the following technical scheme in the embodiment of the present invention may be adopted.
Referring to fig. 1, fig. 1 is a schematic diagram of a main flow of a method for restarting a database according to an embodiment of the present invention, where a database master and a database backup are switched when data in the database master and the database backup are consistent. As shown in fig. 1, the method specifically comprises the following steps:
and S101, responding to the remote procedure call request, and stopping and restarting the database standby library.
In the embodiment of the invention, the Agent service and the MySQL service are deployed in one container. That is, the proxy service and the database master are included in the master container; the standby library container comprises an agent service and a database standby library. The database main library and the database standby library are relative and belong to the database. The database backup database is used as the data backup of the database main database. And the user is responsible for controlling the database through the control system.
In order to restart the database, the management and control system sends an RPC request, invokes proxy service of the database standby database, stops using the database standby database, and restarts the database standby database. As an example, the restarting database backup manner includes forcing a restart of the database backup by an RPC request. As another example, in case of failure of forced restart of the database backup by RPC request, the backup library container is connected by using secure shell protocol (SSH) to execute remote command instead of RPC operation.
Referring to fig. 2, fig. 2 is a schematic diagram of a forced restart database according to an embodiment of the present invention. In fig. 2, the management and control system controls the database backup through RPC request or SHH.
In order to restart the database backup, the management and control system sends an RPC request, and through proxy service, the database backup is stopped (systemctl stop mysql ld) first, and then the database backup is started (systemctl start mysql ld).
If the RPC calling request fails or the RPC calling request is overtime, the standby library container can be connected in an SHH mode, and a remote command is executed to replace the RPC operation. Using the SSH approach, the kill database (pkill-9mysqld) can be forced directly.
It is understood that SSH will only be used if RPC fails to be called. The RPC request is invoked, depending on the proxy service deployed in the container. Once the proxy service is abnormal, the proxy service cannot be called, that is, the database backup cannot be restarted. An alternate approach is taken to use SSH to connect directly to the container and execute the SHELL command that operates on the database.
And S102, under the condition that the data in the database main library and the data in the database standby library are consistent, transferring the data request from the database main library to the database standby library.
In the embodiment of the invention, the restarting database comprises a restarting database standby database and a database main database. In order to restart the database master library, the premise is to ensure that the data in the database master library and the data in the database backup library are consistent. And under the condition that the data in the database main library and the data in the database standby library are consistent, transferring the data request from the database main library to the database standby library.
Referring to fig. 3, fig. 3 is a schematic flowchart illustrating a process of determining data consistency between a database master library and a database backup library according to an embodiment of the present invention. The method specifically comprises the following steps:
s301, accelerating the writing speed of the database standby library.
In order to reduce the time consuming restart of the database, a proxy service of the database backup is requested via an RPC. The agent service is connected with the database backup library and sets a disk write strategy to accelerate the write speed of the database backup library. Such as: set global inbo _ flush _ log _ at _ trx _ commit ═ 2; set global sync _ binlog is 0.
S302, when the delay time of the database main library and the database standby library is less than or equal to a preset delay threshold value, setting the database main library as read-only.
Usually, the delay time is stored between the database master and the database backup. And under the condition that the delay time of the database main library and the database standby library is less than or equal to a preset delay threshold, indicating that the database main library and the database standby library can be synchronized, and setting the database main library as read-only. Namely, set global read _ only ═ on'. The purpose of setting read-only is: and the main database of the database stops writing, so that the backup database of the database can quickly catch up with the main database.
As an example, the preset delay threshold is 10 seconds. By sending an RPC request to a proxy service of the database backup, the proxy service performs in conjunction with the database: the show slow status, and then the delay time.
And S303, determining that the data in the database main database and the data in the database standby database are consistent based on the site information of the database main database and the site information of the database standby database.
After the database master library is set to be read only, it is determined that the data in the database master library and the data in the database backup library are consistent based on the location information of the database master library and the location information of the database backup library.
As an example, the RPC requests are sent to the proxy service in the master library container and the proxy service in the standby library container, respectively. The method comprises the steps of connecting a database through proxy service, and respectively obtaining the site information of a database main library and the site information of a database standby library. Such as: and acquiring site information by adopting select @ @ global.gtid _ executed. The location information is used for recording the identification of the database synchronization data.
During specific implementation, if the difference between the site information of the database master library and the site information of the database backup library, that is, the site difference is 0, it is determined that the data in the database master library and the data in the database backup library are consistent.
In the embodiment of fig. 3, on one hand, the writing speed of the database backup is increased; on one hand, the database main library is set to be read-only so as to improve the speed of data consistency of the database main library and the database standby library.
And under the condition that the data in the database main library and the data in the database standby library are consistent, transferring the data request from the database main library to the database standby library. That is, the database master is no longer processing data requests, and the database backup is responsible for processing data requests.
In one embodiment of the present invention, in the case where the data in the database primary library and the database backup library are consistent, the data request may be transferred from the database primary library to the database backup library. Specifically, in load balancing, the IP of the database master library is deleted, and the IP of the database standby library is configured in load balancing so as to transfer the data request from the database master library to the database standby library. Thus, the database master no longer provides direct read-write services.
Load Balance (LB) means that a Load (a work task) is balanced and distributed to a plurality of operation units to be executed. Thereby completing the work task cooperatively. Load balancing is built on the original network structure, and the method provides a transparent, cheap and effective method for expanding the bandwidth of the server and the network equipment, enhancing the network data processing capacity, increasing the throughput and improving the availability and flexibility of the network.
Referring to fig. 4, fig. 4 is a schematic diagram of a transfer data request according to an embodiment of the present invention. In fig. 4, in the database main library, data is interacted with MySQL through a proxy service (Agent); and in the database, data are interacted with MySQL through the Agent. And in the load balancing process, the user transfers the data request from the database main library to the database standby library. The main database of the database does not need to participate in load balancing, and the standby database of the database participates in load balancing. And the database main library and the database standby library implement master-slave synchronization, namely, the data in the database main library is synchronized to the database standby library.
S103, switching the database main library into a new database standby library, and switching the database standby library into the new database main library.
And if the data request is transferred from the database main library to the database standby library, the database standby library at the moment is used as the main library, and the database main library at the moment is used as the standby library. Further, it is necessary to switch the database master library to a new database backup library and to switch the database backup library to the new database master library.
Referring to fig. 5, fig. 5 is a schematic flowchart illustrating a process of switching a database master library into a database backup library according to an embodiment of the present invention. The method specifically comprises the following steps:
s501, cleaning the synchronous information in the database backup.
And clearing the synchronous information in the database backup library through the RPC request and the proxy service of the database backup library. As an example, the synchronization information includes slave information, and the following instruction is used to implement cleanup: stop slave; reset slave all.
S502, connecting the database master library, and adding replication information for the database master library to switch the database master library into a new database backup library.
And through RPC request, proxy service of the database main library is performed, and replication information is added to the database main library so as to switch the database main library into a new database standby library. As one example, replication information is added to a database master by: change master to master _ host ═ master _ host ', master _ port ═ master _ port', master _ auto _ position ═ 1; the start slave is ' regenerative ' passive ' and ' regenerative '.
In the embodiment of fig. 5, the database master library is switched to the database backup library.
Similarly, the database standby library is switched into a new database main library: and opening the read-only of the database standby library, resetting a disk write strategy, and switching the database standby library into a new database main library. Specifically, the following instructions are used to open a new master library of the database: set global read _ only ═ off'. Reset disk write strategy: set global inbo _ flush _ log _ at _ trx _ commit ═ 1; set globalsync _ binlog 1.
Switching the database main library into a new database standby library and switching the database standby library into a new database main library;
referring to fig. 6, fig. 6 is a schematic diagram of a handover database according to an embodiment of the present invention. In fig. 6, the following master-slave synchronization is deleted, namely: and deleting master-slave synchronization from the database master library to the database standby library. The following master-slave synchronization is established, namely: and establishing master-slave synchronization from the database standby database to the database main database.
And S104, restarting the database to prepare the database newly.
The database new standby library is not restarted, so that the database new standby library is required to be restarted. Specifically, the database new standby library is stopped and started through a proxy server of the database new standby library by using RPC requests. Ensuring that the database is restarted. Wherein, the RPC request is adopted to request the restart failure or timeout, and the forced restart in fig. 2 can also be adopted.
In one embodiment of the invention, handover time may also be supported for the handover database. Namely: and supporting delayed switching, and detecting whether the current time is consistent with the specified switching time. Under the condition that the current time is consistent with the appointed switching time, switching the database main library into a new database standby library and switching the database standby library into a new database main library; in the event that the current time is not consistent with the specified switching time, then the database does not need to be switched.
The database is switched based on the specified switching time, mainly considering that the restart influence duration is short enough and only has a read-only duration of several seconds. The read-only period, which is undesirable, occurs during peak traffic periods. Thus, a low traffic peak may be specified to complete the database switch. As an example, the specified switching time is set by the traffic low peak.
In the specific implementation process, after the database backup is restarted, the current time is judged to be inconsistent with the specified switching time, the current task is suspended, and the task to be dispatched is added. And checking the task to be dispatched at regular time, supporting delayed switching, and executing the task to be dispatched under the condition that the current time is consistent with the specified switching time.
In an embodiment of the present invention, there are many ways to restart the database, and besides the technical solutions of S101 to S104, a forced restart may be directly adopted.
The manner in which the database is restarted may be determined based on the master-slave delays of the database master library and the database slave libraries. Specifically, if the master-slave delay of the database master library and the database slave library is smaller than a preset restart threshold, the technical scheme from S101 to S104 is adopted, so that the data synchronization of the database master library and the database slave library is accelerated; if the master-slave delay of the database master library and the database slave library is greater than or equal to the preset restart threshold, the database slave library is forcibly restarted as described above.
That is, when the database is restarted, the restart mode may not be specified. And requesting a proxy service of the slave database by using RPC, connecting the proxy service to the slave database, and acquiring the delay time. Such as: the show slow status is executed to obtain a delay time to determine the manner in which the database is restarted.
In the above embodiment, in response to a remote procedure call request, the database backup is stopped and restarted; under the condition that the data in the database main library and the data in the database standby library are consistent, transferring the data request from the database main library to the database standby library; switching the database main library into a new database standby library and switching the database standby library into a new database main library; and restarting the database to prepare the database newly. And under the condition that the data of the database main library and the data of the database standby library are consistent, the database main library and the database standby library are exchanged, so that the occupied time for restarting the database is reduced, and the unavailable time of the database can be shortened.
Referring to fig. 7, fig. 7 is a flowchart illustrating restarting a database according to an embodiment of the present invention. The method specifically comprises the following steps:
and S701, restarting the database.
And restarting the database after receiving the restart instruction. The manner in which the database is restarted is determined based on the master-slave delay. If the master-slave delay is greater than or equal to 10 seconds, executing S702; if the master-slave delay is less than 10 seconds, S704 is performed.
And S702, restarting the database master library.
And forcibly restarting the database master library.
And S703, restarting the database standby.
And forcibly restarting the database standby database.
And S704, restarting the database standby.
And restarting the database backup database through proxy service by adopting RPC request.
S705, judging whether the current time is consistent with the switching time.
And judging whether the current time is consistent with the specified switching time. If the current time is not consistent with the designated switching time, executing S706; if the current time coincides with the designated switching time, S707 is executed.
And S706, suspending the current task.
To avoid the impact of switching databases on the traffic, the current task needs to be suspended. Then, it is determined again whether the current time coincides with the specified switching time.
And S707, switching databases.
And switching the database master library into a new database standby library and switching the database standby library into the new database master library.
And S708, restarting the database to prepare a new database.
And after restarting the new standby database of the database, finishing restarting the database.
In the embodiment of fig. 7, S702 to S703 are steps of forced restart; s704 to S708 are steps of graceful restart. It can be determined by S701 which way to restart the database. Of course, a forced restart or graceful restart may also be directly employed.
Referring to fig. 8, fig. 8 is a schematic diagram of a main structure of an apparatus for restarting a database according to an embodiment of the present invention, where the apparatus for restarting a database can implement a method for restarting a database, and as shown in fig. 8, the apparatus for restarting a database specifically includes:
a response module 801, configured to stop and restart the database backup in response to the remote procedure call request;
a transfer module 802, configured to transfer a data request from a database master to a database backup when data in the database master and the database backup are consistent;
a switching module 803, configured to switch the database master library to a new database backup library, and switch the database backup library to a new database master library;
and the restarting module 804 is used for restarting the database new standby library.
In an embodiment of the present invention, the transferring module 802 is specifically configured to accelerate a writing speed of the database backup;
setting the database master library as read-only when the delay time of the database master library and the database standby library is less than or equal to a preset delay threshold;
and determining that the data in the database main library and the data in the database standby library are consistent based on the site information of the database main library and the site information of the database standby library.
In an embodiment of the present invention, the transferring module 802 is specifically configured to delete the IP of the database master library and configure the IP of the database standby library in the load balancing, so as to transfer the data request from the database master library to the database standby library.
In an embodiment of the present invention, the switching module 803 is specifically configured to clear synchronization information in the database backup;
connecting the database master library, and adding replication information for the database master library to switch the database master library into a new database standby library;
and the number of the first and second groups,
and opening the read-only of the database standby library, resetting a disk write strategy, and switching the database standby library into a new database main library.
In an embodiment of the present invention, the response module 801 is further configured to set a master-slave delay of the database master library and the database slave library to be smaller than a preset restart threshold.
In an embodiment of the present invention, the response module 801 is further configured to forcibly restart the database master library and the database slave library if the master-slave delay of the database master library and the database slave library is greater than or equal to a preset restart threshold.
In an embodiment of the present invention, the switching module 803 is further configured to support a delayed switching, and detect that the current time is consistent with the specified switching time.
Fig. 9 illustrates an exemplary system architecture 900 to which the method of restarting a database or the apparatus to restart a database of embodiments of the present invention may be applied.
As shown in fig. 9, the system architecture 900 may include end devices 901, 902, 903, a network 904, and a server 905. Network 904 is the medium used to provide communication links between terminal devices 901, 902, 903 and server 905. Network 904 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
A user may use terminal devices 901, 902, 903 to interact with a server 905 over a network 904 to receive or send messages or the like. The terminal devices 901, 902, 903 may have various messaging client applications installed thereon, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 901, 902, 903 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 905 may be a server providing various services, such as a background management server (for example only) providing support for shopping websites browsed by users using the terminal devices 901, 902, 903. The backend management server may analyze and process the received data such as the product information query request, and feed back a processing result (for example, target push information and product information — just an example) to the terminal device.
It should be noted that the method for restarting the database provided by the embodiment of the present invention is generally executed by the server 905, and accordingly, the apparatus for restarting the database is generally disposed in the server 905.
It should be understood that the number of terminal devices, networks, and servers in fig. 9 are merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for an implementation.
Referring now to FIG. 10, a block diagram of a computer system 1000 suitable for use with a terminal device implementing an embodiment of the invention is shown. The terminal device shown in fig. 10 is only an example, and should not bring any limitation to the functions and the use range of the embodiment of the present invention.
As shown in fig. 10, the computer system 1000 includes a Central Processing Unit (CPU)1001 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)1002 or a program loaded from a storage section 1008 into a Random Access Memory (RAM) 1003. In the RAM 1003, various programs and data necessary for the operation of the system 1000 are also stored. The CPU 1001, ROM 1002, and RAM 1003 are connected to each other by a bus 1004. An input/output (I/O) interface 1005 is also connected to bus 1004.
The following components are connected to the I/O interface 1005: an input portion 1006 including a keyboard, a mouse, and the like; an output section 1007 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 1008 including a hard disk and the like; and a communication section 1009 including a network interface card such as a LAN card, a modem, or the like. The communication section 1009 performs communication processing via a network such as the internet. The driver 1010 is also connected to the I/O interface 1005 as necessary. A removable medium 1011 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 1010 as necessary, so that a computer program read out therefrom is mounted into the storage section 1008 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication part 1009 and/or installed from the removable medium 1011. The computer program executes the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 1001.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a response module, a transfer module, a switch module, and a restart module. Where the names of these modules do not in some cases constitute a limitation on the modules themselves, for example, a response module may also be described as "for stopping and restarting a database library in response to a remote procedure call request.
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not assembled into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise:
stopping and restarting the database backup in response to the remote procedure call request;
under the condition that the data in the database main library and the data in the database standby library are consistent, transferring the data request from the database main library to the database standby library;
switching the database main library into a new database standby library and switching the database standby library into a new database main library;
and restarting the database to prepare the database newly.
According to the technical scheme of the embodiment of the invention, the database standby library is stopped and restarted in response to the remote procedure call request; under the condition that the data in the database main library and the data in the database standby library are consistent, transferring the data request from the database main library to the database standby library; switching the database main library into a new database standby library and switching the database standby library into a new database main library; and restarting the new database. And under the condition that the data of the database main library and the data of the database standby library are consistent, the database main library and the database standby library are exchanged, so that the occupied time for restarting the database is reduced, and the unavailable time of the database can be shortened.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (10)
1. A method of restarting a database, comprising:
stopping and restarting the database backup in response to the remote procedure call request;
under the condition that the data in the database main library and the data in the database standby library are consistent, transferring the data request from the database main library to the database standby library;
switching the database main library into a new database standby library and switching the database standby library into a new database main library;
and restarting the new database.
2. The method for restarting the database according to claim 1, wherein the data in the database master library and the database backup library are consistent, comprising:
accelerating the writing speed of the database standby library;
setting the database master library as read-only when the delay time of the database master library and the database standby library is less than or equal to a preset delay threshold;
and determining that the data in the database main library and the data in the database standby library are consistent based on the site information of the database main library and the site information of the database standby library.
3. The method of restarting a database according to claim 1 wherein said transferring a data request from said database master library to said database backup library comprises:
and in the load balancing, deleting the IP of the database main library, and configuring the IP of the database standby library into the load balancing so as to transfer the data request from the database main library to the database standby library.
4. The method for restarting the database according to claim 1, wherein said switching the database master library to the database backup library comprises:
cleaning the synchronous information in the database standby database;
connecting the database master library, and adding replication information for the database master library to switch the database master library into a new database standby library;
the switching the database standby database into a new database main database comprises the following steps:
and opening the read-only of the database standby library, resetting a disk write strategy, and switching the database standby library into a new database main library.
5. The method of restarting a database according to claim 1, wherein before stopping and restarting the database library in response to a remote procedure call request, further comprising:
and the master-slave delay of the database master library and the database slave library is less than a preset restart threshold value.
6. The method of restarting a database according to claim 1, wherein the method further comprises:
and if the master-slave delay of the database master library and the database slave library is greater than or equal to a preset restart threshold, forcibly restarting the database master library and the database slave library.
7. The method of restarting a database according to claim 1, wherein before switching the database master library to a database new backup library and switching the database backup library to a database new master library, further comprising:
and supporting delayed switching, and detecting that the current time is consistent with the specified switching time.
8. An apparatus for restarting a database, comprising:
the response module is used for responding to the remote procedure call request, and stopping and restarting the database standby library;
the transfer module is used for transferring the data request from the database main library to the database standby library under the condition that the data in the database main library and the data in the database standby library are consistent;
the switching module is used for switching the database main library into a database standby library and switching the database standby library into a database new main library;
and the restarting module is used for restarting the new standby database of the database.
9. An electronic device that reboots a database, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-7.
10. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210542893.7A CN114925052A (en) | 2022-05-18 | 2022-05-18 | Method, device, equipment and computer readable medium for restarting database |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210542893.7A CN114925052A (en) | 2022-05-18 | 2022-05-18 | Method, device, equipment and computer readable medium for restarting database |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114925052A true CN114925052A (en) | 2022-08-19 |
Family
ID=82807993
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210542893.7A Pending CN114925052A (en) | 2022-05-18 | 2022-05-18 | Method, device, equipment and computer readable medium for restarting database |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114925052A (en) |
-
2022
- 2022-05-18 CN CN202210542893.7A patent/CN114925052A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9582532B2 (en) | Management and synchronization of batch workloads with active/active sites OLTP workloads | |
US20190235979A1 (en) | Systems and methods for performing computing cluster node switchover | |
US11709743B2 (en) | Methods and systems for a non-disruptive automatic unplanned failover from a primary copy of data at a primary storage system to a mirror copy of the data at a cross-site secondary storage system | |
WO2019152117A1 (en) | Systems and methods for synchronizing microservice data stores | |
CN105677380B (en) | Method and device for board-by-board upgrading of double master control isolations | |
US12050558B2 (en) | Facilitating immediate performance of volume resynchronization with the use of passive cache entries | |
US9747291B1 (en) | Non-disruptive upgrade configuration translator | |
CN111158949A (en) | Configuration method, switching method and device of disaster recovery architecture, equipment and storage medium | |
CN111181765A (en) | Task processing method and device | |
EP3352415A1 (en) | Smb service failure handling method, and storage device | |
US20240329843A1 (en) | Methods and systems to improve resumption time of input/output (i/o) operations based on prefetching of configuration data and early abort of conflicting workflows during a non-disruptive automatic unplanned failover from a primary copy of data at a primary storage system to a mirror copy of the data at a cross-site secondary storage system | |
CN113467873A (en) | Virtual machine scheduling method and device, electronic equipment and storage medium | |
US20240036996A1 (en) | Methods and systems to improve input/output (i/o) resumption time by batching multiple non-conflicting operations during a non-disruptive automatic unplanned failover from a primary copy of data at a primary storage system to a mirror copy of the data at a cross-site secondary storage system | |
CN108200151B (en) | ISCSI Target load balancing method and device in distributed storage system | |
CN113079098B (en) | Method, device, equipment and computer readable medium for updating route | |
CN107818027B (en) | Method and device for switching main name node and standby name node and distributed system | |
JP6115396B2 (en) | Information processing system, information processing apparatus, information processing apparatus control program, and information processing system control method | |
CN114925052A (en) | Method, device, equipment and computer readable medium for restarting database | |
CN110661857B (en) | Data synchronization method and device | |
CN112883103A (en) | Method and device for data transfer between clusters | |
CN114513524B (en) | Resource synchronization method and device, electronic equipment and storage medium | |
CN113761075B (en) | Method, apparatus, device and computer readable medium for switching databases | |
CN111277632B (en) | Method and device for managing applications in system cluster | |
CN113364615B (en) | Method, device, equipment and computer readable medium for rolling upgrade | |
US11943316B1 (en) | Database connection multiplexing for prepared statements |
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 |