Online change method and platform for database, computer device and readable medium
Through automated database online change methods and platforms, the inefficiency and error problems caused by manual operations in the existing technology are solved, and more efficient and accurate database online changes are achieved.
Patent Information
- Application Number
- CN201910758965.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-08-16
- Publication Date
- 2025-06-17
- Estimated Expiration
- 2039-08-16
AI Technical Summary
The online change process of databases in the prior art involves a large number of manual operations, resulting in low efficiency and error-proneness.
Provides an automated database online change method and platform, which can perform syntax detection and content audits by detecting and obtaining online requests, backing up the database cluster, and perform online SQL according to the preset change strategy.
Reduced manual participation, improved the efficiency and accuracy of online changes, reduced the probability of errors, and reduced labor and time costs through automated processes.
Smart Images

Figure CN110489436B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer application technologies, and particularly to an online change method and platform for a database, a computer device, and a readable medium.
Background Art
[0002] Under the background of the rapid development of the Internet, in order to meet market needs, business parties need to frequently improve the product quality of databases to enhance the user experience. Based on this, due to requirement changes or version iterations, the online change of the database (On-line Change of Database) has emerged as the times require.
[0003] The change operations performed by business parties on the online database may include: changes to the table structure, such as changes to the Data Definition Language (DDL); changes to the table data, such as changes to the Data Manipulation Language (DML). For example: when a new query requirement is added to the business, an index is added to the original table to avoid full table scans; when the business changes, a new field needs to be added to the original table or the original field needs to be extended; in order to avoid excessive data growth, historical data in the database is regularly cleared; in order to support an event, a business launches a commodity activity discount, and the commodity prices in the database need to be modified, etc. The changes to the existing online database in the prior art are mainly completed by business parties by filling out an online form, submitting an online file, and having the Database Administrator (DBA) complete data verification and impact assessment, and finally performing an online change in the main database.
[0004] In the above-mentioned existing online database change process, the entire process involves a large amount of manual operations, which not only occupy a large amount of human resources, are time-consuming and laborious, resulting in very low efficiency of online changes, but also are very prone to errors.
Summary of the Invention
[0005] The present invention provides an online change method and platform for a database, a computer device, and a readable medium, which are used to save human resources and improve the efficiency and accuracy of online changes to the database.
[0006] The present invention provides an online change method for a database, and the method includes:
[0007] Detect and obtain an externally triggered online request, where the online request includes an online SQL and an identifier of an online cluster;
[0008] Perform syntax detection and content review on the online SQL;
[0009] After the above-mentioned syntax detection and content review are passed, back up the database cluster corresponding to the identifier of the online cluster;
[0010] According to the preset change strategy, use the online SQL to change the database cluster corresponding to the identifier of the online cluster.
[0011] Further optionally, in the method as described above, performing syntax detection and content review on the online SQL includes:
[0012] Perform syntax detection on the online SQL;
[0013] And when the detection is passed, perform content review on the online SQL.
[0014] Further optionally, in the method as described above, it further includes:
[0015] If the syntax detection of the online SQL fails, generate a non-passed prompt opinion and display it on the interface for the online requester to refer to.
[0016] Further optionally, in the method as described above, performing content review on the online SQL includes:
[0017] By performing semantic checking on the online SQL, detect whether the online cluster corresponding to the identifier of the online cluster includes the corresponding tables or columns in the online SQL;
[0018] If included, obtain the online impact information.
[0019] Further optionally, in the method as described above, obtaining the online impact information includes:
[0020] Obtain the online type corresponding to the online SQL;
[0021] According to the online type, obtain the corresponding online impact metrics.
[0022] Further optionally, in the method as described above, according to the online type, obtaining the corresponding online impact metrics includes:
[0023] If the online type is DDL change, obtain the maximum number of affected rows of each single SQL after the online SQL is launched and the total number of affected rows calculated by the standby database cluster corresponding to the identifier of the online cluster;
[0024] If the online type is DML change, obtain the maximum number of affected rows of each single insert SQL after the online SQL is launched, the maximum number of affected rows of a single delete SQL, the maximum number of affected rows of a single change SQL, and the total number of affected rows calculated by the backup cluster corresponding to the identifier of the online cluster.
[0025] Further optionally, in the method as described above, before backing up the database cluster corresponding to the identifier of the online cluster, the method further includes:
[0026] Obtaining a backup type according to the total number of affected rows and a preset row threshold;
[0027] Displaying the backup type for the online requester to confirm whether to select the backup type;
[0028] The backing up of the database cluster corresponding to the identifier of the online cluster specifically includes: backing up the standby database corresponding to the identifier of the online cluster according to the backup type selected by the online requester.
[0029] Further optionally, in the method as described above, after performing syntax detection and content review on the online request and before backing up the database cluster corresponding to the identifier of the online cluster, the method further includes:
[0030] Sending an approval request carrying the online impact metrics to a preset approval account according to a pre-configured approval policy for an approver corresponding to the approval account to approve the online request according to the online impact metrics;
[0031] And receiving a message of approval passed returned by the approval account.
[0032] The present invention provides an online change platform for a database, and the platform includes:
[0033] An obtaining module, configured to detect and obtain an externally triggered online request, where the online request includes an online SQL and an identifier of an online cluster;
[0034] A detection and review module, configured to perform syntax detection and content review on the online SQL;
[0035] A backup module, configured to back up the database cluster corresponding to the identifier of the online cluster;
[0036] A change execution module, configured to change the database cluster corresponding to the identifier of the online cluster by using the online SQL according to a preset change policy.
[0037] The present invention further provides a computer device, and the device includes:
[0038] One or more processors;
[0039] A memory, configured to store one or more programs;
[0040] When the one or more programs are executed by the one or more processors, the one or more processors implement the online change method of the database as described above.
[0041] The present invention also provides a computer-readable medium, on which a computer program is stored, and when the program is executed by a processor, the online change method of the database as described above is implemented.
[0042] The online change method, platform, computer device and readable medium of the database of the present invention can realize the online change of the database by adopting the above solution. In the technical solution of the present invention, the whole process is automatically completed by the online change platform of the database. Compared with the manual implementation of the online launch in the prior art, the labor cost and time cost required for the online launch are reduced, the complexity of the online launch is reduced, and the efficiency of the online change can be effectively improved. Moreover, in the present invention, the online change platform of the database is used to replace manual participation in grammar detection and content review, greatly reducing the probability of errors in the online launch.
[0043] Further, in the technical solution of the present invention, the backup type can also be obtained according to the total number of affected rows and a preset row threshold, and displayed to the online launch requester, which can provide accurate suggestions for the backup type and facilitate the online launch requester to select a more reasonable backup method.
[0044] Further, in the technical solution of the present invention, a corresponding approval process is also set up, which can further ensure the accuracy of the online launch and improve the security and stability of the online launch.
Description of the Drawings
[0045] Figure 1 It is a flowchart of the first embodiment of the online change method of the database of the present invention.
[0046] Figure 2 It is an application scenario diagram of an online change method of a database provided by the present invention.
[0047] Figure 3 It is a schematic diagram of an audit report provided by the present invention.
[0048] Figure 4 It is a schematic diagram of a backup result provided by the present invention.
[0049] Figure 5 It is a schematic diagram of an interface for configuring an approval policy provided by the present invention.
[0050] Figure 6 It is a flowchart of the second embodiment of the online change method of the database of the present invention.
[0051] Figure 7 It is a structural diagram of the first embodiment of the online change platform of the database of the present invention.
[0052] Figure 8 This is the structural diagram of the second embodiment of the online change platform for the database of the present invention.
[0053] Figure 9 This is the structural diagram of the computer device embodiment of the present invention.
[0054] Figure 10 This is an example diagram of a computer device provided by the present invention.
Specific Embodiment
[0055] In order to make the objectives, technical solutions and advantages of the present invention clearer, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0056] Generally, the process of changing the online database mainly includes the operations of the business side and the DBA. The operations of the business side can include the following steps: a) The business side fills in the online form, which mainly includes more than a dozen items such as the cluster name, File Transfer Protocol (FTP) address, file MD5 value, and execution time, and then submits it; b) The business side initiates the process approval, and after the approval process is completed, it reminds the DBA to continue to complete the online process. Next, the operations of the DBA side can include the following steps: a) The DBA checks the content of the online form and downloads the online Structured Query Language (SQL) file; b) Reviews whether the syntax and semantics of the SQL file in the submitted file are correct; c) Evaluates the impact of this online operation based on the current database data; d) Queries the information of the main database of the cluster in the database, uploads the file to the instance machine, verifies the file md5 value to prevent network transmission errors, checks the file encoding, and checks whether the file contains special characters; e) Verifies the readonly of the main database to prevent the master-slave switch of the cluster during the gap of obtaining database information and connecting to the database. If the verified readonly = 0, then starts to execute the online SQL; f) Fills back the online form to complete the online operation.
[0057] The above operations of the business side can also be performed by the R & D personnel of the business side, and in addition, the operations of the DBA also belong to the operations performed by people. Therefore, in the existing database change process, all the operations involved in the whole process are manual operations, which not only consume a large amount of human resources, are time-consuming and laborious, but also are very prone to errors. Based on this, the present invention urgently needs to provide a solution for automatically realizing the online change of the database.
[0058] Figure 1 This is the flowchart of the first embodiment of the online change method for the database of the present invention. As Figure 1 shown, the online change method for the database in this embodiment can specifically include the following steps:
[0059] 100. Detect and obtain an external trigger for an online request, where the online request includes an online SQL and an identifier of an online cluster;
[0060] The execution subject of the online change method of the database in this embodiment is the online change platform of the database. This online change platform of the database is used to automatically perform operations on the online change of the database, avoiding manual operations to ensure the correctness of the online change operations of the database.
[0061] The online request in this embodiment can be filled in by the online requester through the interface of the online change platform of the database. Correspondingly, the online change platform of the database can obtain the online request by detecting the information filled in the interface.
[0062] Alternatively, the online request in this embodiment can also be filled in by the online requester through an external application and then pushed to the online change platform of the database through an interface. Correspondingly, the online change platform of the database can obtain the online request by detecting the interface.
[0063] Figure 2 This is an application scenario diagram of an online change method for a database provided by the present invention. As Figure 2 shown in the scenario diagram, the online change method of the database in this embodiment can be deployed in the online change platform of the database. In this embodiment, the online change platform of the database can communicate with n database clusters. Specifically, the n database clusters can be deployed on one, two or more servers. And one, two or more database clusters can be deployed in each server. Specifically, in this embodiment, the online change platform of the database is used to manage and maintain the n database clusters. For example, it can be specifically responsible for the online change of the n database clusters. Multiple MySQL instances can be deployed in each database cluster, such as a primary MySQL instance, a slave MySQL instance and a standby MySQL instance, and there is a replication relationship between the instances. That is to say, each database cluster includes a primary database, a slave database and a standby database, and the primary database, the slave database and the standby database always keep data synchronized, where the slave database is used to provide online services. Moreover, the online change platform of the database can display the entire online change process of the database in the interface, and both the online requester and the responsible DBA related to this online change can see it.
[0064] In this embodiment, taking an online deployment request as an example, the method for online change of the database of the present invention is described. Specifically, an interface for interaction is provided on the online change platform of the database. This interface can receive the online SQL filled in by the online deployment requester, such as a R & D personnel, and the identifier of the online cluster. Specifically, one online deployment can include one, two, or even multiple online SQL statements. Among them, the identifier of the online cluster can be the name of the online cluster. The online deployment process is used to execute the online SQL to the database cluster corresponding to the identifier of the online cluster, so as to realize the change of the corresponding database cluster. And in the online SQL, only a certain table in the database cluster corresponding to the identifier of the online cluster can be changed.
[0065] In addition, in order to facilitate the distinction of each online deployment, in this embodiment, the online deployment requester can also input the name of the online deployment form through the interface. For example, the name of the online deployment form can be identified by adding the date or serial number to the name of the online deployment task, so that the relevant personnel related to this online deployment can see it through the online change platform of the database. After the online deployment requester inputs the relevant information on the interface, the online deployment request set on the interface can be clicked, which is equivalent to triggering an online deployment request to the online change platform of the database. Correspondingly, on the side of the online change platform of the database, the online deployment request triggered by an external party, such as the online deployment requester, can be obtained by detecting the input information of the interface, and the online SQL and the identifier of the online cluster included in the online deployment request can be obtained. Similarly, the name of the online deployment form can also be obtained.
[0066] 101. Perform syntax detection and content review on the online SQL;
[0067] For example, in the specific implementation process of this step, the following steps can be included:
[0068] (a1) Perform syntax detection on the online SQL;
[0069] (b1) Determine whether the syntax detection passes; if it passes, execute step (c1); otherwise, if it does not pass, execute step (d1);
[0070] (c1) Perform content review on the online SQL.
[0071] (d1) Generate a non - passing prompt message and display it on the interface for the online deployment requester to refer to.
[0072] In this embodiment, the syntax check of the online SQL includes two aspects of information: the first aspect is to check whether the syntax of the online SQL is correct, and the second aspect is to check whether the operation corresponding to the online SQL is an operation supported by the online change platform of the database; that is, the online change platform of the database in this embodiment does not support all operations. When the syntax check fails, the reason for failure is generated accordingly to indicate whether the failure is due to syntax errors or due to lack of support from the online platform, for reference by the online requester.
[0073] In this embodiment, the generated prompt opinions of failure can be very rich, and can even include modification suggestions. In this way, the online requester can modify the online SQL based on the prompt opinions to make it meet the online requirements.
[0074] In this embodiment, (c1) content review of online SQL may specifically include the following steps:
[0075] A. Perform a semantic check on the online SQL to detect whether the online cluster corresponding to the online cluster identifier includes the corresponding table and / or column in the online SQL; if yes, execute step B; otherwise, confirm that there is an error in the content of the online SQL. Similarly, generate a prompt message of the error content and display it on the interface for the online requester to refer to and modify.
[0076] B. Obtain information about the impact of going online.
[0077] It should be noted that, in this embodiment, the database cluster corresponding to the identifier of the online cluster may include a master database, a slave database, and a standby database, and there is a replication relationship between the master database, the slave database, and the standby database, which can ensure data synchronization. In order to ensure the stability of the data, the master database provides basic services, such as providing replicated data for the standby database and the slave database, the slave database provides online traffic services, and the standby database does not provide online traffic services. Therefore, in this embodiment, when backing up before the online change, the standby database is preferably backed up to avoid affecting the services of the master database and the slave database. When changing online, it is preferred to perform an online change operation on the master database, and then the master database synchronizes the changed data to the standby database and the slave database. In short, when performing any operation on the database cluster, in order to avoid affecting the online traffic service, try not to perform any operation on the slave database. In addition, in order to ensure the security of the data, it is also avoided to perform any operation on the master database and the standby database at the same time, and only one of them can be operated.
[0078] Correspondingly, in order to ensure the security of data in the database cluster, content review is performed on the SQL to be deployed. Specifically, it may further include: detecting whether the standby database corresponding to the identifier of the deployed cluster exists, whether the status of the standby database is normal, whether the replication relationship between the standby database and the primary database is normal, and whether the latency of the standby database replicating the primary database meets the standard; if all of these are normal, it indicates that the data in the database cluster is relatively secure, and then subsequent backup and deployment change operations can be continued. In this embodiment, a latency threshold for the standby database to replicate the primary database can be pre-configured. If the latency is less than this latency threshold, it is considered that the latency meets the standard; otherwise, it is considered that the latency does not meet the standard.
[0079] Specifically, since the SQL to be deployed is used to be executed in the deployed cluster corresponding to the identifier of the deployed cluster. For example, the SQL statement to be deployed can be inserting a column, deleting a column, etc. in a certain deployed cluster; or inserting data, deleting data, or changing data in a certain table in a certain deployed cluster, etc. Therefore, in this embodiment, when performing content review on the SQL to be deployed, the online change platform of the database can perform lexical analysis on the SQL statement to be deployed through its included sqlparserd component to achieve semantic checking of the SQL statement to be deployed, so as to detect whether the deployed cluster corresponding to the identifier of the deployed cluster includes the table and / or column corresponding to the SQL to be deployed. If a certain table or column corresponding to the SQL to be deployed is not included, it is considered that the content of the SQL statement to be deployed is incorrect. At this time, a prompt message for the error content can be generated and displayed on the interface for the deployment requester to refer to and modify. For example, in this embodiment, preferably, in order not to affect the security of the primary database and the online business of the standby database, it can be detected whether the standby database in the deployed cluster corresponding to the identifier of the deployed cluster includes the table and / or column corresponding to the SQL to be deployed.
[0080] In this embodiment, after the content review of the SQL to be deployed is passed, obtaining the deployment impact information is further included. Specifically, it may include: obtaining the deployment type corresponding to the SQL to be deployed; obtaining the corresponding deployment impact metrics according to the deployment type.
[0081] For example, if the deployment type is DDL change, obtain the maximum number of affected rows of a single SQL after the SQL to be deployed is deployed calculated by the standby database corresponding to the identifier of the deployed cluster, as well as the total number of affected rows.
[0082] Since the information of the primary database and the standby database corresponding to the identifier of the online cluster is always kept synchronized, in order not to affect the normal operation of the corresponding primary database and standby database, in this embodiment, the standby database can be accessed to obtain the maximum affected row count and the total affected row count of the online SQL. Taking the existence of at least two online SQLs as an example, the maximum affected row count of each SQL is the maximum value of the affected row counts of each online SQL statement, and the total affected row count is the sum of the affected row counts of all online SQL statements. Specifically, when implementing, the online change platform of the database can create a temporary audit account, and send the online SQL to the standby database corresponding to the online cluster identifier through this temporary audit account. The standby database calculates the affected row count generated after the online SQL is launched in the standby database based on each SQL, and then obtains the maximum affected row count of a single SQL and the total affected row count, and returns them to the online change platform of the database. In this embodiment, the consideration of establishing a temporary audit account is that the temporary audit account is an ordinary account without super permissions, which can ensure the accuracy of information acquisition. Here, the temporary account is automatically recycled after the online change of the database. Moreover, compared with the unified management of audit accounts, using this temporary account can avoid the overhead of unified management of audit accounts and reduce the risk of password leakage. Compared with directly using root, the temporary account can also meet the audit requirements, that is, the information of accessing the DB can be queried.
[0083] If the online type is a DML change, obtain the maximum affected row count of a single insert SQL, the maximum affected row count of a single delete SQL, the maximum affected row count of a single change SQL, and the total affected row count after the online SQL set corresponding to the identifier of the online cluster is calculated by the standby database.
[0084] Since the type of DML is different from DDL, for the online type of DML, the obtained impact metrics include the maximum affected row count of a single insert SQL, the maximum affected row count of a single delete SQL, the maximum affected row count of a single change SQL, and the total affected row count. Specifically, the online SQL may be used to insert, delete, or change information. Therefore, for each SQL, in the same way as the above DDL, the affected row count of a single insert SQL, the affected row count of a single delete SQL, or the affected row count of a single change SQL brought by executing each SQL needs to be obtained from the standby database. Then, from the information corresponding to all SQLs in the online SQL set, filter out the maximum affected row count of a single insert SQL, the maximum affected row count of a single delete SQL, and the maximum affected row count of a single change SQL. And add up the affected row counts of each SQL in at least two online SQLs to obtain the total affected row count.
[0085] It should be noted that in this embodiment, after auditing each SQL in at least two online SQLs in the above manner, corresponding audit reports can be obtained, which may include the standby database corresponding to the operation cluster, i.e., the online cluster identifier, the number of SQLs included in the online SQL set, and each impact index obtained in the above audit. For example Figure 3 As shown, it is a schematic diagram of an audit report provided by the present invention. In practical applications, corresponding audit reports can be generated according to specific scenarios, and no further examples will be given here
[0086] Optionally, in this embodiment, before content auditing of the online request, pre-checking of the online SQL can also be included. This process mainly checks whether each SQL contains special symbols, whether it is in UTF-8 encoding, etc., to make it meet the standards for online execution
[0087] 102. After passing the syntax detection and content auditing, back up the database cluster corresponding to the identifier of the online cluster
[0088] In this embodiment, in order to prevent the database from failing to be changed online and to be able to restore the database cluster before the change in a timely manner, the database cluster corresponding to the online cluster identifier can also be backed up after passing the syntax detection and content auditing. However, backing up all databases in the database cluster may result in a large amount of data and is not necessary. Therefore, in this embodiment, only the tables involved in the online SQL in the database cluster corresponding to the identifier of the online cluster can be backed up. Similarly, in order to ensure the normal operation of the business and the security of the data, in this embodiment, the tables involved in the online SQL in the standby database corresponding to the identifier of the online cluster can be referred to for backup
[0089] The backup in this embodiment can be divided into full backup and differential backup. A full backup means backing up all tables involved in the online SQL in the database cluster corresponding to the identifier of the online cluster, while a differential backup means, relative to before the backup, only backing up the differential data. Comparing the two backup types, the entire process of full backup takes longer time and occupies more storage space, but the backed-up information is more comprehensive. While the entire process of differential backup has less data volume, takes less time, and occupies limited storage space, only backing up the differential data, with relatively less data volume
[0090] In this embodiment, after the backup is completed, a backup result can be displayed on the interface to inform the online requester and relevant approvers. For example Figure 4 It is a schematic diagram of a backup result provided by the present invention. In practical applications, according to the specific backup content, the backup result can also be presented in other ways, and the content displayed in the backup result can also vary with the backup type and the content of the backup data. No further examples will be given here
[0091] In this embodiment, before backup, two backup methods can be specifically displayed on the interface for the online requester to select one of them. Alternatively, the online change platform of the database can give a recommended backup type, and then the online requester can select the backup type to be executed based on the recommendation. For example, a preset row number threshold can be configured in advance. According to the method of the above embodiment, after obtaining the total number of affected rows, the backup type can be obtained based on the total number of affected rows and the preset row number threshold. For example, if the total number of affected rows is greater than or equal to the preset row number threshold, full backup can be selected; if the total number of affected rows is less than the preset row number threshold, differential backup can be selected. Of course, the backup type obtained at this time is only the recommended backup type obtained by the online change platform of the database based on the total number of affected rows and the preset row number threshold. Then the online change platform of the database can display this backup type on the interface for the online requester to confirm whether to select the backup type. Optionally, in this embodiment, the recommended backup type and information about the backup can also be displayed in the audit report, as Figure 3 shown in the audit report.
[0092] Further optionally, in this embodiment, the backup address can be configured in advance, and then it can be detected in advance whether the storage space in the configured address is greater than the size of the database cluster corresponding to the identifier of the online cluster. Only if it is greater can a full backup be guaranteed to be implemented.
[0093] In this embodiment, the online requester can select the recommended backup type or select another backup type according to their subjective judgment. The online change platform of the database can obtain the backup type selected by the online requester through the detection interface. Then, according to the backup type selected by the online requester, preferably, the standby database corresponding to the identifier of the online cluster is backed up. Specifically, the tables involved in the online SQL may only be a very small part of the standby database. Backing up the entire standby database has too much irrelevant information, which will cause a longer backup time. In this embodiment, only the tables involved in the online SQL in the standby database corresponding to the identifier of the online cluster can be backed up.
[0094] In order not to affect the business of the primary database and the standby database, the backup operation of this embodiment is preferably only performed on the standby database. Of course, in actual applications, backup operations can also be performed on all corresponding database clusters or on some of the databases, which is not limited here.
[0095] It should be noted that when the number of SQLs to be put online is small, the impact of going online is small. When the requester for going online is the Research and Development (RD) manager, at this time, the steps of the above-mentioned embodiment can be directly followed. After syntax detection and content review of the SQL to be put online in step 101, the database cluster corresponding to the identifier of the cluster to be put online can be directly backed up according to step 102.
[0096] Optionally, in practical applications, if the requester for going online usually does not have the permission to directly release and go online, the online change platform of this database is configured with strict approval policies. For example, according to the preset approval policies, it can be approved by any one of (1) the RD manager, (2) the DBA, and (3) the Quality Assurance (QA) person in charge, or it can also be approved by any combination of the two, or jointly approved by the RD manager + DBA + QA person in charge. For example Figure 5 This is a schematic diagram of the interface for configuring an approval policy provided by the present invention. As Figure 5 shown, in this approval policy, taking the approval policy corresponding to 3 conditions as an example, condition 1 is not a DDL independent operation, and the maximum number of affected rows per single UPDATE is 10,000; condition 2 is that the maximum number of affected rows per single DELETE is 10,000; the maximum number of affected rows for DML in total is 100,000; as Figure 4 shown, in the customization of the approval process, corresponding approvers are configured for each condition by adding approvers. After configuring the approval policy, in subsequent use, according to the pre-configured approval policy, for the conditions at that time, an approval request carrying the result of the content review can be sent to the corresponding approver account for the approver to approve the going online request according to the result of the content review; and the message of approval passed returned by the approval account is received before further backup can be performed. Of course, if the approver does not agree to approve, at this point, the entire process ends. The result of the content review in this embodiment can include the online impact index for the approver to evaluate the impact of this online based on the online impact index, etc.
[0097] For example, after step 101 and before step 102, it can also include: according to the pre-configured approval policy, sending an approval request carrying the result of the content review to a preset approval account for the approver corresponding to the approval account to approve the going online request according to the result of the content review; and receiving the message of approval passed returned by the approval account before further backup can be performed. Of course, if the approver does not agree to approve, at this point, the entire process ends. The result of the content review in this embodiment can include the online impact index for the approver to evaluate the impact of this online based on the online impact index, etc.
[0098] It should be noted that when the approver agrees to approve, the approver can also manually select to trigger a full backup according to the online impact indicators. At this time, the online change platform of the database receives the request for full backup initiated by the approver, starts to execute the full backup process, and can display the backup progress on the interface. The online requester can also see it on the online change platform of the database. Or the approver can also place no restrictions on the backup and return a message indicating approval. At this time, the online change platform of the database can display the recommended backup type and also display the available backup types. At this time, if the recommended backup type is differential backup, the online requester can also manually trigger a full backup. Or if the recommended backup type is full backup, the online requester selects differential backup. Or the online requester does not modify the recommended backup type and directly clicks to skip, defaulting to agreeing to start backing up according to the recommended backup type. Regardless of who triggers the backup and which backup type is executed, the online change platform of the database will send the corresponding backup type to the standby database corresponding to the identifier of the online cluster, so that the standby database can back up the corresponding standby database according to the backup type, and the entire backup progress can be displayed on the interface of the online change platform of the database. In this embodiment, the standby database corresponding to the identifier of the online cluster is used for backup to prevent the security of the primary database from being affected when the primary database is used for backup, and to prevent the online services of the standby database from being affected when the standby database is used for backup.
[0099] During the specific process of executing the backup, the online change platform of the database can call the backup execution module such as xagent to execute in the standby database corresponding to the identifier of the online cluster. The advantages are as follows:
[0100] a) There is no need to maintain the account and password information of each instance, that is, the database, reducing the risk of leakage of the accounts and passwords of the database cluster, thereby ensuring the security of the database cluster;
[0101] b) There is no need to consider the version information of each database. According to the deployment specifications of general databases, the mysqldump version in the specified directory of each database is the same as the mysql instance on this machine;
[0102] During the process of executing the backup, the online change platform of the database can call its Server module to write the backup structure into a file. The xagent module pulls the file, and after pulling, verifies the md5 of the file, which can avoid the situation of transmission interruption or inconsistent transmitted and received data caused by special symbols during the network transmission process.
[0103] During the backup process, the xagent module calls the local mysqldump for backup and generates SQL statements for subsequent DBA data recovery reference. If the backup file is small, users can obtain the backup data through the interface. If the file data is large, the online change platform of the database can prompt the DBA to obtain the backup file on the interface.
[0104] During the backup process, the Server module sends the backup structure file and md5 to the xagent module. Since the data backup process may take a long time, it is designed as an asynchronous process. If the xagent module successfully pulls the file and verifies that the md5 is correct, the Server module clears the backup structure, and the xagent module calls the backup mysqldump command to start the backup process and calls mysql to generate the backup SQL file.
[0105] The backup data in this embodiment is used to restore the data before the online change if the online change fails subsequently, which can effectively ensure the data security even if the online change fails.
[0106] 103. According to the preset change strategy, use the online SQL to change the database cluster corresponding to the identifier of the online cluster.
[0107] In this embodiment, after backing up the database cluster corresponding to the identifier of the online cluster according to the process of the above embodiment, the database cluster corresponding to the identifier of the online cluster can be changed using the online SQL according to the preset change strategy. In this embodiment, only the online SQL can be used to change the primary database corresponding to the identifier of the online cluster. Since there is already a data synchronization mechanism between the primary database and the standby database, preferably, only the primary database is changed in this embodiment, and the subsequent primary database cluster will use its synchronization mechanism to synchronize the changed data to the corresponding standby databases. Of course, it is also possible to change the primary database and / or standby databases simultaneously.
[0108] The preset change strategy in this embodiment can be to directly execute the change after backup. At this time, the online change platform of the database can display an execution prompt on the interface to inform relevant personnel. To avoid affecting the normal business in the database, it is also possible to set to execute the change during off-peak hours according to the historical cycle. Or it is also possible to set to execute the change at other time points according to requirements, which will not be elaborated one by one here.
[0109] In this embodiment, specifically, the xagent module in the online change platform of the database can execute the change in the standby database corresponding to the identifier of the online cluster. It should be noted that before the xagent module executes the change, the following operations also need to be performed:
[0110] (1) Judge the read_only value of the current database to be changed. If it is 0, continue the execution; otherwise, it means that the current database is not the master database, and the execution is aborted.
[0111] (2) Create a normal account without super permissions. The advantage of using an account without super permissions is that it can effectively prevent a master-slave switch from occurring after judging read_only and before connecting to the database, thereby preventing the occurrence of database inconsistency caused by double writing in the cluster.
[0112] (3) Start executing the online SQL statements. In order to enable participants to clearly see the execution result report, different execution results can be displayed for different execution types.
[0113] For example, a) The select operation will display the execution result; b) The DML operation will display the number of affected rows in the current execution; c) The DDL operation will display the table structure after execution, such as show create table xxx, etc.
[0114] The online change method of the database in this embodiment can realize the online change of the database by adopting the above scheme. In the technical solution of this embodiment, it is automatically completed by the online change platform of the database throughout the process. Compared with the manual implementation of going online in the prior art, it reduces the human cost and time cost required for going online, reduces the complexity of going online, and can effectively improve the efficiency of online change. Moreover, in this embodiment, the online change platform of the database is used to replace manual participation in grammar detection and content review, greatly reducing the probability of errors in going online.
[0115] Figure 6 This is the flowchart of the second embodiment of the online change method of the database of the present invention. In this embodiment, a scenario where one online deployment includes multiple online SQL statements and requires DBA approval is taken as an example to describe the technical solution of the present invention.
[0116] 200. The online requester inputs multiple online SQL statements and the online cluster name for this online deployment on the interface of the online change platform of the database, marks the name of the online order for this online deployment, and clicks the online request button to trigger an online request.
[0117] 201. The online change platform of the database obtains the multiple online SQL statements and the online cluster name input by the online requester through the detection interface.
[0118] 202. The online change platform of the database performs grammar detection on the SQL statements and judges whether the detection passes. If the detection passes, step 203 is executed; otherwise, if it does not pass, step 204 is executed.
[0119] Specifically, the grammar detection method can refer to the aboveFigure 1 The description of the illustrated embodiment will not be repeated here.
[0120] 203. The online change platform of the database conducts content review on the SQL statement and determines whether the review passes; if the content review passes, step 205 is executed; otherwise, if the content review fails, step 206 is executed.
[0121] Similarly, for the specific content review method, reference can be made to the description of the above Figure 1 illustrated embodiment, which will not be repeated here.
[0122] 204. The online change platform of the database generates a prompt opinion that the syntax check fails and displays it on the interface for the online requester to refer to, and the process ends.
[0123] After the online requester modifies according to the prompt opinion, the online request can be initiated again in accordance with the above process.
[0124] 205. The online change platform of the database generates an audit report and displays the audit report on the interface; step 207 is executed.
[0125] As described in the above Figure 1 illustrated embodiment, the content audit report may include the backup type obtained by the online change platform of the database according to the total number of affected rows and the preset row threshold for the requester to refer to.
[0126] 206. The online change platform of the database generates a prompt opinion that the content review fails and displays it on the interface for the online requester to refer to, and the process ends.
[0127] Similarly, after the online requester modifies according to the prompt opinion, the online request can be initiated again in accordance with the above process.
[0128] 207. The online change platform of the database sends an approval request carrying the audit report to the corresponding account of the DBA according to the pre-configured approval policy; step 208 is executed.
[0129] The DBA can view this approval request by logging in to the online change platform of the database, and determine whether to approve this approval in combination with the audit report. If approved, click the approve online button; if not approved, click the reject online button and enter the reason for not approving online on the interface for the online requester to view. Or when the DBA approves the online request, in order to ensure data security, the DBA can even directly manually trigger the selection of full backup to start the backup according to the audit report.
[0130] In this embodiment, taking the need to approve by the DBA in the pre-configured approval policy as an example, in practical applications, if approval needs to be applied to other personnel, the approval can be initiated according to a similar process.
[0131] 208. The online change platform of the database determines whether the result returned by the account corresponding to the DBA is approved. If it is approved, step 209 is executed; otherwise, if it is not approved, the reason for non-approval is displayed and the process ends.
[0132] 209. The online change platform of the database displays the backup type in the audit report to the online requester; step 210 is executed;
[0133] If the backup type is full backup, but the online requester believes that the full backup takes too long, differential backup can be selected.
[0134] 210. The online change platform of the database detects and receives the backup type selected by the online requester, and according to the backup type, backs up the tables corresponding to each online SQL statement in the standby database corresponding to the online cluster name; step 211 is executed;
[0135] The backup in this embodiment is to prevent the change from failing, so that the DBA can restore the original data according to the backed-up data. In this embodiment, the backup path can be pre-configured to facilitate the DBA to accurately obtain the backed-up data.
[0136] 211. The online change platform of the database changes the primary database cluster corresponding to the online cluster name by using multiple SQLs according to the preset change strategy.
[0137] In this embodiment, in order to improve efficiency, only the primary database cluster corresponding to the online cluster name is synchronized with the data of the standby database according to the synchronization strategy between the primary database and the standby database within the database cluster.
[0138] The online change method of the database in this embodiment can realize the online change of the database by adopting the above scheme. In the technical solution of this embodiment, the whole process is automatically completed by the online change platform of the database. Compared with the manual implementation of the online process in the prior art, the manpower cost and time cost required for the online process are reduced, the complexity of the online process is reduced, and the efficiency of the online change can be effectively improved. Moreover, in this embodiment, the online change platform of the database is used to replace manual participation in syntax detection and content review, greatly reducing the probability of errors in the online process. Moreover, in this embodiment, by adding manual review, the security of the online change is further improved.
[0139] Figure 7 This is the structure diagram of the first embodiment of the online change platform of the database of the present invention. As Figure 7 shown, the online change platform of the database in this embodiment may specifically include:
[0140] The obtaining module 10 is used to detect and obtain an externally triggered online request, and the online request includes the online SQL and the identifier of the online cluster;
[0141] The detection and review module 11 is used to perform syntax detection and content review on the online SQL in the online request obtained by the acquisition module 10;
[0142] The backup module 12 is used to back up the database cluster corresponding to the identifier of the online cluster in the online request obtained by the acquisition module 10 after the detection and review module 11 passes;
[0143] The change execution module 13 is triggered and started after the backup module 12 finishes backing up, and changes the database cluster corresponding to the identifier of the online cluster using the online SQL according to the preset change strategy.
[0144] For the online change platform of the database in this embodiment, the implementation principle and technical effect of realizing the online change of the database by adopting the above modules are the same as those of the above related method embodiments. For details, reference can be made to the records of the above related method embodiments, which will not be elaborated here.
[0145] Figure 8 This is the structure diagram of the second embodiment of the online change platform of the database of the present invention. As Figure 8 shown, for the online change platform of the database in this embodiment, on the basis of the technical solution of the above Figure 8 shown embodiment, the following technical solutions may further be included.
[0146] As Figure 8 shown, in the online change platform of the database in this embodiment, the detection and review module 11 includes:
[0147] The detection unit 111 is used to perform syntax detection on the online SQL in the online request obtained by the acquisition module 10;
[0148] The review unit 112 is used to perform content review on the online SQL in the online request obtained by the acquisition module 10 when the detection unit 111 passes the detection.
[0149] Further optionally, as Figure 8 shown, in the online change platform of the database in this embodiment, the following is further included:
[0150] The generation module 14 is used to generate a non-passed prompt opinion if the detection unit 111 fails to pass the syntax detection of the online SQL;
[0151] The display module 15 is used to display the non-passed prompt opinion generated by the generation module 14 on the interface for the reference of the online requester.
[0152] Further optionally, the review unit 112 is used for:
[0153] Semantically check the online SQL in the online request obtained by the acquisition module 10 to detect whether the tables or columns corresponding to the online SQL are included in the online cluster corresponding to the identifier of the online cluster; if included, obtain the online impact information.
[0154] Further optionally, the auditing unit 112 is specifically configured to:
[0155] Obtain the online type corresponding to the online SQL;
[0156] Obtain the corresponding online impact metrics according to the online type.
[0157] Further optionally, the auditing unit 112 is specifically configured to:
[0158] If the online type is DDL change, obtain the maximum number of affected rows for each single online SQL after going online calculated by the standby database corresponding to the identifier of the online cluster, and the total number of affected rows;
[0159] If the online type is DML change, obtain the maximum number of affected rows for each single insert SQL after going online calculated by the standby database corresponding to the identifier of the online cluster, the maximum number of affected rows for a single delete SQL, the maximum number of affected rows for a single change SQL, and the total number of affected rows.
[0160] Further optionally, in the online change platform of the database in this embodiment:
[0161] The acquisition module 10 is further configured to obtain the backup type according to the total number of affected rows and a preset row threshold;
[0162] The display module 15 is further configured to display the backup type for the online requester to confirm whether to select the backup type;
[0163] The backup module 12 is specifically configured to back up the standby database corresponding to the identifier of the online cluster according to the backup type selected by the online requester.
[0164] Further optionally, as Figure 8 shown, the online change platform of the database in this embodiment further includes an approval processing module 16 for:
[0165] According to a pre-configured approval policy, initiate an approval request carrying the online impact metrics obtained by the auditing unit 112 to a preset approval account for the approval personnel corresponding to the approval account to approve the online request according to the online impact metrics;
[0166] And receive the approval passed message returned by the approval account.
[0167] The online change platform of the database in this embodiment realizes the implementation principle and technical effects of the online change of the database by adopting the above modules, which are the same as those of the above related method embodiments. For details, reference can be made to the records of the above related method embodiments, and details will not be repeated here.
[0168] Figure 9 It is a structural diagram of an embodiment of a computer device of the present invention. As Figure 9 shown, the computer device in this embodiment includes: one or more processors 30, and a memory 40. The memory 40 is used to store one or more programs. When one or more programs stored in the memory 40 are executed by one or more processors 30, the one or more processors 30 implement the online change method of the database in the embodiments as described above Figure 1 and Figure 6 shown. Figure 9 In the illustrated embodiment, an example of including multiple processors 30 is taken.
[0169] For example, Figure 10 It is an example diagram of a computer device provided by the present invention. Figure 10 It shows a block diagram of an exemplary computer device 12a suitable for implementing the embodiments of the present invention. Figure 10 The shown computer device 12a is only an example and should not bring any limitation to the functions and usage scope of the embodiments of the present invention.
[0170] As Figure 10 shown, the computer device 12a is presented in the form of a general-purpose computing device. The components of the computer device 12a may include, but are not limited to: one or more processors 16a, a system memory 28a, and a bus 18a connecting different system components (including the system memory 28a and the processor 16a).
[0171] The bus 18a represents one or more of several types of bus structures, including a memory bus or a memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the multiple bus structures. For example, these architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
[0172] The computer device 12a typically includes a variety of computer system-readable media. These media can be any available media that can be accessed by the computer device 12a, including volatile and non-volatile media, removable and non-removable media.
[0173] System memory 28a may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30a and / or cache memory 32a. Computer device 12a may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34a can be used for reading and writing on non-removable, non-volatile magnetic media ( Figure 10 not shown, typically referred to as a "hard disk drive"). Although Figure 10 not shown in, a disk drive for reading and writing on removable non-volatile disks (such as "floppy disks") and an optical disk drive for reading and writing on removable non-volatile optical disks (such as CD-ROM, DVD-ROM or other optical media) can be provided. In these cases, each drive can be connected to bus 18a through one or more data media interfaces. System memory 28a may include at least one program product having a set (such as at least one) of program modules configured to perform the functions of the above Figures 1 - 8 embodiments of the present invention.
[0174] A program / utility 40a having a set (at least one) of program modules 42a can be stored, for example, in system memory 28a. Such program modules 42a include - but are not limited to - an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include the implementation of a network environment. Program modules 42a generally perform the functions and / or methods in the above Figures 1 - 8 embodiments described in the present invention.
[0175] Computer device 12a can also communicate with one or more external devices 14a (such as a keyboard, a pointing device, a display 24a, etc.), can also communicate with one or more devices that enable a user to interact with the computer device 12a, and / or can communicate with any device that enables the computer device 12a to communicate with one or more other computing devices (such as a network card, a modem, etc.). Such communication can be carried out through an input / output (I / O) interface 22a. And, computer device 12a can also communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 20a. As shown in the figure, network adapter 20a communicates with other modules of computer device 12a through bus 18a. It should be understood that although not shown in the figure, other hardware and / or software modules can be used in conjunction with computer device 12a, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0176] The processor 16a executes various functional applications and data processing by running the programs stored in the system memory 28a, such as implementing the online change method of the database shown in the above embodiments.
[0177] The present invention also provides a computer-readable medium, on which a computer program is stored, and when the program is executed by a processor, it implements the online change method of the database shown in the above embodiments.
[0178] The computer-readable medium of this embodiment may include the RAM 30a, and / or the cache memory 32a, and / or the storage system 34a in the system memory 28a in the above Figure 10 shown embodiments.
[0179] With the development of technology, the dissemination path of computer programs is no longer limited to tangible media, and can also be directly downloaded from the network or obtained in other ways. Therefore, the computer-readable medium in this embodiment may include not only tangible media, but also intangible media.
[0180] The computer-readable medium of this embodiment may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (non-exhaustive list) of the computer-readable storage medium include: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0181] The computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries the computer-readable program code. Such a propagated data signal may take various forms, including - but not limited to - electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0182] The program code contained on a computer-readable medium can be transmitted with any suitable medium, including - but not limited to - wireless, wire, optical fiber cable, RF, etc., or any suitable combination of the above.
[0183] The computer program code for performing the operations of the present invention can be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., by using an Internet service provider to connect through the Internet).
[0184] In several embodiments provided by the present invention, 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 merely illustrative. For example, the division of the units is only a logical function division, and there can be other division methods in actual implementation.
[0185] The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0186] In addition, the functional units in each embodiment of the present invention can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated units can be implemented in the form of hardware or in the form of a combination of hardware and software functional units.
[0187] The integrated units implemented in the form of software functional units can be stored in a computer-readable storage medium. The above-mentioned software functional units stored in a storage medium include a number of instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to execute some steps of the methods described in the various embodiments of the present invention. The foregoing storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs.
[0188] The foregoing is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included within the scope of protection of the present invention.
Claims
1. An online change method for a database, characterized in that, The method includes: Detect and obtain an externally triggered online request, where the online request includes an online SQL and an identifier of the online cluster; Perform syntax detection and content review on the online SQL; After the syntax detection and content review are passed, back up the database cluster corresponding to the identifier of the online cluster; According to a preset change strategy, use the online SQL to change the database cluster corresponding to the identifier of the online cluster; The backup of the database cluster corresponding to the identifier of the online cluster specifically includes: backing up the standby database corresponding to the identifier of the online cluster according to the backup type selected by the online requester; Before backing up the database cluster corresponding to the identifier of the online cluster, the method further includes: Obtain the backup type according to the total affected row count and a preset row count threshold; the total affected row count is the sum of the affected row counts of all online SQLs; the affected row count of an online SQL is the affected row count generated after the online SQL is deployed in the standby database calculated by the standby database; Display the backup type for the online requester to confirm whether to select the backup type.
2. The method according to claim 1, characterized in that, Performing syntax detection and content review on the online SQL includes: Perform syntax detection on the online SQL; And when the detection is passed, perform content review on the online SQL.
3. The method according to claim 2, characterized in that, The method further includes: If the syntax detection of the online SQL fails, generate a non-passed prompt message and display it on the interface for the online requester to refer to.
4. The method according to claim 2, characterized in that, Performing content review on the online SQL includes: By performing semantic checking on the online SQL, detect whether the online cluster corresponding to the identifier of the online cluster includes the tables or columns corresponding to the online SQL; If included, obtain the online impact information.
5. The method according to claim 4, characterized in that, Obtaining the online impact information includes: Obtain the online type corresponding to the online SQL; Obtain the corresponding online impact metrics according to the online type.
6. The method according to claim 5, characterized in that, Obtaining the corresponding online impact metrics according to the online type includes: If the online type is DDL change, obtain the maximum affected row count of each single online SQL and the total affected row count after the online SQLs are deployed in the standby database corresponding to the identifier of the online cluster; If the online type is DML change, obtain the maximum affected row count of each single insert SQL, the maximum affected row count of each single delete SQL, the maximum affected row count of each single change SQL, and the total affected row count after the online SQLs are deployed in the standby database corresponding to the identifier of the online cluster.
7. The method according to claim 1, characterized in that, Before backing up the database cluster corresponding to the identifier of the online cluster after performing syntax detection and content review on the online request, the method further includes: According to a pre-configured approval policy, initiate an approval request carrying the result of the content review to a preset approval account for the approver corresponding to the approval account to approve the online request according to the result of the content review; And receive the approval passed message returned by the approval account.
8. An online change platform for a database, characterized in that, The platform includes: An acquisition module, configured to detect and acquire an online request triggered externally, where the online request includes an online SQL and an identifier of an online cluster; A detection and audit module, configured to perform syntax detection and content audit on the online SQL; A backup module, configured to back up the database cluster corresponding to the identifier of the online cluster; A change execution module, configured to change the database cluster corresponding to the identifier of the online cluster according to a preset change strategy using the online SQL; The backup module is specifically configured to back up the standby database corresponding to the identifier of the online cluster according to the backup type selected by the online requester; The acquisition module is further configured to acquire a backup type according to the total affected row count and a preset row count threshold; the total affected row count is the sum of the affected row counts of all online SQLs; the affected row count of the online SQL is the affected row count generated after the online SQL is put online in the standby database calculated by the standby database; A display module is further configured to display the backup type for the online requester to confirm whether to select the backup type.
9. The platform according to claim 8, wherein, The detection and audit module includes: A detection unit, configured to perform syntax detection on the online SQL; An audit unit, configured to perform content audit on the online SQL when the detection is passed.
10. The platform according to claim 9, wherein, The platform further includes: A generation module, configured to generate a non-passed prompt opinion if the detection unit fails to pass the syntax detection of the online SQL; A display module, configured to display on the interface for the reference of the online requester.
11. The platform according to claim 10, wherein, The audit unit is configured to: Detect whether the online cluster corresponding to the identifier of the online cluster includes the corresponding table or column in the online SQL by performing semantic check on the online SQL; If included, acquire online impact information.
12. The platform according to claim 11, wherein, The audit unit is specifically configured to: Acquire the online type corresponding to the online SQL; Acquire the corresponding online impact indicator according to the online type.
13. The platform according to claim 12, wherein, The audit unit is specifically configured to: If the online type is a DDL change, acquire the maximum affected row count of each single online SQL and the total affected row count after the online SQLs are put online calculated by the standby database corresponding to the identifier of the online cluster; If the online type is a DML change, acquire the maximum affected row count of each single insert SQL, the maximum affected row count of each single delete SQL, the maximum affected row count of each single change SQL, and the total affected row count after the online SQLs are put online calculated by the standby database corresponding to the identifier of the online cluster.
14. The platform according to claim 8, wherein, The platform further includes an approval processing module, configured to: Initiate an approval request carrying the online impact indicator to a preset approval account according to a pre-configured approval strategy for the approval personnel corresponding to the approval account to approve the online request according to the online impact indicator; And receive a message of approval passed returned by the approval account.
15. A computer device, wherein, The device includes: One or more processors; A memory, configured to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1-7.
16. A computer-readable medium having a computer program stored thereon, wherein, When executed by a processor, the program implements the method as described in any one of claims 1-7.
Citation Information
Patent Citations
SQL (Structured Query Language) statement auditing method, and database operation and maintenance method and system
CN104391995A
Script auditing method and device
CN109710518A