Database cluster upgrading method and device, medium and product

By upgrading the backup library of the database cluster one by one and selecting a backup library as the new main library, the problem of business interruption during database cluster upgrade is solved, and a long-term business processing is not interrupted.

CN119829108APending Publication Date: 2025-04-15CETC JINCANG (BEIJING) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411908508.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-23
Publication Date
2025-04-15

AI Technical Summary

Technical Problem

The existing database cluster needs to be downtime during upgrades, resulting in a long period of interruption in business processing, affecting the normal operation of the cluster.

Method used

By obtaining the version upgrade package, upgrade the backup library one by one until all backup libraries are upgraded, then select a backup library as the new main library, continue to process the write operation business, and upgrade the original main library at the same time.

Benefits of technology

During the database cluster upgrade process, the original main library and other backup libraries can continue to process business, avoiding long-term business interruptions and significantly reducing the impact of the upgrade on business processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119829108A_ABST
    Figure CN119829108A_ABST
Patent Text Reader

Abstract

The invention provides a database cluster upgrading method and device, a medium and a product. The database cluster comprises an original main library and a plurality of standby libraries, and the upgrading method of the database cluster comprises the steps of obtaining a trigger event for upgrading the database cluster; obtaining a version upgrade package; using the version upgrade package to upgrade the standby libraries in sequence until all the standby libraries are upgraded; selecting one of the standby libraries and upgrading the standby libraries into a new main library; and upgrading the original main library by using the version upgrade package. In the process of upgrading each standby library, the original main library and the other standby libraries can continue to keep business processing, and the write operation business and the read operation business processed by the database cluster cannot be influenced. And when the original main library is upgraded, one standby library is upgraded into the new main library, so that the service processing of the database cluster is not influenced. In this way, the database cluster can keep service processing for a long time, and therefore the influence of upgrading of the database cluster on service processing is effectively reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of database technology, and in particular to a method, device, medium and product for upgrading a database cluster. Background Art

[0002] A database cluster refers to an overall system consisting of multiple databases. During the operation of a database cluster, one database is generally selected as the primary database, and the other databases are used as backup databases. The primary database is used to process write operations and synchronize data to other backup databases, which are used to process read operations.

[0003] When a database needs to be upgraded, the entire database cluster needs to be shut down, that is, the external business of the database cluster needs to be stopped. When all databases are updated, the database cluster needs to be restarted. Since it takes a long time to upgrade all databases in the database cluster, the business processing of the database cluster needs to be interrupted for a long time, which has a great impact on the business processing of the database cluster. Summary of the invention

[0004] An object of the present invention is to provide a method, device, medium and product for upgrading a database cluster, which can effectively reduce the impact of the database cluster upgrade on business processing.

[0005] In particular, the present invention provides a method for upgrading a database cluster, wherein the database cluster includes an original master database and multiple standby databases, wherein the method for upgrading the database cluster includes:

[0006] Obtain the trigger event for upgrading the database cluster;

[0007] Get the version upgrade package;

[0008] Using the version upgrade package to upgrade the standby databases in sequence until all the standby databases are upgraded;

[0009] Select one of the standby databases and upgrade it to the new primary database;

[0010] The original main library is upgraded using the version upgrade package.

[0011] Optionally, the step of upgrading the standby database includes:

[0012] Shutting down the standby warehouse;

[0013] Decompressing the version upgrade package and storing it in a first preset folder;

[0014] Point the original version directory of the standby library to the directory where the first preset folder is located;

[0015] Start the standby database.

[0016] Optionally, after the step of shutting down the standby database, the following steps are included:

[0017] Copy the original version file of the standby database to a second preset folder;

[0018] The first preset folder and the second preset folder have the same parent path.

[0019] Optionally, the name of the first preset folder includes at least version information corresponding to the version upgrade package, and the name of the second preset folder includes at least version information of the original version file.

[0020] Optionally, the step of selecting one of the standby databases and upgrading it to a new master database includes:

[0021] Selecting a standby database with the latest data from all the standby databases;

[0022] The standby database with the latest data is upgraded to the new primary database.

[0023] Optionally, the step of selecting a standby database with the latest data from all the standby databases includes:

[0024] Read the latest log files of all the standby databases;

[0025] Find the latest log file from all the log files;

[0026] The database to which the latest log file belongs is selected as the standby database with the latest data.

[0027] Optionally, after the step of selecting a standby database with the latest data from all the standby databases, the following steps are included:

[0028] Check whether the data of the standby database with the latest data is the same as that of the original main database. If so, perform the step of upgrading the standby database with the latest data to the new main database. If not, wait until the standby database is synchronized with the original main database until the data is the same, and then perform the step of upgrading the standby database with the latest data to the new main database.

[0029] According to another aspect of the present invention, a computer device is provided, comprising a memory, a processor, and a computer executable program stored in the memory and running on the processor, and the processor implements the database cluster upgrade method according to any one of the above items when executing the computer executable program.

[0030] According to another aspect of the present invention, a computer-readable storage medium is provided, on which a computer-executable program is stored. When the computer-executable program is executed by a processor, the method for upgrading a database cluster according to any one of the above items is implemented.

[0031] According to another aspect of the present invention, a computer program product is provided, including a computer executable program, and when the computer executable program is executed by a processor, the method for upgrading a database cluster according to any one of the above items is implemented.

[0032] The upgrade method of the database cluster of the present invention obtains a version upgrade package after obtaining a trigger event for upgrading the database cluster, uses the version upgrade package to upgrade the standby databases in sequence until all standby databases are upgraded, selects one of the standby databases and upgrades it to a new main database, and uses the version upgrade package to upgrade the original main database. In other words, in the process of upgrading the database cluster, one standby database is upgraded one by one, so in the process of upgrading each standby database, the original main database and the remaining standby databases can continue to maintain business processing, and will not affect the database cluster to process write operations and read operations. When all standby databases are upgraded, one of the standby databases is selected and upgraded to a new main database, that is, the original main database can no longer process write operations, and the new main database can process write operations during the upgrade process of the original main database, that is, upgrading the original main database will not affect the business processing of the database cluster. In this way, in the process of upgrading the database cluster, the database cluster can maintain business processing for a long time, thereby effectively reducing the impact on business processing caused by the database cluster upgrade.

[0033] Based on the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more aware of the above and other objects, advantages and features of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Hereinafter, some specific embodiments of the present invention will be described in detail in an exemplary and non-limiting manner with reference to the accompanying drawings. The same reference numerals in the accompanying drawings indicate the same or similar components or parts. It should be understood by those skilled in the art that these drawings are not necessarily drawn to scale. In the accompanying drawings:

[0035] Figure 1 is a schematic flow chart of a method for upgrading a database cluster according to an embodiment of the present invention;

[0036] Figure 2 is a schematic flow chart of the steps of upgrading a standby database in a method for upgrading a database cluster according to an embodiment of the present invention;

[0037] Figure 3is a schematic flow chart of the steps of upgrading a standby database in a method for upgrading a database cluster according to another embodiment of the present invention;

[0038] Figure 4 is a schematic flow chart of the steps of selecting one of the standby databases and upgrading it to a new master database in a database cluster upgrade method according to another embodiment of the present invention;

[0039] Figure 5 is a schematic flow chart of a step of selecting a standby database with the latest data from all standby databases in a method for upgrading a database cluster according to another embodiment of the present invention;

[0040] Figure 6 is a schematic diagram of a computer device according to an embodiment of the present invention;

[0041] Figure 7 is a schematic diagram of a computer-readable storage medium according to an embodiment of the present invention;

[0042] Figure 8 is a schematic diagram of a computer program product according to an embodiment of the present invention. DETAILED DESCRIPTION

[0043] It should be understood by those skilled in the art that the embodiments described below are only some embodiments of the present invention, rather than all embodiments of the present invention, and these embodiments are intended to explain the technical principles of the present invention, rather than to limit the protection scope of the present invention. Based on the embodiments provided by the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should still fall within the protection scope of the present invention.

[0044] It should be noted that the logic and / or steps represented in the flowchart or described in other ways herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, device or equipment (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or equipment and execute instructions), or used in combination with these instruction execution systems, devices or equipment.

[0045] The flow chart provided by the present invention is not intended to indicate that the operation of the method will be performed in any particular order, or all operations of the method are included in all every case. In addition, the method may include additional operations. Within the scope of the technical thinking provided by the present embodiment method, additional changes can be made to the above method.

[0046] like Figure 1As shown, in one embodiment, the database cluster includes an original master database and multiple standby databases. The upgrade method of the database cluster generally includes:

[0047] Step S101, obtaining a trigger event for upgrading the database cluster. Specifically, both the original master database and the standby database of the database cluster are pre-configured with an upgrade tool, and the trigger event can be that the upgrade tool receives an upgrade start instruction issued by a user.

[0048] Step S102, obtaining a version upgrade package, specifically, obtaining a compressed package including a new version file of the database.

[0049] Step S103: Use the version upgrade package to upgrade the standby databases in sequence until all standby databases are upgraded.

[0050] Reference Figure 2 As shown, in one embodiment, the steps of upgrading the standby database include:

[0051] Step S201, shut down the standby database, specifically, stop the external service of the standby database.

[0052] Step S202, decompress the version upgrade package and store it in a first preset folder. Specifically, decompress the version upgrade package including the new version file of the database, and store all the decompressed files in the first preset folder.

[0053] Step S203, point the original version directory of the standby library to the directory where the first preset folder is located. Specifically, a soft connection is established between the original version directory of the current standby library and the directory where the first preset folder is located. Soft connection is a computer technology well known to those skilled in the art and will not be described in detail here. In this way, when the current standby library accesses the original version directory, it will access the directory where the first preset folder is located, that is, the new version file, thereby completing the upgrade of the standby library.

[0054] Step S204, starting the standby database. Specifically, after the standby database upgrade is completed, the standby database can be restarted to enable the standby database to provide external services.

[0055] For all standby databases in the database cluster, refer to Figure 2 The upgrade is performed according to the process shown in the figure, that is, only the standby database being upgraded is shut down until all standby databases are upgraded.

[0056] Step S104, select one of the standby databases and upgrade it to a new primary database. Specifically, after all standby databases are upgraded, one standby database is selected from all standby databases and upgraded to a new primary database, that is, the new primary database processes the write operation business.

[0057] Step S105, use the version upgrade package to upgrade the original master database. After selecting one of the backup databases and upgrading it to the new master database, the new master database processes the write operation business, and the original master database no longer processes the write operation business, so it can be shut down for upgrading, and it will not affect the business processing of the database cluster. At this time, the original master database is downgraded to a backup database, and the upgrade method of the original master database after being downgraded to a backup database is upgraded in accordance with the upgrade method of other backup databases.

[0058] In the scheme of this embodiment, after obtaining the trigger event for upgrading the database cluster, the version upgrade package is obtained, and the standby databases are upgraded in sequence using the version upgrade package until all standby databases are upgraded, one of the standby databases is selected and upgraded to the new master database, and the original master database is upgraded using the version upgrade package. In other words, in the process of upgrading the database cluster, one standby database is upgraded one by one, so in the process of upgrading each standby database, the original master database and the remaining standby databases can continue to maintain business processing, and will not affect the database cluster to process write operations and read operations. When all standby databases are upgraded, one of the standby databases is selected and upgraded to the new master database, that is, the original master database can no longer process write operations, and the new master database can process write operations during the upgrade process of the original master database, that is, upgrading the original master database will not affect the business processing of the database cluster. In this way, in the process of upgrading the database cluster, the database cluster can maintain business processing for a long time, thereby effectively reducing the impact of the database cluster upgrade on business processing.

[0059] In addition, when upgrading the standby database, the standby database is shut down, and then the version upgrade package is decompressed and stored in the first preset folder, and then the original version directory of the standby database is pointed to the directory where the first preset folder is located, and the standby database is started. In other words, there is no need to replace the original version file with the new version file obtained by decompressing the version upgrade package, which helps to reduce the time used for each database upgrade, and further helps to improve the upgrade efficiency of the database cluster.

[0060] like Figure 3 As shown, in one embodiment, the step of shutting down the standby database includes: copying the original version file of the standby database to a second preset folder; wherein the first preset folder and the second preset folder have the same parent path.

[0061] In this embodiment, the steps of upgrading the standby database include:

[0062] Step S301, shutting down the standby database.

[0063] Step S302: decompress the version upgrade package and store it in a first preset folder.

[0064] Step S303, copy the original version file of the backup library to the second preset folder. Specifically, the original version file of the backup library is backed up to the second preset folder. The first preset folder and the second preset folder have the same parent path, that is, the directory of the first preset folder and the directory of the second preset folder are different only in the last level folder name.

[0065] Specifically, the name of the first preset folder includes at least the version information corresponding to the version upgrade package, and the name of the second preset folder includes at least the version information of the original version file. Exemplarily, the name of the first preset folder can use the version number of the new version, and the name of the second preset folder can use the version number of the original version file.

[0066] In summary, in one example, the directory of the first preset folder may be:

[0067] “KINGBASEHOME / KESRealPro / New Version Number / ”;

[0068] The directory of the second default folder can be:

[0069] “KINGBASEHOME / KESRealPro / Old version number / ”.

[0070] Step S304: point the original version directory of the standby database to the directory where the first preset folder is located.

[0071] Step S305: start the standby database.

[0072] In the solution of this embodiment, by copying the original version file of the standby library to the second preset folder when upgrading the standby library, the first preset folder and the second preset folder have the same parent path, so that it is convenient to switch the version access path between the directory where the first preset folder is located and the directory where the second preset folder is located. In addition, by making the name of the first preset folder include at least the version information corresponding to the version upgrade package, and making the name of the second preset folder include at least the version information of the original version file, it is convenient to identify the directory where the version file of each version is located, and it is more convenient to switch the accessed version.

[0073] like Figure 4 As shown, in one embodiment, the step of selecting one of the standby databases and upgrading it to a new primary database includes:

[0074] Step S401: Select a standby database with the latest data from all standby databases.

[0075] like Figure 5 As shown, in one embodiment, this step includes:

[0076] Step S501, read the latest log files of all standby databases. Specifically, after the original master database completes the write operation, it will synchronize its own data to all standby databases. When the synchronization operation is performed on the standby database, an operation log file will be generated, that is, the log files corresponding to the last transaction operation of all standby databases are read.

[0077] Step S502: Find the latest log file from all log files, that is, compare the time of the latest log files in all standby databases to find the latest log file.

[0078] Step S503: Select the database to which the latest log file belongs as the standby database with the latest data. The database to which the latest log file belongs is the standby database with the latest synchronization time, that is, the standby database with the latest data and the data closest to the original primary database.

[0079] Step S404: Upgrade the standby database with the latest data to the new primary database. After the standby database with the latest data is determined, the standby database with the latest data is upgraded to the new primary database, and the new primary database starts to process write operations. The original primary database no longer processes write operations and can be shut down for upgrade.

[0080] By upgrading the standby database with the latest data to the new primary database when the original primary database needs to be upgraded, it can be ensured that the data in the new primary database is more consistent with the original primary database, reducing the occurrence of transaction operation errors.

[0081] Continue to refer to Figure 4 As shown in the figure, the steps of selecting the latest standby database from all standby databases include:

[0082] Step S402, check whether the data in the standby database with the latest data is the same as the data in the original master database, if so, execute step S404, if not, execute step S403. Specifically, it is to check whether the data in the standby database with the latest data is the same as the data in the original master database.

[0083] Step S403, wait for the standby database to be synchronized with the original master database until the data is the same. Execute step S404. If not, wait for the standby database to be synchronized with the original master database until the data is consistent, and then upgrade the standby database with the latest data to the new master database, so as to avoid transaction operation errors.

[0084] It should be noted that in some other embodiments, if the waiting time exceeds the preset threshold, the original master database is shut down, that is, the write operation business is no longer processed, and only synchronization is performed until the backup database is synchronized with the original master database to the same data, and then the backup database with the latest data is upgraded to the new master database, and the new master database performs the write operation business, thereby avoiding excessive waiting time.

[0085] This embodiment also provides a computer device and a computer-readable storage medium. Figure 6is a schematic diagram of a computer device 10 according to one embodiment of the present invention. Figure 7 is a schematic diagram of a computer-readable storage medium 20 according to one embodiment of the present invention.

[0086] The computer device 10 may include a memory 110, a processor 120, and a computer executable program 11 stored in the memory 110 and running on the processor 120, and the processor 120 implements the database cluster upgrade method of any of the above embodiments when executing the computer executable program 11.

[0087] The computer-readable storage medium 20 stores a computer-executable program 11 thereon. When the computer-executable program 11 is executed by a processor, the method for upgrading a database cluster in any of the above-mentioned embodiments can be implemented.

[0088] This embodiment also provides a computer program product. Figure 8 1 is a schematic diagram of a computer program product 30 according to an embodiment of the present invention. The computer program product 30 includes a computer executable program 11, and when the computer executable program 11 is executed by the processor 120, it can implement any of the above-mentioned database cluster upgrade methods.

[0089] Specifically, the computer executable program 11 for performing the operations of the present invention may be assembly instructions, instruction set architecture (ISA) instructions, computer instructions, computer-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages.

[0090] For the purpose of the description of the present embodiment, the computer-readable storage medium 20 can be any device that can contain, store, communicate, propagate or transmit a program for use with an instruction execution system, device or equipment or in conjunction with these instruction execution systems, devices or equipment. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection portion (electronic device) with one or more wirings, a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable storage medium 20 can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpreting or processing in other suitable ways as necessary, and then stored in a computer memory.

[0091] It should be understood that each part of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system.

[0092] The computer device 10 may be, for example, a server, a desktop computer, a notebook computer, a tablet computer, or a smart phone. In some examples, the computer device 10 may be a cloud acquisition node. The computer device 10 may be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, a program module may include routines, programs, object programs, components, logic, data structures, etc. that perform specific tasks or implement specific abstract data types. The computer device 10 may be implemented in a distributed cloud acquisition environment where remote processing devices linked via a communication network perform tasks. In a distributed cloud acquisition environment, program modules may be located on a local or remote acquisition system storage medium including a storage device.

[0093] The computer device 10 may include a processor 120 adapted to execute stored instructions, and a memory 110 that provides temporary storage space for the operation of the instructions during operation. The processor 120 may be a single-core processor, a multi-core processor, an acquisition cluster, or any number of other configurations. The memory 110 may include random access memory (RAM), read-only memory, flash memory, or any other suitable storage system.

[0094] The processor 120 may be connected to an I / O interface (input / output interface) suitable for connecting the computer device 10 to one or more I / O devices (input / output devices) via a system interconnect (e.g., PCI, PCI-Express, etc.). The I / O devices may include, for example, a keyboard and a pointing device, wherein the pointing device may include a touch pad or a touch screen, etc. The I / O devices may be built-in components of the computer device 10, or may be devices externally connected to an acquisition device.

[0095] Processor 120 can also be linked to a display interface suitable for connecting computer device 10 to a display device through a system interconnection. Display device can include a display screen as a built-in component of computer device 10. Display device can also include a computer monitor, a television or a projector, etc., which are externally connected to computer device 10. In addition, a network interface controller (NIC) can be suitable for connecting computer device 10 to a network through a system interconnection. In some embodiments, NIC can use any suitable interface or protocol (such as an Internet small computer system interface, etc.) to transmit data. The network can be a cellular network, a radio network, a wide area network (WAN), a local area network (LAN) or the Internet, etc. A remote device can be connected to a computer device through a network.

[0096] At this point, those skilled in the art should recognize that, although multiple exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications that conform to the principles of the present invention can still be directly determined or derived based on the content disclosed in the present invention without departing from the spirit and scope of the present invention. Therefore, the scope of the present invention should be understood and recognized as covering all these other variations or modifications.

Claims

1. A method for upgrading a database cluster, wherein the database cluster includes an original master database and multiple backup databases, wherein: The database cluster upgrade method includes: Obtain the trigger event for upgrading the database cluster; Get the version upgrade package; Using the version upgrade package to upgrade the standby databases in sequence until all the standby databases are upgraded; Select one of the standby databases and upgrade it to the new primary database; The original main library is upgraded using the version upgrade package.

2. The method for upgrading a database cluster according to claim 1, wherein: The step of upgrading the standby database includes: Shutting down the standby warehouse; Decompressing the version upgrade package and storing it in a first preset folder; Point the original version directory of the standby library to the directory where the first preset folder is located; Start the standby database.

3. The method for upgrading a database cluster according to claim 2, wherein: The step of shutting down the standby database includes: Copy the original version file of the standby database to a second preset folder; The first preset folder and the second preset folder have the same parent path.

4. The method for upgrading a database cluster according to claim 3, wherein: The name of the first preset folder includes at least the version information corresponding to the version upgrade package, and the name of the second preset folder includes at least the version information of the original version file.

5. The method for upgrading a database cluster according to claim 1, wherein: The steps of selecting one of the standby databases and upgrading it to a new master database include: Selecting a standby database with the latest data from all the standby databases; The standby database with the latest data is upgraded to the new primary database.

6. The method for upgrading a database cluster according to claim 5, wherein: The step of selecting the standby database with the latest data from all the standby databases includes: Read the latest log files of all the standby databases; Find the latest log file from all the log files; The database to which the latest log file belongs is selected as the standby database with the latest data.

7. The method for upgrading a database cluster according to claim 5, wherein: The step of selecting the standby database with the latest data from all the standby databases includes: Check whether the data of the standby database with the latest data is the same as that of the original main database. If so, perform the step of upgrading the standby database with the latest data to the new main database. If not, wait until the standby database is synchronized with the original main database until the data is the same, and then perform the step of upgrading the standby database with the latest data to the new main database.

8. A computer device, comprising a memory, a processor, and a computer executable program stored in the memory and running on the processor, wherein the processor implements the database cluster upgrade method according to any one of claims 1 to 7 when executing the computer executable program.

9. A computer-readable storage medium having a computer-executable program stored thereon, wherein the computer-executable program, when executed by a processor, implements the method for upgrading a database cluster according to any one of claims 1 to 7.

10. A computer program product, comprising a computer executable program, wherein when the computer executable program is executed by a processor, the method for upgrading a database cluster according to any one of claims 1 to 7 is implemented.