Data processing method and device and electronic equipment

By detecting the synchronization delay and disk pressure of the MySQL master-slave database, calculating the rewrite value, and optimizing the disk flushing mechanism, it solves the problem of reduced disk writing efficiency caused by the synchronization delay of the MySQL master-slave database under high concurrency, and achieves automated efficiency improvement.

CN118796936APending Publication Date: 2024-10-18ZUNYI BRANCH OF CHINA MOBILE GRP GUIZHOU COMPANY +1
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202311654362.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-01
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

In high-concurrency business systems, the default parameter configuration of the MySQL master-slave database affects the disk IO writing performance, causing the master-slave database data synchronization delay and reducing the disk writing efficiency. The existing technology requires manual intervention and takes a long time. .

Method used

By collecting system resource information and database performance indicators, we can detect the synchronization delay between the master and slave databases, collect disk pressure parameters, calculate the rewrite value of the disk brush mechanism, and rewrite the database log brush mechanism to improve the efficiency of data writing to disk. .

Benefits of technology

Automatically detect and optimize the disk flushing mechanism of MySQL master-slave database, improve the efficiency of data writing to disk, avoid manual intervention, and solve the problem of reduced disk writing efficiency caused by master-slave database synchronization delay.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118796936A_ABST
    Figure CN118796936A_ABST
Patent Text Reader

Abstract

The invention discloses a data processing method and device and electronic equipment, and relates to the technical field of cloud computing and big data. The method comprises the following steps: collecting system resource information and database performance indexes; detecting whether synchronization delay exists between the slave database and the master database or not through the system resource information and the database performance indexes; under the condition that the synchronous delay exists, collecting a disk pressure parameter, and judging the read-write pressure of the disk according to the disk pressure parameter; and under the condition of judging that the writing pressure of the disk is relatively high, calculating a rewriting value of the disk refreshing mechanism, and rewriting the log disk refreshing mechanism of the database. Compared with a mode of manual intervention when the master-slave data synchronization delay is large in a related technical scheme, the method has the advantages that the rewrite value of the optimal disk refreshing mechanism is calculated, and the log disk refreshing mechanism of the database is rewritten based on the rewrite value, so that the efficiency of writing the data into the disk is improved; the problem that the disk writing efficiency is reduced due to delay during synchronization of master and slave databases is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of cloud computing and big data, and in particular to a data processing method, device and electronic device. Background Art

[0002] MySQL is a lightweight relational database that is widely used. For MySQL, in a high-concurrency business system, if the reading and writing of business data are all on the master database, it will cause huge overhead on the performance and processing capacity of the master database. Therefore, the business data flow can be read and written separately. The write-related traffic data is processed by the master database, while the slave database shares the reading function. In this case, when the reading and writing of the business system are amortized to the master and slave databases, in order to ensure the consistency of data in the master and slave databases, transactions need to be committed. MySQL needs to write the commit mark of the transaction log bin-log into the redo log redo-log data file.

[0003] However, the speed of committing transactions in the storage engine of the database is affected by the default parameter configuration (such as innodb_flush_log_at_trx_commit, sync_binlog, etc.). Each time a transaction is committed, the synchronization function fsync will be called to operate the disk. When the concurrency of the MySQL database is large, these default configuration parameters will affect the disk IO write performance, and then affect the transaction write speed. It may cause the master database to write data that cannot be queried from the slave database or the query timeout, causing data synchronization delays between the master and slave databases and reducing the disk write efficiency. In order to solve this problem in the related art, manual intervention is usually required, and the processing process is very time-consuming. Summary of the invention

[0004] In view of this, the present application provides a data processing method, device and electronic device, the main purpose of which is to improve the current problem that due to the default parameter configuration, there will be delays in the synchronization of master and slave databases, resulting in reduced disk writing efficiency.

[0005] In a first aspect, the present application provides a data processing method, comprising:

[0006] Collect system resource information and database performance indicators;

[0007] Detecting whether there is a synchronization delay between the slave database and the master database through the system resource information and the database performance index;

[0008] In the case of synchronization delay, collecting disk pressure parameters, and judging the read and write pressure of the disk by the disk pressure parameters;

[0009] When it is determined that the write pressure of the disk is relatively large, the rewrite value of the disk flushing mechanism is calculated, and the log disk flushing mechanism of the database is rewritten.

[0010] Optionally, when it is determined that the write pressure of the disk is large, the rewrite value of the disk flushing mechanism is calculated, and the log disk flushing mechanism of the database is rewritten, including: calculating the rewrite value through the system resource information and the database performance index; and rewriting the disk flushing mechanism of the redo log and the transaction log based on the rewrite value.

[0011] Optionally, the transaction log disk flushing mechanism is rewritten based on the rewrite value, including: reading the preset value of the transaction log disk flushing mechanism in the configuration parameters; when the rewrite value is greater than the preset value, replacing the preset value with the rewrite value, and storing the transaction log data in batches into the cache for disk flushing according to the number of the rewrite values.

[0012] Optionally, the redo log disk flushing mechanism is rewritten based on the rewrite value, including: reading the optional value of the redo log disk flushing mechanism in the configuration parameters; after storing the transaction log data in batches into the cache for disk flushing according to the number of preset values, determining the highest score of the redo log disk flushing mechanism in the optional values ​​through a binary search algorithm; and rewriting the redo log disk flushing mechanism using the highest score.

[0013] Optionally, the disk read and write pressure is determined by the disk pressure parameters, including: collecting the disk pressure parameters; comparing the disk pressure parameters at the current moment with the disk pressure parameters at the previous moment, if the disk pressure parameters at the current moment are greater than the disk pressure parameters at the previous moment and greater than a preset threshold, it is determined that the current disk read and write pressure is greater.

[0014] Optionally, collecting the disk pressure parameter includes: collecting the number of disk operations and the number of disk writes per second within a preset time period; and calculating the average number of disk operations and the average number of disk writes as the disk pressure parameter collected at that time.

[0015] Optionally, detecting whether there is a synchronization delay between the slave database and the master database through the system resource information and the database performance indicators includes: reading a current log update point and a recent log update point; calculating a synchronization delay time based on the current log update point and the recent log update point; reading a delay monitoring threshold, and calculating a delay multiplier using the synchronization delay time and the delay monitoring threshold; and judging whether there is a synchronization delay between the slave database and the master database based on the delay multiplier.

[0016] In a second aspect, the present application provides a data processing device, comprising:

[0017] A collection unit configured to collect system resource information and database performance indicators;

[0018] a detection unit configured to detect whether there is a synchronization delay between the slave database and the master database through the system resource information and the database performance indicator;

[0019] A judgment unit is configured to collect disk pressure parameters in the presence of synchronization delay, and judge the read and write pressure of the disk by the disk pressure parameters;

[0020] The processing unit is configured to calculate a rewrite value of a disk flushing mechanism and rewrite the log disk flushing mechanism of the database when it is determined that the write pressure of the disk is large.

[0021] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the data processing method described in the first aspect.

[0022] In a fourth aspect, the present application provides an electronic device, comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements the data processing method described in the first aspect when executing the computer program.

[0023] By means of the above technical scheme, a data processing method, device and electronic device provided by the present application, the present application first detects the performance index of the mysql master-slave database server, that is, collects system resource information and database performance index, and then detects whether there is a synchronization delay between the slave database and the master database through the system resource information and database performance index. In the case of synchronization delay, the disk pressure parameter is collected, and the read and write pressure of the disk is judged by the disk pressure parameter. When it is determined that the write pressure of the disk is large, the rewrite value of the disk brushing mechanism is calculated, and the log disk brushing mechanism of the database is rewritten. Compared with the method of manual intervention in the related technical scheme when the master-slave data synchronization delay is large, the present application detects the performance index of the mysql master-slave database server, and calculates the rewrite value of the optimal disk brushing mechanism when the master-slave data synchronization delay and the disk pressure are large, and rewrites the log disk brushing mechanism of the database based on the rewrite value, thereby improving the efficiency of data writing to the disk, and solving the problem that there will be delays in the synchronization of the master-slave database, resulting in reduced disk writing efficiency.

[0024] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0026] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0027] Figure 1 A schematic diagram of a data processing method provided in an embodiment of the present application is shown;

[0028] Figure 2 A structural schematic diagram of a data processing device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0029] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the scheme of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.

[0030] In order to improve the problem that due to the default parameter configuration, there is a delay in the synchronization of the master and slave databases, resulting in reduced disk writing efficiency, this embodiment provides a data processing method, such as Figure 1 As shown, the method includes:

[0031] S101, collecting system resource information and database performance indicators.

[0032] Database performance indicators refer to various performance and information indicators of the MySQL database, including master-slave synchronization status indicators, synchronization delay time, etc., which are used to calculate the delay between the master and slave databases and the subsequent rewrite value. They can be obtained through the point value of the thread, the execution position of the log, etc. System resource information refers to the database service status and system resources, and is used to analyze whether the operating system memory and CPU resources are bottlenecks, analyze the disk pressure, and calculate the subsequent rewrite value.

[0033] S102, detecting whether there is a synchronization delay between the slave database and the master database through system resource information and database performance indicators.

[0034] Specifically, it is possible to determine whether there is a synchronization delay by calculating the delay time and delay multiplier between the master and slave databases.

[0035] S103, in the case of synchronization delay, collecting disk pressure parameters, and determining the read and write pressure of the disk according to the disk pressure parameters.

[0036] The disk pressure parameter is used to determine the current read and write pressure of the disk. Specifically, the average number of disk operations and the average number of disk writes can be used as the disk pressure parameter.

[0037] S104: When it is determined that the write pressure of the disk is high, the log flushing mechanism of the database is rewritten.

[0038] In this embodiment, firstly, by detecting the MySQL master-slave database server performance index, that is, collecting system resource information and database performance index, and then by the system resource information and database performance index, detecting whether there is a synchronization delay between the slave database and the master database. In the case of synchronization delay, the disk pressure parameter is collected, and the disk read and write pressure is judged by the disk pressure parameter. When it is determined that the disk write pressure is large, the rewrite value of the disk brushing mechanism is calculated, and the log disk brushing mechanism of the database is rewritten. Compared with the method of manual intervention in the related technical scheme when the master-slave data synchronization delay is large, this embodiment detects the MySQL master-slave database server performance index, and in the case of master-slave data synchronization delay and disk pressure is large, the rewrite value of the optimal disk brushing mechanism is calculated, and the log disk brushing mechanism of the database is rewritten based on the rewrite value, thereby improving the efficiency of data writing to the disk, and solving the problem that there will be delays in the synchronization of the master-slave database, resulting in reduced disk writing efficiency.

[0039] Optionally, when it is determined that the write pressure of the disk is high, the rewrite value of the disk flushing mechanism is calculated, and the log disk flushing mechanism of the database is rewritten, including: calculating the rewrite value through system resource information and database performance indicators; and rewriting the disk flushing mechanism of the transaction log and redo log based on the rewrite value.

[0040] In this embodiment, the transaction log is also called bin-log, and the redo log is also called redo-log. The rewrite value is a better number value calculated by system resource information and database performance indicators, which means that when the transaction log submits data to the disk in a single batch for disk flushing, the number of transactions or data corresponding to the rewrite value is submitted to the disk, thereby improving the write rate and avoiding synchronization delay.

[0041] Optionally, the transaction log flushing mechanism is rewritten based on the rewrite value, including: reading the preset value of the transaction log flushing mechanism in the configuration parameters; when the rewrite value is greater than the preset value, replacing the preset value with the rewrite value, and storing the transaction log data in batches into the cache for flushing according to the number of rewrite values.

[0042] In this embodiment, the preset value of the bin-log log flushing mode in the MySQL configuration parameters is read, and the preset value is that the existing MySQL submits transactions or data to the disk according to the number of times corresponding to the preset value by default. The purpose of this embodiment is to modify the preset value by calculating a better rewrite value, and submit transactions or data to the disk according to the number of times corresponding to the rewrite value, thereby improving the write rate.

[0043] Optionally, the redo log disk flushing mechanism is rewritten based on the rewrite value, including: reading the optional value of the redo log disk flushing mechanism in the configuration parameters; after storing the transaction log data in batches into the cache for disk flushing according to the number of preset values, determining the highest score of the redo log disk flushing mechanism in the optional values ​​through a binary search algorithm; and rewriting the redo log disk flushing mechanism using the highest score.

[0044] In this embodiment, the flushing mechanism of the innodb storage engine in the mysql database is controlled by a configuration parameter (flush_log_at_trx_commit), and its optional values ​​are 0, 1, and 2. After the transaction log data is stored in batches into the cache for flushing, the highest score of the flushing mechanism for the redo log is determined from the optional values ​​through a binary search algorithm, and then the flushing mechanism of the redo-log log is rewritten using the highest score.

[0045] Optionally, the read and write pressure of the disk is determined by disk pressure parameters, including: collecting the disk pressure parameters; comparing the disk pressure parameters at the current moment with the disk pressure parameters at the previous moment, if the disk pressure parameters at the current moment are greater than the disk pressure parameters at the previous moment and greater than a preset threshold, it is determined that the current disk read and write pressure is greater.

[0046] In this embodiment, the disk pressure parameters may include the number of disk operations per second (tps) and the number of disk writes (wrs) within a preset time period, and are compared with the disk pressure parameters at the previous moment to determine the current disk read and write pressure, so that the disk flushing mechanism can be rewritten when the disk pressure is high.

[0047] Optionally, collecting disk pressure parameters includes: collecting the number of disk operations and the number of disk writes per second in a preset time period; and calculating the average number of disk operations and the average number of disk writes as the disk pressure parameters collected at that time.

[0048] In this embodiment, the preset time period is 10 seconds as an example, and 10 groups of disk operation times are obtained, such as tps = {3, 5, 2, 4, 5, ..., 5}; 10 groups of disk write times wrs = {19, 14, 16, 17, ..., 14}, and then the average disk operation times and the average disk write times are calculated, and the current disk operation times are compared with the average disk operation times at the previous moment, and the current disk write times are compared with the average disk write times at the previous moment, so as to judge the disk pressure. It should be noted that when judging the disk pressure, it can be determined that the disk pressure is large if the current value of the disk operation times or the disk write times is greater than the previous moment; it can also be determined that the disk pressure is large if the disk pressure parameter at the current moment is greater than the disk pressure parameter at the previous moment. The specific needs are determined according to the actual disk usage. For the case where both the disk operation times and the disk write times are small, it is preferred to use the condition that both are satisfied at the same time to determine that the disk pressure is large.

[0049] Optionally, through system resource information and database performance indicators, detect whether there is a synchronization delay between the slave database and the master database, including: reading the current log update point and the recent log update point; calculating the synchronization delay time according to the current log update point and the recent log update point; reading the delay monitoring threshold, and using the synchronization delay time and the delay monitoring threshold to calculate the delay multiplier; according to the delay multiplier, determine whether there is a synchronization delay between the slave database and the master database.

[0050] In this embodiment, when detecting whether there is a synchronization delay, the synchronization delay time is calculated by reading the current log update point and the recent log update point, and then the delay multiplier is calculated to determine whether there is a synchronization delay between the slave database and the master database.

[0051] In order to facilitate the understanding of the data processing method proposed in this scheme, the method proposed in this embodiment is described from the perspective of an actual processing device. First, the flow of data read and written by the business system is generally carried out on the master database. For general business peaks, the master database can support this data flow. However, as the number of users of the business system increases to a certain amount, the number of concurrent user accesses increases. At this time, the master database not only has to bear large concurrent user data queries, but also has to bear the increase of user data, which may increase the load of the master database. When the MySQL database is temporarily overloaded, an effective optimization method is to separate business data reading and writing. The master database on the database side writes data as the master database and reads data from the slave database, so that the slave database can share the query pressure of the original master database. However, the original default configuration parameters in the database will affect the disk IO write performance, and then affect the transaction write speed, which may cause the master database to write data that cannot be queried from the slave database or the query timeout, causing the data synchronization of the master and slave databases to be delayed, reducing the problem of disk write efficiency.

[0052] This embodiment collects various performance and information indicators of the MySQL database to detect whether there is a delay in the slave database when synchronizing the master database transaction. When there is a delay in database synchronization, the transaction concurrency of the current database, the disk IO read and write pressure, etc. are automatically analyzed. If the delay is greater than the monitoring threshold, the disk IO write pressure is automatically determined, and the rewrite value is calculated based on the database log information. The rewrite value is placed in the buffer cache as the number of submitted transactions for batch submission to avoid increasing the IO load of the data disk due to frequent disk flushing. At the same time, the disk flushing mechanism of the storage engine log is dynamically configured to improve the synchronization rate of the master and slave databases, thereby avoiding delays.

[0053] First, the device will actively initiate monitoring of the MySQL database, collect system resource information and database performance indicators, including master-slave synchronization status indicators, and check whether the replication thread status on the slave is normal. In the MySQL replication architecture, two replication threads are mainly generated on the slave. One is the IO-Thread thread for connection, which opens the binlogdump dump thread on the master library to read the binlog information and write it into its own relay log. The other is the SQL-Thread thread, which is used to read the relay log information and parse the unexecuted transactions to replay the data on this library.

[0054] At the same time, the synchronization delay time is calculated, and the judgment is made through the master database log currently read by the slave database, the log currently executed by the slave database, the current transaction position of the master database, and the position executed by the slave database. If there is no synchronization delay, the device is informed that the current master-slave database data synchronization is normal, otherwise it is determined that there is a synchronization delay. The specific example is as follows:

[0055] Master_Log_File = bin.000006 (the latest bin-log file read by the IO thread)

[0056] Read_Master_Log_Pos = 238467 (the latest relay position read by the SQ thread)

[0057] Relay_Log_File = relay.000012 (the latest relay file read by the SQ thread)

[0058] Relay_Log_Pos = 236290 (the latest relay point executed by the SQ thread)

[0059] Relay_Master_Log_File = bin.000006 (SQ thread executes to the binary log containing most recent events)

[0060] Exec_Master_Log_Pos = 236290 (SQ thread executes to the binary log position)

[0061] Seconds_Behind_Master = 1903 (the time that the slave database syncs with the master database)

[0062] The above data is the system resource information and database performance index collected by the device, and may include other parameters depending on the specific application. In this embodiment, the above parameters can be calculated. Further, the synchronization delay time and delay ratio are calculated by the above data:

[0063] If the bin-log numbers displayed by Relay_Master_Log_File and Master_Log_File differ greatly, and the transaction positions of Read_Master_Log_Pos(rlp) and Exec_Master_Log_Pos(elp) differ greatly, it means that the bin-log is not synchronized in time on the slave database. Calculate the transaction position difference according to the formula:

[0064] dlp = rlp - elp; rlp is the current delay time, and mt is the delay monitoring threshold during the off-peak period. The device records the delay multiplier dlp value calculated in this round of collection.

[0065] Take the monitoring threshold mt of database synchronization delay as 500, the currently collected delay time dt is 1903, and calculate the current delay multiplier according to the formula:

[0066] dtp = dt / mt = 3.8; dt is the current delay time, and mt is the delay monitoring threshold during the off-peak period. The calculation results show that the current master-slave data synchronization delay is 3.8 times the monitoring threshold. The device will record the delay multiplier dtp and compare it with the next collection.

[0067] Judging from the dlp and dtp numerical results, it can be determined that the current master-slave database data synchronization delay is 3.8 times the monitoring threshold, thereby determining that there is a synchronization delay between the master and slave databases. A threshold can also be set, and if the delay ratio is greater than the threshold, it is determined that there is a synchronization delay. In this embodiment, if the delay ratio is greater than 1, it is determined that there is a synchronization delay.

[0068] Furthermore, in the case of synchronization delay, analyze whether the operating system memory and CPU resources are bottlenecks, obtain the mysql process information to obtain the disk partition information used by the DB service, and then further analyze the read and write status of the data disk, and calculate the disk pressure parameters including the average number of disk operations and the average number of disk writes. By comparing the disk pressure parameters with the disk pressure parameters of the previous moment (and the preset pressure threshold), the IO pressure of the disk can be determined. For example, taking n times collected within the preset time period as an example:

[0069] Number of disk operation times: tps = [tp1, tps2, tps3, tps4, rps5, ..., tpns]

[0070] Number of disks written: wrs = [wrs1, wrs2, wrs3, wrs4, wrs5, ... wrsn]

[0071] According to the formula, we can get the average number of disk operations tpsA and the average number of disk writes wrsA:

[0072] tpsA=(wc1+wc2+wc3+....+wcN) / n=1896.00

[0073] wrsA=(rc1+rc2+rc3+…+rcN) / n=487995.00

[0074] The device records the tpsA and wrsA information and compares it with the previous collection. If the current tpsA is greater than the previous moment (and greater than the preset threshold) or the current wrsA is greater than the previous moment wrsA (and greater than the preset threshold), it is determined that the write pressure of the disk is large. In this embodiment, if one of the two conditions is met, it is determined that the pressure is large. If the actual disk read and write times are small, it can also be determined that the pressure is large if both conditions are met.

[0075] By analyzing the transaction volume, concurrency, and active number of the current database server (obtained in advance through system resource information and database performance indicators), MySQL will flush the data updated by each transaction to disk by default. MySQL may generate multiple transactions per second when there is high concurrency. If an fsync operation is performed each time it is flushed, it will undoubtedly increase the disk IO load. Therefore, we can analyze and calculate the optimal value, that is, the rewrite value, and put the rewrite value pn transactions into the burrer cache, and then submit the data to the disk in batches.

[0076] Determine the rewrite value pn by the formula:

[0077]

[0078] Where, dlp is the transaction site difference, n is the number of collections, wrsA is the average disk write, dtp is the delay multiplier, tb is the number of concurrency, th is the active session, rlen is the log write queue size, and t is the time.

[0079] Then read the preset value of the bin-log disk flushing mechanism in the configuration parameters as 1, calculate the pn value as 15, then change the preset value to 15, store 35 transaction log data in batches into the cache, and flush the batch commit log data to the disk, reducing the number of frequent fsync disk operations and disk IO overhead. This completes the rewriting of the bin-log disk flushing mechanism.

[0080] Then the flushing mechanism of redo-log is rewritten. Since the flushing mechanism of innodb storage engine in MySQL database is controlled by flush_log_at_trx_commit parameter, the optional values ​​are 0, 1, and 2. Then, bin-log logs are stored in the cache in batches according to the rewritten values ​​after being rewritten. Through the binary search algorithm, the highest score of the flushing mechanism of redo log is determined to be 2 in the optional values. Part of the algorithm is as follows:

[0081] def calpri(rdl,item):

[0082] first=0

[0083] last=len(rdl)-1

[0084] while first<=last:

[0085] mid=(first+last) / / 2

[0086] if rdl[mid] <item;

[0087] first=mid+1

[0088] elif rdl[mid]>item;

[0089] last=mid-1

[0090] else:

[0091] return mid

[0092] rdl=[0,1,2]

[0093] n = print(calpri(rdl,2))

[0094] Then set the redo-log parameter to the highest score of 2 to improve disk synchronization efficiency.

[0095] In the above embodiment, by detecting indicators such as the performance synchronization status of the MySQL database server, when the database synchronization delay is large, by calculating and determining the number of transaction logs rewritten by batch submission, a reasonable binlog disk flushing mechanism is dynamically set, and the highest score is found from the redo-log optional value list through an algorithm. The redo-log disk flushing mechanism is dynamically set, and reasonable combination parameters ({innodb_flush_log_at_trx_commit, sync_binlog)) are set to rewrite the data disk flushing mechanism to avoid frequent fsync operations, effectively improve the disk IO write performance, and effectively ensure the consistency and real-time synchronization of master-slave data.

[0096] Further, as Figure 1 The specific implementation of the method shown in this embodiment provides a data processing device, such as Figure 2 As shown, the device includes: a collection unit 21, a detection unit 22, a judgment unit 23 and a processing unit 24.

[0097] A collection unit 21 is configured to collect system resource information and database performance indicators;

[0098] The detection unit 22 is configured to detect whether there is a synchronization delay between the slave database and the master database through the system resource information and the database performance indicator;

[0099] The judging unit 23 is configured to collect disk pressure parameters in the presence of synchronization delay, and judge the read and write pressure of the disk according to the disk pressure parameters;

[0100] The processing unit 24 is configured to calculate the rewrite value of the disk flushing mechanism and rewrite the log disk flushing mechanism of the database when it is determined that the write pressure of the disk is large.

[0101] In a specific application scenario, the processing unit 24 is specifically configured to calculate the rewrite value through the system resource information and the database performance indicator; and rewrite the disk flushing mechanism of the transaction log and the redo log based on the rewrite value.

[0102] In a specific application scenario, the processing unit 24 is also specifically configured to read the preset value of the transaction log flushing mechanism in the configuration parameters; when the overwrite value is greater than the preset value, the overwrite value replaces the preset value, and according to the number of overwrite values, the transaction log data is stored in the cache in batches for flushing.

[0103] In a specific application scenario, the processing unit 24 is specifically configured to read the optional value of the redo log disk flushing mechanism in the configuration parameters; after storing the transaction log data in batches into the cache for disk flushing according to the number of the preset value, determine the highest score of the redo log disk flushing mechanism in the optional values ​​through a binary search algorithm; and rewrite the redo log disk flushing mechanism using the highest score.

[0104] In a specific application scenario, the judgment unit 23 is also specifically configured to collect disk pressure parameters; compare the disk pressure parameters at the current moment with the disk pressure parameters at the previous moment. If the disk pressure parameters at the current moment are greater than the disk pressure parameters at the previous moment and greater than a preset threshold, it is determined that the current disk read and write pressure is greater.

[0105] In a specific application scenario, the judgment unit 23 is further configured to collect the number of disk operations and the number of disk writes per second within a preset time period; calculate the average number of disk operations and the average number of disk writes as the disk pressure parameters collected at that time.

[0106] In a specific application scenario, the detection unit 22 is also specifically configured to read the current log update point and the recent log update point; calculate the synchronization delay time based on the current log update point and the recent log update point; read the delay monitoring threshold, and use the synchronization delay time and the delay monitoring threshold to calculate the delay multiplier; based on the delay multiplier, determine whether there is a synchronization delay between the slave database and the master database.

[0107] It should be noted that for other corresponding descriptions of the functional units involved in the data processing device provided in this embodiment, reference can be made to Figure 1 The corresponding description in will not be repeated here.

[0108] Based on the above Figure 1 The method shown in the embodiment also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned Figure 1 The method shown.

[0109] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of the present application.

[0110] Based on the above Figure 1 The method shown, and Figure 2 In order to achieve the above-mentioned purpose, the embodiment of the present application also provides an electronic device, which can be configured on a computer terminal, etc. The device includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figure 1 The method shown.

[0111] Based on the above Figure 1 The method shown, and Figure 2 In order to achieve the above-mentioned purpose, the embodiment of the virtual device shown in the embodiment of the present application further provides a chip, including one or more interface circuits and one or more processors; the interface circuit is used to receive a signal from the memory of the electronic device and send the signal to the processor, the signal including the computer instruction stored in the memory; when the processor executes the computer instruction, the electronic device executes the above-mentioned Figure 1 The method shown.

[0112] Optionally, the above-mentioned physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.

[0113] Those skilled in the art will appreciate that the above-mentioned physical device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different arrangements of components.

[0114] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the above-mentioned physical device, and supports the operation of the information processing program and other software and / or programs. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.

[0115] Through the description of the above implementation mode, the technicians in this field can clearly understand that the present application can be implemented by means of software plus the necessary general hardware platform, or by hardware. By applying the scheme of this embodiment, firstly, by detecting the mysql master-slave database server performance index, that is, collecting system resource information and database performance index, and then by the system resource information and database performance index, detecting whether there is a synchronization delay between the slave database and the master database. In the case of synchronization delay, the disk pressure parameter is collected, and the disk read and write pressure is judged by the disk pressure parameter. When it is determined that the disk write pressure is large, the rewrite value of the disk brushing mechanism is calculated, and the log disk brushing mechanism of the database is rewritten. Compared with the related technical scheme, when the master-slave data synchronization delay is large, the rewrite value of the optimal disk brushing mechanism is calculated by detecting the mysql master-slave database server performance index, and when the master-slave data synchronization delay and the disk pressure are large, the log disk brushing mechanism of the database is rewritten based on the rewrite value, thereby improving the efficiency of data writing to the disk, solving the problem that there will be delays in the synchronization of the master-slave database, resulting in reduced disk writing efficiency.

[0116] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprises" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0117] The above is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features applied for herein.

Claims

1. A data processing method, characterized in that: include: Collect system resource information and database performance indicators; Detecting whether there is a synchronization delay between the slave database and the master database through the system resource information and the database performance index; In the case of synchronization delay, collecting disk pressure parameters, and judging the read and write pressure of the disk by the disk pressure parameters; When it is determined that the write pressure of the disk is relatively large, the rewrite value of the disk flushing mechanism is calculated, and the log disk flushing mechanism of the database is rewritten.

2. The method according to claim 1, characterized in that When it is determined that the write pressure of the disk is large, calculating the rewrite value of the disk flushing mechanism and rewriting the log disk flushing mechanism of the database includes: Calculating the rewrite value through the system resource information and the database performance index; The disk flushing mechanism of the transaction log and the redo log is rewritten based on the rewrite value.

3. The method according to claim 2, characterized in that Rewriting the disk flushing mechanism of the transaction log based on the rewrite value includes: Read the preset value of the transaction log flushing mechanism in the configuration parameters; In the case that the rewrite value is greater than the preset value, the preset value is replaced by the rewrite value, and the transaction log data is stored in batches into the cache for disk flushing according to the number of the rewrite values.

4. The method according to claim 3, characterized in that Rewriting the flushing mechanism of the redo log based on the rewrite value includes: Read the optional value of the redo log flushing mechanism in the configuration parameters; After storing the transaction log data in batches into the cache for disk flushing according to the preset number, determining the highest score of the redo log flushing mechanism from the optional values ​​by using a binary search algorithm; The highest score is used to rewrite the redo log flushing mechanism.

5. The method according to claim 1, characterized in that Determining the read and write pressure of the disk by the disk pressure parameter includes: Collect disk pressure parameters; The disk pressure parameter at the current moment is compared with the disk pressure parameter at the previous moment. If the disk pressure parameter at the current moment is greater than the disk pressure parameter at the previous moment and greater than a preset threshold, it is determined that the current disk read / write pressure is high.

6. The method according to claim 5, characterized in that The collecting of disk pressure parameters includes: Collect the number of disk operations and disk writes per second within a preset time period; The average number of disk operations and the average number of disk writes are calculated as the disk pressure parameters collected at that time.

7. The method according to claim 1, characterized in that The detecting whether there is a synchronization delay between the slave database and the master database by using the system resource information and the database performance indicator includes: Read the current log update point and the recent log update point; Calculate the synchronization delay time according to the current log update point and the recent log update point; Reading a delay monitoring threshold, and calculating a delay multiplier using the synchronization delay time and the delay monitoring threshold; According to the delay multiplier, it is determined whether there is a synchronization delay between the slave database and the master database.

8. A data processing device, characterized in that: include: A collection unit configured to collect system resource information and database performance indicators; a detection unit configured to detect whether there is a synchronization delay between the slave database and the master database through the system resource information and the database performance indicator; A judgment unit is configured to collect disk pressure parameters in the presence of synchronization delay, and judge the read and write pressure of the disk by the disk pressure parameters; The processing unit is configured to calculate a rewrite value of a disk flushing mechanism and rewrite the log disk flushing mechanism of the database when it is determined that the write pressure of the disk is large.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

10. An electronic device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Remote medical data management system and method based on cloud platform

    CN120050292A

  • Database pre-write log self-adaptive disk refreshing scheduling method and device and medium

    CN122261493A