Database Upgrade Method, Device, Equipment, Storage Medium and Program Product
By automating the database upgrade process, using the target database installation package and upgrade process definition files, the problem of complex and inefficient database upgrade process in the existing technology is solved, and a more efficient and reliable database upgrade is achieved.
Patent Information
- Application Number
- CN202510037534.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-10
- Publication Date
- 2025-06-03
- Estimated Expiration
- 2045-01-10
AI Technical Summary
The existing database upgrade process is complex and requires strict sequential operation, resulting in large workload, low efficiency and error-prone, increasing the risk of upgrade failure.
By obtaining the target database installation package, the relevant upgrade process definition files are called, including pre-detection scripts, installation scripts, database startup scripts and uninstall scripts, to automate the entire upgrade process and simplify the order requirements between files.
The database upgrade process is simplified, the operation complexity is reduced, the execution efficiency and success rate is improved, and the problems of complex and low efficiency in the existing technology are solved.
Smart Images

Figure CN119440590B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of databases, and in particular to a database upgrade method, device, equipment, storage medium and program product. Background Art
[0002] When a database software is installed and upgraded based on a software package manager (Red Hat Package Manager, RPM), generally multiple software packages are required. In addition to the necessary main program package, there are also dependency library packages, tool packages, plugin packages, etc. These packages completely constitute a set of database software. Since there are dependency relationships between the packages, it is necessary to operate one by one in sequence during installation and upgrade to ensure that the dependencies between the software packages can be well resolved. In the existing upgrade process, there are strict order requirements for installing multiple software packages, which increases the workload and difficulty of upgrading the database. Secondly, the upgrade processes for different modes are different and involve multiple steps. If each step is manually operated, not only will the efficiency be reduced but also errors are likely to occur, thereby increasing the failure rate of the entire upgrade. Summary of the Invention
[0003] In view of the above problems, the present invention provides a database upgrade method, device, equipment, storage medium and program product.
[0004] According to a first aspect of the present invention, there is provided a database upgrade method, including: obtaining a target database installation package, where the target database installation package includes a main program file, a function library file, and an auxiliary tool file; calling an upgrade process definition file related to the target database installation package, where the upgrade process definition file includes a pre-detection script, an installation script, a database startup script, and an uninstallation script; calling the pre-detection script to detect the version numbers of the old version database and the new version database respectively to obtain an operation result; based on the operation result and the target database installation package, calling the installation script to install the new version database; calling the database startup script to start the new version database based on the operation result; calling the uninstallation script to uninstall the old version database.
[0005] Optionally, call a pre-detection script to detect the version numbers of the old version database and the new version database respectively, and the operation results include: call the pre-detection script, and when the version numbers of the old version database and the new version database are different, determine the first upgrade mode; based on the first upgrade mode, perform a logical backup operation on the old version database to obtain a logical backup result; when the logical backup result includes a backup success result, perform a deactivation operation on the old version database to obtain a deactivation result; when a deactivation result indicating successful deactivation is obtained, perform a configuration information backup operation on the old version database to obtain a configuration information backup result; when the configuration information backup result includes a backup success result, perform a transfer operation on the data directory information in the old version database to obtain a transfer result, where the operation results include the logical backup result, the configuration information backup result, the transfer result, and the deactivation result.
[0006] Optionally, the logical backup result further includes a data logical backup file, the configuration information backup result further includes a configuration parameter file, and the transfer result includes a data directory information status result; among them, calling a database startup script to start the new version database based on the operation results includes: calling the database startup script, and when the data directory information status result is an empty status, perform an initialization operation on the new version database to obtain an initialization result; when an initialization result indicating successful initialization is obtained, start the new version database based on the configuration parameter file and import the data logical backup file.
[0007] Optionally, calling a pre-detection script to detect the version numbers of the old version database and the new version database respectively, and the operation results further include: call the pre-detection script, and when the version numbers of the old version database and the new version database are the same, determine the second upgrade mode; based on the second upgrade mode, perform a deactivation operation on the old version database to obtain a deactivation result, where the operation results include the deactivation result; calling a database startup script to start the new version database based on the operation results includes: calling the database startup script, detecting the status of the data directory information in the old version database based on the operation results to obtain a data detection result; when a data detection result indicating a non-empty status is obtained, start the new version database based on the data directory information.
[0008] Optionally, the upgrade process definition file further includes a data cleaning script; the database upgrade method further includes: calling the data cleaning script to clean the automatic startup function configuration information and environment variable information related to the old version database.
[0009] Optionally, the target database installation package is obtained based on the following operations: parsing the list file to determine the target file name; copying the function library file and auxiliary tool file corresponding to the target file name to the installation folder, where the installation folder includes the main program file; and packaging the installation folder to obtain the target database installation package.
[0010] The second aspect of the present invention provides a database upgrade device, including: an acquisition module for acquiring a target database installation package, where the target database installation package includes a main program file, a function library file, and an auxiliary tool file; a call module for calling an upgrade process definition file related to the target database installation package, where the upgrade process definition file includes a pre-detection script, an installation script, a database startup script, and an uninstallation script; a pre-detection module for calling the pre-detection script to detect the version numbers of the old version database and the new version database respectively to obtain an operation result; an installation module for calling the installation script based on the operation result and the target database installation package to install the new version database; a startup module for calling the database startup script to start the new version database based on the operation result; and an uninstallation module for calling the uninstallation script to uninstall the old version database.
[0011] The third aspect of the present invention provides an electronic device, including: one or more processors; a memory for storing one or more programs, where when the one or more programs are executed by the one or more processors, the one or more processors are caused to execute the above-mentioned database upgrade method.
[0012] The fourth aspect of the present invention further provides a computer-readable storage medium, on which executable instructions are stored, and when the instructions are executed by a processor, the processor is caused to execute the above-mentioned database upgrade method.
[0013] The fifth aspect of the present invention further provides a computer program product, including a computer program, and when the computer program is executed by a processor, the above-mentioned database upgrade method is implemented.
[0014] According to the database upgrade method, device, equipment, storage medium and program product provided by the present invention, by calling a pre-detection script, the version numbers of the old version database and the new version database are detected respectively to obtain an operation result; based on the operation result and the target database installation package, and by calling an installation script, the new version database is installed; a database startup script is called to start the new version database based on the operation result; and an uninstallation script is called to uninstall the old version database. Since the function library files, auxiliary tool files and main program files are uniformly packaged into a target database installation package, and there is no order requirement between the files, the installation process and upgrade process of the new version database can be simplified, and the complexity of the operation can be reduced. In addition, custom scripts are injected into each stage of the upgrade process definition file, so that the entire upgrade process can flexibly adapt to different upgrade scenarios based on the version numbers of the old version database and the new version database. The one-key automation of the upgrade process greatly improves the execution efficiency and success rate, and solves the technical problems of complex operation and low efficiency in installing and upgrading the database. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Through the following description of the embodiments of the present invention with reference to the accompanying drawings, the above and other objects, features and advantages of the present invention will become clearer. In the drawings:
[0016] Figure 1 The application scenario of the database upgrade method and device according to the embodiment of the present invention is shown.
[0017] Figure 2 The flowchart of the database upgrade method according to the embodiment of the present invention is shown.
[0018] Figure 3A The flowchart of calling the pre-detection script according to the embodiment of the present invention is shown.
[0019] Figure 3B The flowchart of calling the database startup script according to the embodiment of the present invention is shown.
[0020] Figure 3C The flowchart of the database upgrade according to the embodiment of the present invention is shown.
[0021] Figure 4 The structural block diagram of the database upgrade device according to the embodiment of the present invention is shown.
[0022] Figure 5 The block diagram of the electronic device suitable for implementing the database upgrade method according to the embodiment of the present invention is shown. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0023] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are merely exemplary and are not intended to limit the scope of the present invention. In the following detailed description, for the sake of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the present invention. However, obviously, one or more embodiments can also be implemented without these specific details. In addition, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessarily obscuring the concepts of the present invention.
[0024] The terms used herein are merely for describing specific embodiments and are not intended to limit the present invention. The terms "comprising", "including", etc. used herein indicate the presence of features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0025] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.
[0026] In the case of using expressions such as "at least one of A, B, and C, etc.", generally, it should be interpreted according to the meaning commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include, but is not limited to, a system having only A, only B, only C, having A and B, having A and C, having B and C, and / or having A, B, and C, etc.).
[0027] In the process of implementing the present invention, it is found that when installing and upgrading database software based on the software package manager (Red Hat Package Manager, RPM), generally multiple software packages are required. In addition to the necessary main program package, there are also dependency library packages, tool packages, plugin packages, etc. These packages completely constitute a set of database software. Since there are dependency relationships between the packages, when installing and upgrading, it is necessary to operate one by one in sequence to ensure that the dependencies between the software packages can be well resolved. In the existing upgrade process, there are strict sequence requirements for installing multiple software packages, which increases the workload and difficulty of upgrading the database. Secondly, the upgrade processes for different modes are different and involve multiple steps. If each step is manually operated, not only will the efficiency be reduced but also errors are likely to occur, thereby increasing the failure rate of the entire upgrade.
[0028] In view of this, embodiments of the present invention provide a database upgrade method, apparatus, device, storage medium, and program product. The method includes: obtaining a target database installation package, where the target database installation package includes a main program file, a function library file, and an auxiliary tool file; calling an upgrade process definition file related to the target database installation package, where the upgrade process definition file includes a pre-detection script, an installation script, a database startup script, and an uninstallation script; calling the pre-detection script to detect the version numbers of the old version database and the new version database respectively, and obtaining an operation result; based on the operation result and the target database installation package, calling the installation script to install the new version database; calling the database startup script to start the new version database based on the operation result; and calling the uninstallation script to uninstall the old version database.
[0029] In the technical solution of the present invention, the user information involved (including but not limited to user personal information, user image information, user device information, such as location information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) are all information and data authorized by the user or fully authorized by all parties. Moreover, the processing of relevant data, such as collection, storage, use, processing, transmission, provision, disclosure, and application, complies with relevant laws, regulations, and standards, takes necessary confidentiality measures, does not violate public order and good customs, and provides corresponding operation entrances for users to choose to authorize or refuse.
[0030] Figure 1 The application scenarios of the database upgrade method and apparatus according to embodiments of the present invention are shown.
[0031] As Figure 1 shown, the business system architecture 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a cluster server 105. The network 104 is used to provide a medium for communication links between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the cluster server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.
[0032] Users can use at least one of the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications may be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).
[0033] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices with a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0034] The server 105 may be a server that provides various services, such as a background management server (only for example) that supports the websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. A cluster distributed database is deployed on the server 105. The server 105 includes multiple server nodes that can analyze and process data such as user requests received, and feedback the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal devices.
[0035] It should be noted that the database upgrade method provided by the embodiments of the present invention can generally be executed by the server 105. Correspondingly, the database upgrade device provided by the embodiments of the present invention can generally be set in the server 105. The database upgrade method provided by the embodiments of the present invention can also be executed by a server or a server cluster different from the server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or the server 105. Correspondingly, the database upgrade device provided by the embodiments of the present invention can also be set in a server or a server cluster different from the server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or the server 105.
[0036] Alternatively, the database upgrade method provided by the embodiments of the present invention can also be executed by the first terminal device 101, the second terminal device 102, or the third terminal device 103, or can also be executed by other terminal devices different from the first terminal device 101, the second terminal device 102, or the third terminal device 103. Correspondingly, the database upgrade device provided by the embodiments of the present invention can also be set in the first terminal device 101, the second terminal device 102, or the third terminal device 103, or set in other terminal devices different from the first terminal device 101, the second terminal device 102, or the third terminal device 103.
[0037] It should be understood that Figure 1 the numbers of the terminal devices, networks, and servers in
[0038] are merely illustrative. According to the implementation requirements, there can be any number of terminal devices, networks, and servers. Attention should be paid that the sequence numbers of the operations in the following methods are only used as representations of the operations for description, and should not be regarded as indicating the execution sequence of the operations. Unless explicitly stated, the method does not need to be executed exactly in the shown sequence.
[0039] Figure 2 The flowchart of the database upgrade method according to an embodiment of the present invention is shown.
[0040] As Figure 2 shown, the method 200 includes operation S210 to operation S260.
[0041] In operation S210, obtain the target database installation package.
[0042] Optionally, the target database installation package includes a main program file, a function library file, and an auxiliary tool file.
[0043] Optionally, the target database installation package can be generated based on a software package manager (Red Hat Package Manager, RPM), and the main program file, function library file, and auxiliary tool file in the target database installation package are used to install the new version of the database.
[0044] Optionally, the main program file supports the operation of the new version of the database; the function library file is a third-party dependency library, and the function library file supports the functions of the new version of the database; the auxiliary tool file can be a plug-in tool, etc., and the auxiliary tool file also supports the functions of the new version of the database. The main program file, function library file, and auxiliary tool file are packaged into a target database installation package.
[0045] In operation S220, call the upgrade process definition file related to the target database installation package.
[0046] Optionally, the upgrade process definition file can be a specification file (SPEC), and the functions of each upgrade stage in the upgrade process definition file are implemented by calling scripts.
[0047] Optionally, the upgrade process definition file is a configuration specification file of the target database installation package, and includes information such as the name, version, dependencies, source code, publisher, etc. of the target database installation package.
[0048] Optionally, operation commands are customarily added to the scripts of each upgrade stage in the upgrade process definition file, so as to obtain a pre-detection script, an installation script, a database startup script, and an uninstallation script.
[0049] Optionally, the pre-detection script is used to detect the database version number and perform pre-operations, etc. before installing the new version of the database. The installation script is used to install the new version of the database, the database startup script is used to start the installed new version of the database, and the uninstallation script is executed after startup to uninstall the old version of the database.
[0050] In operation S230, a pre-detection script is called to detect the version numbers of the old version database and the new version database respectively, and an operation result is obtained.
[0051] Optionally, first execute the upgrade command, such as rpm -Uvh ***.rpm, to start the database upgrade in RPM mode.
[0052] Optionally, the old version database is an existing database in the system, and the new version database is the database to be upgraded based on the old version database.
[0053] Optionally, execute the pre-detection script in the upgrade process definition file to detect the version numbers of the old version database and the new version database respectively, and operate on the old version database according to the detection results of the two version numbers to obtain an operation result. For example, the operation result can be a stop result or a backup result, etc.
[0054] In operation S240, based on the operation result and the target database installation package, an installation script is called to install the new version database.
[0055] Optionally, based on the operation result, the main program file, the function library file, and the auxiliary tool file in the target database installation package, execute the installation script in the upgrade process definition file to install the new version database.
[0056] In operation S250, a database start script is called to start the new version database based on the operation result.
[0057] Optionally, after installing the new version database, execute the database start script in the upgrade process definition file to start the new version database according to the operation result.
[0058] For example, in the case where the operation result only includes a stop result, directly start the new version database; in the case where the operation result also includes a backup result, first initialize the new version database, and then start the new version database based on the operation result.
[0059] In operation S260, an uninstall script is called to uninstall the old version database.
[0060] Optionally, after starting the new version database, execute the uninstall script in the upgrade process definition file to uninstall the old version database and clean up the main program file, the function library file, the auxiliary tool file, etc. related to the old version database.
[0061] Optionally, by packaging the function library file, auxiliary tool file, and main program file into a target database installation package, and without requiring an order among the files, the installation process and upgrade process of the new version database are simplified, and the operation complexity is reduced. In addition, custom scripts are injected into each stage of the upgrade process definition file, so that the entire upgrade process can flexibly adapt to different upgrade scenarios based on the version numbers of the old version database and the new version database. The one-key automation of the upgrade process greatly improves the execution efficiency and success rate, and solves the technical problems of complex operation and low efficiency in installing and upgrading the database.
[0062] Optionally, call the pre-detection script to detect the version numbers of the old version database and the new version database respectively, and the operation results include: call the pre-detection script, and when the version numbers of the old version database and the new version database are different, determine the first upgrade mode; based on the first upgrade mode, perform a logical backup operation on the old version database to obtain a logical backup result; when the logical backup result includes a backup success result, perform a deactivation operation on the old version database to obtain a deactivation result; when a deactivation result indicating successful deactivation is obtained, perform a configuration information backup operation on the old version database to obtain a configuration information backup result; when the configuration information backup result includes a backup success result, perform a transfer operation on the data directory information in the old version database to obtain a transfer result, where the operation results include the logical backup result, the configuration information backup result, the transfer result, and the deactivation result.
[0063] Optionally, execute the pre-detection script in the upgrade process definition file to detect the version numbers of the old version database and the new version database respectively. When the version numbers of the old version database and the new version database are different, determine the first upgrade mode. The first upgrade mode can be a major upgrade mode.
[0064] Optionally, the fact that the version numbers of the old version database and the new version database are different indicates that the main programs of the new version database and the old version database are incompatible, and the new version database cannot use the data directory of the old version database. Therefore, it is necessary to perform a logical backup operation on the old version database first.
[0065] Optionally, the logical backup operation is to dump the data in the old version database to a data file in a stored manner. The data file format is a Structured Query Language (SQL) file, and the logical backup result includes the data file, and the content in the data file is the creation statements of all objects and data in the old version database during backup.
[0066] Optionally, the logical backup result further includes a backup success result or a backup failure result. In the case of obtaining a backup failure result, the upgrade process is directly terminated; in the case of obtaining a backup success result, the old version database is stopped to obtain a stop result indicating successful stop.
[0067] Optionally, in the case where the transfer result includes a transfer success result, a configuration information backup operation is performed on the old version database to obtain a configuration information backup result.
[0068] Optionally, the configuration information backup result may further include backup results of configuration operation parameters, environment, ports, etc. of the old version database.
[0069] Optionally, in the case where the configuration information backup result includes a backup success result, a transfer operation is performed on the data directory information in the old version database to obtain a transfer result. The data directory information in the old version database is copied to other path files, and the data directory information in the old version database is cleared so that the main program of the new version database can be re-initialized in the original path.
[0070] Optionally, the logical backup result further includes a data logical backup file, the configuration information backup result further includes a configuration parameter file, and the transfer result includes a data directory information status result; among them, calling a database startup script to start the new version database based on the operation result includes: calling a database startup script, and in the case where the data directory information status result is an empty status, an initialization operation is performed on the new version database to obtain an initialization result; in the case of obtaining an initialization result indicating successful initialization, the new version database is started based on the configuration parameter file, and the data logical backup file is imported.
[0071] Optionally, the content in the data logical backup file is the creation statements of all objects and data in the old version database during backup; the configuration parameter file includes configuration operation parameters, environment, ports, etc. information of the old version database.
[0072] Optionally, in the case of obtaining a transfer success result, the data directory information status result may be an empty status; in the case of obtaining a transfer failure result, the data directory information status result may be a non-empty status.
[0073] Optionally, after installing the new version database, the database startup script in the upgrade process definition file is executed to detect the data directory information status of the old version database. In the case where the data directory information status result is an empty status, an initialization operation is performed on the new version database based on the default data directory information to obtain an initialization result indicating successful initialization.
[0074] Optionally, in the case of obtaining an initialization result indicating successful initialization, start the new version database based on the configuration parameter file, and then import the data logical backup file into the new version database to ensure the consistency of the data in the new version database and the data in the old version database.
[0075] Optionally, call the pre-detection script to detect the version numbers of the old version database and the new version database respectively. The obtained operation results also include: calling the pre-detection script, and determining the second upgrade mode when the version numbers of the old version database and the new version database are the same; based on the second upgrade mode, perform a stop operation on the old version database to obtain a stop result, where the operation results include the stop result.
[0076] Calling the database startup script to start the new version database based on the operation results includes: calling the database startup script to detect the status of the data directory information in the old version database based on the operation results to obtain a data detection result; in the case of obtaining a data detection result indicating a non-empty status, start the new version database based on the data directory information.
[0077] Optionally, execute the pre-detection script in the upgrade process definition file to detect the version numbers of the old version database and the new version database respectively. When the version numbers of the old version database and the new version database are the same, determine the second upgrade mode. The second upgrade mode can be the small upgrade mode.
[0078] Optionally, the same version numbers of the old version database and the new version database indicate that the main programs of the new version database and the old version database are compatible, and the new version database can be started based on the data directory of the old version database. Therefore, a stop operation can be directly performed on the old version database. The operation results include the stop result.
[0079] Optionally, in the case of obtaining a stop result indicating successful stop, install the new version database, and then execute the database startup script in the upgrade process definition file to detect the status of the data directory information of the old version database. In the case where the status result of the data directory information is a non-empty status, directly start the new version database based on the data directory information of the old version database, and the data in the new version database is consistent with the data in the old version database.
[0080] Optionally, inject a custom script in the pre-detection stage of the upgrade process definition file, and flexibly determine different upgrade modes by detecting the version numbers of the old version database and the new version database, so that the entire upgrade process can adapt to different upgrade scenarios, achieve one-key upgrade, and greatly improve the execution efficiency and success rate.
[0081] Figure 3AThe flowchart of invoking a pre - detection script according to an embodiment of the present invention is shown.
[0082] As Figure 3A shown, invoking the pre - detection script includes steps S311 to S319.
[0083] In step S311, it is judged whether it is the first upgrade mode. Specifically, in the case of the first upgrade mode, it jumps to step S312; otherwise, it jumps to step S315.
[0084] In step S312, a logical backup operation is performed on the old - version database.
[0085] In step S313, it is judged whether the backup result is successful. Specifically, in the case of obtaining a backup failure result, it jumps to step S314; otherwise, it jumps to step S315.
[0086] In step S314, the upgrade process is exited.
[0087] In step S315, the old - version database is deactivated.
[0088] In step S316, it is judged again whether it is the first upgrade mode. Specifically, in the case of the first upgrade mode, it jumps to step S317; otherwise, it jumps to step S319.
[0089] In step S317, a configuration information backup operation is performed on the old - version database.
[0090] In step S318, a transfer operation is performed on the data directory information in the old - version database.
[0091] In step S319, a new - version database is installed.
[0092] Figure 3B The flowchart of invoking a database startup script according to an embodiment of the present invention is shown.
[0093] As Figure 3B shown, invoking the database startup script includes steps S321 to S327.
[0094] In step S321, it is judged whether it is the first upgrade mode. Specifically, in the case of the first upgrade mode, it jumps to step S322; otherwise, it jumps to step S324.
[0095] In step S322, an initialization operation is performed on the new - version database.
[0096] In step S323, the configuration parameter file is copied.
[0097] In step S324, the new - version database is started.
[0098] In step S325, it is determined whether it is the first upgrade mode. Specifically, in the case of the first upgrade mode, it jumps to step S326; otherwise, it jumps to step S327.
[0099] In step S326, the data logic backup file is imported into the new version database.
[0100] In step S327, the execution of the database startup script ends.
[0101] Optionally, the upgrade process definition file further includes a data cleaning script; the database upgrade method further includes:
[0102] Call the data cleaning script to clean the automatic startup function configuration information and environment variable information related to the old version database.
[0103] Optionally, the upgrade process definition file further includes a pre-uninstallation detection script. After executing the database startup script in the upgrade process definition file, the pre-uninstallation detection script is executed. The pre-uninstallation detection script has no additional operations for the upgrade process, and for a simple uninstallation operation, it will stop the database.
[0104] Optionally, after executing the pre-uninstallation detection script, an uninstallation script is executed to uninstall the old version database and clean the main program files, function library files, auxiliary tool files, etc. related to the old version database.
[0105] Optionally, after executing the uninstallation script, the data cleaning script is executed again to clean the automatic startup function configuration information and environment variable information related to the old version database.
[0106] Optionally, the automatic startup function configuration information represents the information for configuring the automatic startup function of the old version database.
[0107] Figure 3C The flowchart of database upgrade according to an embodiment of the present invention is shown.
[0108] As Figure 3C shown, the database upgrade includes steps S331 to S336.
[0109] In step S331, a pre-detection script is called.
[0110] In step S332, an installation script is called.
[0111] In step S333, a database startup script is called.
[0112] In step S334, a pre-uninstallation detection script is called.
[0113] In step S335, an uninstallation script is called.
[0114] In step S336, a data cleaning script is called.
[0115] Optionally, the target database installation package is obtained based on the following operations:
[0116] Parse the list file to determine the target file name; copy the function library file and auxiliary tool file corresponding to the target file name to the installation folder, where the installation folder includes the main program file; package the installation folder to obtain the target database installation package.
[0117] Optionally, the list file is used to record files related to the database, and the function library file and auxiliary tool file are recorded in the list file.
[0118] Optionally, parse the list file to determine the target file name.
[0119] Optionally, copy the main program file, function library file, and auxiliary tool file to the installation folder according to the target file name, and then package them into a target database installation package uniformly.
[0120] Optionally, by copying the function library file and auxiliary tool file in the list file to the installation folder, and then packaging them together with the main program file and upgrade process definition file into a target database installation package, the installation and subsequent upgrade processes are simplified, the database upgrade process is optimized, and the operation complexity is reduced.
[0121] Based on the above database upgrade method, the present invention also provides a database upgrade device. The following will be combined with Figure 4 Describe this device in detail.
[0122] Figure 4 The structural block diagram of the database upgrade device according to an embodiment of the present invention is shown.
[0123] As Figure 4 shown, the database upgrade device 400 of this embodiment includes an acquisition module 410, a call module 420, a pre-detection module 430, an installation module 440, a start module 450, and an uninstall module 460.
[0124] The acquisition module 410 is used to acquire the target database installation package, where the target database installation package includes the main program file, function library file, and auxiliary tool file. In one embodiment, the acquisition module 410 can be used to execute the operation S210 described above, which will not be elaborated here.
[0125] A calling module 420, which is used to call an upgrade process definition file related to a target database installation package. The upgrade process definition file includes a pre-detection script, an installation script, a database startup script, and an uninstallation script. In an embodiment, the calling module 420 can be used to perform the operation S220 described above, which will not be elaborated here.
[0126] A pre-detection module 430, which is used to call a pre-detection script to detect the version numbers of the old version database and the new version database respectively, and obtain an operation result. In an embodiment, the pre-detection module 430 can be used to perform the operation S230 described above, which will not be elaborated here.
[0127] An installation module 440, which is used to call an installation script based on the operation result and the target database installation package to install the new version database. In an embodiment, the installation module 440 can be used to perform the operation S240 described above, which will not be elaborated here.
[0128] A startup module 450, which is used to call a database startup script to start the new version database based on the operation result. In an embodiment, the startup module 450 can be used to perform the operation S250 described above, which will not be elaborated here.
[0129] An uninstallation module 460, which is used to call an uninstallation script to uninstall the old version database. In an embodiment, the uninstallation module 460 can be used to perform the operation S260 described above, which will not be elaborated here.
[0130] Optionally, the pre-detection module 430 includes a first detection sub-module, a second detection sub-module, a third detection sub-module, a fourth detection sub-module, and a fifth detection sub-module.
[0131] The first detection sub-module is used to call a pre-detection script to determine a first upgrade mode when the version numbers of the old version database and the new version database are different.
[0132] The second detection sub-module is used to perform a logical backup operation on the old version database based on the first upgrade mode to obtain a logical backup result.
[0133] The third detection sub-module is used to perform a deactivation operation on the old version database when the logical backup result includes a backup success result to obtain a deactivation result.
[0134] The fourth detection sub-module is used to perform a configuration information backup operation on the old version database when a deactivation result indicating successful deactivation is obtained to obtain a configuration information backup result.
[0135] The fifth detection sub-module is used to perform a transfer operation on the data directory information in the old version database when the configuration information backup result includes a backup success result, so as to obtain a transfer result. Among them, the operation results include a logical backup result, a configuration information backup result, a transfer result, and a deactivation result.
[0136] Optionally, the startup module 450 includes a first startup sub-module and a second startup sub-module.
[0137] The first startup sub-module is used to call the database startup script and perform an initialization operation on the new version database when the data directory information status result is an empty status, so as to obtain an initialization result.
[0138] The second startup sub-module is used to start the new version database based on the configuration parameter file and import the data logical backup file when an initialization result indicating successful initialization is obtained.
[0139] Optionally, the pre-detection module 430 includes a sixth detection sub-module and a seventh detection sub-module.
[0140] The sixth detection sub-module is used to call the pre-detection script and determine the second upgrade mode when the version numbers of the old version database and the new version database are the same.
[0141] The seventh detection sub-module is used to perform a deactivation operation on the old version database based on the second upgrade mode to obtain a deactivation result. Among them, the operation results include a deactivation result.
[0142] Optionally, the database upgrade device 400 includes a cleaning module.
[0143] The cleaning module is used to call the data cleaning script to clean the automatic startup function configuration information and environment variable information related to the old version database.
[0144] Optionally, any combination of the obtaining module 410, the invoking module 420, the pre-detection module 430, the installation module 440, the starting module 450, and the uninstalling module 460 can be combined and implemented in one module, or any one of them can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. Optionally, at least one of the obtaining module 410, the invoking module 420, the pre-detection module 430, the installation module 440, the starting module 450, and the uninstalling module 460 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or any other reasonable way of integrating or packaging circuits, etc., implemented by hardware or firmware, or implemented in any one of the three implementation manners of software, hardware, and firmware, or in any appropriate combination of several of them. Alternatively, at least one of the obtaining module 410, the invoking module 420, the pre-detection module 430, the installation module 440, the starting module 450, and the uninstalling module 460 can be at least partially implemented as a computer program module, which can perform corresponding functions when the computer program module is run.
[0145] Figure 5 FIG. shows a block diagram of an electronic device suitable for implementing the database upgrade method according to an embodiment of the present invention.
[0146] Figure 5 The illustrated electronic device is merely an example and should not impose any limitation on the functions and usage scope of the embodiments of the present invention.
[0147] As Figure 5 shown, the computer electronic device 500 according to an embodiment of the present invention includes a processor 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage section 508 into a random access memory (RAM) 503. The processor 501 can include, for example, a general microprocessor (such as a CPU), an instruction set processor, and / or a related chipset, and / or a dedicated microprocessor (such as an application specific integrated circuit (ASIC)), etc. The processor 501 can also include on-board memory for caching purposes. The processor 501 can include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.
[0148] In the RAM 503, various programs and data required for the operation of the electronic device 500 are stored. The processor 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. The processor 501 performs various operations of the method flow according to the embodiments of the present invention by executing the programs in the ROM 502 and / or the RAM 503. It should be noted that the programs can also be stored in one or more memories other than the ROM 502 and the RAM 503. The processor 501 can also perform various operations of the method flow according to the embodiments of the present invention by executing the programs stored in one or more memories.
[0149] Optionally, the electronic device 500 may further include an input / output (I / O) interface 505, and the input / output (I / O) interface 505 is also connected to the bus 504. The electronic device 500 may further include one or more of the following components connected to the input / output (I / O) interface 505: an input portion 506 including a keyboard, a mouse, etc.; an output portion 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc. and a speaker, etc.; a storage portion 508 including a hard disk, etc.; and a communication portion 509 including a network interface card such as a LAN card, a modem, etc. The communication portion 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the input / output (I / O) interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed so that a computer program read from it can be installed into the storage portion 508 as needed.
[0150] Optionally, the method flow according to the embodiments of the present invention can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program includes program codes for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication portion 509, and / or installed from the removable medium 511. When the computer program is executed by the processor 501, the above functions defined in the system according to the embodiments of the present invention are executed. Optionally, the above-described systems, devices, apparatuses, modules, units, etc. can be implemented by computer program modules.
[0151] The present invention also provides a computer-readable storage medium, which can be included in the device / device / system described in the above embodiments; or can exist separately without being assembled into the device / device / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, a database upgrade method according to the embodiments of the present invention is implemented.
[0152] Optionally, the computer-readable storage medium may be a non-volatile computer-readable storage medium. For example, it may include but is not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In the present invention, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0153] For example, optionally, the computer-readable storage medium may include one or more memories other than the ROM 502 and / or RAM 503 and / or ROM 502 and RAM 503 described above.
[0154] An embodiment of the present invention further includes a computer program product, which includes a computer program. The computer program contains program code for executing the method provided by the embodiment of the present invention. When the computer program product runs on an electronic device, the program code is used to cause the electronic device to implement the database upgrade method provided by the embodiment of the present invention.
[0155] When the computer program is executed by the processor 501, the above functions defined in the system / apparatus of the embodiment of the present invention are executed. Optionally, the above-described systems, apparatuses, modules, units, etc. may be implemented by computer program modules.
[0156] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of a signal on a network medium, and be downloaded and installed through the communication part 509, and / or be installed from the removable medium 511. The program code contained in the computer program may be transmitted by any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0157] Optionally, the program code for executing the computer program provided by the embodiments of the present invention can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level procedures and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, such as Java, C++, Python, the "C" language, or similar programming languages. The program code can be executed entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user's computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., by connecting through the Internet using an Internet service provider).
[0158] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations 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 diagram can represent a module, a program segment, or a part of code, and the above-mentioned module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram or flowchart, and the combination of blocks in the block diagram or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions. Those skilled in the art can understand that the features described in the various embodiments of the present invention can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in the present invention. In particular, without departing from the spirit and teachings of the present invention, the features described in the various embodiments of the present invention can be combined and / or combined in various ways. All such combinations and / or combinations fall within the scope of the present invention.
[0159] The above describes the embodiments of the present invention. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of the present invention. Although the embodiments are described separately above, this does not mean that the measures in each embodiment cannot be used advantageously in combination. Without departing from the scope of the present invention, those skilled in the art can make various substitutions and modifications, and all such substitutions and modifications should fall within the scope of the present invention.
Claims
1. A database upgrade method, characterized in that: The method comprises: Obtain a target database installation package, wherein the target database installation package includes a main program file, a function library file, and an auxiliary tool file; Calling an upgrade process definition file related to the target database installation package, wherein the upgrade process definition file includes a pre-detection script, an installation script, a database startup script, and an uninstallation script; The pre-detection script is called to detect the version numbers of the old version database and the new version database, and the operation results obtained include: Calling the pre-detection script, and determining a first upgrade mode when the version numbers of the old version database and the new version database are different; Based on the first upgrade mode, a logical backup operation is performed on the old version database to obtain a logical backup result; In the case where the logical backup result includes a backup success result, performing a deactivation operation on the old version database to obtain a deactivation result; When the deactivation result indicating successful deactivation is obtained, a configuration information backup operation is performed on the old version database to obtain a configuration information backup result; In the case where the configuration information backup result includes a backup success result, performing a transfer operation on the data directory information in the old version database to obtain a transfer result, wherein the operation result includes the logical backup result, the configuration information backup result, the transfer result, and the deactivation result; Based on the operation result and the target database installation package, calling the installation script to install the new version database; Calling the database startup script to start the new version database based on the operation result; The uninstall script is called to uninstall the old version database.
2. The method according to claim 1, characterized in that The logical backup result also includes a data logical backup file, the configuration information backup result also includes a configuration parameter file, and the transfer result includes a data directory information status result; The calling of the database startup script and starting the new version database based on the operation result includes: Calling the database startup script, and when the data directory information status result is in an empty state, performing an initialization operation on the new version database to obtain an initialization result; When the initialization result indicating successful initialization is obtained, the new version database is started based on the configuration parameter file, and the data logic backup file is imported.
3. The method according to claim 1, characterized in that The calling of the pre-detection script to detect the version numbers of the old version database and the new version database to obtain the operation result also includes: Calling the pre-detection script, and determining a second upgrade mode when the version numbers of the old version database and the new version database are the same; Based on the second upgrade mode, a deactivation operation is performed on the old version database to obtain a deactivation result, wherein the operation result includes the deactivation result; The calling of the database startup script and starting the new version database based on the operation result includes: Calling the database startup script, and detecting the status of the data directory information in the old version database based on the operation result to obtain a data detection result; When the data detection result indicating a non-empty state is obtained, the new version database is started based on the data directory information.
4. The method according to claim 1, characterized in that The upgrade process definition file also includes a data cleaning script; the method also includes: The data cleaning script is called to clean up the automatic startup function configuration information and environment variable information related to the old version database.
5. The method according to claim 1, characterized in that The target database installation package is obtained based on the following operations: Parse the list file to determine the target file name; Copying the function library file and the auxiliary tool file corresponding to the target file name to an installation folder, wherein the installation folder includes the main program file; The installation folder is packaged to obtain the target database installation package.
6. A database upgrade device, characterized in that: The device comprises: An acquisition module, used to acquire a target database installation package, wherein the target database installation package includes a main program file, a function library file, and an auxiliary tool file; A calling module, used to call an upgrade process definition file related to the target database installation package, wherein the upgrade process definition file includes a pre-detection script, an installation script, a database startup script, and an uninstallation script; A pre-detection module, used to call the pre-detection script, detect the version numbers of the old version database and the new version database, and obtain an operation result. The pre-detection module includes a first detection submodule, a second detection submodule, a third detection submodule, a fourth detection submodule and a fifth detection submodule; A first detection submodule, configured to call the pre-detection script and determine a first upgrade mode when the version numbers of the old version database and the new version database are different; A second detection submodule is used to perform a logical backup operation on the old version database based on the first upgrade mode to obtain a logical backup result; A third detection submodule is used to, when the logical backup result includes a backup success result, perform a deactivation operation on the old version database to obtain a deactivation result; A fourth detection submodule is used to perform a configuration information backup operation on the old version database to obtain a configuration information backup result when the deactivation result indicating successful deactivation is obtained; a fifth detection submodule, configured to, when the configuration information backup result includes a backup success result, perform a transfer operation on the data directory information in the old version database to obtain a transfer result, wherein the operation result includes the logic backup result, the configuration information backup result, the transfer result, and the deactivation result; An installation module, configured to call the installation script based on the operation result and the target database installation package to install the new version database; A startup module, used to call the database startup script and start the new version database based on the operation result; The uninstallation module is used to call the uninstallation script to uninstall the old version database.
7. An electronic device, characterized in that: include: one or more processors; a memory for storing one or more instructions, Wherein, when the one or more instructions are executed by the one or more processors, the one or more processors are enabled to implement the method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: Executable instructions are stored thereon, and when the instructions are executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 5.
9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Database management method and device, equipment and storage medium
CN113901025A
Data version management method and device, storage medium and electronic equipment
CN115344585A