Database updating method, related device and medium

By receiving and verifying server image files, the version of the target database is automatically updated, which solves the problem of inefficient database upgrades in the existing technology, and achieves rapid and automated database updates.

CN120029638APending Publication Date: 2025-05-23TENCENT TECH WUHAN
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311576074.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-21
Publication Date
2025-05-23

AI Technical Summary

Technical Problem

In the prior art, manual operation is required when upgrading databases, resulting in large operational workload and inefficient efficiency.

Method used

By receiving the server image file, verifying and extracting the current version information of the target database, and automatically updating the target database based on the database update script.

Benefits of technology

It realizes automated database updates, improves database update efficiency, reduces manual intervention, and can quickly roll back versions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120029638A_ABST
    Figure CN120029638A_ABST
Patent Text Reader

Abstract

The invention provides a database updating method, a related device and a medium. The method comprises the steps that a server mirror image file is received, and the server mirror image file is used for updating a server; the server comprises a plurality of services, the server mirror image file comprises a mirror image sub-file of each service, and each service is associated with at least one target database; for each service, if it is determined that the database updating script of the target database exists in the mirror image subfile, performing first verification on the database updating script and the current environment; if it is determined that the first verification is passed, current version information of the target database is extracted; and performing version updating on the target database based on the current version information and the database updating script so as to execute the service after the target database is updated. According to the embodiment, the database can be automatically updated, and the database updating efficiency is improved. The embodiment of the invention can be applied to various scenes such as big data and information technologies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer software, and in particular to a database updating method, related devices and media. Background Art

[0002] Currently, various types of databases are often required in applications to process and manage the flow of data. In response to different needs, the database often needs to be upgraded or downgraded to meet different needs.

[0003] In the related art, when upgrading a database, developers usually provide a data upgrade list to deployers, who then update the database. Specifically, deployers manually input preset data, add, delete, and modify database content or structure, etc. This method often results in a large workload and low database update efficiency. Summary of the invention

[0004] The embodiments of the present disclosure provide a database update method, related devices and media, which can realize automatic update of the database and improve the database update efficiency.

[0005] According to one aspect of the present disclosure, a database updating method is provided, the method comprising:

[0006] Receive a server image file, wherein the server image file is used to update the server; the server includes multiple services, the server image file contains an image sub-file of each service, and each service is associated with at least one target database;

[0007] For each of the services, if it is determined that the database update script of the target database exists in the mirror sub-file, a first verification is performed on the database update script and the current environment;

[0008] If it is determined that the first verification passes, extracting the current version information of the target database;

[0009] The target database is updated based on the current version information and the database update script, so as to execute the service after the target database is updated.

[0010] According to one aspect of the present disclosure, a database updating device is provided, the device comprising:

[0011] A receiving unit, configured to receive a server image file, wherein the server image file is used to update a server; the server includes a plurality of services, the server image file includes an image sub-file of each of the services, and each of the services is associated with at least one target database;

[0012] a verification unit, configured to, for each of the services, if it is determined that the database update script of the target database exists in the mirror sub-file, perform a first verification on the database update script and the current environment;

[0013] an extracting unit, configured to extract the current version information of the target database if it is determined that the first verification passes;

[0014] An updating unit is used to perform a version update on the target database based on the current version information and the database update script, so as to execute the service after the target database is updated.

[0015] Optionally, the current version information includes the current version number of the target database, and the database update script includes the database update version number;

[0016] The updating unit specifically includes:

[0017] an upgrade processing unit, configured to perform version upgrade processing on the target database based on the database update script if it is determined that the current version number is less than the database update version number;

[0018] A downgrade processing unit is used to obtain a rollback script corresponding to the current version number if it is determined that the current version number is greater than the database update version number, and perform version downgrade processing on the target database based on the rollback script, wherein the rollback script corresponding to the current version number is stored in a remote database of the server.

[0019] Optionally, the upgrade processing unit is specifically used to:

[0020] Storing the rollback script in a remote database of the server;

[0021] Performing a version upgrade on the target database based on the upgrade script, and determining a script code generated based on the version upgrade;

[0022] If the script code meets the predetermined condition, it is determined that the target database has been updated, and the current version number of the target database is updated based on the database update version number;

[0023] If the script code does not meet the predetermined condition, the rollback script is executed to clear the data generated in the version upgrade.

[0024] Optionally, the degradation processing unit is specifically used for:

[0025] Based on the current version number, extracting a rollback script corresponding to the current version number from the remote database;

[0026] Downgrading the target database based on the rollback script, and determining a script code generated based on the version downgrading;

[0027] If the script code meets the predetermined condition, it is determined that the target database has been updated, and the current version number of the target database is updated based on the database update version number.

[0028] Optionally, the degradation processing unit is further used for:

[0029] After the determining of the script code generated based on the version downgrade, if the script code does not meet a predetermined condition, determining an abnormal result of the version downgrade based on the script code;

[0030] The abnormal result is sent to a target object, so that the target object updates the target database based on the abnormal result.

[0031] Optionally, the server image file is generated in the following manner:

[0032] For each of the services, determining service association information, database update script, and database execution data of the service;

[0033] Building a mirror subfile of the service based on the service association information, the database update script, and the database execution data;

[0034] The plurality of image sub-files are packaged into an image to obtain the server image file.

[0035] Optionally, the database update script is named as follows:

[0036] Based on the database update script, determine the database type, update type, database update version number, and database description field of the target database of the service;

[0037] The database update version number, the database description field, the update type, and the database type are concatenated to obtain a script name of the database update script.

[0038] Optionally, the verification unit specifically includes:

[0039] A script checking unit, used for performing script checking on the database update script;

[0040] An environment detection unit, configured to obtain environment-related information of the current environment if the database update script passes the verification, and perform environment detection based on the environment-related information to obtain an environment detection result;

[0041] A verification and determination unit is used to determine that the first verification is passed if the environmental detection result indicates that there is no abnormality in the current environment.

[0042] Optionally, the database update script has database type, update type, database update version number, and database description fields;

[0043] The script verification unit is specifically used for:

[0044] If it is determined that the database update version number conforms to a predetermined format, a field detection is performed on the database description field to obtain a field detection result;

[0045] If the field detection result indicates that there is no error in the database description field, performing a type check on the update type;

[0046] If it is determined that the update type meets the first condition, determining a first type of the target database in the service;

[0047] If the first type is consistent with the database type, it is determined that the database update script has passed the verification.

[0048] Optionally, the environment-related information includes a current network environment and a current hardware environment;

[0049] The environment detection unit is specifically used for:

[0050] Determine current network latency, current disk capacity, and current server memory capacity;

[0051] Based on the current network delay, determining the current network environment;

[0052] Determining the current hardware environment based on the current disk capacity and the current server memory capacity;

[0053] If the current network environment and the current hardware environment meet the second condition, the environment detection result is determined as no abnormality in the current environment.

[0054] Optionally, the database updating device further includes a preprocessing unit, and the preprocessing unit is used to:

[0055] If it is determined that there is pre-stored information for updating the database, then reading the preset storage space;

[0056] The login information of the target database is extracted from the preset storage space, and a connection is established with the target database based on the login information.

[0057] Optionally, the determining whether there is pre-stored information for updating the database includes:

[0058] If it is determined that the server has a remote database, performing content detection on the remote database;

[0059] If it is determined that the target data table exists in the remote database, performing content detection on the target data table;

[0060] If it is determined that the target data table is not empty, it is determined that the pre-stored information exists.

[0061] Optionally, the remote database and the target data table are generated in the following manner:

[0062] Creating the remote database on the server;

[0063] Creating the target data table in the remote database;

[0064] Based on the original version information of the target database, the target data table is initially filled with content.

[0065] Optionally, the target data table includes a version data table for recording the version number of the target database, and a rollback data table for recording the rollback scripts of the target database under each version number;

[0066] The version data table and the rollback data table are updated in the following manner:

[0067] Based on the database update version number of each version update of the target database, updating the version data table;

[0068] The rollback data table is updated based on each of the database update version numbers and the rollback script corresponding to the database update version number.

[0069] Optionally, the service is associated with a plurality of the target databases;

[0070] The updating unit is specifically used for:

[0071] Determining update priorities of the plurality of target databases;

[0072] According to the update priority, for each target database, the target database is updated based on the current version information and the database update script.

[0073] Optionally, the update priorities of the multiple target databases are determined in the following manner:

[0074] For each of the target databases, determining a first score based on the database type of the target database;

[0075] For each of the target databases, determining a second score based on a creation timestamp of the target database;

[0076] Determining a total score of the target database based on the first score and the second score;

[0077] Based on the total scores, update priorities of the plurality of target databases are determined.

[0078] According to one aspect of the present disclosure, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned database updating method when executing the computer program.

[0079] According to one aspect of the present disclosure, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the database updating method as described above is implemented.

[0080] According to one aspect of the present disclosure, a computer program product is provided. The computer program product includes a computer program. The computer program is read and executed by a processor of a computer device, so that the computer device executes the database updating method as described above.

[0081] In the disclosed embodiment, the database update script is delivered in the form of a mirror image, and for each server, a server mirror file for updating the server is generated. Since the server includes multiple services, the server mirror file contains a mirror sub-file for each service. Each service in the server is often associated with at least one target database when executed. For each service, if it is determined that there is a database update script for the target database in the mirror sub-file, it means that the target database in the service can be updated. First, a first verification is performed on the database update script and the current environment; if it is determined that the first verification passes, the current version information of the target database is extracted; based on the current version information and the database update script, the target database is updated. The above method delivers the update script in the form of a mirror image when the database is updated, which can achieve a rapid rollback of the database version. This process does not require manual intervention, can improve the rapid update and automatic update of the database, and thus improve the efficiency of database update.

[0082] Other features and advantages of the present disclosure will be described in the following description, and partly become apparent from the description, or understood by practicing the present disclosure. The purpose and other advantages of the present disclosure can be realized and obtained by the structures particularly pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0083] The accompanying drawings are used to provide further understanding of the technical solution of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the technical solution of the present disclosure and do not constitute a limitation on the technical solution of the present disclosure.

[0084] Figure 1 is a system architecture diagram of a system to which a database updating method according to an embodiment of the present disclosure is applied;

[0085] Figure 2A It is a schematic diagram of applying a database update method according to related technologies in a database upgrade scenario;

[0086] Figure 2B-2C A schematic diagram showing the application of the database update method according to an embodiment of the present disclosure in a database upgrade scenario;

[0087] Figure 3 is a flowchart of a database updating method according to an embodiment of the present disclosure;

[0088] Figure 4 is a flow chart of generating a server image file according to an embodiment of the present disclosure;

[0089] Figure 5 is a flowchart of naming a database update script according to an embodiment of the present disclosure;

[0090] Figure 6 is a schematic diagram of an implementation process of generating a server image file according to an embodiment of the present disclosure;

[0091] Figure 7 is a flowchart of first verifying a database update script and a current environment according to an embodiment of the present disclosure;

[0092] Figure 8 is a flowchart of performing script verification on a database update script according to an embodiment of the present disclosure;

[0093] Fig. 9 is a flow chart of performing environment detection based on environment-related information according to an embodiment of the present disclosure;

[0094] Fig.10 is a flow chart of establishing a connection with a target database according to an embodiment of the present disclosure;

[0095] Fig.11 is a flow chart for determining the existence of pre-stored information according to an embodiment of the present disclosure;

[0096] Fig.12 is a flow chart of generating a remote database and a target data table according to an embodiment of the present disclosure;

[0097] Fig.13 is a flowchart of updating a version data table and updating a rollback data table according to an embodiment of the present disclosure;

[0098] Figure 14A-Figure 14C is a schematic diagram of the structure of a version data table and a rollback data table according to an embodiment of the present disclosure;

[0099] Fig.15 is a flow chart of a data smooth upgrade tool performing a self-check according to an embodiment of the present disclosure;

[0100] Fig.16 is a flow chart of performing version update on a target database according to an embodiment of the present disclosure;

[0101] Fig.17 is a flow chart of performing version upgrade of a target database according to an embodiment of the present disclosure;

[0102] Fig.18 is a flow chart of downgrading a target database according to an embodiment of the present disclosure;

[0103] Fig.19 is a schematic diagram of an implementation process of performing version update on a target database according to an embodiment of the present disclosure;

[0104] Fig. 20 is a flow chart of performing version update on multiple target databases according to an embodiment of the present disclosure;

[0105] Fig.21 is a flowchart of determining update priorities of multiple target databases according to an embodiment of the present disclosure;

[0106] Fig. 22 is a schematic diagram of an implementation process of determining update priorities of multiple target databases according to an embodiment of the present disclosure;

[0107] Fig.23 is a module diagram of a database updating device according to an embodiment of the present disclosure;

[0108] Fig.24 is a terminal structure diagram of a database updating method according to an embodiment of the present disclosure;

[0109] Fig.25The server structure diagram of the database updating method according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0110] In order to make the purpose, technical solution and advantages of the present disclosure more clear, the present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present disclosure and are not used to limit the present disclosure.

[0111] Before further describing the embodiments of the present disclosure in detail, the nouns and terms involved in the embodiments of the present disclosure are described. The nouns and terms involved in the embodiments of the present disclosure are subject to the following interpretations:

[0112] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making. Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level technology and software-level technology. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, pre-trained model technology, operation / interaction system, mechatronics, etc. Among them, the pre-trained model is also called the large model or basic model. After fine-tuning, it can be widely used in downstream tasks in various major directions of artificial intelligence. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning. With the research and advancement of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, automatic driving, drones, robots, smart medical care, smart customer service, etc. I believe that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.

[0113] Currently, various types of databases are often required in applications to process and manage the flow of data. In response to different needs, the database often needs to be upgraded or downgraded to meet different needs.

[0114] In the related art, when upgrading a database, developers usually provide a data upgrade list to deployers, who then update the database. Specifically, deployers manually input preset data, add, delete, and modify database content or structure, etc. This method often results in a large workload and low database update efficiency.

[0115] System architecture and scenario description of the application of the embodiments of the present disclosure

[0116] Figure 1 The system architecture diagram of the database update method according to the embodiment of the present disclosure includes an object terminal 140, the Internet 130, a gateway 120, a server 110, a data smooth upgrade tool 150, and a remote database 160.

[0117] The target terminal 140 includes various forms such as desktop computers, laptop computers, PDAs (personal digital assistants), mobile phones, vehicle-mounted terminals, home theater terminals, and dedicated terminals. In addition, it can be a single device or a collection of multiple devices. The target terminal 140 can communicate with the Internet 130 in a wired or wireless manner to exchange data.

[0118] The server 110 refers to a computer system that can provide certain services to the object terminal 140. Compared with the ordinary object terminal 140, the server 110 has higher requirements in terms of stability, security, performance, etc. The server 110 can be a high-performance computer in a network platform, a cluster of multiple high-performance computers, a part of a high-performance computer (such as a virtual machine), a combination of parts of multiple high-performance computers (such as virtual machines), etc. The server 110 includes various types of services, wherein the implementation of each service of the server is often associated with some intermediate databases or storage media. The data smooth upgrade tool 150 is used to update the intermediate database or storage medium, and the remote database 160 is used to store the update scripts of each version.

[0119] The gateway 120 is also called an internetwork connector or a protocol converter. The gateway realizes network interconnection at the transport layer and is a computer system or device that acts as a converter. The gateway is a translator between two systems that use different communication protocols, data formats or languages, or even completely different architectures. At the same time, the gateway can also provide filtering and security functions. The message sent by the object terminal 140 to the server 110 is sent to the corresponding server through the gateway 120. The message sent by the server 110 to the object terminal 140 is also sent to the corresponding object terminal 140 through the gateway 120.

[0120] When various services of the server 110 need to be upgraded, object A or object B can upload the written service upgrade script in the form of an image to the server 110 through the object terminal 140. The data smooth upgrade tool 150 updates the versions of the associated intermediate database or storage medium in the service according to the service upgrade script in the image form. At the same time, the service upgrade script is stored in the remote database 160.

[0121] As Figure 2A shown, during the database upgrade process in the related art, it is often the case that object A provides the edited data upgrade list to object B, enabling object B to perform various operations such as creating databases, entering prefabricated data, creating object buckets, and partitioning databases and tables on-site according to the data upgrade list. Additionally, during the database upgrade, object B manually enters the prefabricated data, adds, deletes, or modifies the content or structure of the database. Among them, object A often refers to the development side, which is used to determine script data for server maintenance, etc. Object B often refers to the deployment side, which is used to debug the server.

[0122] This method is mainly implemented through manual operations, and problems such as omissions, execution errors, and inability to maintain multiple versions, multiple customers, and multiple platforms often occur.

[0123] Compared with the related art, the embodiment of the present disclosure performs database updates based on an image, and the server upgrade operation can be achieved without the intervention of relevant personnel. The embodiment of the present disclosure can be applied in various scenarios, such as Figure 2B-2C the database upgrade scenario shown, etc.

[0124] As Figure 2B shown, first, object A edits multiple data upgrade scripts. Then, the edited multiple data upgrade scripts are packaged into an image to form an image file. Finally, the image file is provided to object B so that object B uploads the image file to the server.

[0125] As Figure 2C shown, object B uploads the received image file to the server and starts the server. Among them, the server contains a service set composed of multiple services. Further, the data smooth update tool updates the versions of the intermediate database or storage medium associated with the service according to the data upgrade script in the image file. After the upgrade is completed, the service is started to execute the corresponding service process.

[0126] General description of the disclosed embodiments

[0127] According to an embodiment of the present disclosure, a database update method is provided.

[0128] This database update method is generally used in business scenarios such as big data technology and server upgrades. For example Figure 2B-2C The database upgrade scenario shown. The disclosed embodiment provides a database update solution based on a server image file, which can package multiple database update scripts into an image file, and implement automatic update of the database by deploying the image file to the server, thereby improving the database update efficiency.

[0129] like Figure 3 As shown, a database updating method according to an embodiment of the present disclosure may include:

[0130] Step 310: receiving a server image file;

[0131] Step 350: For each service, if it is determined that the database update script of the target database exists in the mirror subfile, a first verification is performed on the database update script and the current environment;

[0132] Step 330: If it is determined that the first verification is passed, extract the current version information of the target database;

[0133] Step 340: Update the target database based on the current version information and the database update script, so as to execute the service after the target database is updated.

[0134] Steps 310 - 340 are described in detail below.

[0135] In step 310, a server image file is received.

[0136] Server image files are used to update servers. Server image files store all the data content of server hardware and software. The process of copying all the data content in a server image file to another server can quickly and easily rebuild an identical server when a server fails or needs to be upgraded for protection, reducing the loss of data and business interruption caused by server failure.

[0137] The server includes multiple services. Services are used to meet the various needs of users. For example, the services included in the server include websites, emails, etc.

[0138] The server image file contains an image sub-file for each service. The image sub-file is used to provide hardware and software data content related to the service. For example, the image sub-file contains a database related to the service, script data of the storage medium, service code, etc.

[0139] Each service is associated with at least one target database, which refers to the medium used to provide data storage on the Internet.

[0140] The target database of the embodiment of the present disclosure includes but is not limited to MySQL database, Redis database, Elasticsearch database, Kafka database, Clickhouse database, etc. Among them, MySQL database is a transactional storage medium, Elasticsearch database is a search storage medium, Redis database is a non-relational storage medium, Kafka database is a data stream processing queue storage medium, and Clickhouse database is a transactional storage medium.

[0141] In the specific implementation of this embodiment, when the server needs to be updated, the development end often writes a data update script for each service in the server, and packages all the data update scripts into an image to form a server image file of the server, and then provides the server image file to the deployment end to upload to the server. Based on this, the server will receive the server image file, and check the server image file by calling the data smooth upgrade tool. When the check is correct, the server is upgraded or downgraded based on the server image file.

[0142] In step 320, for each service, if it is determined that the database update script of the target database exists in the mirror sub-file, a first verification is performed on the database update script and the current environment.

[0143] The database update script of the target database is used to provide code data for updating the target database.

[0144] The current environment refers to the server's hardware environment, network environment, etc.

[0145] The first verification is used to measure whether the database update script and the current environment meet the requirements for updating the target database.

[0146] When this embodiment is specifically implemented, for each service, a content query is performed on the mirror subfile of the server. If the database update script of the target database is queried in the mirror subfile, it is determined that the database update script of the target database exists in the mirror subfile, and the target database needs to be updated according to the database update script. Furthermore, in order to improve the security of database updates, it is also necessary to verify the database update script and the current environment to determine whether the database update script and the current environment meet the requirements for updating the target database. When both the database update script and the current environment meet the requirements for updating the target database, the first verification is considered to have passed. If at least one of the database update script and the current environment does not meet the requirements for updating the target database, the first verification is considered to have failed.

[0147] To save space, the specific implementation process of the first verification of the database update script and the current environment in the embodiment of the present disclosure will be described in detail below. No further description will be given here.

[0148] In step 330, if it is determined that the first verification passes, the current version information of the target database is extracted.

[0149] The current version information is used to indicate the specific content of the version currently used by the target database, including the current version number, release date, etc.

[0150] In the specific implementation of this embodiment, if it is determined that the first verification is passed, it indicates that both the database update script and the current environment meet the requirements for updating the target database, so the current version information of the target database can be extracted, and the version currently being used by the target database can be determined according to the current version information.

[0151] It should be noted that, in order to improve the efficiency of version query, the current version information of all target databases can be stored in the remote database of the server, or the current version information of all target databases can be recorded in the data smoothing update tool. Specifically, for each update of the target database, after the target database is updated, the version information of the version used by the target database is stored so that the current version information of the target database can be queried at any time.

[0152] In step 340, the target database is updated based on the current version information and the database update script, so as to execute the service after the target database is updated.

[0153] Version update refers to the process of updating the target database from the current version to the target version indicated by the database update script.

[0154] When this embodiment is implemented, the version numbers of the current version information and the database update script are first compared. If the version number indicated by the current version information is greater than the version number indicated by the database update script, it indicates that the current version of the target database is higher than the target version, and the target database is downgraded. If the version number indicated by the current version information is less than the version number indicated by the database update script, it indicates that the current version of the target database is lower than the target version, and the target database is upgraded. If the version number indicated by the current version information is equal to the version number indicated by the database update script, it indicates that the current version of the target database is the target version, and there is no need to update the target database. Furthermore, when the target database is updated, the service is executed, so that the target database runs with a version that meets the requirements, thereby improving the stability of service execution.

[0155] To save space, the specific implementation process of updating the target database based on the current version information and the database update script in the embodiment of the present disclosure will be described in detail below. No further description will be given here.

[0156] Through the above steps 310-340, the embodiment of the present disclosure delivers the database update script in the form of a mirror image, and for each server, a server mirror file for updating the server is generated. Since the server includes multiple services, the mirror subfile of each service is included in the server mirror file. Each service in the server is often associated with at least one target database when executed. For each service, if it is determined that there is a database update script of the target database in the mirror subfile, it means that the target database in the service can be updated. First, the database update script and the current environment are first verified; if it is determined that the first verification passes, the current version information of the target database is extracted; based on the current version information and the database update script, the target database is updated. The above method delivers the update script in the form of a mirror image when the database is updated, which can realize the rapid rollback of the database version. This process does not require manual intervention, can improve the rapid update and automatic update of the database, and thus improve the database update efficiency. The database update method of the embodiment of the present disclosure can greatly reduce the software deployment time, especially in the second level when the database is installed and initialized and upgraded. In addition, the embodiment of the present disclosure is implemented by using a data smoothing upgrade tool, which can greatly reduce software failures caused by human errors, misoperations, etc., and improve the reliability of database updates. In addition, the database update method of the embodiment of the present disclosure can be deployed on multiple platforms and multiple computer rooms, and has good applicability.

[0157] The above is a general description of steps 310 to 340. Since step 330 has been described in detail in the above general description, the specific implementation of step 310, step 320, and step 340 will be described in detail below.

[0158] Detailed description of step 310

[0159] In step 310, a server image file is received.

[0160] Please refer to Figure 4 In some embodiments, the server image file is pre-generated by the following process:

[0161] Step 410: for each service, determine the service association information, database update script, and database execution data of the service;

[0162] Step 420: construct a service image subfile based on the service association information, the database update script, and the database execution data;

[0163] Step 430: Pack multiple image sub-files into an image to obtain a server image file.

[0164] Steps 410 - 430 are described in detail below.

[0165] In step 410, for each service, service association information, database update script, and database execution data of the service are determined.

[0166] Service-related information is used to indicate the data content required to execute the service. Service-related information is often in the form of a service code.

[0167] Database execution data refers to the code data required to execute the target database.

[0168] When this embodiment is implemented, the development end will use the resources of the code repository according to the actual database update requirements and edit and generate the service association information, database update script, and database execution data of each service according to the predetermined script rules.

[0169] In step 420, a service image subfile is constructed based on the service association information, the database update script, and the database execution data.

[0170] In the specific implementation of this embodiment, for each service, the service association information, database update script and database execution data are stored in a file in the code repository, and the stored file is used as a mirror subfile of the service. The mirror subfile may be a code file.

[0171] In step 430, multiple image sub-files are packaged into an image to obtain a server image file.

[0172] In the specific implementation of this embodiment, multiple mirror sub-files are uniformly packaged into a mirror to obtain a file in a mirrored form, and the file in the mirrored form is used as a server mirror file.

[0173] Through the above steps 410-430, in the embodiment of the present disclosure, the development end uses the code repository to prepare all the service association information, database execution data, and database update scripts associated with a service, and packages the service association information, database execution data, and database update scripts into an image file and delivers them to the deployment end. The deployment end does not need to pay attention to and maintain the service association information, database execution data, and database update scripts associated with the service. It only needs to upload the image file to the server through remote deployment to execute the database update of the server. This method greatly simplifies the database update process, reduces the time and resources spent by the deployment end on data maintenance and database update, and is conducive to improving the automation and intelligence of database updates.

[0174] Since a mirror sub-file of a service often contains multiple database update scripts, and different database update scripts are often used to update different target databases, and for the same target database, the mirror sub-file often contains different versions of database update scripts. Based on this, in order to distinguish different database update scripts, the embodiment of the present disclosure provides a solution for naming database update scripts based on a predetermined naming rule, which can effectively distinguish different database update scripts, improve script query efficiency and script storage efficiency, and thus improve database update efficiency.

[0175] Please refer to Figure 5 In some embodiments, the process of naming the database update script includes but is not limited to the following steps 510-520:

[0176] Step 510: Determine the database type, update type, database update version number, and database description field of the target database of the service based on the database update script;

[0177] Step 520: Concatenate the database update version number, the database description field, the update type, and the database type to obtain the script name of the database update script.

[0178] Steps 510 - 520 are described in detail below.

[0179] In step 510, based on the database update script, the database type, update type, database update version number, and database description field of the target database of the service are determined.

[0180] The database type is used to indicate the specific type of the target database to which the database update script is applicable. For example, the database type includes sql, redis, and so on.

[0181] The update type is used to indicate whether to upgrade or downgrade the target database. For example, when the database update script is an upgrade script, the update type is up; when the database update script is a rollback script, the update type is down.

[0182] The database update version number is used to indicate the version that the database update script can make the target database reach.

[0183] The database description field is used to briefly describe the database update script. For example, the database description field is used to describe the release time, developer, etc. of the database update script.

[0184] When this embodiment is specifically implemented, for each database update script, the database update script is first parsed to determine the database to which the database update script applies and obtain the database type. Next, the database update version number of the current database update script is determined based on the existing database update scripts in the code repository. Furthermore, the update type of the database update script is determined based on whether the execution function of the database update script is to upgrade the database or to return the database to the previous version. Finally, the database description field is determined based on the specific content of the database update script.

[0185] In step 520, the database update version number, the database description field, the update type, and the database type are concatenated to obtain the script name of the database update script.

[0186] The script name is used to distinguish different database update scripts. The script name is also used to indicate the database type, update type, etc. to which the database update script applies.

[0187] In the specific implementation of this embodiment, for each database update script, the contents are concatenated in the order of database update version number, database description field, update type, and database type to obtain a concatenation result, which is used as the script name of the database update script.

[0188] For example, the script name of a database update script is 0001_xxx.up.sql. Based on this, it is determined that the database update script is an upgrade script for the SQL database version number 0001.

[0189] like Figure 6As shown, it is a schematic diagram of the implementation process of generating a mirror sub-file of a service. Specifically, the development end edits the database update script in the code repository and stores the database update script in a fixed location. Among them, the database update script includes four update scripts for the SQL database, which are the database update script with the script name [0001_xxx.up.sql], the database update script with the script name [0001_xxx.down.sql], the database update script with the script name [0002_xxx.up.sql], and the database update script with the script name [0002_xxx.down.sql]. In addition, the code repository also stores the database execution data (data) determined by the development end and the service association information. Among them, the database execution data includes redis code and the "xxxx.json" file. The service association information includes the service code. Based on this, the development end packages all the data content of the service through the pipeline to obtain the data upgrade script (start.sh) of the service. Next, the data smoothing update tool is used in the image to process the data upgrade script into binary service (service-binary), database update script (migration), and database execution data (data). Finally, the binary service, database update script, and database execution data are used as image sub-files of the service.

[0190] Through the above steps 510-520, the embodiment of the present disclosure names the database update script based on a predetermined naming rule. For each database update script, the concatenation result of the database update version number, the database description field, the update type, and the database type is used as the script name, which can effectively distinguish different database update scripts, improve the script query efficiency and the script storage efficiency, and thus improve the database update efficiency.

[0191] Detailed description of step 320

[0192] In step 320, for each service, if it is determined that the database update script of the target database exists in the mirror sub-file, a first verification is performed on the database update script and the current environment.

[0193] Please refer to Figure 7 In some embodiments, the process of first verifying the database update script and the current environment includes but is not limited to the following steps 710-730:

[0194] Step 710: Perform script verification on the database update script;

[0195] Step 720: If the database update script passes the verification, then obtain the environment-related information of the current environment, and perform environment detection based on the environment-related information to obtain the environment detection result;

[0196] Step 730: If the environmental detection result indicates that there is no abnormality in the current environment, it is determined that the first verification is passed.

[0197] Steps 710 - 730 are described in detail below.

[0198] In step 710, script verification is performed on the database update script.

[0199] Script verification is used to measure whether there are any anomalies in the database update script.

[0200] In the specific implementation of this embodiment, since the database update script often contains a variety of information such as the script name, version number, release date, and applicable database, in order to improve the inspection efficiency, a portion of the more important content data in the database update script can be selected for inspection. If the selected content data meets the requirements, the script inspection is considered to have passed. If the selected content data does not meet the requirements, the script inspection is considered to have failed.

[0201] In addition, in order to improve the accuracy of the inspection, a comprehensive inspection method can be adopted to inspect all content data of the database update script. When all content data meets the requirements, the script inspection is considered to have passed.

[0202] In step 720, if the database update script passes the verification, the environment-related information of the current environment is obtained, and the environment detection is performed based on the environment-related information to obtain the environment detection result.

[0203] The environment-related information is used to indicate the network conditions and hardware resource conditions of the environment in which the deployed server is located.

[0204] The environmental detection result is used to indicate whether there is an abnormality in the current environment or whether there is no abnormality in the current environment.

[0205] In the specific implementation of this embodiment, if the database update script passes the inspection, it indicates that the database update script meets the requirements for the version update of the target database. Based on this, in order to determine whether the hardware environment and network environment deployed by the server meet the requirements for the version update of the target database, it is also necessary to obtain the environment-related information of the current environment. Based on this, a pre-written code program can be run to collect the hardware environment parameters and network environment parameters at the current time, and determine the environment-related information based on the hardware environment parameters and network environment parameters. Further, an environment detection is performed based on the environment-related information to determine whether there is an abnormality in the current environment, thereby obtaining an environment detection result.

[0206] It should be noted that the hardware environment parameters refer to the available disk space, CPU memory, etc. in the hardware environment where the server is deployed, and the network environment parameters refer to the network delay rate, etc. in the network environment where the server is deployed.

[0207] In step 730, if the environmental detection result indicates that there is no abnormality in the current environment, it is determined that the first verification is passed.

[0208] In the specific implementation of this embodiment, if the environmental detection result indicates that there is no abnormality in the current environment, it means that there is no abnormality in the database update script and the current environment, and both meet the requirements for version updating of the target database. Therefore, it is determined that the first verification is passed and enters the database update stage.

[0209] In addition, if the environmental detection result indicates that there is an abnormality in the current environment, it means that the current environment does not meet the requirements for updating the target database version. In order to reduce the risk of database update failure, it is determined that the first verification fails and the target database version is not updated temporarily.

[0210] Through the above steps 710-730, the embodiment of the present disclosure takes into account the impact of the database update script and the current environment on the database update. First, the script check is performed on the database update script, and the current environment is tested after the script check passes. The database update is performed only when it is determined that there are no abnormalities in the database update script and the current environment. This can effectively improve the security and reliability of the database update and reduce the risk of update failure due to script abnormalities or environmental abnormalities.

[0211] Since database update scripts often have many problems that need to be checked, if only a single content in the database update script is checked during the script checking phase, it will often affect the accuracy of the check and the success rate of the database update. Based on this, the embodiment of the present disclosure provides a solution for multiple checks on the database update script, which can effectively improve the accuracy of the script check and thus improve the success rate of the database update.

[0212] In the disclosed embodiment, the database update script has database type, update type, database update version number, and database description fields.

[0213] Please refer to Figure 8 In some embodiments, the process of performing script verification on the database update script includes but is not limited to the following steps 810-840:

[0214] Step 810: If it is determined that the database update version number conforms to the predetermined format, a field detection is performed on the database description field to obtain a field detection result;

[0215] Step 820: If the field detection result indicates that there is no error in the database description field, then perform a type check on the update type;

[0216] Step 830: If it is determined that the update type meets the first condition, determine the first type of the target database in the service;

[0217] Step 840: If the first type is consistent with the database type, it is determined that the database update script verification has passed.

[0218] Steps 810-840 are described in detail below.

[0219] In step 810, if it is determined that the database update version number conforms to a predetermined format, a field detection is performed on the database description field to obtain a field detection result.

[0220] The database update version number is used to indicate the version that the database update script can make the target database reach.

[0221] The predetermined format refers to the format requirements that the database update version number should meet in advance. For example, the predetermined format stipulates that the database update version number is expressed as a number that increases sequentially from 0001, or as A+a number that increases sequentially from 001. For example, the database update version number is A001.

[0222] The field detection result is used to indicate whether the composition form and specific content of the database description field meet the requirements.

[0223] When this embodiment is specifically implemented, the database update version number is first compared with the predetermined format. If the database update version number is consistent with the predetermined format, it is determined that the database update version number conforms to the predetermined format. If the database update version number is inconsistent with the predetermined format, it is determined that the database update version number does not conform to the predetermined format, and it is determined that the script inspection of the database update script fails. Further, after it is determined that the database update version number conforms to the predetermined format, a field detection is further performed on the database description field to determine whether the field length, field composition form, and field content of the database description field meet the requirements. If the field length, field composition form, and field content of the database description field all meet the requirements, the field detection result is that there is no error in the database description field.

[0224] For example, when the database update version number is 0001 and the predetermined format is a number that increases sequentially from 0001, it is determined that the database update version complies with the predetermined format. When the database update version number is 0001 and the predetermined format is A+a number that increases sequentially from 001, it is determined that the database update version does not comply with the predetermined format.

[0225] In step 820, if the field detection result indicates that there is no error in the database description field, a type check is performed on the update type.

[0226] The type check is used to measure whether the update type of the database update script meets the first condition. When the update type meets the first condition, it is confirmed that the update type check of the database update script passes.

[0227] The first condition is used to define whether the update type needs to be upgrade (up) or downgrade (down).

[0228] In the specific implementation of this embodiment, if the field detection result indicates that there is no error in the database description field, it is determined that the database description field test has passed. Further, the update type is type-checked. Specifically, first determine whether the update type is an upgrade or a downgrade. If the update type is an upgrade or a downgrade, it is determined that the update type meets the first condition, and it is confirmed that the update type test of the database update script has passed. If the update type is neither an upgrade nor a downgrade, it is determined that the update type does not meet the first condition, and it is confirmed that the update type test of the database update script has failed.

[0229] In step 830, if it is determined that the update type meets the first condition, the first type of the target database in the service is determined.

[0230] The first type refers to the type of the target database in the service. The first type of the target database includes but is not limited to SQL, Redis, Kafka, etc.

[0231] In the specific implementation of this embodiment, if it is determined that the update type meets the first condition, it is confirmed that the update type check of the database update script passes. Further, the database type is checked. Specifically, first, the first type of all target databases existing in the service is determined. Then, the first type of all target databases is deduplicated to obtain the first type contained in the target database in the service.

[0232] For example, if there are SQL databases and Redis databases in the service, the first type in the service is SQL and Redis.

[0233] In step 840, if there is a first type that is consistent with the database type, it is determined that the database update script verification has passed.

[0234] When this embodiment is specifically implemented, the database type is first compared with the first type. If the first type is consistent with the database type, it indicates that the database type applicable to the database update script can be used to perform version updates on a target database in the service. Therefore, it is determined that the database type check of the database update script has passed, and the database update script check has passed. If the first type is not consistent with the database type, it indicates that the database type applicable to the database update script cannot be used to perform version updates on any target database in the service. Therefore, it is determined that the database type check of the database update script has failed, and the database update script check has failed.

[0235] For example, the first type of target databases in a service includes SQL, Redis, and Kafka. The database type of the database update script is clickhouse, and there is no first type that is consistent with the database type. Based on this, it is determined that the database update script is applicable to the clickhouse database, and there is no clickhouse database in the service. Therefore, the database update script cannot be used to update the version of any target database in the service, and it is determined that the database type check of the database update script fails.

[0236] Through the above steps 810-840, the embodiment of the present disclosure sequentially verifies the database update version number, database description field, update type, and database type of the database update script, thereby achieving multiple verifications of the database update script, which can effectively improve the accuracy of the script verification and thus improve the success rate of the database update.

[0237] Since the hardware environment and network environment of the server often affect the normal update of the target database in the server, when the network is disconnected or the available space of the network disk is small, the database update often fails. Based on this, the embodiment of the present disclosure provides a solution for detecting the environment of the server, which can enable the database to be updated when the environment is normal, thereby improving the success rate of database update.

[0238] In the disclosed embodiment, the environment-related information includes the current network environment and the current hardware environment.

[0239] The current network environment refers to the environment consisting of various different computer systems, system architectures, servers, deployment locations, and hardware devices connected through the Internet at the current time.

[0240] The current hardware environment refers to the computer physical system composed of the computer and its peripheral devices at the current time. The content of the current hardware environment is mainly the computer's hardware facilities.

[0241] Please refer to Fig. 9In some embodiments, the process of performing environment detection based on environment-related information includes but is not limited to the following steps 910-940:

[0242] Step 910, determining current network latency, current disk capacity, and current server memory capacity;

[0243] Step 920: Determine the current network environment based on the current network delay;

[0244] Step 930: determine the current hardware environment based on the current disk capacity and the current server memory capacity;

[0245] Step 940: If the current network environment and the current hardware environment meet the second condition, the environmental detection result is determined as no abnormality in the current environment.

[0246] Steps 910-940 are described in detail below.

[0247] In step 910, the current network latency, current disk capacity, and current server memory capacity are determined.

[0248] The current network delay is used to indicate the delay time of data transmission. The current network delay is generally measured in milliseconds.

[0249] The current disk capacity is used to indicate the available capacity of the current disk.

[0250] The current server memory capacity is used to indicate the available capacity of the current server memory.

[0251] In the specific implementation of this embodiment, under the premise of authorization and permission, a pre-written code program is executed to collect the current network delay, current disk capacity, and current server memory capacity in the environment where the server is located.

[0252] In step 920, the current network environment is determined based on the current network delay.

[0253] In the specific implementation of this embodiment, in order to improve the efficiency of environmental detection, the current network delay can be directly used as the main detection indicator of the current network environment, and whether the current network environment is abnormal can be determined according to the size of the current network delay.

[0254] In step 930, the current hardware environment is determined based on the current disk capacity and the current server memory capacity.

[0255] In the specific implementation of this embodiment, in order to improve the efficiency of environmental detection, the current disk capacity and the current server memory capacity can be directly used as the main detection indicators of the current hardware environment, and whether there is any abnormality in the current hardware environment can be determined based on the current disk capacity and the current server memory capacity.

[0256] In step 940, if the current network environment and the current hardware environment meet the second condition, the environmental detection result is determined as no abnormality in the current environment.

[0257] The second condition is used to measure whether the current network environment and the current hardware environment meet the requirements for updating the target database version.

[0258] For example, the second condition may limit the current disk capacity and the current server memory capacity to be greater than a certain threshold, and limit the current network delay to not exceed a certain threshold.

[0259] When this embodiment is specifically implemented, first, according to the second condition, determine the first threshold for the current network delay, the second threshold for the current disk capacity, and the third threshold for the current server memory capacity. Then, compare the current network delay with the first threshold, compare the current disk capacity with the second threshold, and compare the current server memory capacity with the third threshold. Since both the network environment and the hardware environment have a great impact on database updates. Based on this, only when the current network delay is less than the first threshold, the current disk capacity is greater than the second threshold, and the current server memory capacity is greater than the third threshold, it is determined that the current network environment and the current hardware environment meet the second condition, and the environmental detection result is determined as no abnormality in the current environment. Otherwise, it is determined that the current network environment and the current hardware environment do not meet the second condition, and the environmental detection result is determined as an abnormality in the current environment. At the same time, the target database is not updated temporarily, and the database update process ends.

[0260] Through the above steps 910-940, the embodiment of the present disclosure detects the hardware environment and network environment of the server according to the current network delay, the current disk capacity, and the current server memory capacity, so that the database can be updated when the environment is normal, thereby improving the success rate of database updates.

[0261] In actual database update scenarios, if the target database needs to run at a previous version, it is often necessary to execute a rollback script or a version downgrade operation. At this time, it is necessary to extract the rollback script corresponding to the previous version from the remote database. If the required script data is not pre-stored in the remote database, it will often affect the normal update of the target database and cause update failures. Based on this, the embodiment of the present disclosure provides a pre-processing solution that can establish a connection with the target database before the target database is updated, and check the remote database in advance to improve the update stability and update security of the target database.

[0262] Please refer to Fig.10In some embodiments, before determining that the database update script of the target database exists in the mirror sub-file, the database update method may further include but is not limited to the following steps 1010-1020:

[0263] Step 1010: If it is determined that there is pre-stored information for updating the database, read the preset storage space;

[0264] Step 1020: extract the login information of the target database from the preset storage space, and establish a connection with the target database based on the login information.

[0265] Steps 1010 - 1020 are described in detail below.

[0266] In step 1010, if it is determined that pre-stored information for database update exists, a preset storage space is read.

[0267] The pre-stored information refers to pre-stored script data, version information, etc. that can be used for database update.

[0268] The preset storage space refers to a storage space with certain confidentiality permissions. Since the login information of each database is stored in plain text in the code or file, it often reduces the security of the database. Therefore, in order to improve security, a preset storage space is set to store the login information of each database. This preset storage space is generally only open to limited platforms and people.

[0269] For example, the preset storage space in the embodiment of the present disclosure may be referred to as an environment variable, and the preset storage space is generally only open to the operation and maintenance end.

[0270] In the specific implementation of this embodiment, it is first determined whether a remote database exists. If a remote database exists, the remote database is traversed to search for script data, version information, etc. that can be used for database update in the remote database. If script data, version information, etc. that can be used for database update are found, it is determined that pre-stored information for database update exists. Further, when authorization permission is obtained, the preset storage space is read.

[0271] In step 1020, the login information of the target database is extracted from the preset storage space, and a connection is established with the target database based on the login information.

[0272] The login information is used to indicate the information required to establish a connection with the target database. The login information generally includes the login name and login key of the target database.

[0273] In the specific implementation of this embodiment, with authorization, the data smooth upgrade tool first extracts the login information of the target database from the preset storage space. Then, the login name and login key of the target database are extracted from the login information. Finally, a connection with the target database is established by inputting the login name and login key.

[0274] It should be noted that since the preset storage space often contains login information of multiple databases, it often takes a lot of time to search and identify the login information of the target database one by one. Based on this, a correspondence between the login information of each database and the database type of each database can be constructed in the preset storage space, so that when extracting login information, the login information corresponding to the database type of the target database can be directly determined in the preset storage space, thereby improving the efficiency of extracting login information.

[0275] Through the above steps 1010-1020, the embodiment of the present disclosure determines whether there is pre-stored information for updating the database before the target database is updated, and on the premise that there is pre-stored information for updating the database, uses the login information stored in the preset storage space to communicate with the target database, thereby establishing a connection with the target database before the target database is updated, and checking the remote database in advance, thereby improving the update stability and update security of the target database.

[0276] Please refer to Fig.11 In some embodiments, the process of determining whether there is pre-stored information for updating the database includes but is not limited to the following steps 1110-1130:

[0277] Step 1110: If it is determined that the server has a remote database, then perform content detection on the remote database;

[0278] Step 1120: If it is determined that the target data table exists in the remote database, then content detection is performed on the target data table;

[0279] Step 1130: If it is determined that the target data table is not empty, it is determined that pre-stored information exists.

[0280] Steps 1110 - 1130 are described in detail below.

[0281] In step 1110, if it is determined that a remote database exists on the server, a content check is performed on the remote database.

[0282] Content detection is used to detect whether the target data table exists in the remote database.

[0283] The target data table is used to indicate the contents related to the database update. For example, the target data table is used to record the current version number of the database, the version release time, etc.

[0284] When this embodiment is implemented, first determine whether there is a remote database. If the server has a remote database, perform content detection on the remote database to detect whether there is a target data table in the remote database. If the server does not have a remote database, create a remote database to store data.

[0285] To save space, the process of creating a remote database in the embodiment of the present disclosure will be described in detail below, but will not be repeated here.

[0286] In step 1120, if it is determined that the target data table exists in the remote database, a content check is performed on the target data table.

[0287] Content detection is used to detect whether the target data table is empty.

[0288] In the specific implementation of this embodiment, if it is determined that the target data table exists in the remote database, the target data table is detected and the content is extracted to detect whether the target data table is empty. If the target data table is empty, the target data table is filled with content.

[0289] To save space, the process of creating and filling the target data table in the embodiment of the present disclosure will be described in detail below. No further description will be given here.

[0290] In step 1130 , if it is determined that the target data table is not empty, it is determined that pre-stored information exists.

[0291] In the specific implementation of this embodiment, if the content related to the database update can be extracted from the target data table, it is determined that the target data table is not empty and that the pre-stored information exists.

[0292] Through the above steps 1110-1130, the embodiment of the present disclosure determines the existence of pre-stored information based on whether there is a remote database and whether there is a non-empty target data table in the remote database. It can effectively determine whether the database is updated when there is pre-stored information, and can greatly improve the reliability of database updates.

[0293] Please refer to Fig.12 In some embodiments, the remote database and the target data table are generated by:

[0294] Step 1210: Create a remote database on the server;

[0295] Step 1220: Create a target data table in the remote database;

[0296] Step 1230: Based on the original version information of the target database, the target data table is initially filled with content.

[0297] Steps 1210 - 1230 are described in detail below.

[0298] In step 1210, a remote database is created on the server.

[0299] When this embodiment is implemented, a remote database may be created on the server through a command line or using a UI tool.

[0300] In step 1220, a target data table is created in the remote database.

[0301] When this embodiment is implemented, first the table form and table name of the target data table are obtained, then the target data table is created in the remote database according to the table form, and the target data table is named and identified according to the table name.

[0302] In step 1230, the target data table is initially filled with content based on the original version information of the target database.

[0303] The original version information is used to indicate the earliest version of the target database.

[0304] When this embodiment is implemented, the version used when the target database is created is first determined to obtain the original version information. Then, the version number, release date, etc. in the original version information are filled into the target data table.

[0305] Through the above steps 1210-1230, the embodiment of the present disclosure, by creating a remote database and a target data table in the server, can better improve the data content required for the database update lock, so that the database update process can be executed normally, thereby improving the reliability and security of the database update.

[0306] In the embodiment of the present disclosure, the target data table includes a version data table for recording the version number of the target database, and a rollback data table for recording the rollback scripts of the target database under each version number.

[0307] Please refer to Fig.13 In some embodiments, the version data table and the rollback data table are updated in the following manner:

[0308] Step 1310, based on the target database, the database update version number of each version update is updated, and the version data table is updated;

[0309] Step 1320: Update the rollback data table based on each database update version number and the rollback script corresponding to the database update version number.

[0310] Steps 1310 - 1320 are described in detail below.

[0311] In step 1310, the version data table is updated based on the database update version number of each version update of the target database.

[0312] In the specific implementation of this embodiment, after each version update is completed, if the version update is successful, the database update version number of the target database in each version update is recorded in the version data table to implement the update of the version database, so that the current version of the target database can be determined from the version data table.

[0313] like Fig.14A As shown, the remote database stores a version data table, a rollback data table, and log data. The version data table is used to record information such as the version number of each database. The rollback data table is used to record the rollback script of each database under each version number. The log data is used to record the relevant information of each version update of the database. For example, the log data includes the update time of each version update of the database, whether the update is successful or not, the reason for the update failure, etc.

[0314] like Fig. 14B As shown, the version data table records the database type and historical version number of each database. Specifically, the version data table records the historical version numbers of the database with SQL type as 0001 and 0002; the historical version numbers of the database with Redis type as 0001 and 0002; and the historical version number of the database with Kafka type as 0001.

[0315] In step 1320, based on each database update version number and the rollback script corresponding to the database update version number, the rollback data table is updated.

[0316] In the specific implementation of this embodiment, in each version update process, each database update version number and the rollback script corresponding to the database update version number are recorded one by one in the rollback data table to implement the update of the rollback data table, so that the corresponding rollback script can be extracted according to the database update version number.

[0317] like Fig. 14CAs shown, the rollback database records the database type, historical version number, and rollback script corresponding to each historical version number of each database. Specifically, the rollback script of the SQL database with a historical version number of 0001 is rollback script 1; the rollback script of the SQL database with a historical version number of 0002 is rollback script 2; the rollback script of the Redis database with a historical version number of 0001 is rollback script 3; the rollback script of the Redis database with a historical version number of 0002 is rollback script 4; and the rollback script of the Kafka database with a historical version number of 0001 is rollback script 5.

[0318] Through the above steps 1410-1420, the embodiment of the present disclosure updates the version data table and the rollback data table according to the database update version number of the database update script and the rollback script, and can realize synchronous update of the version data table and the rollback data table in each version update, thereby improving the timeliness of the table update, and further improving the reliability of the version data table and the rollback data table.

[0319] like Fig.15 As shown, it is the self-check process of the data smoothing update tool in the embodiment of the present disclosure. Specifically, after the data smoothing update tool is started, it is first determined whether the pre-stored data is in place, and its specific implementation process is similar to the above steps 1110-1130. Then, if the pre-stored data is not in place, the remote database is initialized, and after the remote database is initialized, the target data table is initialized, and its specific implementation process is similar to the above steps 1210-1230. Further, after the pre-stored data is in place, the pre-storage space is read to obtain login information, and its specific implementation process is similar to the above steps 1010-1020. Further, it is determined whether there is a database update script in the mirror subfile of the service. If there is no database update script in the mirror subfile, the self-check process is terminated and the update of the target database is suspended. If there is a database update script in the mirror subfile, the database update script is script-checked, and its specific implementation process is similar to the above steps 810-840. If the script check of the database update script fails, the self-check process is terminated and the update of the target database is suspended. If the script check of the database update script passes, the current environment is tested, and the specific implementation process is similar to the above steps 910-940. If there is an abnormality in the current environment, the self-test process is terminated and the update of the target database is suspended. If there is no abnormality in the current environment test, the target database is updated.

[0320] Detailed description of step 340

[0321] In step 340, the target database is updated based on the current version information and the database update script, so as to execute the service after the target database is updated.

[0322] In the specific implementation of this embodiment, when the current version indicated by the current version information of the target database is inconsistent with the updated version indicated by the database update script, it is often necessary to upgrade or downgrade the target database to achieve the version update of the target database. However, the upgrade and downgrade processes of the target database are often different, which will eventually cause the target database to run at different versions.

[0323] In the embodiment of the present disclosure, the current version information includes the current version number of the target database, and the database update script includes the database update version number.

[0324] Please refer to Fig.16 In some embodiments, the process of updating the target database based on the current version information and the database update script includes but is not limited to steps 1610-1620:

[0325] Step 1610: If it is determined that the current version number is less than the database update version number, then a version upgrade process is performed on the target database based on the database update script;

[0326] Step 1620: If it is determined that the current version number is greater than the database update version number, a rollback script corresponding to the current version number is obtained, and the target database is downgraded based on the rollback script.

[0327] Steps 1610-1620 are described in detail below.

[0328] In step 1610, if it is determined that the current version number is smaller than the database update version number, a version upgrade process is performed on the target database based on the database update script.

[0329] The version upgrade process refers to upgrading the target database from the current version to a version released after the current version, so that the target database runs at the next version.

[0330] In the specific implementation of this embodiment, if it is determined that the current version number is less than the database update version number, it indicates that the current version used by the target database is lower than the version indicated by the database update script. Therefore, it is necessary to perform version upgrade processing on the target database according to the database update script so that the target database runs with a higher version.

[0331] In step 1620, if it is determined that the current version number is greater than the database update version number, a rollback script corresponding to the current version number is obtained, and a version downgrade process is performed on the target database based on the rollback script.

[0332] The rollback script corresponding to the current version number is used to provide a code program for clearing data content related to the current version.

[0333] Version downgrade processing refers to upgrading the target database from the current version to a version released before the current version, so that the target database runs with the previous version.

[0334] In the specific implementation of this embodiment, if it is determined that the current version number is greater than the database update version number, it indicates that the current version used by the target database is higher than the version indicated by the database update script. Therefore, it is necessary to perform version downgrade processing on the target database according to the database update script so that the target database runs at a lower version.

[0335] Through the above steps 1610-1620, the embodiment of the present disclosure determines whether the current version used by the target database is too high or too low by comparing the current version number indicated by the current version information and the database update version number indicated by the database update script. When the current version number is less than the database update version number, the target database is upgraded; when the current version number is greater than the database update version number, the target database is downgraded, which can achieve accurate update of the target database and improve update efficiency and update accuracy.

[0336] Please refer to Fig.17 In some embodiments, the database update script includes an upgrade script and a rollback script. The process of performing version upgrade processing on the target database based on the database update script includes but is not limited to steps 1710-1740:

[0337] Step 1710: store the rollback script in a remote database of the server;

[0338] Step 1720: perform a version upgrade on the target database based on the upgrade script, and determine the script code generated based on the version upgrade;

[0339] Step 1730: If the script code meets the predetermined condition, it is determined that the target database is updated, and the current version number of the target database is updated based on the database update version number;

[0340] Step 1740: If the script code does not meet the predetermined condition, the rollback script is executed to clear the data generated during the version upgrade.

[0341] Steps 1710-1740 are described in detail below.

[0342] In step 1710, the rollback script is stored in a remote database of the server.

[0343] When this embodiment is implemented, the correspondence between the rollback script and the database update version number is first determined. Then, the database update version number and the rollback script are stored in the rollback data table of the remote database according to the correspondence, so as to realize the backup of the rollback script, which is conducive to the rapid rollback of the target database when an exception occurs during the upgrade process.

[0344] For example, if the database type of the database update script is SQL, the database update version number is 0003, and the rollback script is rollback script 6, then in the rollback data table, add a new item "Sql" in the "Database Type" column, add an item "0003" in the "Historical Version Number" column, and add an item "Rollback Script 6" in the "Rollback Script" column.

[0345] In step 1720, the target database is upgraded based on the upgrade script, and the script code generated based on the version upgrade is determined;

[0346] The upgrade script is used to provide code data for the target database to upgrade its version.

[0347] The script code is used to indicate the result of the version upgrade. The script code can be represented by numbers, letters, or a combination of letters and numbers. For example, when the version upgrade is successful, the script code is 1; when the version upgrade fails, the script code is 2 or 3. When the script code is 2, it means that the version upgrade failure is caused by a network failure; when the script code is 3, it means that the version upgrade failure is caused by an error in the upgrade script.

[0348] In the specific implementation of this embodiment, the upgrade script is first executed to upgrade the target database according to the execution of the upgrade script. Then, the execution progress of the upgrade script is recorded. When the execution progress of the upgrade script indicates that the upgrade is completed, the script code corresponding to the upgrade completion is generated. When an exception occurs in the execution of the upgrade script, the version upgrade of the target database will be terminated and the corresponding script code will be generated.

[0349] In step 1730, if the script code meets the predetermined condition, it is determined that the target database is updated, and the current version number of the target database is updated based on the database update version number.

[0350] The predetermined condition is used to measure whether the version upgrade is successful, and the predetermined condition is used to limit the generated script code to be the script code corresponding to the successful version upgrade.

[0351] In the specific implementation of this embodiment, if the script code meets the predetermined conditions, it indicates that there is no abnormality in the version upgrade of the target database based on the upgrade script, and the version upgrade of the target database can be achieved. Based on this, it is determined that the target database is updated, and the database update version number is used as the new current version number of the target database, and the database update version number is recorded in the version data table of the remote database.

[0352] In step 1740, if the script code does not meet the predetermined condition, the rollback script is executed to clear the data generated during the version upgrade.

[0353] In the specific implementation of this embodiment, if the script code does not meet the predetermined conditions, it indicates that there is an abnormality in the version upgrade of the target database based on the upgrade script, and the version upgrade of the target database cannot be implemented. Based on this, the rollback script corresponding to the database update version number is executed to clear the data previously generated in the version upgrade process, reduce the existence of redundant information, and enable the target database to still run with the current version.

[0354] Through the above steps 1710-1740, the embodiment of the present disclosure first stores the rollback script corresponding to the database update version number to the remote database of the server, thereby realizing the backup of the rollback script, which is conducive to the rapid rollback of the target database when an exception occurs during the upgrade process. Further, the target database is upgraded based on the upgrade script, and when the script code generated based on the version upgrade meets the predetermined conditions, the database update version number is updated to the current version number of the target database, thereby realizing the version update of the target database and improving the efficiency of database update.

[0355] Please refer to Fig.18 In some embodiments, the process of performing version downgrade processing on the target database based on the rollback script includes but is not limited to steps 1810-1830:

[0356] Step 1810: based on the current version number, extract the rollback script corresponding to the current version number from the remote database;

[0357] Step 1820: downgrade the target database based on the rollback script, and determine the script code generated based on the version downgrade;

[0358] Step 1830: If the script code meets the predetermined condition, it is determined that the target database is updated, and the current version number of the target database is updated based on the database update version number.

[0359] Steps 1810-1830 are described in detail below.

[0360] In step 1810, based on the current version number, a rollback script corresponding to the current version number is extracted from a remote database.

[0361] In the specific implementation of this embodiment, since the rollback data table of the remote database records the rollback scripts corresponding to various historical version numbers, based on this, according to the current version number, a query is performed in the rollback data table of the remote database, and the rollback script of the historical version number consistent with the current version number in the rollback data table is used as the rollback script for downgrading the target database, and the queried rollback script is extracted.

[0362] In step 1820, the target database is downgraded based on the rollback script, and the script code generated based on the version downgrade is determined.

[0363] When this embodiment is implemented, the specific implementation process of step 1820 is similar to the specific implementation process of step 1720. The difference is that step 1720 is to upgrade the version according to the upgrade script, and step 1820 is to downgrade the version according to the rollback script. The scripts used by the two versions when updating are different. To save space, it will not be repeated.

[0364] In step 1830, if the script code meets the predetermined condition, it is determined that the target database is updated, and the current version number of the target database is updated based on the database update version number.

[0365] When this embodiment is implemented, the specific implementation process of step 1830 is similar to the specific implementation process of the above step 1730. To save space, it will not be repeated.

[0366] In another embodiment, if the script code does not meet the predetermined condition, an abnormal result of version downgrade is determined based on the script code; the abnormal result is sent to the target object, so that the target object updates the target database based on the abnormal result.

[0367] The abnormal result is used to indicate the specific reason for the version downgrade. In the embodiment of the present disclosure, the abnormal result includes but is not limited to network failure, data missing in the rollback script, etc.

[0368] The target objects refer to the operation and maintenance platform, related operation and maintenance personnel, etc.

[0369] In the specific implementation of this embodiment, different script codes correspond to different abnormal results. Based on this, first, according to the script code, the correspondence table between the script code and the abnormal result is queried, and the abnormal result corresponding to the script code is used as the abnormal result of the version downgrade. Further, the abnormal result is sent to the target object, so that the target object updates the target database based on the abnormal result.

[0370] Through the above steps 1810-1830, the embodiment of the present disclosure, based on the current version number, extracts the rollback script corresponding to the current version number from the remote database, and downgrades the target database based on the rollback script. It can more conveniently clear the relevant data corresponding to the current version, return the target database to the previous version, and implement version updates of the target database, thereby improving the efficiency of database updates.

[0371] like Fig.19 As shown, it is a specific process of using the data smoothing update tool to update the database. Specifically, after the data smoothing update tool completes the self-check, the current version information is extracted, and the current database update version indicated by the database update script is determined, and its specific implementation process is similar to the above step 330. Further, the current version number indicated by the current version information and the current database update version number are compared. If the current version number and the database update version number are consistent, the process ends. If the current version number is greater than the database update version number, the rollback script is downloaded from the remote database, and the target database is downgraded. When the downgrade process is successfully executed, the process ends; when the downgrade process fails, the operation and maintenance end is notified to intervene. The specific implementation process is similar to the above steps 1810-1830. If the current version number is less than the database update version number, the rollback script is uploaded to the remote database, and the target database is upgraded. When the upgrade process is successfully executed, the process ends. When the upgrade process fails, the rollback operation is performed. If the rollback operation is successfully executed, the process ends. If the rollback operation fails, the operation and maintenance side is notified to intervene, and the specific implementation process is similar to the above steps 1710-1740.

[0372] Detailed description of an embodiment of the present disclosure for updating multiple target databases based on priority

[0373] Since there are often multiple target databases in a service of a server, if there are multiple target databases in a service that need to be updated, limited network resources often cannot meet the demand for updating all of the multiple target databases at the same time. Based on this, the embodiment of the present disclosure provides a solution for updating multiple target databases based on priority, which can update the target databases in order when network resources are limited, thereby improving the rationality of database updates.

[0374] Please refer to Fig. 20 In some embodiments, the process of updating multiple target databases based on priority includes but is not limited to the following steps 2010-2020:

[0375] Step 2010: determining the update priorities of multiple target databases;

[0376] Step 220: According to the update priority, for each target database, the target database is updated based on the current version information and the database update script.

[0377] Steps 2010-2020 are described in detail below.

[0378] In step 2010, update priorities of multiple target databases are determined.

[0379] Update priority is used to limit the update order of each target database. When network resources are limited, the target database with a higher update priority will be updated first; the target database with a lower update priority will be updated later.

[0380] When this embodiment is implemented, the update priority of the target databases may be determined according to multiple indicators such as the database type, creation time, storage capacity, etc. of each target database.

[0381] To save space, the specific implementation process of determining the update priorities of multiple target databases in the embodiment of the present disclosure will be described in detail below. No further description will be given here.

[0382] In step 220, according to the update priority, for each target database, the target database is updated based on the current version information and the database update script.

[0383] In the specific implementation of this embodiment, the specific implementation process of step 2020 is similar to the specific implementation process of the above steps 1610-1620, which will not be described in detail to save space.

[0384] Through the above steps 2010-2020, the embodiment of the present disclosure updates multiple target databases based on priority, and can update the target databases in sequence in an orderly manner when network resources are limited, thereby improving the rationality of database updating.

[0385] Please refer to Fig.21 In some embodiments, the process of determining the update priorities of multiple target databases includes but is not limited to the following steps 2110-2140:

[0386] Step 2110: for each target database, determine a first score based on the database type of the target database;

[0387] Step 2120: for each target database, determine a second score based on a creation timestamp of the target database;

[0388] Step 2130: Determine a total score of the target database based on the first score and the second score;

[0389] Step 2140: Based on the total scores, determine the update priorities of the multiple target databases.

[0390] Steps 2110-2140 are described in detail below.

[0391] In step 2110 , for each target database, a first score is determined based on the database type of the target database.

[0392] The database type is used to distinguish different target databases. Database types include but are not limited to Redis, Sql, Kafka, etc.

[0393] In the specific implementation of this embodiment, firstly, a preset relationship comparison table is called, wherein the relationship comparison table is used to indicate the score corresponding to each database type. Then, for each target database, the score corresponding to the database type of the target database is queried in the relationship comparison table, and the queried score is used as the first score.

[0394] In step 2120 , for each target database, a second score is determined based on a creation timestamp of the target database.

[0395] The creation timestamp of the target database is used to indicate the creation time point of the target database.

[0396] When this embodiment is implemented, the specific implementation process of step 2120 is similar to the specific implementation process of the above step 2110. To save space, it will not be repeated.

[0397] In step 2130 , a total score of the target database is determined based on the first score and the second score.

[0398] When this embodiment is implemented, the first weight and the second weight are first determined, wherein the first weight is used to indicate the importance of the database type in determining the update priority, and the second weight is used to indicate the importance of the creation time in determining the update priority, and the sum of the first weight and the second weight is 1. Next, the first weight and the first score are multiplied to obtain a first product; the second weight and the second score are multiplied to obtain a second product; the first product and the second product are added to obtain an addition result, thereby achieving a weighted sum of the first score and the second score. Finally, the addition result is used as the total score of the target database.

[0399] In step 2140 , based on the total scores, update priorities of the multiple target databases are determined.

[0400] In the specific implementation of this embodiment, according to the total scores, multiple target databases are arranged in descending order according to the total scores to obtain a priority sequence. The order of each target database in the priority sequence is used as the update priority of the multiple target databases.

[0401] like Fig. 22 As shown, the first weight and the second weight are both determined to be 0.5. Based on this, when the first score of the target database whose database type is Sql is 88 and the second score is 80, the total score of the target database is 84. When the first score of the target database whose database type is Kafka is 76 and the second score is 82, the total score of the target database is 79. When the first score of the target database whose database type is Redis is 80 and the second score is 84, the total score of the target database is 82. Based on this, it is determined that the update priority of the target database whose database type is Sql is 1, the update priority of the target database whose database type is Redis is 2, and the update priority of the target database whose database type is Kafka is 3. When network resources are limited, the version update of the target database whose database type is Sql is executed first, and then the version update of the target database whose database type is Redis is executed, and finally, the version update of the target database whose database type is Kafka is executed.

[0402] Through the above steps 2110-2140, the embodiment of the present disclosure calculates the total score of each target database according to the database type of each target database and the early or late creation timestamp, and determines the update priority of multiple target databases according to the size of the total score, which can improve the efficiency and accuracy of determining the update priority, and is conducive to improving the rationality of database updates.

[0403] Description of the apparatus and device of the present disclosure

[0404] It is to be understood that, although the steps in the above-mentioned flowcharts are sequentially displayed according to the characterization of arrows, these steps are not necessarily executed in sequence according to the order of arrow characterization. Unless there is a clear description in the present embodiment, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the above-mentioned flowcharts can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the steps or stages in other steps.

[0405] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to the characteristics of the target object such as the target object attribute information or attribute information set, the permission or consent of the target object will be obtained first, and the collection, use and processing of these data will comply with relevant laws, regulations and standards. In addition, when the embodiment of the present application needs to obtain the attribute information of the target object, the separate permission or separate consent of the target object will be obtained through a pop-up window or jump to a confirmation page. After clearly obtaining the separate permission or separate consent of the target object, the necessary target object-related data used to enable the normal operation of the embodiment of the present application is obtained.

[0406] Fig.23 The following is a schematic diagram of the structure of a database updating device 2300 provided in an embodiment of the present disclosure. The database updating device 2300 includes:

[0407] The receiving unit 2310 is used to receive a server image file, wherein the server image file is used to update the server; the server includes multiple services, the server image file includes an image sub-file of each service, and each service is associated with at least one target database;

[0408] The verification unit 2320 is used for, for each service, if it is determined that the database update script of the target database exists in the mirror sub-file, to perform a first verification on the database update script and the current environment;

[0409] The extraction unit 2330 is configured to extract the current version information of the target database if it is determined that the first verification passes;

[0410] The updating unit 2340 is used to perform version update on the target database based on the current version information and the database update script, so as to execute the service after the target database is updated.

[0411] Optionally, the current version information includes a current version number of the target database, and the database update script includes a database update version number;

[0412] The updating unit 2340 specifically includes:

[0413] An upgrade processing unit (not shown), configured to perform version upgrade processing on the target database based on a database update script if it is determined that the current version number is less than the database update version number;

[0414] A downgrade processing unit (not shown) is used to obtain a rollback script corresponding to the current version number if it is determined that the current version number is greater than the database update version number, and perform version downgrade processing on the target database based on the rollback script, wherein the rollback script corresponding to the current version number is stored in a remote database of the server.

[0415] Optionally, the upgrade processing unit (not shown) is specifically used for:

[0416] Store the rollback script in the server's remote database;

[0417] Perform version upgrade on the target database based on the upgrade script, and determine the script code generated based on the version upgrade;

[0418] If the script code meets the predetermined condition, it is determined that the target database has been updated, and the current version number of the target database is updated based on the database update version number;

[0419] If the script code does not meet the predetermined condition, the rollback script is executed to clear the data generated in the version upgrade.

[0420] Optionally, the degradation processing unit (not shown) is specifically used for:

[0421] Based on the current version number, extract the rollback script corresponding to the current version number from the remote database;

[0422] Downgrade the target database version based on the rollback script and determine the script code generated based on the version downgrade;

[0423] If the script code meets the predetermined condition, it is determined that the target database is updated, and the current version number of the target database is updated based on the database update version number.

[0424] Optionally, the degradation processing unit (not shown) is further configured to:

[0425] After determining the script code generated based on the version downgrade, if the script code does not meet the predetermined condition, determining an abnormal result of the version downgrade based on the script code;

[0426] The abnormal result is sent to the target object, so that the target object updates the target database based on the abnormal result.

[0427] Optionally, the server image file is generated by:

[0428] For each service, determine the service association information, database update script, and database execution data of the service;

[0429] Build the service image sub-file based on the service association information, database update script, and database execution data;

[0430] Package multiple image sub-files into an image to obtain a server image file.

[0431] Optionally, the database update scripts are named as follows:

[0432] Based on the database update script, determine the database type, update type, database update version number, and database description field of the target database of the service;

[0433] The database update version number, the database description field, the update type, and the database type are concatenated to obtain the script name of the database update script.

[0434] Optionally, the verification unit 2320 specifically includes:

[0435] A script checking unit (not shown), used to perform script checking on the database update script;

[0436] An environment detection unit (not shown), configured to obtain environment-related information of the current environment if the database update script passes the verification, and perform environment detection based on the environment-related information to obtain an environment detection result;

[0437] The verification determination unit (not shown) is used to determine that the first verification is passed if the environmental detection result indicates that there is no abnormality in the current environment.

[0438] Optionally, the database update script has database type, update type, database update version number, and database description fields;

[0439] The script checking unit (not shown) is specifically used for:

[0440] If it is determined that the database update version number conforms to the predetermined format, a field detection is performed on the database description field to obtain a field detection result;

[0441] If the field check result indicates that there is no error in the database description field, then type checking is performed on the update type;

[0442] If it is determined that the update type meets the first condition, determining a first type of the target database in the service;

[0443] If there is a first type that is consistent with the database type, it is determined that the database update script verification passes.

[0444] Optionally, the environment-related information includes the current network environment and the current hardware environment;

[0445] The environment detection unit (not shown) is specifically used for:

[0446] Determine current network latency, current disk capacity, and current server memory capacity;

[0447] Based on the current network delay, determine the current network environment;

[0448] Determine the current hardware environment based on the current disk capacity and the current server memory capacity;

[0449] If the current network environment and the current hardware environment meet the second condition, the environmental detection result is determined as no abnormality in the current environment.

[0450] Optionally, the database updating device 2300 further includes a preprocessing unit (not shown), which is used to:

[0451] If it is determined that there is pre-stored information for updating the database, then reading the preset storage space;

[0452] The login information of the target database is extracted from the preset storage space, and a connection is established with the target database based on the login information.

[0453] Optionally, determining whether there is pre-stored information for updating the database includes:

[0454] If it is determined that the server has a remote database, then the remote database is checked for content;

[0455] If it is determined that the target data table exists in the remote database, then the content of the target data table is detected;

[0456] If it is determined that the target data table is not empty, it is determined that pre-stored information exists.

[0457] Optionally, the remote database and the target data table are generated by:

[0458] Create a remote database on the server;

[0459] Create a target data table in the remote database;

[0460] Based on the original version information of the target database, the target data table is initially filled with content.

[0461] Optionally, the target data table includes a version data table for recording the version number of the target database, and a rollback data table for recording the rollback scripts of the target database under each version number;

[0462] The version data table and rollback data table are updated in the following ways:

[0463] Based on the target database, update the version number in each version update and update the version data table;

[0464] Based on each database update version number and the rollback script corresponding to the database update version number, the rollback data table is updated.

[0465] Optionally, the service is associated with multiple target databases;

[0466] The updating unit 2340 is specifically used for:

[0467] Determine update priorities for multiple target databases;

[0468] According to the update priority, for each target database, the target database is updated based on the current version information and the database update script.

[0469] Optionally, the update priority of multiple target databases is determined by:

[0470] For each target database, determining a first score based on a database type of the target database;

[0471] For each target database, determining a second score based on a creation timestamp of the target database;

[0472] Determining an overall score of the target database based on the first score and the second score;

[0473] Based on the total scores, update priorities of the multiple target databases are determined.

[0474] Reference Fig.24 , Fig.24 The structural block diagram of the terminal part for implementing the database updating method of the embodiment of the present disclosure is as follows: the terminal includes: a radio frequency (RF) circuit 2410, a memory 2415, an input unit 2430, a display unit 2440, a sensor 2450, an audio circuit 2460, a wireless fidelity (WiFi) module 2470, a processor 2480, and a power supply 2490. Those skilled in the art can understand that Fig.24 The terminal structure shown does not constitute a limitation on the mobile phone or computer, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0475] The RF circuit 2410 may be used for receiving and sending signals during information transmission or calls. In particular, after receiving the downlink information from the base station, it is sent to the processor 2480 for processing; in addition, the designed uplink data is sent to the base station.

[0476] The memory 2415 may be used to store software programs and modules. The processor 2480 executes various functional applications and data processing of the target terminal by running the software programs and modules stored in the memory 2415 .

[0477] The input unit 2430 may be used to receive input digital or character information and generate key signal input related to the setting and function control of the target terminal. Specifically, the input unit 2430 may include a touch panel 2431 and other input devices 2425 .

[0478] The display unit 2440 may be used to display input information or provided information and various menus of the target terminal. The display unit 2440 may include a display panel 2441.

[0479] The audio circuit 2460, the speaker 2461, and the microphone 2462 may provide an audio interface.

[0480] In this embodiment, the processor 2480 included in the terminal can execute the database updating method of the previous embodiment.

[0481] The terminals of the embodiments of the present disclosure include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc. The embodiments of the present invention can be applied to various scenarios, including but not limited to database updates, server maintenance, big data technology, intelligent customer service, etc.

[0482] Fig.25 A block diagram of the structure of a portion of a server for implementing the database update method of an embodiment of the present disclosure. The server may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPUs) 2522 (for example, one or more processors) and a memory 2525, and one or more storage media 2530 (for example, one or more mass storage devices) storing application programs 2542 or data 2544. Among them, the memory 2525 and the storage medium 2530 can be short-term storage or permanent storage. The program stored in the storage medium 2530 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the central processing unit 2522 can be configured to communicate with the storage medium 2530 and execute a series of instruction operations in the storage medium 2530 on the server.

[0483] The server may also include one or more power supplies 2526, one or more wired or wireless network interfaces 2550, one or more input and output interfaces 2558, and / or one or more operating systems 2541, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.

[0484] The central processor 2522 in the server can be used to execute the database updating method of the embodiment of the present disclosure.

[0485] The embodiments of the present disclosure also provide a computer-readable storage medium, which is used to store program codes, and the program codes are used to execute the database updating methods of the aforementioned embodiments.

[0486] The embodiment of the present disclosure also provides a computer program product, which includes a computer program. A processor of a computer device reads and executes the computer program, so that the computer device executes and implements the above-mentioned database update method.

[0487] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can, for example, be implemented in an order other than those illustrated or described herein. In addition, the terms "comprises" and "comprising" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0488] In the embodiments of the present disclosure, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0489] It should be understood that in the present disclosure, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0490] It should be understood that in the description of the embodiments of the present disclosure, the meaning of multiple (or multiple items) is more than two, greater than, less than, exceed, etc. are understood to not include the number, and above, below, within, etc. are understood to include the number.

[0491] In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0492] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0493] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0494] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store program codes.

[0495] It should also be understood that the various implementations provided in the embodiments of the present disclosure can be combined arbitrarily to achieve different technical effects.

[0496] The above is a specific description of the implementation methods of the present disclosure, but the present disclosure is not limited to the above implementation methods. Technical personnel familiar with the art can also make various equivalent modifications or substitutions without violating the spirit of the present disclosure. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present disclosure.

Claims

1. A database updating method, It is characterized in that The method comprises: Receive a server image file, wherein the server image file is used to update the server; the server includes multiple services, the server image file contains an image sub-file of each service, and each service is associated with at least one target database; For each of the services, if it is determined that the database update script of the target database exists in the mirror sub-file, a first verification is performed on the database update script and the current environment; If it is determined that the first verification passes, extracting the current version information of the target database; The target database is updated based on the current version information and the database update script, so as to execute the service after the target database is updated.

2. The method according to claim 1, It is characterized in that The current version information includes the current version number of the target database, and the database update script includes the database update version number; The performing version updating on the target database based on the current version information and the database update script includes: If it is determined that the current version number is less than the database update version number, performing version upgrade processing on the target database based on the database update script; If it is determined that the current version number is greater than the database update version number, a rollback script corresponding to the current version number is obtained, and the target database is downgraded based on the rollback script, wherein the rollback script corresponding to the current version number is stored in a remote database of the server.

3. The method according to claim 2, It is characterized in that The database update script includes an upgrade script and a rollback script; the version upgrade process of the target database based on the database update script includes: Storing the rollback script in a remote database of the server; Performing a version upgrade on the target database based on the upgrade script, and determining a script code generated based on the version upgrade; If the script code meets the predetermined condition, it is determined that the target database has been updated, and the current version number of the target database is updated based on the database update version number; If the script code does not meet the predetermined condition, the rollback script is executed to clear the data generated in the version upgrade.

4. The method according to claim 2, It is characterized in that The obtaining of a rollback script corresponding to the current version number, and performing version downgrade processing on the target database based on the rollback script, includes: Based on the current version number, extracting a rollback script corresponding to the current version number from the remote database; Downgrading the target database based on the rollback script, and determining a script code generated based on the version downgrading; If the script code meets the predetermined condition, it is determined that the target database has been updated, and the current version number of the target database is updated based on the database update version number.

5. The method according to claim 1, It is characterized in that The server image file is generated in the following way: For each of the services, determining service association information, database update script, and database execution data of the service; Building a mirror subfile of the service based on the service association information, the database update script, and the database execution data; The plurality of image sub-files are packaged into an image to obtain the server image file.

6. The method according to claim 1, It is characterized in that The database update scripts are named as follows: Based on the database update script, determine the database type, update type, database update version number, and database description field of the target database of the service; The database update version number, the database description field, the update type, and the database type are concatenated to obtain a script name of the database update script.

7. The method according to claim 1, It is characterized in that The first verification of the database update script and the current environment includes: Performing script verification on the database update script; If the database update script passes the verification, then obtaining the environment-related information of the current environment, and performing an environment detection based on the environment-related information to obtain an environment detection result; If the environmental detection result indicates that there is no abnormality in the current environment, it is determined that the first verification is passed.

8. The method according to claim 7, It is characterized in that The database update script has database type, update type, database update version number, and database description fields; The script verification of the database update script includes: If it is determined that the database update version number conforms to a predetermined format, a field detection is performed on the database description field to obtain a field detection result; If the field detection result indicates that there is no error in the database description field, performing a type check on the update type; If it is determined that the update type meets the first condition, determining a first type of the target database in the service; If the first type is consistent with the database type, it is determined that the database update script has passed the verification.

9. The method according to claim 7, It is characterized in that The environment-related information includes the current network environment and the current hardware environment; The performing environment detection based on the environment-related information to obtain an environment detection result includes: Determine current network latency, current disk capacity, and current server memory capacity; Based on the current network delay, determining the current network environment; Determining the current hardware environment based on the current disk capacity and the current server memory capacity; If the current network environment and the current hardware environment meet the second condition, the environment detection result is determined as no abnormality in the current environment.

10. The method according to claim 1, It is characterized in that Before determining that the database update script of the target database exists in the mirror sub-file, the method includes: If it is determined that there is pre-stored information for updating the database, then reading the preset storage space; The login information of the target database is extracted from the preset storage space, and a connection is established with the target database based on the login information.

11. The method according to claim 10, It is characterized in that The determining whether there is pre-stored information for updating the database includes: If it is determined that the server has a remote database, performing content detection on the remote database; If it is determined that the target data table exists in the remote database, performing content detection on the target data table; If it is determined that the target data table is not empty, it is determined that the pre-stored information exists.

12. The method according to claim 11, It is characterized in that The remote database and the target data table are generated in the following manner: Creating the remote database on the server; Creating the target data table in the remote database; Based on the original version information of the target database, the target data table is initially filled with content.

13. The method according to claim 12, It is characterized in that The target data table includes a version data table for recording the version number of the target database, and a rollback data table for recording the rollback scripts of the target database under each version number; The version data table and the rollback data table are updated in the following manner: Based on the database update version number of each version update of the target database, updating the version data table; The rollback data table is updated based on each of the database update version numbers and the rollback script corresponding to the database update version number.

14. The method according to claim 1, It is characterized in that The service is associated with a plurality of target databases, and the version update of the target database based on the current version information and the database update script includes: Determining update priorities of the plurality of target databases; According to the update priority, for each target database, the target database is updated based on the current version information and the database update script.

15. The method according to claim 14, It is characterized in that The update priorities of the target databases are determined in the following manner: For each of the target databases, determining a first score based on the database type of the target database; For each of the target databases, determining a second score based on a creation timestamp of the target database; Determining a total score of the target database based on the first score and the second score; Based on the total scores, update priorities of the plurality of target databases are determined.

16. The method according to claim 4, It is characterized in that After determining the script code generated based on the version downgrade, the method includes: If the script code does not meet the predetermined condition, determining the abnormal result of the version downgrade based on the script code; The abnormal result is sent to a target object, so that the target object updates the target database based on the abnormal result.

17. A database updating device, It is characterized in that The device comprises: A receiving unit, configured to receive a server image file, wherein the server image file is used to update a server; the server includes a plurality of services, the server image file includes an image sub-file of each of the services, and each of the services is associated with at least one target database; a verification unit, configured to, for each of the services, if it is determined that the database update script of the target database exists in the mirror sub-file, perform a first verification on the database update script and the current environment; an extracting unit, configured to extract the current version information of the target database if it is determined that the first verification passes; An updating unit is used to perform a version update on the target database based on the current version information and the database update script, so as to execute the service after the target database is updated.

18. An electronic device comprising a memory and a processor, wherein the memory stores a computer program. It is characterized in that When the processor executes the computer program, the database updating method according to any one of claims 1 to 16 is implemented.

19. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, the database updating method according to any one of claims 1 to 16 is implemented.

20. A computer program product, comprising a computer program, wherein the computer program is read and executed by a processor of a computer device, so that the computer device executes the database updating method according to any one of claims 1 to 16.