WO2022001965A1 - Database configuration parameter adjustment method, and device and storage medium - Google Patents

Database configuration parameter adjustment method, and device and storage medium Download PDF

Info

Publication number
WO2022001965A1
WO2022001965A1 PCT/CN2021/102782 CN2021102782W WO2022001965A1 WO 2022001965 A1 WO2022001965 A1 WO 2022001965A1 CN 2021102782 W CN2021102782 W CN 2021102782W WO 2022001965 A1 WO2022001965 A1 WO 2022001965A1
Authority
WO
WIPO (PCT)
Prior art keywords
database
parameters
parameter
current
state
Prior art date
Application number
PCT/CN2021/102782
Other languages
French (fr)
Chinese (zh)
Inventor
弄庆鹏
李忠良
屠要峰
郭斌
黄震江
陈小强
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2022001965A1 publication Critical patent/WO2022001965A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0803Configuration setting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0876Aspects of the degree of configuration automation

Definitions

  • the embodiments of the present application relate to, but are not limited to, the technical field of databases, and in particular, relate to a method, device, and storage medium for adjusting database configuration parameters.
  • a database is an organized, sharable collection of data stored in a computer for a long time. With the development of science and technology, the amount of data used for user information connection has grown rapidly. As the basic support for information technology storage services, the database will be more widely used.
  • Embodiments of the present application provide a database configuration parameter adjustment method, device, and storage medium.
  • an embodiment of the present application provides a method for adjusting database configuration parameters, which is applied to a database tuning module, including: obtaining a database state mixed representation parameter from a database server; inputting the database state mixed representation parameter into Deep Enhancement Generate target database configuration parameters in the learning model; send the target database configuration parameters to the database server.
  • an embodiment of the present application provides a method for adjusting database configuration parameters, which is applied to a database server, including: sending a database state mixed representation parameter to a database tuning module, so that the database tuning module executes as described in the first aspect receiving the target database configuration parameters sent from the database tuning module; and performing parameter configuration on the database server according to the database configuration parameters.
  • an embodiment of the present application provides an electronic device, including: at least one processor, and a memory communicatively connected to the at least one processor; wherein the memory stores instructions, and the instructions are The at least one processor executes, so that when the at least one processor executes the instructions, the method as described in the first aspect or the method as described in the second aspect is implemented.
  • an embodiment of the present application provides a computer-readable storage medium, where the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to cause a computer to execute the method described in the first aspect or the method described in the second aspect.
  • FIG. 1 is a flowchart of a method for adjusting database configuration parameters provided by an embodiment of the present application
  • FIG. 2 is a schematic diagram of database configuration parameter adjustment provided by an embodiment of the present application.
  • FIG. 3 is a flowchart of a method for adjusting database configuration parameters provided by another embodiment of the present application.
  • FIG. 4 is a schematic diagram of a hybrid characterization module in database configuration parameter adjustment provided by an embodiment of the present application
  • FIG. 5 is a schematic diagram of a database configuration parameter adjustment module provided by another embodiment of the present application.
  • FIG. 6 is a schematic diagram of a reward function module in a database configuration parameter adjustment module provided by another embodiment of the present application.
  • FIG. 7 is a schematic diagram of a database configuration parameter self-tuning module provided by an embodiment of the present application.
  • FIG. 8 is a flowchart of a method for adjusting database configuration parameters provided by another embodiment of the present application.
  • FIG. 9 is a flow chart of the principle of self-tuning of database configuration parameters provided by another embodiment of the present application.
  • FIG. 10 is a flowchart of a method for adjusting database configuration parameters provided by another embodiment of the present application.
  • FIG. 11 is a flowchart of a method for adjusting database configuration parameters provided by another embodiment of the present application.
  • FIG. 12 is an application scenario diagram of the method for adjusting database configuration parameters provided by an embodiment of the present application.
  • 13(a) and 13(b) are an overall flowchart of a method for adjusting database configuration parameters provided by another embodiment of the present application.
  • FIG. 14 is an application scenario diagram of a method for adjusting database configuration parameters provided by another embodiment of the present application.
  • FIG. 15 is a schematic diagram of an electronic device for adjusting database configuration parameters provided by an embodiment of the present application.
  • a database is an organized, sharable collection of data stored in a computer for a long time. With the development of science and technology, the amount of data used for user information connection has grown rapidly. As the basic support for information technology storage services, the database will be more widely used.
  • the embodiment of the present application proposes a database configuration parameter adjustment method, device, and storage medium.
  • the embodiment of the present application can use a deep reinforcement learning model to process the obtained database state mixed representation parameters to generate target database configuration parameters,
  • the generated database configuration parameters are sent to the database server for configuration, thereby overcoming the problems of low automation, slow speed and low efficiency of database configuration, and effectively improving the automation, speed and efficiency of database configuration.
  • the electronic device may be a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, and a personal computer.
  • Digital assistant personal digital assistant, PDA
  • augmented reality augmented reality, AR
  • virtual reality virtual reality, VR
  • an embodiment of the present application provides a method for adjusting database configuration parameters, which is applied to a database tuning module.
  • the database configuration parameter adjustment method includes:
  • Step S1100 obtaining the database state mixed representation parameter from the database server
  • Step S1200 inputting the database state mixed representation parameters into the deep reinforcement learning model to generate target database configuration parameters
  • Step S1300 sending the target database configuration parameters to the database server.
  • the database state mixed characterization parameters in step S1100 may be database state parameters or configuration parameters, etc.
  • the performance of the database can be learned through these state mixed characterization parameters of the database, such as the database performance parameters in the database state parameters etc., and the quality of database configuration parameters directly affects the query and response speed of the database.
  • step S1200 after inputting the above-mentioned database state mixed representation parameters into the deep reinforcement learning model for training, configuration parameters of the target database will be generated, and these configuration parameters will play an important role in database optimization.
  • machine learning is a multi-domain interdisciplinary subject involving probability theory, statistics, approximation theory, algorithmic complexity theory and other disciplines. Specializing in the study of how computers simulate or implement human learning behavior. In order to acquire new knowledge or skills, reorganize the existing knowledge structure to continuously improve its own performance.
  • Machine learning is divided into supervised learning, unsupervised learning and reinforcement learning. Among them, supervised learning is that the computer obtains simple input and gives the desired output. The process is to learn general principles to map from input to output through a "training model"; no Supervised learning does not give a label to learn the algorithm, allowing it to discover the structure of the input by itself.
  • Unsupervised learning itself can be regarded as a goal or a way to achieve results, which can also be called feature learning; reinforcement learning is a computer program with Dynamically interacting with the environment while showing a precise goal, such as driving a vehicle or playing a game against an opponent, the program’s reward and punishment mechanism serves as feedback to enable it to navigate the problem domain.
  • the deep reinforcement learning model is a deep reinforcement learning model formed by combining a deep learning model and a reinforcement learning model.
  • the deep learning model is a recurrent neural network model.
  • the recurrent neural network model is hereinafter referred to as RNN (Recurrent Neural Network)
  • RNN Recurrent Neural Network
  • One of the deep learning algorithms, RNN is a type of recurrent neural network that takes sequence data as input, performs recursion in the evolution direction of the sequence, and all nodes, namely cyclic units, are connected in a chain, so that RNN can capture the correlation of each output parameter.
  • the database state hybrid representation parameters can be synthesized and processed.
  • the reinforcement learning model belongs to the above reinforcement learning, which combines deep learning and reinforcement learning to form deep reinforcement learning, which overcomes the problem that traditional reinforcement learning algorithms cannot handle high-dimensional state space, and combines reinforcement learning and deep learning to realize the end from perception to action.
  • a brand new algorithm for peer-to-peer learning that simplifies features and enables unsupervised learning.
  • the agent can discover the internal connection between features in the process of self-learning. Therefore, deep reinforcement learning has the potential to enable the agent to achieve completely autonomous learning of one or even multiple skills.
  • the application in this embodiment can provide the ability to process high-dimensional parameters, and continuously optimize model parameters through autonomous learning.
  • the database state mixed representation parameters obtained in step S1100 are input into the deep reinforcement learning model to generate database configuration parameters, which can achieve faster convergence speed, improve the speed of configuration parameter generation, and improve configuration efficiency.
  • the database server in step S1300 is composed of one or more computers running in the local area network and database management system software.
  • the database server can provide data services for the client's application program.
  • the target database configuration parameters are sent to the database server, so that the database server can be optimized, thereby improving the performance of the database in the database server.
  • a deep reinforcement learning model can be used to process the acquired database state mixed representation parameters to generate target database configuration parameters, and the generated database configuration parameters can be sent to the database server for configuration, thereby overcoming the slow and efficient database configuration.
  • Low problem effectively improve the speed and efficiency of database configuration.
  • the database status table mixed characterization parameters include one or more of the following: database performance parameters, current database configuration parameters, hardware resource parameters, and hardware resource status parameters.
  • the database performance parameters include, but are not limited to, throughput, query delay, and automatic VACUUM times, where throughput refers to the number of successfully transmitted data per unit time to a network, device, port, virtual circuit, or other facility , the amount of data is measured in bits, bytes, packets, etc.
  • the throughput directly affects the response speed of database data writing, data reading and database access;
  • the query delay is the time from the start of the database query to the database response.
  • the size of the database query delay directly affects the access response speed of the database; among them, the main function of automatic VACUUM is to move free pages to the end of the database, thereby reducing the size of the database.
  • Automatic VACUUM can make the database occupy more space. small.
  • CPU Central Processing Unit
  • memory capacity can be understood as the storage capacity of the memory stick.
  • the memory capacity is in MB.
  • the memory capacity of a computer usually refers to the capacity of random access memory (RAM).
  • RAM random access memory
  • the memory capacity is generally a multiple of 2, such as 64MB, 128MB, 256MB, etc. The larger the memory capacity, the more beneficial the operation of the hardware system or computer system.
  • the hardware resource status parameters include but are not limited to parameters such as CPU utilization, memory utilization, and storage utilization.
  • the CPU utilization is the percentage of the CPU occupied by the running process.
  • the size of the CPU utilization directly affects the service life of the CPU. If the CPU utilization is too high, it will cause the internal aging of the CPU, thereby reducing the service life of the CPU; the memory occupancy rate Refers to the memory occupied by the running process. Excessive memory utilization will slow down the access speed of the CPU and affect the performance of the entire hardware resource.
  • the deep reinforcement learning model includes a hybrid representation module and a self-tuning module, the hybrid representation module is connected to the self-tuning module, wherein the hybrid representation module uses an RNN model, and the self-tuning module uses a Reinforcement learning models.
  • the self-tuning module transmits the database configuration parameters to the control interface of the server through the control interface, and the server outputs the workload pressure signal to pressurize the target database (such as the database server) by controlling the pressure measurement device; the parameter acquisition module monitors the hardware resources in the target database
  • the state parameters and database performance parameters are collected, combined with the server's own hardware resource parameters, the above parameters are transmitted to the hybrid characterization module in the database tuning module through the server's control interface for hybrid characterization, and the output database state hybrid characterization vector is sent to the self-tuning
  • the self-tuning module completes the interaction with the database through the current action network in reinforcement learning, so as to transmit the configuration parameters generated by the self-tuning module to the target database.
  • This embodiment can realize the deep reinforcement learning model formed by the RNN model and the reinforcement learning model, and then combine the database state mixed representation parameters to obtain the configuration parameters of the database, thereby improving the generation speed of the database configuration parameters and improving the efficiency of the database configuration.
  • step S1200 specifically includes:
  • Step S1210 input the database state mixed characterization parameters into the mixed characterization module
  • Step S1220 the hybrid characterization module uses the RNN model to process the database state hybrid characterization parameters to obtain a database state hybrid characterization vector;
  • Step S1230 the database state mixed representation vector is input to the self-tuning module, and the self-tuning module uses the reinforcement learning model to process the database state mixed representation vector to obtain target database configuration parameters.
  • the purpose of inputting the above-mentioned database state mixed representation parameters into the mixed representation module in step S1210 is to obtain a vector of the mixed representation of database states.
  • the mixed representation of the above parameters is used in this embodiment, which can ensure the completeness and accuracy of the database state representation.
  • the hybrid representation module in step S1220 uses a neural network model to process the features of the above database state hybrid representation parameters to obtain a database state hybrid representation vector.
  • the neural network model used RNN is a recurrent neural network model, RNN refers to a structure that recurs over time; a typical RNN network contains an input, an output and a neural network unit, where the neural network unit of the RNN network is not only related to There is a relationship between input and output, and there is also a loop with itself, that is, the network state information at the previous moment will act on the network state at the next moment.
  • RNN can improve the convergence speed of the model, thereby improving the generation speed of database configuration parameters and making the database configuration more efficient.
  • the database state mixed representation parameters include database performance parameters, current database configuration parameters, hardware resource parameters, and hardware resource state parameters.
  • the above step S1220 includes:
  • Step S1221 acquiring the current database performance parameters and the previous database performance parameters; and, acquiring the current database configuration parameters and the previous database configuration parameters; and, acquiring the current hardware resource state parameters and the previous hardware resource state parameters; and, acquiring the hardware resources parameter;
  • Step S1222 obtain the current database performance parameter feature vector according to the current database performance parameter; obtain the previous database performance parameter feature vector according to the previous database performance parameter; obtain the current database configuration parameter feature vector according to the current database configuration parameter; Obtain the previous database configuration parameter feature vector; obtain the current hardware resource state parameter feature vector according to the current hardware resource state parameter; obtain the previous hardware resource state parameter feature vector according to the previous hardware resource state parameter; obtain the hardware resource according to the hardware resource parameter parameter eigenvector;
  • Step S1223 Calculate and obtain the database performance parameter difference feature vector according to the current database performance parameter feature vector and the previous database performance parameter feature vector; calculate and obtain the database configuration parameter according to the current database configuration parameter feature vector and the previous database configuration parameter feature vector Difference feature vector; according to the current hardware resource state parameter feature vector and the previous hardware resource state parameter feature vector, calculate the hardware resource state parameter difference feature vector; step S1224, the database performance parameter feature vector, database performance parameter difference feature vector Vector, database configuration parameter feature vector, database configuration parameter difference feature vector, hardware resource state parameter feature vector, hardware resource state parameter difference feature vector, hardware resource parameter feature vector are input into the neural network model, and the neural network model is used to output the database State mixture representation vector.
  • step S1222 after inputting the parameter features obtained in step S1221 into the hybrid characterization module, preprocessing coding is performed, and the process of preprocessing is to obtain the current database performance parameters and the previous database performance parameters; And, current database configuration parameter and previous database configuration parameter; And, current hardware resource state parameter and previous hardware resource state parameter; And, obtain hardware resource parameter to carry out vectorization processing, and obtain parameter difference value vector by step S1223,
  • the vector of parameters and the corresponding vector of parameter differences are outputted as a mixed representation vector of database state after the neural network model is trained.
  • the historical records in the figure are the previous database performance parameters, the previous database configuration parameters, and the previous database hardware resource status parameters.
  • the resource state parameters are preprocessed to form a mixed representation vector of database state and transmitted to the self-tuning module.
  • the current database performance parameters, the current database hardware resource state parameters, the previous database performance parameters, the previous database hardware resource state parameters and The previous database configuration database is input to the sample pool and stored as a sample.
  • This embodiment can realize the generation of the database state mixed representation vector in the self-tuning module and the generation of parameters in the sample pool, which provides a parameter basis for optimizing the database tuning module.
  • step S1224 there are a database performance parameter feature vector, a database performance parameter difference vector, a database configuration parameter feature vector, a database configuration parameter difference vector, a hardware resource state parameter feature vector, and a hardware resource state parameter difference vector , hardware resource parameter vector
  • These seven vectors are input into the neural network model, and the neural network model is used to output the mixed representation vector of the database state.
  • These seven eigenvectors are related, and the cyclic neural network RNN is used to extract the relationship and reduce the dimensionality of the coding, so as to realize the mixed representation of the database state, which improves the comprehensiveness and characterization of the database and its hardware resource environment state by the database characterization vector. Accuracy improves the effectiveness and efficiency of database configuration parameter adjustment.
  • the core idea of this embodiment is described by taking a database server whose hardware resource parameters are 4-core CPU, 32G memory, and 256G storage as an example.
  • the memory is the running memory, which can also be called RAM, and the data will not exist after the shutdown.
  • the size of the memory determines the running speed of the machine; the storage as 256G represents the storage capacity of the CPU, which can store 256G of data.
  • the database hardware resource parameter feature vector is [4, 32, 256, 0, 0, 0, 0, 0, 0, 0], where 4 It means that the CPU does not have 4 cores, 32 means that the memory size is 32G, and 256 means that the storage size is 256G.
  • the missing dimension after the vector is processed with 0s, that is, 7 0s are added as supplementary dimensions.
  • the current hardware resource state parameter feature vector is [0.6, 0.58, 0.3, 0, 0, 0, 0, 0, 0, 0], where 0.6 represents the CPU utilization rate, 0.58 represents the memory utilization rate, 0.3 represents the storage utilization.
  • the following seven 0s represent the missing dimension;
  • the previous hardware resource status parameter feature vector is [0.4, 0.48, 0.5, 0, 0, 0, 0, 0, 0, 0], then
  • the hardware resource state parameter difference vector is, the current hardware resource state parameter feature vector minus the previous hardware resource state parameter feature vector, then the hardware resource state parameter difference vector is [0.2, 0.10, -0.2, 0, 0, 0, 0, 0, 0, 0];
  • the current configuration parameter feature vector in this embodiment is [542, 730, 9, 7, 55, 23, 99, 10, 67, 86], where 542 represents temp_buffers in the database configuration parameters, that is, the size of the temporary buffer. Accessing temporary table data in a database session, 730 represents work_mem, the memory size used by internal sorting operations and hash tables before writing to the temporary file, 9 represents max_wal_size, and a vector of related configuration parameters such as WAL grows to the maximum size during automatic WAL checkpoints.
  • the previous configuration parameter feature vector is [372, 650, 3, 4, 32, 21, 76, 13, 67, 56], then the database configuration parameter difference vector is the current current configuration parameter feature vector and the previous current configuration parameter Difference vector between feature vectors, i.e. [170, 80, 6, 3, 23, 2, 23, -3, 0, 30].
  • the current database performance parameter feature vector is [1154.5, 8.5, 515, 9325.0, 854.8, 0.0, 91, 1.0, 6.7, 8.6], where 1154.5 represents the n_tup_ins state parameter, 8.5 represents the buffers_alloc configuration parameter, and 515 represents the xact_commit Configuration parameters, 9325.0 represents n_dead_tup status parameters, etc.
  • the performance database performance parameter difference vector is [104.0, 3.0, 15, 2.0, -122.1, 0, 23, 0.2, 1.4, 1.0].
  • database performance parameters, database configuration parameters, hardware resource parameters, current values, and the difference between the current value and the previous value are used for mixed characterization, wherein the previous value can be understood as a historical value, which is understandable .
  • the previous value can be understood as a historical value, which is understandable .
  • the changes of database performance parameters are determined by the database configuration parameters. It is determined by the amount of change, and the current database performance parameters are generally determined by hardware resource parameters.
  • the state of the database is mixed with the previous value or the historical value, and the RNN can capture the relationship between the parameters so that the database configuration parameters can be adjusted in real time and accurately.
  • the deep reinforcement learning model further includes a database configuration parameter reward function module
  • step S1200 further includes:
  • the mixed representation parameters of the database state in S1240 include database performance parameters, current database configuration parameters, hardware resource parameters, and hardware resource state parameters, wherein the database configuration parameters are parameters configured during the operation of the database, and this parameter will affect the database.
  • the performance parameters and database hardware status parameters are usually called action a in reinforcement learning; the performance parameters of the database include but are not limited to the throughput and latency performance indicators of the database, and the database hardware status parameters include but are not limited to Limited to indicators such as CPU utilization, memory utilization, and storage utilization.
  • the database configuration parameter reward function in the database configuration parameter reward function module is mainly used to evaluate the quality of the current database configuration parameters, such as whether the throughput and latency of the database meet the business requirements, which is usually called reward r in reinforcement learning.
  • the database performance parameters and hardware resource state parameters can be collectively referred to as database state parameters, which are called state s in reinforcement learning. It is understandable that database state parameters and database configuration parameters appear in pairs, that is, a set of database configuration parameters.
  • the database state parameters include but are not limited to database performance parameters, current configuration parameters, and hardware resource state parameters, wherein the hardware resource state parameters include CPU utilization and/or memory utilization, which are usually called in reinforcement learning. is state s.
  • the database configuration parameter reward function module in step S1240 is configured to generate the reward value r of the current database configuration parameter
  • the hybrid characterization module is configured to output database configuration parameters, database performance parameters and hardware resource status parameters, wherein The database performance parameters and hardware resource status parameters can be combined as database status parameters.
  • the current database status parameter is represented as s_
  • the previous database status parameter is represented as s
  • the current database configuration parameter is represented as a.
  • the database configuration parameter reward function module outputs samples of (s, a, r, s_) together, and then executes step S1250 to place the reward strategy in the sample pool.
  • the above step S1240 includes:
  • S1241 output the reward value of the current database configuration parameter after normalizing the difference between the current database performance parameter and the previous database performance parameter, and the difference between the current hardware resource state parameter and the previous hardware resource state parameter;
  • the normalization process is to calculate the proportion of the difference between the current database performance parameter and the previous database performance parameter in the previous database performance parameter; and, the difference between the current hardware resource state parameter and the previous hardware resource state parameter is the first The ratio of the secondary hardware resource status parameters, and the ratio is multiplied by the corresponding weighted value to output the reward value of the current database configuration parameter;
  • S1242 Generate a reward policy according to the reward value of the current database configuration parameter, the current database configuration parameter, the current database performance parameter, the current hardware resource state parameter, the previous database performance parameter, and the previous hardware resource state parameter.
  • the normalization in step S1241 is to change the number into a decimal between 0 and 1
  • the normalization in this embodiment is to calculate the current database performance parameter and the previous database performance parameter, and, The difference between the current hardware resource state parameter and the previous hardware resource state parameter, and the ratio of the current database performance parameter and the previous database performance parameter to the current database performance parameter, and the current hardware resource state parameter and the previous The ratio of the difference value of the hardware resource state parameter to the previous hardware resource state parameter, and the above ratio is multiplied by the corresponding weighted value and summed to output the reward value of the current database configuration parameter; the specific formula is as follows:
  • r (difference between current database performance parameter and previous database performance parameter/previous database performance parameter)* ⁇ +(difference between current hardware resource state parameter and previous hardware resource state parameter/previous hardware resource state parameter)* ⁇ ;
  • ⁇ and ⁇ are weighted values
  • r is a normalized value after normalizing the above-mentioned database performance parameters and hardware resource state parameters, and in this embodiment, represents the reward value of the current database configuration parameter.
  • the hardware resource status parameters in step S1241 include CPU utilization and memory utilization.
  • the database configuration parameters can be adjusted according to the database configuration parameters during the process. Performance parameters, CPU utilization and memory utilization have different degrees of emphasis.
  • the specific normalization process is carried out by setting the size of the weighted value.
  • the specific normalization formula is:
  • ⁇ cpu_rate cur_cpu_rate-hist_cpu_rate
  • ⁇ men_rate cur_men_rate-hist_men_rate
  • ⁇ , ⁇ , ⁇ are weighted values
  • r is the reward value of the current database configuration parameter
  • cur_perfor is the current database performance parameter
  • hist_perfor is the previous or historical database performance parameter
  • cur_cpu_rate is the current CPU utilization
  • hist_cpu_rate is the previous or Historical CPU utilization
  • cur_men_rate is the current memory utilization
  • hist_men_rate is the previous or historical memory utilization
  • ⁇ perfor is the difference between the current database performance parameters and the previous or historical database performance parameters
  • ⁇ cpu_rate is the current CPU utilization and previous The difference between the current or historical CPU utilization
  • ⁇ men_rate is the difference between the current memory utilization and the previous or historical memory utilization.
  • the weighted value can be set to adjust the degree of emphasis on database performance parameters, CPU utilization and memory utilization in the process of database configuration parameter adjustment. For example, focusing on the optimization of database performance parameters, then performance parameters
  • the component weight ⁇ can be set to a larger value. If it focuses on the optimization of CPU utilization, ⁇ can be set to a larger value. Similarly, if the database optimization focuses on the optimization of memory utilization, set ⁇ to a larger value.
  • the normalization of the above components is to solve the problem of different dimensions and varying degrees of the three parameters.
  • the optimization of the database in this embodiment focuses on the database performance parameters.
  • the generation of the reward value of the current database configuration parameter is calculated by combining the current value and the previous value or the historical value of the database performance parameter, CPU utilization and memory utilization parameter. It is understandable that when optimizing the data configuration parameter In the process, the focus is not on the absolute value of the current database performance, but more on the changes in database performance parameters, CPU utilization, and memory utilization after the database configuration parameters are adjusted.
  • the historical value of the parameters can be the historical maximum value. Or the default configuration of the database corresponds to the collected value or the mean value recorded in the sliding window.
  • the differences of the above three parameters of database performance parameters, CPU utilization and memory utilization are calculated respectively, then the three differences are normalized, and finally the weighted sum is used as the reward output.
  • the module includes a current action network, a current evaluation network, a target action network, and a target evaluation network, wherein the current action network mainly uses the current state to generate the next action,
  • the current evaluation network is set to evaluate the current state and the next action
  • the target action network is set to generate the next action using the next state
  • the next action and the next state are evaluated using the target evaluation network.
  • the current state parameter is represented as states
  • the current action is represented as actions
  • the next state is represented as next_states
  • the next action is represented as next_states
  • the self-tuning module includes: a current action network, a current evaluation network, a target action network, and a target evaluation network; the current action network is configured to generate a target database according to the database state hybrid characterization parameters
  • the configuration parameters are sent to the database server;
  • the sampling data includes the current database configuration parameters, the current database state parameters, the next database state parameters, and the reward value of the current database configuration parameters;
  • the sampling data in step S1270 includes the current database configuration parameters, the current database state parameters, the next database state parameters, wherein the database state parameters include database performance parameters and database hardware resource state parameters, the above step S1270 includes:
  • Step S1271 Input the current database state parameters into the current action network, and generate the next database configuration parameters
  • the current database state parameter can be represented as states, and the next database configuration parameter can be represented as next_actions. It is understandable that the current action network is also set to output the destination database configuration parameter by processing the current database state parameter and the mixed representation vector.
  • Step S1272 Input the next database configuration parameters and the current database state parameters into the current evaluation network to determine the first loss function value
  • Step S1273 Optimizing the current action network according to the first loss function value and softly updating the target action network according to the parameters output by the current action network;
  • the current database state parameter is states
  • policy_loss can be used as the loss value of the current network, which can optimize the current action network, and Q'(states, next_actions) represents the evaluation value of the current database state parameters and the next database configuration parameters in the current evaluation network.
  • Step S1274 Input the next database state parameters into the target action network, and generate the next database configuration parameters
  • next_states the next database state parameter is represented as next_states
  • Step S1275 Input the current database configuration parameters and the current database state parameters into the current evaluation network to generate the current action evaluation value
  • Step S1276 Add the next database configuration parameters and the next database state parameters to the target evaluation network to generate the next action evaluation value
  • Step S1277 Calculate the second loss function value according to the current action evaluation value, the next action evaluation value and the reward value of the current database configuration parameter;
  • Step S1278 Use the second loss function value to optimize the current evaluation network, and at the same time perform a soft update on the target evaluation network through the parameters output by the current evaluation network.
  • the second loss function formula is as follows:
  • Q'(next_state, next_action) is the current action evaluation value
  • Q(state, action) is the previous action evaluation value
  • Loss() represents the loss value between the target evaluation network and the current evaluation network
  • Q(state, action) is represented as Q(s, a) in Figure 7.
  • r represents the reward value of the current database configuration parameter
  • max(Q'(next_state, next_action) is the highest evaluation score that may be generated by the action taken in the next state. In this embodiment, it represents the database configuration corresponding to the next database parameter. The highest evaluation score produced, where ⁇ is a numeric value from 0 to 1.
  • the target evaluation value Loss -r, that is, the current evaluation value plus the Loss value is plus -r, which is the target evaluation value, where r is the reward value of the current database configuration parameter in step S1241 .
  • the self-tuning module in the embodiment of the present application consists of four parts, the current action network, the current evaluation network, the target action network, and the target evaluation network, all of which are composed of neural networks;
  • the best action to be applied to the environment at the next moment is determined according to the current state; here, the action can be regarded as the configuration parameter to be configured in the database, and the state can be regarded as the state parameter of the database.
  • the value obtained by the Loss formula is the value of the second loss function
  • the current evaluation network is optimized to determine the output value of the current action network, that is, the optimized current evaluation network can predict the input state parameter corresponding to the next A database configuration parameter (target database configuration parameter).
  • the target action network can provide the target evaluation network with the action corresponding to the next state, that is, the database configuration parameters corresponding to the next database state.
  • the database status is database performance parameters and database hardware resource status parameters.
  • the target evaluation network is mainly responsible for the calculation of the target Q value.
  • the current evaluation network also needs to optimize the module, so it is necessary to compare a target value with the generated value of the current evaluation network to obtain the loss value to optimize the current evaluation network.
  • this embodiment can periodically update the parameters of the current evaluation network with the parameters of the target evaluation network, and use the soft update method to use the loss function once for each update, so as to ensure that each update will be adjusted according to the loss function, Guarantee more optimization of the module.
  • the update() function in the self-tuning module is used to trigger the optimization process of the entire self-tuning module.
  • the self-tuning module obtains the previous state parameter from the sample pool, which is represented as state, and the previous configuration parameter is represented as action.
  • the current state parameter is represented as next_state and the reward value reward (represented as r in the above embodiment) parameter of the current database configuration parameter is processed through steps S1271 to S1277 and the optimized database configuration parameter is output.
  • the configuration parameters in this embodiment are added with the reward value of the current database configuration parameters, the database configuration parameters generated by the self-tuning module can be more optimal, and the database configuration parameters in this embodiment are input into the target database server for configuration. , which can improve the access speed, reading speed and other database processing matters of the database in the target database server.
  • the hybrid characterization module is responsible for providing the database state hybrid characterization vector for the self-tuning module, and also provides parameter samples for the sample pool, while the hybrid characterization module receives the target.
  • the database performance parameters, database configuration parameters, and database hardware resource status parameters sent by the database are mixed with the above parameters.
  • the organic system of parameters can quickly and efficiently complete the generation, optimization and configuration of the database.
  • the current action network is responsible for the interaction of the self-optimization module with the database environment, that is, generating database configuration parameters according to database state parameters, and configuring the configuration parameters into the database.
  • the current evaluation network is responsible for evaluating the value (good or bad) of each pair of database state-actions, the evaluation is the Q value, so that it can determine what action to take in what database state. That is, what kind of database configuration parameters can be used in what kind of database state can bring higher database performance, wherein the database state includes database performance parameters, database hardware resource state parameters, and database performance includes throughput, delay, etc. , High database performance means high throughput, low latency, etc.
  • the data server includes a backup database server and a service database server
  • step S1100 includes:
  • Step 1110 Obtain the database state hybrid representation parameter of the backup server
  • Step S1300 includes:
  • Step S1310 Send the target database configuration parameters to the service database server.
  • the business database server is a server that is running and being used.
  • the server that needs to perform database configuration can be called a business server.
  • the database status of the business server and the backup server is The mixed characterization parameters are the same.
  • step S1310 may be executed to send the target database configuration parameters to the business database server for tuning of the business database server.
  • the database configuration parameters can be adjusted on the backup server first, and only when the configuration is successful and the database runs normally after the configuration, the relevant configuration parameters can be configured on the business server.
  • This offline method configures the database for the business server. Parameter adjustment can prevent unexpected situations in the process of database configuration parameter adjustment from damaging the running business server and causing unnecessary losses.
  • the online mode optimization is performed on the database server, and the database optimization module directly obtains the database state mixed representation parameter from the business database, and after obtaining the above-mentioned database state mixed representation parameter, executes the methods of the above steps S1100 to S1300 to obtain
  • the target database configuration parameters are transmitted, and the newly generated target database configuration parameters are transmitted to the business database in real time, so that the business database can configure the database configuration parameters in real time.
  • This embodiment can realize the real-time online optimization of the configuration parameters of the business database, and improve the optimization efficiency.
  • steps S1100 and S1200 in the database configuration parameter adjustment method include:
  • N is a positive integer
  • the value of N can be preset, and N can be obtained through an experimental value or an empirical value.
  • This embodiment can continuously converge through model training by means of a preset number of iterations until better database configuration parameters are obtained, which enhances the real-time and efficient configuration of database configuration parameters.
  • the embodiments of the present application provide a method for adjusting database configuration parameters, which is applied to a database server.
  • the database configuration parameter adjustment method includes:
  • Step S2100 sending the database state mixed representation parameter to the database tuning module, so that the database tuning module executes the method of the first aspect
  • Step S2200 receiving the target database configuration parameters sent from the database tuning module
  • Step S2300 perform parameter configuration on the database server according to the target database configuration parameters.
  • the database state hybrid characterization parameters include one or more of the following: database performance parameters, current database configuration parameters, hardware resource parameters, and hardware resource state parameters.
  • step S2100 further includes:
  • Step S2400 obtaining the first mixed representation parameter of database state
  • Step S2500 obtaining the workload pressure signal from the pressure simulation server
  • Step S2600 performing a pressurization operation on the database server according to the workload pressure signal
  • Step S2700 after the pressurization operation is completed, obtain the second database state mixed representation parameter.
  • the database server includes a backup database server and a service database server
  • step S2100 includes:
  • Step 2110 use the backup database server to send the database state mixed representation parameters to the database tuning module and perform the methods from steps S1100 to S1300 to generate target database configuration parameters;
  • Step 2120 use the service server to receive target database configuration parameters
  • Step 2130 Perform parameter configuration on the service database server according to the target database configuration parameters.
  • the specific physical environment of the application scenario is as follows:
  • the physical environment in Table 1 is based on the PASS environment
  • the PG10.11 database represents the Postgresql 10.11 version database
  • the offline debugging mode is to pass the database tuning server 101 before the business starts (the database tuning server has a built-in database Tuning module) to tune the most configuration parameters, and directly configure it into the business database after obtaining the better configuration, and then start the database service.
  • the database configuration parameter adjustment system includes a database configuration parameter self-tuning server 101, a database query pressure simulation server 103, and a PG database server (service server) based on the PASS platform.
  • the database tuning server 101 is the core of this embodiment, and is responsible for running the database tuning module, controlling the database user query pressure simulation server, and interacting with the PG10.11 database server.
  • the service server is responsible for the operation of the PG10.11 database, limiting the hardware resources for database operation, receiving the query from the database user query pressure simulation server, and interacting with the database tuning server 101 .
  • the database user queries the pressure simulation server, which is responsible for the operation of the pressure measurement device, and performs the pressure test on the PG10.11 database under the control of the self-tuning module to simulate the database workload during the actual operation.
  • the PG10.11 database can be used as a service server.
  • the database tuning server 101 is connected to the database query pressure simulation server 103 and the service server 102 in two-way communication respectively, and the output of the database query pressure simulation server is connected to the service server through a one-way connection, and the communication connection can be RJ45 port or other communication connection.
  • the database configuration parameter adjustment method specifically includes:
  • Step S3100 Obtain database server hardware resource parameters
  • Step S3200 Build a database tuning module, if there are already trained database configuration parameters, load them, otherwise go to the next step;
  • Step S3300 Acquire the default configuration parameters of the PG10.11 database
  • Step S3400 reset the environment state of the PG10.11 database
  • the purpose of resetting the environment state of the PG10.11 database is to rebuild the data tables in the database, prevent changes in the database tables after multiple stress tests, ensure the consistency of the database environment for each stress test, and make each stress test.
  • the obtained database performance parameters are comparable.
  • Step S3500 Configure the current database configuration parameters into the database server PG10.11 database through the network, and reset the database.
  • the current database configuration parameters are equal to the default configuration parameters only during the first round of model training. During the continuous iteration of model training, the current configuration parameters will be continuously updated, and some configuration parameters require a database reset to take effect.
  • Step S3600 collect database performance parameters for the first time
  • the collected database state parameters include but are not limited to the types shown in Table 2:
  • Step S3700 The control database query pressure simulation server starts to pressurize the PG10.11 database in the PG database server, and starts to record the database hardware resource status parameters in real time.
  • the database hardware resource status parameters include but are not limited to: CPU utilization, memory utilization, storage utilization and other parameters;
  • Step S3800 the compression of the PG10.11 database in the PG database server is completed, and the recording of the database hardware resource status parameters is stopped;
  • Step S3900 collect database performance parameters for the second time
  • Step S31000 Calculate the current performance parameter of the database according to the difference between the database performance parameter collected for the first time in step S3600 and the database state parameter collected for the second time in step S3900, and calculate the current performance parameter of the database according to the database hardware resource state parameter record during the stress measurement process.
  • the average value of the database hardware resource status parameters such as CPU utilization, memory utilization, and storage utilization during the process.
  • Step S31100 Calculate the difference according to the database performance parameters, hardware resource status parameters collected in step S31000, the current database configuration parameters in S3500, and the historical record values of the above parameters, and then use the current parameters and the obtained difference parameters.
  • the difference is used for mixed representation, and the mixed representation vector of the database state is obtained.
  • Step S31200 Input the generated database state hybrid representation vector into the self-tuning module to generate new database configuration parameters.
  • the generated database configuration parameters include, but are not limited to, as shown in Table 3:
  • Step S31300 Calculate the reward value r of the current database configuration parameter according to each database state parameter and its historical record value collected in step S31000.
  • the calculation formula is as follows:
  • ⁇ cpu_rate cur_cpu_rate-hist_cpu_rate
  • ⁇ men_rate cur_men_rate-hist_men_rate
  • ⁇ , ⁇ , ⁇ are weighted values
  • r is the reward value of the current database configuration parameter
  • cur_perfor is the current database performance parameter
  • hist_perfor is the previous or historical database performance parameter
  • cur_cpu_rate is the current CPU utilization
  • hist_cur_cpu_rate is the previous or Historical CPU utilization
  • cur_men_rate is the current memory utilization
  • hist_men_rate is the previous or historical memory utilization
  • ⁇ perfor is the difference between the current database performance parameters and the previous or historical database performance parameters
  • ⁇ cpu_rate is the current CPU utilization and previous The difference between the current or historical CPU utilization
  • ⁇ men_rate is the difference between the current memory utilization and the previous or historical memory utilization.
  • the cur_perfor and hist_perfor parameters can be parameters such as database throughput TPS and query delay;
  • Step S31400 Record the optimal database configuration parameter according to the reward value of the current database configuration parameter calculated in step S31300;
  • Step S31500 Store the previous database state parameters, current database configuration parameters, the reward value of the current database configuration parameters, and the current database state parameters as an interactive sample in the experience pool, where the database state parameters include database hardware resource state parameters, database performance parameters.
  • Step S31600 Perform batch sampling on the sample pool, and optimize the self-tuning module in step S31200.
  • step S1270 The specific self-tuning module optimization process is as described in step S1270, which is not repeated here.
  • Step S31700 Update the current database configuration parameters according to the database configuration parameters generated in step S31200, and update the current database status record value for the database status parameters obtained in step S31000, where the database status parameters include database performance parameters and database hardware. Resource status parameters.
  • Step S31800 If the current iteration counter iter value is not greater than the maximum iteration value max_iter, return to step S3500, configure the database configuration parameters in the PG10.11 database, and continue the iterative process; otherwise, go to step S31900.
  • Step S31900 Return the optimal database configuration parameters and corresponding database performance parameters to the database administrator, and the database administrator decides whether to configure the database configuration parameters recommended by the model into the target database PG10.11 of the server.
  • Step S32000 Save the parameters of the current database self-tuning module.
  • this embodiment provides another database parameter adjustment situation performed in an application scenario, as shown in Table 4.
  • this embodiment adopts the mode of two database servers, one of which is the backup database server 102 and the other is the business database server 104, both of which are PG10.11 database servers.
  • the server 102 searches for optimal configuration parameters of the database, and then recommends the configuration parameters to the business database server 104 for configuration, so as to avoid interfering with the normal operation of business data during the tuning process.
  • the database configuration and debugging system is composed of four parts: a database tuning server 101 (the database tuning server 101 has a built-in database tuning module), a database query pressure simulation server 103, a backup database server 102 and a business database server 104, wherein the database tuning server 101 It is responsible for the operation of the database tuning module, the control of the database user query pressure simulation server 103, the interaction with the backup database server 102, and the parameter configuration of the business database server 104.
  • the backup database server 102 is responsible for running the interactive database, limiting the hardware resources for running the database, receiving queries from the database user query pressure simulation server 103 , and interacting with the database tuning server 101 .
  • the database query pressure simulation server 103 is responsible for running the pressure measurement tool and interacting with the database tuning server 101 .
  • the above servers are connected through network cables, but are not limited to the above connection methods.
  • an embodiment of the present application provides an electronic device.
  • the above-mentioned electronic device includes one or more processors 201; a storage device 202 is used to store one or more programs, when the above-mentioned one or more programs are processed by the above-mentioned one or more processors
  • the execution causes the above one or more processors to implement: the method for adjusting database configuration parameters in the first aspect; or, the method for adjusting database configuration parameters in the second aspect.
  • an embodiment of the present application provides a computer-readable storage medium.
  • the above-mentioned computer-readable storage medium stores computer-executable instructions, and the above-mentioned computer-executable instructions are used to perform: as the database configuration parameter adjustment method in the first aspect; or, as the database configuration parameter in the second aspect adjustment method.
  • the embodiments of the present application include: acquiring database state mixed representation parameters from a database server; inputting the database state mixed representation parameters into a deep reinforcement learning model to generate target database configuration parameters; and sending the target database configuration parameters to the database server.
  • a deep reinforcement learning model can be used to process the obtained database state mixed representation parameters to generate target database configuration parameters, and the generated database configuration parameters can be sent to the database server for configuration, thereby overcoming the low degree of database configuration automation. , slow speed and low efficiency, which effectively improves the automation, speed and efficiency of database configuration.
  • Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cartridges, magnetic tape, magnetic disk storage or other magnetic storage devices, or may Any other medium used to store desired information and which can be accessed by a computer.
  • communication media typically embodies computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and can include any information delivery media, as is well known to those of ordinary skill in the art .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Computing Systems (AREA)
  • Artificial Intelligence (AREA)
  • Evolutionary Computation (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Signal Processing (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Mathematical Physics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Automation & Control Theory (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)
  • Stored Programmes (AREA)

Abstract

A database configuration parameter adjustment method, and a device and a storage medium. The embodiments of the present application comprise: acquiring a database state hybrid characterization parameter from a database server (S1100); inputting the database state hybrid characterization parameter into a deep reinforcement learning model to generate a target database configuration parameter (S1200); and sending the target database configuration parameter to the database server (S1300).

Description

数据库配置参数调整方法、设备及存储介质Database configuration parameter adjustment method, device and storage medium
相关申请的交叉引用CROSS-REFERENCE TO RELATED APPLICATIONS
本申请基于申请号为202010618107.8、申请日为2020年06月30日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。This application is based on the Chinese patent application with the application number of 202010618107.8 and the filing date of June 30, 2020, and claims the priority of the Chinese patent application. The entire content of the Chinese patent application is incorporated herein by reference.
技术领域technical field
本申请实施例涉及但不限于数据库技术领域,尤其涉及一种数据库配置参数调整方法、设备及存储介质。The embodiments of the present application relate to, but are not limited to, the technical field of databases, and in particular, relate to a method, device, and storage medium for adjusting database configuration parameters.
背景技术Background technique
数据库是长期储存在计算机内、有组织的、可共享的数据集合。随着科学技术的发展,用于用户信息连接的数据量急剧增长,数据库作为信息技术存储服务的基础支撑,其应用将更加广泛,数据库的广泛应用随之而来的是数据库的优化问题。A database is an organized, sharable collection of data stored in a computer for a long time. With the development of science and technology, the amount of data used for user information connection has grown rapidly. As the basic support for information technology storage services, the database will be more widely used.
目前,大规模数据库的优化一般依赖于数据库管理员,但是数据库的差异化配置对于数据库管理员而言是一个繁杂、重复、耗时费力的挑战,而经验不同的数据库管理员对数据库的配置参数质量也大相径庭,从而使数据库配置参数的调整存在自动化程度低、速度慢、效率低的问题。At present, the optimization of large-scale databases generally relies on database administrators, but the differential configuration of databases is a complicated, repetitive, time-consuming and labor-intensive challenge for database administrators. The quality is also quite different, so that the adjustment of database configuration parameters has the problems of low automation, slow speed and low efficiency.
发明内容SUMMARY OF THE INVENTION
本申请实施例提供了数据库配置参数调整方法、设备及存储介质。Embodiments of the present application provide a database configuration parameter adjustment method, device, and storage medium.
第一方面,本申请实施例提供了一种数据库配置参数调整方法,应用于数据库调优模块,包括:获取来自数据库服务器的数据库状态混合表征参数;将所述数据库状态混合表征参数输入到深度强化学习模型中生成目标数据库配置参数;将所述目标数据库配置参数发送至数据库服务器。In a first aspect, an embodiment of the present application provides a method for adjusting database configuration parameters, which is applied to a database tuning module, including: obtaining a database state mixed representation parameter from a database server; inputting the database state mixed representation parameter into Deep Enhancement Generate target database configuration parameters in the learning model; send the target database configuration parameters to the database server.
第二方面,本申请实施例提供了一种数据库配置参数调整方法,应用于数据库服务器,包括:发送数据库状态混合表征参数给数据库调优模块,以使数据库调优模块执行如第一方面所述的方法;接收来自所述数据库调优模块发送的目标数据库配置参数;根据所述数据库配置参数对数据库服务器进行参数配置。In a second aspect, an embodiment of the present application provides a method for adjusting database configuration parameters, which is applied to a database server, including: sending a database state mixed representation parameter to a database tuning module, so that the database tuning module executes as described in the first aspect receiving the target database configuration parameters sent from the database tuning module; and performing parameter configuration on the database server according to the database configuration parameters.
第三方面,本申请实施例提供了一种电子设备,包括:至少一个处理器,以及,与所述至少一个处理器通信连接的存储器;其中,所述存储器存储有指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器执行所述指令时实现如第一方面所述的方法或如第二方面所述的方法。In a third aspect, an embodiment of the present application provides an electronic device, including: at least one processor, and a memory communicatively connected to the at least one processor; wherein the memory stores instructions, and the instructions are The at least one processor executes, so that when the at least one processor executes the instructions, the method as described in the first aspect or the method as described in the second aspect is implemented.
第四方面,本申请实施例提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可执行指令,所述计算机可执行指令用于使计算机执行第一方面所述的方法或第二方面所述的方法。In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, where the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to cause a computer to execute the method described in the first aspect or the method described in the second aspect.
本申请的其它特征和优点将在随后的说明书中阐述,并且,部分地从说明书中变得显而易见,或者通过实施本申请而了解。本申请的目的和其他优点可通过在说明书、权利要求书以及附图中所特别指出的结构来实现和获得。Other features and advantages of the present application will be set forth in the description which follows, and in part will be apparent from the description, or may be learned by practice of the present application. The objectives and other advantages of the application may be realized and attained by the structure particularly pointed out in the description, claims and drawings.
附图说明Description of drawings
附图用来提供对本申请技术方案的进一步理解,并且构成说明书的一部分,与本申请的实施例一起用于解释本申请的技术方案,并不构成对本申请技术方案的限制。The accompanying drawings are used to provide a further understanding of the technical solutions of the present application, and constitute a part of the specification. They are used to explain the technical solutions of the present application together with the embodiments of the present application, and do not constitute a limitation on the technical solutions of the present application.
图1是本申请实施例提供的数据库配置参数调整方法的流程图;1 is a flowchart of a method for adjusting database configuration parameters provided by an embodiment of the present application;
图2是本申请实施例提供的数据库配置参数调整示意图;2 is a schematic diagram of database configuration parameter adjustment provided by an embodiment of the present application;
图3是本申请另一实施例提供的数据库配置参数调整方法的流程图;3 is a flowchart of a method for adjusting database configuration parameters provided by another embodiment of the present application;
图4是本申请实施例提供的数据库配置参数调整中混合表征模块示意图;4 is a schematic diagram of a hybrid characterization module in database configuration parameter adjustment provided by an embodiment of the present application;
图5是本申请另一实施例提供的数据库配置参数调整模块示意图;5 is a schematic diagram of a database configuration parameter adjustment module provided by another embodiment of the present application;
图6是本申请另一实施例提供的数据库配置参数调整模块中奖励函数模块示意图;6 is a schematic diagram of a reward function module in a database configuration parameter adjustment module provided by another embodiment of the present application;
图7是本申请实施例提供的数据库配置参数自调优模块示意图;7 is a schematic diagram of a database configuration parameter self-tuning module provided by an embodiment of the present application;
图8是本申请另一实施例提供的数据库配置参数调整方法的流程图;8 is a flowchart of a method for adjusting database configuration parameters provided by another embodiment of the present application;
图9是本申请另一实施例提供的数据库配置参数自调优原理流程图;FIG. 9 is a flow chart of the principle of self-tuning of database configuration parameters provided by another embodiment of the present application;
图10是本申请另一实施例提供的数据库配置参数调整方法的流程图;10 is a flowchart of a method for adjusting database configuration parameters provided by another embodiment of the present application;
图11是本申请另一实施例提供的数据库配置参数调整方法的流程图;11 is a flowchart of a method for adjusting database configuration parameters provided by another embodiment of the present application;
图12是本申请实施例提供的数据库配置参数调整方法应用场景图;12 is an application scenario diagram of the method for adjusting database configuration parameters provided by an embodiment of the present application;
图13(a)、13(b)是本申请另一实施例提供的数据库配置参数调整方法整体流程图;13(a) and 13(b) are an overall flowchart of a method for adjusting database configuration parameters provided by another embodiment of the present application;
图14是本申请另一实施例提供的数据库配置参数调整方法应用场景图;14 is an application scenario diagram of a method for adjusting database configuration parameters provided by another embodiment of the present application;
图15是本申请一实施例提供的数据库配置参数调整电子设备示意图。FIG. 15 is a schematic diagram of an electronic device for adjusting database configuration parameters provided by an embodiment of the present application.
具体实施方式detailed description
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。不冲突的情况下,本申请中的实施例及实施例中的特征可以相互任意组合。In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application will be described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, but not to limit the present application. If there is no conflict, the embodiments in this application and the features in the embodiments may be combined with each other arbitrarily.
需要说明的是,虽然在装置示意图中进行了功能模块划分,在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于装置中的模块划分,或流程图中的顺序执行所示出或描述的步骤。说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。It should be noted that although the functional modules are divided in the schematic diagram of the device, and the logical sequence is shown in the flowchart, in some cases, the modules may be divided differently from the device, or executed in the order in the flowchart. steps shown or described. The terms "first", "second" and the like in the description and claims and the above drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
数据库是长期储存在计算机内、有组织的、可共享的数据集合。随着科学技术的发展,用于用户信息连接的数据量急剧增长,数据库作为信息技术存储服务的基础支撑,其应用将更加广泛,数据库的广泛应用随之而来的是数据库的优化问题。A database is an organized, sharable collection of data stored in a computer for a long time. With the development of science and technology, the amount of data used for user information connection has grown rapidly. As the basic support for information technology storage services, the database will be more widely used.
目前,大规模数据库的优化一般依赖于数据库管理员,但是数据库的差异化配置对于数据库管理员而言是一个繁杂、重复、耗时费力的挑战,而经验不同的数据库管理员对数据库的配置参数质量也大相径庭,从而使数据库配置参数的调整存在自动化程度低、速度慢、效率低的情况。At present, the optimization of large-scale databases generally relies on database administrators, but the differential configuration of databases is a complicated, repetitive, time-consuming and labor-intensive challenge for database administrators. The quality also varies widely, resulting in low automation, slow speed, and low efficiency in the adjustment of database configuration parameters.
基于此,本申请实施例提出了一种数据库配置参数调整方法、设备及存储介质,本申请实施例能够利用深度强化学习模型将获取到的数据库状态混合表征参数进行处理后生成目标数据库配置参数,并将生成的数据库配置参数发送到数据库服务器进行配置,从而克服了数据库配置自动化程度低、速度慢、效率低的问题,有效提高了数据库配置的自动化程度、速度和效率。Based on this, the embodiment of the present application proposes a database configuration parameter adjustment method, device, and storage medium. The embodiment of the present application can use a deep reinforcement learning model to process the obtained database state mixed representation parameters to generate target database configuration parameters, The generated database configuration parameters are sent to the database server for configuration, thereby overcoming the problems of low automation, slow speed and low efficiency of database configuration, and effectively improving the automation, speed and efficiency of database configuration.
需要说明的是,下列多种实施例中,电子设备可以是平板电脑、桌面型、膝上型、手持计算机、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本,以及个人数字助理(personal digital assistant,PDA)、增强现实(augmented reality,AR)/虚拟现实(virtual reality,VR)设备等包括上述折叠屏的设备,本申请实施例对该电子设备的具体形态不作特殊限制。It should be noted that, in the following various embodiments, the electronic device may be a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, and a personal computer. Digital assistant (personal digital assistant, PDA), augmented reality (augmented reality, AR)/virtual reality (virtual reality, VR) device and other devices including the above-mentioned folding screen, the embodiment of this application does not make special restrictions on the specific form of the electronic device .
第一方面,本申请实施例提供了一种数据库配置参数调整方法,应用于数据库调优模块。In a first aspect, an embodiment of the present application provides a method for adjusting database configuration parameters, which is applied to a database tuning module.
在一些实施例中,参照图1,数据库配置参数调整方法包括:In some embodiments, referring to FIG. 1 , the database configuration parameter adjustment method includes:
步骤S1100,获取来自数据库服务器的数据库状态混合表征参数;Step S1100, obtaining the database state mixed representation parameter from the database server;
步骤S1200,将数据库状态混合表征参数输入到深度强化学习模型中生成目标数据库配置参数;Step S1200, inputting the database state mixed representation parameters into the deep reinforcement learning model to generate target database configuration parameters;
步骤S1300,将目标数据库配置参数发送至数据库服务器。Step S1300, sending the target database configuration parameters to the database server.
在一些实施例中,步骤S1100中的数据库状态混合表征参数可以是数据库的状态参数或者配置参数等,通过数据库的这些状态混合表征参数可以了解到数据库的性能,比如数据库状态参数中的数据库性能参数等,而数据库配置参数的好坏直接影响到数据库的查询和响应速度。In some embodiments, the database state mixed characterization parameters in step S1100 may be database state parameters or configuration parameters, etc. The performance of the database can be learned through these state mixed characterization parameters of the database, such as the database performance parameters in the database state parameters etc., and the quality of database configuration parameters directly affects the query and response speed of the database.
在一些实施例中,步骤S1200中,将上述的数据库状态混合表征参数输入到深度强化学习模型进行训练后会生成目标数据库的配置参数,这些配置参数会对数据库的优化起到重要作用。In some embodiments, in step S1200, after inputting the above-mentioned database state mixed representation parameters into the deep reinforcement learning model for training, configuration parameters of the target database will be generated, and these configuration parameters will play an important role in database optimization.
可以理解的,机器学习是一门多领域交叉学科,涉及概率论、统计学、逼近论、算法复杂 度理论等多门学科。专门研究计算机怎样模拟或实现人类的学习行为。以获取新的知识或技能,重新组织已有的知识结构使之不断改善自身的性能。机器学习分为监督学习、无监督学习和强化学习,其中监督学习是计算机获得简单的输入给出期望的输出,过程是通过一个“训练模型”,学习通用的准则来从输入映射到输出;无监督学习是没有给出标记用来学习算法,让它自己去发现输入的结构,无监督学习自己可以被当成一个目标或者一个实现结果的途径,也可以叫做特征学习;强化学习是一个计算机程序与动环境交互,同时表现出确切目标,比如驾驶一辆交通工具或者玩一个游戏对抗一个对手,这个程序的奖惩机制会作为反馈,实现它在问题领域中的导航。Understandably, machine learning is a multi-domain interdisciplinary subject involving probability theory, statistics, approximation theory, algorithmic complexity theory and other disciplines. Specializing in the study of how computers simulate or implement human learning behavior. In order to acquire new knowledge or skills, reorganize the existing knowledge structure to continuously improve its own performance. Machine learning is divided into supervised learning, unsupervised learning and reinforcement learning. Among them, supervised learning is that the computer obtains simple input and gives the desired output. The process is to learn general principles to map from input to output through a "training model"; no Supervised learning does not give a label to learn the algorithm, allowing it to discover the structure of the input by itself. Unsupervised learning itself can be regarded as a goal or a way to achieve results, which can also be called feature learning; reinforcement learning is a computer program with Dynamically interacting with the environment while showing a precise goal, such as driving a vehicle or playing a game against an opponent, the program’s reward and punishment mechanism serves as feedback to enable it to navigate the problem domain.
其中,深度强化学习模型是深度学习模型和强化学习模型相结合形成的深度强化学习模型,本实施例中深度学习模型为循环神经网络模型,循环神经网络模型以下简称为RNN(Recurrent Neural Network)是深度学习算法之一,RNN是一类以序列数据为输入,在序列的演进方向进行递归且所有节点即循环单元按链式连接的递归神经网络,使得RNN能捕捉到各个输出参数的相关性,可以综合数据库状态混合表征参数并进行处理。强化学习模型属于上述强化学习,将深度学习和强化学习结合形成深度强化学习,克服了传统强化学习算法无法处理高维状态空间的问题,结合强化学习与深度学习,实现了从感知到动作的端对端学习的一种全新的算法,使特征变得简单,实现无监督学习。同时智能体在自我学习的过程中可以发现特征之间的内在联系。因此深度强化学习具备了使智能体实现完全自主的学习的一种甚至多种技能的潜力,应用在本实施例中能够提供高维度参数处理的能力,并且通过自主学习不断优化模型参数。The deep reinforcement learning model is a deep reinforcement learning model formed by combining a deep learning model and a reinforcement learning model. In this embodiment, the deep learning model is a recurrent neural network model. The recurrent neural network model is hereinafter referred to as RNN (Recurrent Neural Network) One of the deep learning algorithms, RNN is a type of recurrent neural network that takes sequence data as input, performs recursion in the evolution direction of the sequence, and all nodes, namely cyclic units, are connected in a chain, so that RNN can capture the correlation of each output parameter. The database state hybrid representation parameters can be synthesized and processed. The reinforcement learning model belongs to the above reinforcement learning, which combines deep learning and reinforcement learning to form deep reinforcement learning, which overcomes the problem that traditional reinforcement learning algorithms cannot handle high-dimensional state space, and combines reinforcement learning and deep learning to realize the end from perception to action. A brand new algorithm for peer-to-peer learning that simplifies features and enables unsupervised learning. At the same time, the agent can discover the internal connection between features in the process of self-learning. Therefore, deep reinforcement learning has the potential to enable the agent to achieve completely autonomous learning of one or even multiple skills. The application in this embodiment can provide the ability to process high-dimensional parameters, and continuously optimize model parameters through autonomous learning.
本实施例将步骤S1100中获取到的数据库状态混合表征参数输入到深度强化学习模型中生成数据库配置参数,可以达到更快的收敛速度,提高配置参数生成的速度,提高配置效率。In this embodiment, the database state mixed representation parameters obtained in step S1100 are input into the deep reinforcement learning model to generate database configuration parameters, which can achieve faster convergence speed, improve the speed of configuration parameter generation, and improve configuration efficiency.
在一些实施例中,步骤S1300中的数据库服务器由运行在局域网中的一台或多台计算机和数据库管理系统软件共同构成,数据库服务器可以为客户的应用程序提供数据服务,将步骤S1200中生成的目标数据库配置参数发送给数据库服务器,可以使数据库服务器得到优化,从而提高数据库服务器中数据库性能的提高。In some embodiments, the database server in step S1300 is composed of one or more computers running in the local area network and database management system software. The database server can provide data services for the client's application program. The target database configuration parameters are sent to the database server, so that the database server can be optimized, thereby improving the performance of the database in the database server.
本实施例能够利用深度强化学习模型将获取到的数据库状态混合表征参数进行处理后生成目标数据库配置参数,并将生成的数据库配置参数发送到数据库服务器进行配置,从而克服了数据库配置速度慢、效率低的问题,有效提高了数据库配置的速度和效率。在一些实施例中,数据库状态表混合征参数包括以下的一种或多种:数据库性能参数、当前数据库配置参数、硬件资源参数、硬件资源状态参数。In this embodiment, a deep reinforcement learning model can be used to process the acquired database state mixed representation parameters to generate target database configuration parameters, and the generated database configuration parameters can be sent to the database server for configuration, thereby overcoming the slow and efficient database configuration. Low problem, effectively improve the speed and efficiency of database configuration. In some embodiments, the database status table mixed characterization parameters include one or more of the following: database performance parameters, current database configuration parameters, hardware resource parameters, and hardware resource status parameters.
在一些实施例中,数据库性能参数包括但不限于吞吐量、查询时延、自动VACUUM次数,其中,吞吐量是指对网络、设备、端口、虚电路或其他设施单位时间内成功传送数据的数量,数据的数量以比特、字节、分组等测量,吞吐量的大小直接影响到数据库数据写入、数据读出以及数据库访问的响应速度;其中查询时延是数据库从开始查询到数据库作出响应之间的延时,数据库查询时延的大小直接影响到数据库的访问响应速度;其中,自动VACUUM的主要作用是把空闲页移到数据库末尾,从而减小数据库大小,自动VACUUM可以使数据库占用空间更小。In some embodiments, the database performance parameters include, but are not limited to, throughput, query delay, and automatic VACUUM times, where throughput refers to the number of successfully transmitted data per unit time to a network, device, port, virtual circuit, or other facility , the amount of data is measured in bits, bytes, packets, etc. The throughput directly affects the response speed of database data writing, data reading and database access; the query delay is the time from the start of the database query to the database response. The size of the database query delay directly affects the access response speed of the database; among them, the main function of automatic VACUUM is to move free pages to the end of the database, thereby reducing the size of the database. Automatic VACUUM can make the database occupy more space. small.
其中,硬件资源参数包括但不限于CPU的数量、内存容量大小、存储空间大小等参数,CPU(Central Processing Unit)是一块超大规模的集成电路,是一台计算机的运算核心和控制核心。它的功能主要是解释计算机指令以及处理计算机软件中的数据其中内存主要作用是记忆与加载功能,内存容量可以理解为内存条的存储容量,一般内存容量以MB作为单位,内存容量越大越有利于硬件系统的运行。例如,计算机的内存容量通常是指随机存储器(RAM)的容量。内存的容量一般都是2的整次方倍,比如64MB、128MB、256MB等,内存容量越大越有利于硬件系统或者计算机系统的运行。Among them, hardware resource parameters include but are not limited to the number of CPUs, memory capacity, storage space and other parameters. CPU (Central Processing Unit) is an ultra-large-scale integrated circuit, which is the computing core and control core of a computer. Its function is mainly to interpret computer instructions and process data in computer software. The main function of memory is memory and loading functions. The memory capacity can be understood as the storage capacity of the memory stick. Generally, the memory capacity is in MB. The larger the memory capacity, the more beneficial it is. operation of the hardware system. For example, the memory capacity of a computer usually refers to the capacity of random access memory (RAM). The memory capacity is generally a multiple of 2, such as 64MB, 128MB, 256MB, etc. The larger the memory capacity, the more beneficial the operation of the hardware system or computer system.
其中,硬件资源状态参数包括但不限于CPU利用率、内存利用率、存储利用率等参数。其中,CPU利用率是运行进程占用的CPU的百分比,CPU利用率的大小直接影响到CPU的使用寿命,CPU利用率过高会导致CPU内部老化,从而减小了CPU的使用寿命;内存占用率指运行进程所占用的内存,内存的利用率过高会使CPU的访问速度变慢,影响整个硬件资源的性能。The hardware resource status parameters include but are not limited to parameters such as CPU utilization, memory utilization, and storage utilization. Among them, the CPU utilization is the percentage of the CPU occupied by the running process. The size of the CPU utilization directly affects the service life of the CPU. If the CPU utilization is too high, it will cause the internal aging of the CPU, thereby reducing the service life of the CPU; the memory occupancy rate Refers to the memory occupied by the running process. Excessive memory utilization will slow down the access speed of the CPU and affect the performance of the entire hardware resource.
在一些实施例中,参照图2,深度强化学习模型包括混合表征模块和自调优模块,混合表征模块连接自调优模块,其中混合表征模块使用的为RNN模型,自调优模块使用的为强化学习模型。In some embodiments, referring to FIG. 2 , the deep reinforcement learning model includes a hybrid representation module and a self-tuning module, the hybrid representation module is connected to the self-tuning module, wherein the hybrid representation module uses an RNN model, and the self-tuning module uses a Reinforcement learning models.
自调优模块通过控制接口将数据库配置参数传输给服务器的控制接口,服务器通过控制压测装置输出工作负载压力信号给目标数据库(如数据库服务器)加压;参数采集模块对目标数据库中的硬件资源状态参数、数据库性能参数进行采集,结合服务器自身的硬件资源参数,将上述参数通过服务器的控制接口传送给数据库调优模块中的混合表征模块进行混合表征,输出数据库状态混合表征向量输送给自调优模块,自调优模块通过强化学习中的当前动作网络完成与数据库的交互,从而把自调优模块生成的配置参数传输给目标数据库。The self-tuning module transmits the database configuration parameters to the control interface of the server through the control interface, and the server outputs the workload pressure signal to pressurize the target database (such as the database server) by controlling the pressure measurement device; the parameter acquisition module monitors the hardware resources in the target database The state parameters and database performance parameters are collected, combined with the server's own hardware resource parameters, the above parameters are transmitted to the hybrid characterization module in the database tuning module through the server's control interface for hybrid characterization, and the output database state hybrid characterization vector is sent to the self-tuning The self-tuning module completes the interaction with the database through the current action network in reinforcement learning, so as to transmit the configuration parameters generated by the self-tuning module to the target database.
本实施例能够实现通过RNN模型和强化学习模型形成的深度强化学习模型,再结合数据库状态混合表征参数,获得数据库的配置参数,从而提高了数据库配置参数的生成速度,提高了数据库配置的效率。This embodiment can realize the deep reinforcement learning model formed by the RNN model and the reinforcement learning model, and then combine the database state mixed representation parameters to obtain the configuration parameters of the database, thereby improving the generation speed of the database configuration parameters and improving the efficiency of the database configuration.
参照图3,步骤S1200具体包括:3, step S1200 specifically includes:
步骤S1210,将数据库状态混合表征参数输入到混合表征模块;Step S1210, input the database state mixed characterization parameters into the mixed characterization module;
步骤S1220,混合表征模块利用RNN模型对数据库状态混合表征参数处理,得到数据库状态混合表征向量;Step S1220, the hybrid characterization module uses the RNN model to process the database state hybrid characterization parameters to obtain a database state hybrid characterization vector;
步骤S1230,将数据库状态混合表征向量输入到自调优模块,自调优模块利用加强学习模型对数据库状态混合表征向量处理得到目标数据库配置参数。Step S1230, the database state mixed representation vector is input to the self-tuning module, and the self-tuning module uses the reinforcement learning model to process the database state mixed representation vector to obtain target database configuration parameters.
在一些实施例中,步骤S1210中将上述数据库状态混合表征参数输入到混合表征模块的目的是为了得到数据库状态混合表征的向量,混合表征即各种特征相互融合,输入到混合表征模块中。In some embodiments, the purpose of inputting the above-mentioned database state mixed representation parameters into the mixed representation module in step S1210 is to obtain a vector of the mixed representation of database states.
本实施例中使用了上述参数的混合表征,能够保证数据库状态表征的完备性和准确性。The mixed representation of the above parameters is used in this embodiment, which can ensure the completeness and accuracy of the database state representation.
在一些实施例中,步骤S1220中混合表征模块中使用的是神经网络模型对上述数据库状态混合表征参数的特征进行处理,得到一个数据库状态混合表征向量,更为具体的是,使用的神经网络模型为循环神经网络模型即RNN,RNN是指一个随着时间的推移,重复发生的结构;一个典型的RNN网络包含一个输入,一个输出和一个神经网络单元,其中RNN网络的神经网络单元不仅仅与输入和输出存在联系,其与自身也存在一个回路也即上一个时刻的网络状态信息将会作用于下一个时刻的网络状态。RNN能够提高模型的收敛速度,从而提高了数据库配置参数的生成速度,使数据库配置更加高效。In some embodiments, the hybrid representation module in step S1220 uses a neural network model to process the features of the above database state hybrid representation parameters to obtain a database state hybrid representation vector. More specifically, the neural network model used RNN is a recurrent neural network model, RNN refers to a structure that recurs over time; a typical RNN network contains an input, an output and a neural network unit, where the neural network unit of the RNN network is not only related to There is a relationship between input and output, and there is also a loop with itself, that is, the network state information at the previous moment will act on the network state at the next moment. RNN can improve the convergence speed of the model, thereby improving the generation speed of database configuration parameters and making the database configuration more efficient.
在一些实施例中,数据库状态混合表征参数包括数据库性能参数、当前数据库配置参数、硬件资源参数、硬件资源状态参数,上述步骤S1220包括:In some embodiments, the database state mixed representation parameters include database performance parameters, current database configuration parameters, hardware resource parameters, and hardware resource state parameters. The above step S1220 includes:
步骤S1221,获取当前数据库性能参数和前次数据库性能参数;以及,获取当前数据库配置参数和前次数据库配置参数;以及,获取当前硬件资源状态参数和前次硬件资源状态参数;以及,获取硬件资源参数;Step S1221, acquiring the current database performance parameters and the previous database performance parameters; and, acquiring the current database configuration parameters and the previous database configuration parameters; and, acquiring the current hardware resource state parameters and the previous hardware resource state parameters; and, acquiring the hardware resources parameter;
步骤S1222,根据当前数据库性能参数获得当前数据库性能参数特征向量;根据前次数据库性能参数获得前次数据库性能参数特征向量;根据当前数据库配置参数获得当前数据库配置参数特征向量;根据前次数据库配置参数获得前次数据库配置参数特征向量;根据当前硬件资源状态参数获得当前硬件资源状态参数特征向量;根据前次硬件资源状态参数获得前次所述硬件资源状态参数特征向量;根据硬件资源参数获得硬件资源参数特征向量;Step S1222, obtain the current database performance parameter feature vector according to the current database performance parameter; obtain the previous database performance parameter feature vector according to the previous database performance parameter; obtain the current database configuration parameter feature vector according to the current database configuration parameter; Obtain the previous database configuration parameter feature vector; obtain the current hardware resource state parameter feature vector according to the current hardware resource state parameter; obtain the previous hardware resource state parameter feature vector according to the previous hardware resource state parameter; obtain the hardware resource according to the hardware resource parameter parameter eigenvector;
步骤S1223,根据当前数据库性能参数特征向量和前次数据库性能参数特征向量,计算得到数据库性能参数差值特征向量;根据当前数据库配置参数特征向量和前次数据库配置参数特征向量,计算得到数据库配置参数差值特征向量;根据当前硬件资源状态参数特征向量和前次硬件资源状态参数特征向量,计算得到硬件资源状态参数差值特征向量;步骤S1224,将数据库性能参数特征向量、数据库性能参数差值特征向量、数据库配置参数特征向量、数据库配置参数差值特征向量、硬件资源状态参数特征向量、硬件资源状态参数差值特征向量、硬件资源参数特征向量输入到神经网络模型中,利用神经网络模型输出数据库状态混合表征向量。Step S1223: Calculate and obtain the database performance parameter difference feature vector according to the current database performance parameter feature vector and the previous database performance parameter feature vector; calculate and obtain the database configuration parameter according to the current database configuration parameter feature vector and the previous database configuration parameter feature vector Difference feature vector; according to the current hardware resource state parameter feature vector and the previous hardware resource state parameter feature vector, calculate the hardware resource state parameter difference feature vector; step S1224, the database performance parameter feature vector, database performance parameter difference feature vector Vector, database configuration parameter feature vector, database configuration parameter difference feature vector, hardware resource state parameter feature vector, hardware resource state parameter difference feature vector, hardware resource parameter feature vector are input into the neural network model, and the neural network model is used to output the database State mixture representation vector.
在一些实施例中,步骤S1222中将步骤S1221获取到的参数特征,输入到混合表征模块后,进行预处理编码,预处理的过程是将获取到的当前数据库性能参数和前次数据库性能参数;以及,当前数据库配置参数和前次数据库配置参数;以及,当前硬件资源状态参数和前次硬件资源状态参数;以及,获取硬件资源参数进行向量化处理,并且通过步骤S1223获得参数差值向量,通过参数的向量以及相应的参数差值向量,进行神经网络模型训练之后输出数据库状态混合表征向量。In some embodiments, in step S1222, after inputting the parameter features obtained in step S1221 into the hybrid characterization module, preprocessing coding is performed, and the process of preprocessing is to obtain the current database performance parameters and the previous database performance parameters; And, current database configuration parameter and previous database configuration parameter; And, current hardware resource state parameter and previous hardware resource state parameter; And, obtain hardware resource parameter to carry out vectorization processing, and obtain parameter difference value vector by step S1223, The vector of parameters and the corresponding vector of parameter differences are outputted as a mixed representation vector of database state after the neural network model is trained.
在一些实施例中,参照图4,图中历史记录为前次数据库性能参数、前次数据库配置参数、前次数据库硬件资源状态参数,通过结合当前数据库性能参数、当前数据库配置参数、当前数据库硬件资源状态参数,进行预处理之后形成数据库状态混合表征向量传输给自调优模块,同时,将当前数据库性能参数、当前数据库硬件资源状态参数、前次数据库性能参数、前次数据库硬件资源状态参数以及前次数据库配置数据库输入到样本池,作为样本存储。In some embodiments, referring to FIG. 4 , the historical records in the figure are the previous database performance parameters, the previous database configuration parameters, and the previous database hardware resource status parameters. By combining the current database performance parameters, the current database configuration parameters, and the current database hardware The resource state parameters are preprocessed to form a mixed representation vector of database state and transmitted to the self-tuning module. At the same time, the current database performance parameters, the current database hardware resource state parameters, the previous database performance parameters, the previous database hardware resource state parameters and The previous database configuration database is input to the sample pool and stored as a sample.
本实施例能够实现自调优模块中数据库状态混合表征向量的生成以及实现样本池中参数的生成,为优化数据库调优模块的提供参数基础。This embodiment can realize the generation of the database state mixed representation vector in the self-tuning module and the generation of parameters in the sample pool, which provides a parameter basis for optimizing the database tuning module.
在一些实施例中,步骤S1224中存在数据库性能参数特征向量、数据库性能参数差值向量、数据库配置参数特征向量、数据库配置参数差值向量、硬件资源状态参数特征向量、硬件资源状态参数差值向量、硬件资源参数向量这七个向量输入到神经网络模型中,利用神经网络模型输出数据库状态混合表征向量。这七个特征向量具有相关性,采用循环神经网络RNN对其进行关系提取并进行编码降维,实现数据库状态混合表征,这样提高了数据库表征向量对数据库及其硬件资源环境状态表征的全面性和准确性,提高了数据库配置参数调整的有效性和高效性。In some embodiments, in step S1224, there are a database performance parameter feature vector, a database performance parameter difference vector, a database configuration parameter feature vector, a database configuration parameter difference vector, a hardware resource state parameter feature vector, and a hardware resource state parameter difference vector , hardware resource parameter vector These seven vectors are input into the neural network model, and the neural network model is used to output the mixed representation vector of the database state. These seven eigenvectors are related, and the cyclic neural network RNN is used to extract the relationship and reduce the dimensionality of the coding, so as to realize the mixed representation of the database state, which improves the comprehensiveness and characterization of the database and its hardware resource environment state by the database characterization vector. Accuracy improves the effectiveness and efficiency of database configuration parameter adjustment.
本实施例中以硬件资源参数为CPU为4核、内存为32G、存储为256G的数据库服务器为例说明本实施例的核心思想。其中,内存为运行内存,也可以叫做RAM,关机后数据就会不存在。内存的大小决定了机器的运行速度;存储为256G代表CPU的存储能力,能够存储256G大小的数据。假设数据库相关的采集数据,以10个维度的向量特征为例,则数据库硬件资源参数特征向量为[4,32,256,0,0,0,0,0,0,0],其中,4代表CPU未4核,32代表内存大小是32G,256代表存储大小为256G,向量后面缺失的维度以补0处理,即后面补充7个0作为补充维度。In this embodiment, the core idea of this embodiment is described by taking a database server whose hardware resource parameters are 4-core CPU, 32G memory, and 256G storage as an example. Among them, the memory is the running memory, which can also be called RAM, and the data will not exist after the shutdown. The size of the memory determines the running speed of the machine; the storage as 256G represents the storage capacity of the CPU, which can store 256G of data. Assuming database-related collection data, taking 10-dimensional vector features as an example, the database hardware resource parameter feature vector is [4, 32, 256, 0, 0, 0, 0, 0, 0, 0], where 4 It means that the CPU does not have 4 cores, 32 means that the memory size is 32G, and 256 means that the storage size is 256G. The missing dimension after the vector is processed with 0s, that is, 7 0s are added as supplementary dimensions.
本实施例中的当前硬件资源状态参数特征向量为[0.6,0.58,0.3,0,0,0,0,0,0,0],其中,0.6代表CPU的利用率,0.58代表内存利用率,0.3代表存储利用率,同样,后面7个0代表缺失的维度;前次的硬件资源状态参数特征向量为[0.4,0.48,0.5,0,0,0,0,0,0,0],则硬件资源状态参数差值向量为,当前硬件资源状态参数特征向量减去前次硬件资源状态参数特征向量,则硬件资源状态参数差值向量为[0.2,0.10,-0.2,0,0,0,0,0,0,0];In this embodiment, the current hardware resource state parameter feature vector is [0.6, 0.58, 0.3, 0, 0, 0, 0, 0, 0, 0], where 0.6 represents the CPU utilization rate, 0.58 represents the memory utilization rate, 0.3 represents the storage utilization. Similarly, the following seven 0s represent the missing dimension; the previous hardware resource status parameter feature vector is [0.4, 0.48, 0.5, 0, 0, 0, 0, 0, 0, 0], then The hardware resource state parameter difference vector is, the current hardware resource state parameter feature vector minus the previous hardware resource state parameter feature vector, then the hardware resource state parameter difference vector is [0.2, 0.10, -0.2, 0, 0, 0, 0, 0, 0, 0];
本实施例中的当前配置参数特征向量为[542,730,9,7,55,23,99,10,67,86],其中542代表数据库配置参数中的temp_buffers,即临时缓冲区大小,用于数据库会话访问临时表数据,730代表work_mem,写入临时文件之前内部排序操作和散列表使用的内存大小,9代表max_wal_size,在自动WAL检查点使得WAL增长到最大尺寸等相关配置参数向量,若前次配置参数特征向量为[372,650,3,4,32,21,76,13,67,56],则数据库配置参数差值向量为当前的当前配置参数特征向量与前次当前配置参数特征向量之间的差值向量,即[170,80,6,3,23,2,23,-3,0,30]。The current configuration parameter feature vector in this embodiment is [542, 730, 9, 7, 55, 23, 99, 10, 67, 86], where 542 represents temp_buffers in the database configuration parameters, that is, the size of the temporary buffer. Accessing temporary table data in a database session, 730 represents work_mem, the memory size used by internal sorting operations and hash tables before writing to the temporary file, 9 represents max_wal_size, and a vector of related configuration parameters such as WAL grows to the maximum size during automatic WAL checkpoints. The previous configuration parameter feature vector is [372, 650, 3, 4, 32, 21, 76, 13, 67, 56], then the database configuration parameter difference vector is the current current configuration parameter feature vector and the previous current configuration parameter Difference vector between feature vectors, i.e. [170, 80, 6, 3, 23, 2, 23, -3, 0, 30].
本实施例中当前数据库性能参数特征向量为[1154.5,8.5,515,9325.0,854.8,0.0,91,1.0,6.7,8.6],其中,1154.5代表n_tup_ins状态参数,8.5代表buffers_alloc配置参数,515代表xact_commit配置参数,9325.0代表n_dead_tup状态参数等。则性能数据库性能参数差值向量为[104.0,3.0,15,2.0,-122.1,0,23,0.2,1.4,1.0]。In this embodiment, the current database performance parameter feature vector is [1154.5, 8.5, 515, 9325.0, 854.8, 0.0, 91, 1.0, 6.7, 8.6], where 1154.5 represents the n_tup_ins state parameter, 8.5 represents the buffers_alloc configuration parameter, and 515 represents the xact_commit Configuration parameters, 9325.0 represents n_dead_tup status parameters, etc. Then the performance database performance parameter difference vector is [104.0, 3.0, 15, 2.0, -122.1, 0, 23, 0.2, 1.4, 1.0].
本实施例中利用了数据库性能参数、数据库配置参数、硬件资源参数、当前值以及当前值与前次值之间的差值进行混合表征,其中,前次值可以理解为历史值,可以理解的,在进行数据库配置参数调优过程中不会只观察当前的数据库性能参数,而是经过一次数据库配置参数调整之后观察数据库性能参数的变化情况,而数据库性能参数的变化又是由数据库配置参数的变 化量所决定的,而当前的数据库性能参数总体又是由硬件资源参数所决定的,将数据库管理员的人工调整过程进行抽象化就是利用硬件资源参数、数据库性能参数、数据库配置参数的当前值和前次值或者历史值对数据库的状态进行混合表征,并且RNN可以捕捉各参数间的关系从而可以实时、准确作出数据库配置参数的调整。In this embodiment, database performance parameters, database configuration parameters, hardware resource parameters, current values, and the difference between the current value and the previous value are used for mixed characterization, wherein the previous value can be understood as a historical value, which is understandable , In the process of database configuration parameter tuning, we will not only observe the current database performance parameters, but observe the changes of database performance parameters after one database configuration parameter adjustment, and the changes of database performance parameters are determined by the database configuration parameters. It is determined by the amount of change, and the current database performance parameters are generally determined by hardware resource parameters. To abstract the manual adjustment process of database administrators is to use the current values of hardware resource parameters, database performance parameters, and database configuration parameters. The state of the database is mixed with the previous value or the historical value, and the RNN can capture the relationship between the parameters so that the database configuration parameters can be adjusted in real time and accurately.
在一些实施例中,参照图5,深度强化学习模型还包括数据库配置参数奖励函数模块;In some embodiments, referring to FIG. 5 , the deep reinforcement learning model further includes a database configuration parameter reward function module;
具体的,步骤S1200还包括:Specifically, step S1200 further includes:
S1240,将数据库状态混合表征参数分别输入到混合表征模块和数据库配置参数奖励函数模块,生成奖励策略;S1240, input the database state mixed characterization parameters into the mixed characterization module and the database configuration parameter reward function module, respectively, to generate a reward strategy;
S1250,将奖励策略存储到样本池中;S1250, store the reward strategy in the sample pool;
S1260,对样本池采样获得采样数据;S1260, sampling the sample pool to obtain sampling data;
S1270,利用采样数据,对自调优模块进行优化。S1270, using the sampled data to optimize the self-tuning module.
可以理解的,S1240中数据库状态混合表征参数包括数据库性能参数、当前数据库配置参数、硬件资源参数、硬件资源状态参数,其中,数据库配置参数是数据库运行过程中所配置的参数,该参数会影响数据库的性能参数和数据库硬件状态参数,在强化学习中通常称为动作a;其中数据库的性能参数,其中性能参数包括但不限于数据库的吞吐量、时延的性能指标,数据库硬件状态参数包括但不限于CPU利用率、内存利用率、存储利用率等指标。数据库配置参数奖励函数模块中的数据库配置参数奖励函数主要用于评价当前数据库配置参数的好坏,例如数据库的吞吐量、时延是否满足业务需求,在强化学习中通常称为奖励r。It can be understood that the mixed representation parameters of the database state in S1240 include database performance parameters, current database configuration parameters, hardware resource parameters, and hardware resource state parameters, wherein the database configuration parameters are parameters configured during the operation of the database, and this parameter will affect the database. The performance parameters and database hardware status parameters are usually called action a in reinforcement learning; the performance parameters of the database include but are not limited to the throughput and latency performance indicators of the database, and the database hardware status parameters include but are not limited to Limited to indicators such as CPU utilization, memory utilization, and storage utilization. The database configuration parameter reward function in the database configuration parameter reward function module is mainly used to evaluate the quality of the current database configuration parameters, such as whether the throughput and latency of the database meet the business requirements, which is usually called reward r in reinforcement learning.
其中,的数据库性能参数和硬件资源状态参数可以统称为数据库状态参数,在强化学习中称为状态s,可以理解的,数据库状态参数和数据库配置参数是成对出现的,即一组数据库配置参数对应着一组数据库状态参数,数据库状态参数包括但不限于数据库性能参数、当前配置参数、硬件资源状态参数,其中硬件资源状态参数包括CPU利用率和/或内存利用率,在强化学习中通常称为状态s。Among them, the database performance parameters and hardware resource state parameters can be collectively referred to as database state parameters, which are called state s in reinforcement learning. It is understandable that database state parameters and database configuration parameters appear in pairs, that is, a set of database configuration parameters. Corresponding to a set of database state parameters, the database state parameters include but are not limited to database performance parameters, current configuration parameters, and hardware resource state parameters, wherein the hardware resource state parameters include CPU utilization and/or memory utilization, which are usually called in reinforcement learning. is state s.
在一些实施例中,步骤S1240中的数据库配置参数奖励函数模块被设置成生成当前数据库配置参数的奖励值r,混合表征模块被设置成输出数据库配置参数、数据库性能参数和硬件资源状态参数,其中的数据库性能参数和硬件资源状态参数可以结合看作是数据库状态参数,当前的数据库状态参数表示为s_,前次的数据库状态参数表示为s,当前数据库配置参数表示为a,结合混合表征模块和数据库配置参数奖励函数模块共同输出(s,a,r,s_)的样本,再执行步骤S1250将奖励策略放在样本池。In some embodiments, the database configuration parameter reward function module in step S1240 is configured to generate the reward value r of the current database configuration parameter, and the hybrid characterization module is configured to output database configuration parameters, database performance parameters and hardware resource status parameters, wherein The database performance parameters and hardware resource status parameters can be combined as database status parameters. The current database status parameter is represented as s_, the previous database status parameter is represented as s, and the current database configuration parameter is represented as a. Combined with the hybrid characterization module and The database configuration parameter reward function module outputs samples of (s, a, r, s_) together, and then executes step S1250 to place the reward strategy in the sample pool.
在一些实施例中,上述步骤S1240包括:In some embodiments, the above step S1240 includes:
S1241,将当前数据库性能参数与前次数据库性能参数差值、当前硬件资源状态参数与前次硬件资源状态参数差值归一化处理后输出当前数据库配置参数的奖励值;S1241, output the reward value of the current database configuration parameter after normalizing the difference between the current database performance parameter and the previous database performance parameter, and the difference between the current hardware resource state parameter and the previous hardware resource state parameter;
其中,归一化处理为,计算当前数据库性能参数与前次数据库性能参数差值在前次数据库性能参数中的占比;以及,当前硬件资源状态参数与前次硬件资源状态参数差值在前次硬件资源状态参数的占比,并对占比乘以相应的加权值求和后输出当前数据库配置参数的奖励值;Among them, the normalization process is to calculate the proportion of the difference between the current database performance parameter and the previous database performance parameter in the previous database performance parameter; and, the difference between the current hardware resource state parameter and the previous hardware resource state parameter is the first The ratio of the secondary hardware resource status parameters, and the ratio is multiplied by the corresponding weighted value to output the reward value of the current database configuration parameter;
S1242,根据当前数据库配置参数的奖励值、当前数据库配置参数、当前数据库性能参数、当前硬件资源状态参数、前次数据库性能参数、前次硬件资源状态参数,生成奖励策略。S1242: Generate a reward policy according to the reward value of the current database configuration parameter, the current database configuration parameter, the current database performance parameter, the current hardware resource state parameter, the previous database performance parameter, and the previous hardware resource state parameter.
在一些实施例中,步骤S1241中的归一化是把数变为0到1之间的小数,本实施例中的归一化是通过计算当前数据库性能参数和前次数据库性能参数,以及,当前硬件资源状态参数与前次硬件资源状态参数之间的差值,并且分别通过当前数据库性能参数和前次数据库性能参数与当前数据库性能参数的占比,以及,当前硬件资源状态参数与前次硬件资源状态参数差值在前次硬件资源状态参数的占比,并且对上述占比乘以相应的加权值求和,输出当前数据库配置参数的奖励值;具体公式如下:In some embodiments, the normalization in step S1241 is to change the number into a decimal between 0 and 1, and the normalization in this embodiment is to calculate the current database performance parameter and the previous database performance parameter, and, The difference between the current hardware resource state parameter and the previous hardware resource state parameter, and the ratio of the current database performance parameter and the previous database performance parameter to the current database performance parameter, and the current hardware resource state parameter and the previous The ratio of the difference value of the hardware resource state parameter to the previous hardware resource state parameter, and the above ratio is multiplied by the corresponding weighted value and summed to output the reward value of the current database configuration parameter; the specific formula is as follows:
r=(当前数据库性能参数和前次数据库性能参数差值/前次数据库性能参数)*α+(当前硬件资源状态参数与前次硬件资源状态参数差值/前次硬件资源状态参数)*β;r=(difference between current database performance parameter and previous database performance parameter/previous database performance parameter)*α+(difference between current hardware resource state parameter and previous hardware resource state parameter/previous hardware resource state parameter)*β ;
其中,α,β为加权值,r为对上述数据库性能参数和硬件资源状态参数归一化处理后的归 一化值,在本实施例中代表当前数据库配置参数的奖励值。Wherein, α and β are weighted values, and r is a normalized value after normalizing the above-mentioned database performance parameters and hardware resource state parameters, and in this embodiment, represents the reward value of the current database configuration parameter.
在一些实施例中,参照图6,步骤S1241中的硬件资源状态参数包括CPU利用率和内存利用率,利用步骤S1241中的归一化方法处理过程中,可以根据数据库配置参数调整过程中对数据库性能参数、CPU利用率和内存利用率的侧重程度不同,进行通过设置加权值的大小,进行具体的归一化处理,具体的归一化公式为:In some embodiments, referring to FIG. 6 , the hardware resource status parameters in step S1241 include CPU utilization and memory utilization. In the processing process using the normalization method in step S1241, the database configuration parameters can be adjusted according to the database configuration parameters during the process. Performance parameters, CPU utilization and memory utilization have different degrees of emphasis. The specific normalization process is carried out by setting the size of the weighted value. The specific normalization formula is:
Figure PCTCN2021102782-appb-000001
Figure PCTCN2021102782-appb-000001
Δperfor=cur_perfor-hist_perfor;Δperfor=cur_perfor-hist_perfor;
Δcpu_rate=cur_cpu_rate-hist_cpu_rate;Δcpu_rate=cur_cpu_rate-hist_cpu_rate;
Δmen_rate=cur_men_rate-hist_men_rate;Δmen_rate=cur_men_rate-hist_men_rate;
其中,α、β、γ为加权值,r为当前数据库配置参数的奖励值,cur_perfor为当前数据库性能参数,hist_perfor为前次或者历史数据库性能参数,cur_cpu_rate为当前CPU利用率,hist_cpu_rate为前次或者历史CPU利用率,cur_men_rate为当前内存利用率,hist_men_rate为前次或者历史内存利用率,△perfor为当前数据库性能参数和前次或者历史数据库性能参数的差值,△cpu_rate为当前CPU利用率和前次或者历史CPU利用率的差值,△men_rate为当前内存利用率和前次或者历史内存利用率的差值。Among them, α, β, γ are weighted values, r is the reward value of the current database configuration parameter, cur_perfor is the current database performance parameter, hist_perfor is the previous or historical database performance parameter, cur_cpu_rate is the current CPU utilization, and hist_cpu_rate is the previous or Historical CPU utilization, cur_men_rate is the current memory utilization, hist_men_rate is the previous or historical memory utilization, △perfor is the difference between the current database performance parameters and the previous or historical database performance parameters, and △cpu_rate is the current CPU utilization and previous The difference between the current or historical CPU utilization, and △men_rate is the difference between the current memory utilization and the previous or historical memory utilization.
可以理解的,可以通过设置加权值的大小来调整在数据库配置参数调整过程中对数据库性能参数、CPU利用率和内存利用率的侧重程度不同,例如侧重于对数据库性能参数的优化,那么性能参数分量权值α可以设置为较大值,如果侧重于对CPU利用率的优化,则β可以设置为较大值,同理如果数据库优化侧重于内存利用率的优化,则将γ设置为较大值,对上述各个分量归一化是为了解决三个参数量纲和变化程度不同的问题。It is understandable that the weighted value can be set to adjust the degree of emphasis on database performance parameters, CPU utilization and memory utilization in the process of database configuration parameter adjustment. For example, focusing on the optimization of database performance parameters, then performance parameters The component weight α can be set to a larger value. If it focuses on the optimization of CPU utilization, β can be set to a larger value. Similarly, if the database optimization focuses on the optimization of memory utilization, set γ to a larger value. The normalization of the above components is to solve the problem of different dimensions and varying degrees of the three parameters.
例如,本是实施例中对数据库的优化比较侧重于数据库性能参数,则综合实验考虑之后设定其中的加权值α为0.8,β为0.1,γ为0.1,cur_perfor=8550tps,hist_perfor=6800tps,cur_cpu_rate=85%,hist_cpu_rate=56%,cur_men_rate=72%,hist_men_rate=63%,则根据上述归一化处理后,r为0.2647,则此处的0.2647就是奖励输出,也即是当前数据库配置参数的奖励值。For example, the optimization of the database in this embodiment focuses on the database performance parameters. After comprehensive experimental consideration, the weighted values α are set to 0.8, β to 0.1, γ to 0.1, cur_perfor=8550tps, hist_perfor=6800tps, cur_cpu_rate =85%, hist_cpu_rate=56%, cur_men_rate=72%, hist_men_rate=63%, then according to the above normalization processing, r is 0.2647, then 0.2647 here is the reward output, that is, the reward of the current database configuration parameters value.
本实施例中当前数据库配置参数的奖励值的生成是结合数据库性能参数、CPU利用率和内存利用率参数的当前值和前次值或历史值来计算,可以理解的,在对数据配置参数优化过程中关注的不是当前数据库性能的绝对值,更多的是关注在对数据库配置参数进行调整之后数据库性能参数、CPU利用率和内存利用率的变化量,其中的参数历史值可以是历史最大值或者数据库默认配置时对应采集值或者是滑动窗口内记录的均值。在计算奖励过程中首先对上述数据库性能参数、CPU利用率和内存利用率三个参数分别求差值,然后对三个差值进行归一化,最后加权求和作为奖励输出。In this embodiment, the generation of the reward value of the current database configuration parameter is calculated by combining the current value and the previous value or the historical value of the database performance parameter, CPU utilization and memory utilization parameter. It is understandable that when optimizing the data configuration parameter In the process, the focus is not on the absolute value of the current database performance, but more on the changes in database performance parameters, CPU utilization, and memory utilization after the database configuration parameters are adjusted. The historical value of the parameters can be the historical maximum value. Or the default configuration of the database corresponds to the collected value or the mean value recorded in the sliding window. In the process of calculating the reward, firstly, the differences of the above three parameters of database performance parameters, CPU utilization and memory utilization are calculated respectively, then the three differences are normalized, and finally the weighted sum is used as the reward output.
在一些实施例中,参照图7,为自调优模块原理图,模块内包括当前动作网络、当前评价网络、目标动作网络、目标评价网络,其中当前动作网络主要利用当前状态生成下次动作,当前评价网络被设置成对当前状态和下次动作进行评估,目标动作网络被设置成利用下次状态生成下次动作,并且利用目标评价网络对下次动作和下次状态进行评估。其中,当前状态参数表示为states,当前动作表示为actions,下次状态表示为next_states,下次动作表示为next_states,通过当前动作网络、当前评价网络、目标动作网络、目标评价网络之间的相互作用,在当前评价网络和目标评价网络之间会通过损失函数有机地建立联系。In some embodiments, referring to FIG. 7 , which is a schematic diagram of a self-tuning module, the module includes a current action network, a current evaluation network, a target action network, and a target evaluation network, wherein the current action network mainly uses the current state to generate the next action, The current evaluation network is set to evaluate the current state and the next action, the target action network is set to generate the next action using the next state, and the next action and the next state are evaluated using the target evaluation network. Among them, the current state parameter is represented as states, the current action is represented as actions, the next state is represented as next_states, and the next action is represented as next_states, through the interaction between the current action network, the current evaluation network, the target action network, and the target evaluation network , an organic connection will be established between the current evaluation network and the target evaluation network through the loss function.
在一些实施例中,参照图7和图8,自调优模块包括:当前动作网络、当前评价网络、目标动作网络、目标评价网络;当前动作网络被设置成根据数据库状态混合表征参数生成目标数据 库配置参数并发送到数据库服务器;采样数据包括当前数据库配置参数、当前数据库状态参数、下次数据库状态参数、当前数据库配置参数的奖励值;步骤S1270中的采样数据包括当前数据库配置参数、当前数据库状态参数、下次数据库状态参数,其中数据库状态参数包括数据库性能参数和数据库硬件资源状态参数,上述步骤S1270包括:In some embodiments, referring to FIGS. 7 and 8 , the self-tuning module includes: a current action network, a current evaluation network, a target action network, and a target evaluation network; the current action network is configured to generate a target database according to the database state hybrid characterization parameters The configuration parameters are sent to the database server; the sampling data includes the current database configuration parameters, the current database state parameters, the next database state parameters, and the reward value of the current database configuration parameters; the sampling data in step S1270 includes the current database configuration parameters, the current database state parameters, the next database state parameters, wherein the database state parameters include database performance parameters and database hardware resource state parameters, the above step S1270 includes:
步骤S1271:将当前数据库状态参数输入到当前动作网络中,并生成下次数据库配置参数;Step S1271: Input the current database state parameters into the current action network, and generate the next database configuration parameters;
其中,当前数据库状态参数可以表示为states,下次数据库配置参数可以表示为next_actions,可以理解的,当前动作网络还被设置成通过处理当前数据库状态参数和混合表征向量输出目的数据库配置参数。The current database state parameter can be represented as states, and the next database configuration parameter can be represented as next_actions. It is understandable that the current action network is also set to output the destination database configuration parameter by processing the current database state parameter and the mixed representation vector.
步骤S1272:将下次数据库配置参数和当前数据库状态参数输入到当前评价网络,以确定第一损失函数值;Step S1272: Input the next database configuration parameters and the current database state parameters into the current evaluation network to determine the first loss function value;
步骤S1273:根据第一损失函数值对当前动作网络进行优化并根据当前动作网络输出的参数对目标动作网络进行软更新;Step S1273: Optimizing the current action network according to the first loss function value and softly updating the target action network according to the parameters output by the current action network;
其中,当前数据库状态参数为states,第一损失函数为policy_loss=-Q'(states,next_actions)Among them, the current database state parameter is states, and the first loss function is policy_loss=-Q'(states, next_actions)
其中,policy_loss可以作为当前网络的损失值,可以对当前动作网络进行优化,Q'(states,next_actions)表示当前数据库状态参数和下次数据库配置参数在当前评价网络中的评估值。Among them, policy_loss can be used as the loss value of the current network, which can optimize the current action network, and Q'(states, next_actions) represents the evaluation value of the current database state parameters and the next database configuration parameters in the current evaluation network.
步骤S1274:将下次数据库状态参数输入到目标动作网络中,生成下次数据库配置参数;Step S1274: Input the next database state parameters into the target action network, and generate the next database configuration parameters;
其中,下次数据库状态参数表示为next_states;Among them, the next database state parameter is represented as next_states;
步骤S1275:将当前数据库配置参数和当前数据库状态参数输入到当前评价网络中,生成当前动作评估值;Step S1275: Input the current database configuration parameters and the current database state parameters into the current evaluation network to generate the current action evaluation value;
步骤S1276:将下次数据库配置参数和下次数据库状态参数到目标评价网络中,生成下次动作评估值;Step S1276: Add the next database configuration parameters and the next database state parameters to the target evaluation network to generate the next action evaluation value;
步骤S1277:根据当前动作评估值、下次动作评估值和当前数据库配置参数的奖励值计算得到第二损失函数值;Step S1277: Calculate the second loss function value according to the current action evaluation value, the next action evaluation value and the reward value of the current database configuration parameter;
步骤S1278:利用第二损失函数值优化当前评价网络,同时通过当前评价网络输出的参数对目标评价网络进行软更新。Step S1278: Use the second loss function value to optimize the current evaluation network, and at the same time perform a soft update on the target evaluation network through the parameters output by the current evaluation network.
具体的,第二损失函数公式如下:Specifically, the second loss function formula is as follows:
Loss=Q'(next_state,next_action)-Q(state,action)Loss=Q'(next_state,next_action)-Q(state,action)
其中,Q'(next_state,next_action)为当前动作评估值,Q(state,action)为前次动作评估值,Loss()表示目标评价网络和当前评价网络之间的损失值,其中Q(state,action)在图7中的表示为Q(s,a)。Among them, Q'(next_state, next_action) is the current action evaluation value, Q(state, action) is the previous action evaluation value, Loss() represents the loss value between the target evaluation network and the current evaluation network, where Q(state, action) is represented as Q(s, a) in Figure 7.
其中,Q(state,action)与Q'(state_next,action_next)之间的关系为:Among them, the relationship between Q(state, action) and Q'(state_next, action_next) is:
Q(state,action)=r+γ*(max(Q'(next_state,next_action)));Q(state,action)=r+γ*(max(Q'(next_state,next_action)));
其中r表示当前数据库配置参数的奖励值,max(Q'(next_state,next_action)为下一个状态采取的动作可能产生的最高评估分,在本实施例中即表示下一次数据库参数对应的数据库配置所产生的最高评估分,其中γ为0到1的数值。Among them, r represents the reward value of the current database configuration parameter, and max(Q'(next_state, next_action) is the highest evaluation score that may be generated by the action taken in the next state. In this embodiment, it represents the database configuration corresponding to the next database parameter. The highest evaluation score produced, where γ is a numeric value from 0 to 1.
可以理解的,将Q(state,action)的公式代入Loss函数公式中得到:It is understandable that the formula of Q(state, action) is substituted into the Loss function formula to get:
Loss=-r+(1-γ)Q'(next_state,next_action)Loss=-r+(1-γ)Q'(next_state,next_action)
当γ取值为1时,目标评估值Loss=-r,也即当前评估值加上Loss值即加上-r,为目标评估值,其中r为步骤S1241中的当前数据库配置参数的奖励值。When the value of γ is 1, the target evaluation value Loss=-r, that is, the current evaluation value plus the Loss value is plus -r, which is the target evaluation value, where r is the reward value of the current database configuration parameter in step S1241 .
可以理解的,本申请实施例中的自调优模块由四个部分组成,当前动作网络、当前评价网络、目标动作网络、目标评价网络,四个网络均由神经网络组成;其中,动作网络是根据当前的状态决定下一时刻施加到环境上去的最好动作;此处,可以把动作当作数据库要配置的配置参数,状态可以看作数据库的状态参数。It can be understood that the self-tuning module in the embodiment of the present application consists of four parts, the current action network, the current evaluation network, the target action network, and the target evaluation network, all of which are composed of neural networks; The best action to be applied to the environment at the next moment is determined according to the current state; here, the action can be regarded as the configuration parameter to be configured in the database, and the state can be regarded as the state parameter of the database.
具体的,通过Loss公式所求得的值即第二损失函数值,对当前评价网络进行优化,以便决定当前动作网络的输出值,即通过优化后的当前评价网络可以预测输入状态参数对应的下一数据库配置参数(目标数据库配置参数)。Specifically, the value obtained by the Loss formula is the value of the second loss function, and the current evaluation network is optimized to determine the output value of the current action network, that is, the optimized current evaluation network can predict the input state parameter corresponding to the next A database configuration parameter (target database configuration parameter).
其中,目标动作网络,可以为目标评价网络提供下一个状态所对应的动作,即下一个数据库状态所对应的数据库配置参数。其中的数据库状态为数据库性能参数和数据库硬件资源状态参数。目标评价网络主要是负责目标Q值的计算,同时,当前评价网络也需要进行模块的优化,所以需要一个目标值和当前评价网络的生成值进行比较,获取损失值,来优化当前评价网络。The target action network can provide the target evaluation network with the action corresponding to the next state, that is, the database configuration parameters corresponding to the next database state. The database status is database performance parameters and database hardware resource status parameters. The target evaluation network is mainly responsible for the calculation of the target Q value. At the same time, the current evaluation network also needs to optimize the module, so it is necessary to compare a target value with the generated value of the current evaluation network to obtain the loss value to optimize the current evaluation network.
可以理解的,本实施例能够实现定期的用目标评价网络的参数更新当前评价网络的参数,利用软更新方式每更新一次使用一次损失函数,这样就可以保证每次更新都会根据损失函数进行调整,保证模块的更优化。It can be understood that this embodiment can periodically update the parameters of the current evaluation network with the parameters of the target evaluation network, and use the soft update method to use the loss function once for each update, so as to ensure that each update will be adjusted according to the loss function, Guarantee more optimization of the module.
可以理解的,通过自调优模块中的update()函数来触发整个自调优模块的优化过程,自调优模块从样本池中获取前次状态参数表示为state,前次配置参数表示为action,当前状态参数表示为next_state以及当前数据库配置参数的奖励值reward(在上述实施例中表示为r)参数后经过步骤S1271至步骤S1277处理后输出优化后的数据库配置参数。本实施例中的配置参数因为加入了当前数据库配置参数的奖励值reward,能够使自调优模块生成的数据库配置参数更优,将本实施例中的数据库配置参数输入到目标数据库服务器中进行配置,能够提高目标数据库服务器中数据库的访问速度、读取速度以及其他数据库的处理事项。It is understandable that the update() function in the self-tuning module is used to trigger the optimization process of the entire self-tuning module. The self-tuning module obtains the previous state parameter from the sample pool, which is represented as state, and the previous configuration parameter is represented as action. , the current state parameter is represented as next_state and the reward value reward (represented as r in the above embodiment) parameter of the current database configuration parameter is processed through steps S1271 to S1277 and the optimized database configuration parameter is output. Because the configuration parameters in this embodiment are added with the reward value of the current database configuration parameters, the database configuration parameters generated by the self-tuning module can be more optimal, and the database configuration parameters in this embodiment are input into the target database server for configuration. , which can improve the access speed, reading speed and other database processing matters of the database in the target database server.
在一些实施例中,参照图9,为数据库调优模块原理流程图,混合表征模块负责为自调优模块提供数据库状态混合表征向量,同时也为样本池提供参数样本,同时混合表征模块接收目标数据库发送的数据库性能参数、数据库配置参数、数据库硬件资源状态参数,并对上述参数进行混合表征处理,同时,目标数据库接收自调优模块生成的数据库配置参数,从而形成了一个不间断更新数据库配置参数的有机系统,能够快速、高效的完成数据库的生成、优化和配置。In some embodiments, referring to FIG. 9 , which is a schematic flowchart of the database tuning module, the hybrid characterization module is responsible for providing the database state hybrid characterization vector for the self-tuning module, and also provides parameter samples for the sample pool, while the hybrid characterization module receives the target. The database performance parameters, database configuration parameters, and database hardware resource status parameters sent by the database are mixed with the above parameters. The organic system of parameters can quickly and efficiently complete the generation, optimization and configuration of the database.
在一些实施例中,当前动作网络负责自优化模块对数据库环境的交互,即根据数据库状态参数生成数据库配置参数,并把配置参数配置到数据库中。当前评价网络负责对每一对数据库state-action的价值(好坏)的评价,评价即Q值,从而能够确定在什么数据库状态下采取什么的动作,可以理解的,在本实施例中的体现即是,在什么样的数据库状态下采用什么样的数据库配置参数能带来更高的数据库性能,其中,数据库状态包括数据库性能参数、数据库硬件资源状态参数,数据库性能包括吞吐量、时延等,高的数据库性能即高的吞吐量、低延时等。In some embodiments, the current action network is responsible for the interaction of the self-optimization module with the database environment, that is, generating database configuration parameters according to database state parameters, and configuring the configuration parameters into the database. The current evaluation network is responsible for evaluating the value (good or bad) of each pair of database state-actions, the evaluation is the Q value, so that it can determine what action to take in what database state. That is, what kind of database configuration parameters can be used in what kind of database state can bring higher database performance, wherein the database state includes database performance parameters, database hardware resource state parameters, and database performance includes throughput, delay, etc. , High database performance means high throughput, low latency, etc.
在一些实施例中,数据服务器包括备份数据库服务器和业务数据库服务器,步骤S1100包括:In some embodiments, the data server includes a backup database server and a service database server, and step S1100 includes:
步骤1110:获取备份服务器的数据库状态混合表征参数;Step 1110: Obtain the database state hybrid representation parameter of the backup server;
步骤S1300包括:Step S1300 includes:
步骤S1310:将目标数据库配置参数发送至业务数据库服务器。Step S1310: Send the target database configuration parameters to the service database server.
可以理解的,业务数据库服务器为正在运行、正在使用的服务器。Understandably, the business database server is a server that is running and being used.
在一些实施例中,对数据库服务器进行离线模式优化,可以把需要进行数据库配置的服务器叫做业务服务器,在进行数据库配置参数调整时,是通过一台备份服务器进行,业务服务器和备份服务器的数据库状态混合表征参数相同,此时需要通过步骤S1110获取备份服务器的数据库状态混合表征参数,目的是为了在执行上述步骤S1100至S1300的方法之后生成的目标数 据库配置参数也同样适用于业务服务器。In some embodiments, when optimizing the database server in offline mode, the server that needs to perform database configuration can be called a business server. When adjusting the database configuration parameters, it is performed through a backup server. The database status of the business server and the backup server is The mixed characterization parameters are the same. At this time, it is necessary to obtain the database state mixed characterization parameters of the backup server through step S1110, so that the target database configuration parameters generated after performing the methods of steps S1100 to S1300 are also applicable to the service server.
在一些实施例中,在备份服务器通过新生成的目标配置参数进行配置优化之后,数据库运行正常,则可以执行步骤S1310,将目标数据库配置参数发送至业务数据库服务器进行业务数据库服务器的调优工作。In some embodiments, after the backup server performs configuration optimization through the newly generated target configuration parameters, and the database is running normally, step S1310 may be executed to send the target database configuration parameters to the business database server for tuning of the business database server.
本实施例能够通过在备份服务器上先进行数据库配置参数的调整工作,配置成功并且配置后数据库运行正常时,才会把相关的配置参数配置到业务服务器,这种离线方式对业务服务器进行数据库配置参数调整,可以防止在数据库配置参数调整过程中的意外情况破坏正在运行的业务服务器,造成不必要的损失。In this embodiment, the database configuration parameters can be adjusted on the backup server first, and only when the configuration is successful and the database runs normally after the configuration, the relevant configuration parameters can be configured on the business server. This offline method configures the database for the business server. Parameter adjustment can prevent unexpected situations in the process of database configuration parameter adjustment from damaging the running business server and causing unnecessary losses.
在一些实施例中,对数据库服务器进行在线模式优化,数据库调优模块直接从业务数据库获取数据库状态混合表征参数,并且在获取到上述数据库状态混合表征参数之后,执行上述步骤S1100至S1300的方法获得目标数据库配置参数,并且实时把新生成的目标数据库配置参数传送给业务数据库,以便业务数据库进行实时的数据库配置参数的配置。In some embodiments, the online mode optimization is performed on the database server, and the database optimization module directly obtains the database state mixed representation parameter from the business database, and after obtaining the above-mentioned database state mixed representation parameter, executes the methods of the above steps S1100 to S1300 to obtain The target database configuration parameters are transmitted, and the newly generated target database configuration parameters are transmitted to the business database in real time, so that the business database can configure the database configuration parameters in real time.
本实施例能够实现业务数据库配置参数的实时在线优化,提高优化的效率。This embodiment can realize the real-time online optimization of the configuration parameters of the business database, and improve the optimization efficiency.
在一些实施例中,数据库配置参数调整方法中步骤S1100、S1200,包括:In some embodiments, steps S1100 and S1200 in the database configuration parameter adjustment method include:
S1120,获取来自数据库服务器的数据库状态混合表征参数;S1120, obtain the database state mixed representation parameter from the database server;
S1280,将数据库状态混合表征参数输入到深度强化学习模型中生成中间数据库配置参数,将中间数据库配置参数发送至数据库服务器;S1280, input the database state mixed representation parameters into the deep reinforcement learning model to generate intermediate database configuration parameters, and send the intermediate database configuration parameters to the database server;
S1290,重复执行上述步骤N次,直至得到目标数据库配置参数。即,将中间数据库配置参数作为数据库服务器的数据库配置参数输入到数据库服务器的中,重复执行步骤S1120、S1280直到达到N次,得到目标数据库配置参数,其中,N为正整数,可以预设N的取值。通过多次迭代,获得更优的数据库配置参数。S1290: Repeat the above steps N times until the target database configuration parameters are obtained. That is, the intermediate database configuration parameters are input into the database server as the database configuration parameters of the database server, and steps S1120 and S1280 are repeated until N times are reached to obtain the target database configuration parameters, where N is a positive integer, and N can be preset. value. Through multiple iterations, better database configuration parameters are obtained.
在一些实施例中,设置预设的迭代次数N=max_iter,其中,max_iter表示为最大的迭代次数,迭代次数表示为iter,迭代次数的增加表示为iter++;当进行迭代时,每迭代一次,iter的数值增加1,直到迭代次数iter达到最大迭代次数max_iter,即本实施例中的N时,结束迭代。即当iter>N时,表示迭代结束,此时可以获取到了更优的数据库配置参数,如果iter≤max_iter,则继续重复执行步骤S1120、S1280直到迭代次数iter的数值达到最大迭代次数max_iter即本实施例中的N。其中,N为正整数,可以预设N的取值,N可以通过实验值或者经验值获取。In some embodiments, a preset number of iterations N=max_iter is set, where max_iter represents the maximum number of iterations, the number of iterations is represented as iter, and the increase in the number of iterations is represented as iter++; when iteration is performed, for each iteration, iter The value of is increased by 1 until the iteration number iter reaches the maximum iteration number max_iter, that is, N in this embodiment, and the iteration ends. That is, when iter>N, it means that the iteration is over, and better database configuration parameters can be obtained at this time. If iter≤max_iter, continue to repeat steps S1120 and S1280 until the value of the iteration number iter reaches the maximum iteration number max_iter, that is, this implementation N in the example. Wherein, N is a positive integer, the value of N can be preset, and N can be obtained through an experimental value or an empirical value.
本实施例能够通过预设迭代次数的方式,不断通过模型训练收敛,直到获取到更优的数据库配置参数,增强了数据库配置参数配置的实时性和高效性。This embodiment can continuously converge through model training by means of a preset number of iterations until better database configuration parameters are obtained, which enhances the real-time and efficient configuration of database configuration parameters.
第二方面,本申请实施例提供了一种数据库配置参数调整方法,应用于数据库服务器。In a second aspect, the embodiments of the present application provide a method for adjusting database configuration parameters, which is applied to a database server.
在一些实施例中,参照图10,数据库配置参数调整方法包括:In some embodiments, referring to FIG. 10 , the database configuration parameter adjustment method includes:
步骤S2100,发送数据库状态混合表征参数给数据库调优模块,以使数据库调优模块执行如第一方面的方法;Step S2100, sending the database state mixed representation parameter to the database tuning module, so that the database tuning module executes the method of the first aspect;
步骤S2200,接收来自数据库调优模块发送的目标数据库配置参数;Step S2200, receiving the target database configuration parameters sent from the database tuning module;
步骤S2300,根据目标数据库配置参数对数据库服务器进行参数配置。Step S2300, perform parameter configuration on the database server according to the target database configuration parameters.
在一些实施例中,在一些实施例中,数据库状态混合表征参数包括以下的一种或多种:数据库性能参数、当前数据库配置参数、硬件资源参数、硬件资源状态参数。In some embodiments, in some embodiments, the database state hybrid characterization parameters include one or more of the following: database performance parameters, current database configuration parameters, hardware resource parameters, and hardware resource state parameters.
在一些实施例中,参照图11,上述步骤S2100之前还包括:In some embodiments, referring to FIG. 11 , before the above step S2100, it further includes:
步骤S2400,获取第一次数据库状态混合表征参数;Step S2400, obtaining the first mixed representation parameter of database state;
步骤S2500,获取来自压力模拟服务器的工作负载压力信号;Step S2500, obtaining the workload pressure signal from the pressure simulation server;
步骤S2600,根据工作负载压力信号对数据库服务器进行加压操作;Step S2600, performing a pressurization operation on the database server according to the workload pressure signal;
步骤S2700,加压操作结束后,获取第二次数据库状态混合表征参数。Step S2700, after the pressurization operation is completed, obtain the second database state mixed representation parameter.
在一些实施例中,数据库服务器包括备份数据库服务器和业务数据库服务器,步骤S2100包括:In some embodiments, the database server includes a backup database server and a service database server, and step S2100 includes:
步骤2110:利用备份数据库服务器发送数据库状态混合表征参数给数据库调优模块执行步骤S1100至步骤S1300的方法生成目标数据库配置参数;Step 2110: use the backup database server to send the database state mixed representation parameters to the database tuning module and perform the methods from steps S1100 to S1300 to generate target database configuration parameters;
步骤2120:利用业务服务器接收目标数据库配置参数;Step 2120: use the service server to receive target database configuration parameters;
步骤2130:根据目标数据库配置参数对业务数据库服务器进行参数配置。Step 2130: Perform parameter configuration on the service database server according to the target database configuration parameters.
为了更好的理解本申请实施例的核心思想,下面根据具体的应用场景进行对本申请实施例数据库配置参数调整的整体方案。In order to better understand the core idea of the embodiments of the present application, an overall solution for adjusting the database configuration parameters of the embodiments of the present application is described below according to specific application scenarios.
在一些实施例中,参照图12,应用场景的具体物理环境如下表:In some embodiments, referring to FIG. 12 , the specific physical environment of the application scenario is as follows:
表1实施例物理环境Table 1 Example physical environment
数据库版本Database version PG10.11数据库PG10.11 database
CPU核数Number of CPU cores 44
内存RAM 4G4G
磁盘存储disk storage 20G20G
数据库配置参数调试模式Database Configuration Parameters Debug Mode 离线offline
其中,表1中所处的物理环境为基于PASS环境,PG10.11数据库表示Postgresql10.11版本的数据库,离线调试模式为在业务开始之前对通过数据库调优服务器101(数据库调优服务器内置有数据库调优模块)最配置参数进行调优,获取到较优的配置之后直接配置到业务数据库中,然后开启数据库服务。Among them, the physical environment in Table 1 is based on the PASS environment, the PG10.11 database represents the Postgresql 10.11 version database, and the offline debugging mode is to pass the database tuning server 101 before the business starts (the database tuning server has a built-in database Tuning module) to tune the most configuration parameters, and directly configure it into the business database after obtaining the better configuration, and then start the database service.
在一些实施例中,数据库配置参数调整系统包括数据库配置参数自调优服务器101、数据库查询压力模拟服务器103、基于PASS平台的PG数据库服务器(业务服务器)三部分组成。其中,数据库调优服务器101是本实施例的核心,其负责数据库调优模块的运行、对数据库用户查询压力模拟服务器的控制、与PG10.11数据库服务器交互。业务服务器负责PG10.11数据库的运行、对数据库运行硬件资源进行限定、接收数据库用户查询压力模拟服务器的查询、与数据库调优服务器101交互。数据库用户查询压力模拟服务器负责压测装置的运行、在自调优模块的控制下对PG10.11数据库进行压力测试,以模拟实际运行过程中的数据库工作负载。其中,在本实施例中PG10.11数据库可以作为业务服务器。In some embodiments, the database configuration parameter adjustment system includes a database configuration parameter self-tuning server 101, a database query pressure simulation server 103, and a PG database server (service server) based on the PASS platform. The database tuning server 101 is the core of this embodiment, and is responsible for running the database tuning module, controlling the database user query pressure simulation server, and interacting with the PG10.11 database server. The service server is responsible for the operation of the PG10.11 database, limiting the hardware resources for database operation, receiving the query from the database user query pressure simulation server, and interacting with the database tuning server 101 . The database user queries the pressure simulation server, which is responsible for the operation of the pressure measurement device, and performs the pressure test on the PG10.11 database under the control of the self-tuning module to simulate the database workload during the actual operation. Wherein, in this embodiment, the PG10.11 database can be used as a service server.
其中,数据库调优服务器101分别与数据库查询压力模拟服务器103和业务服务器102双向通信连接,数据库查询压力模拟服务器输出通过单向连接业务服务器,通信连接方式可以为RJ45口或者其他通信连接方式。Wherein, the database tuning server 101 is connected to the database query pressure simulation server 103 and the service server 102 in two-way communication respectively, and the output of the database query pressure simulation server is connected to the service server through a one-way connection, and the communication connection can be RJ45 port or other communication connection.
在一些实施例中,参照图13(a)、13(b),数据库配置参数调整方法具体包括:In some embodiments, referring to Figures 13(a) and 13(b), the database configuration parameter adjustment method specifically includes:
步骤S3100:获取数据库服务器硬件资源参数;Step S3100: Obtain database server hardware resource parameters;
步骤S3200:构建数据库调优模块,若是已有已经训练好的数据库配置参数则进行加载,否则进行下一步骤;Step S3200: Build a database tuning module, if there are already trained database configuration parameters, load them, otherwise go to the next step;
步骤S3300:获取PG10.11数据库默认配置参数;Step S3300: Acquire the default configuration parameters of the PG10.11 database;
步骤S3400:对PG10.11数据库环境状态进行复位;Step S3400: reset the environment state of the PG10.11 database;
可以理解的,对PG10.11数据库环境状态进行复位是为了对数据库中的数据表进行重建,防止多次压测后数据库表变化,保证数据库每次压测环境的一致性,使得每次压测所获得的数据库性能参数具有可比性。It is understandable that the purpose of resetting the environment state of the PG10.11 database is to rebuild the data tables in the database, prevent changes in the database tables after multiple stress tests, ensure the consistency of the database environment for each stress test, and make each stress test. The obtained database performance parameters are comparable.
步骤S3500:将当前数据库配置参数通过网络配置到数据库服务器PG10.11数据库中,并对数据库进行复位。Step S3500: Configure the current database configuration parameters into the database server PG10.11 database through the network, and reset the database.
可以理解的,当前数据库配置参数只有在第一轮模型训练时等于默认配置参数,在模型训练不断迭代的过程中,当前配置参数会不断更新,有一些配置参数需要数据库复位才可以生效。It is understandable that the current database configuration parameters are equal to the default configuration parameters only during the first round of model training. During the continuous iteration of model training, the current configuration parameters will be continuously updated, and some configuration parameters require a database reset to take effect.
步骤S3600:对数据库性能参数进行第一次采集;Step S3600: collect database performance parameters for the first time;
其中,采集的数据库状态参数包括但不限于如表2所示类型:Among them, the collected database state parameters include but are not limited to the types shown in Table 2:
表2数据库配置参数类型Table 2 Database configuration parameter types
Figure PCTCN2021102782-appb-000002
Figure PCTCN2021102782-appb-000002
Figure PCTCN2021102782-appb-000003
Figure PCTCN2021102782-appb-000003
步骤S3700:控制数据库查询压力模拟服务器开始对PG数据库服务器中PG10.11数据库进行加压,并开始对数据库硬件资源状态参数实时记录。Step S3700: The control database query pressure simulation server starts to pressurize the PG10.11 database in the PG database server, and starts to record the database hardware resource status parameters in real time.
其中,数据库硬件资源状态参数包括但不限于:CPU利用率、内存利用率、存储利用率等参数;The database hardware resource status parameters include but are not limited to: CPU utilization, memory utilization, storage utilization and other parameters;
步骤S3800:PG数据库服务器中PG10.11数据库加压结束,停止对数据库硬件资源状态参数记录;Step S3800: the compression of the PG10.11 database in the PG database server is completed, and the recording of the database hardware resource status parameters is stopped;
步骤S3900:对数据库性能参数进行第二次采集;Step S3900: collect database performance parameters for the second time;
步骤S31000:根据步骤S3600中第一次采集到的数据库性能参数和步骤S3900中第二次采集到的数据库状态参数差值计算数据库当前性能参数,根据压测过程中数据库硬件资源状态参数记录计算该过程中数据库硬件资源状态参数如CPU利用率、内存利用率、存储利用率等参数的均值。Step S31000: Calculate the current performance parameter of the database according to the difference between the database performance parameter collected for the first time in step S3600 and the database state parameter collected for the second time in step S3900, and calculate the current performance parameter of the database according to the database hardware resource state parameter record during the stress measurement process. The average value of the database hardware resource status parameters such as CPU utilization, memory utilization, and storage utilization during the process.
步骤S31100:根据步骤S31000中采集到的数据库性能参数、硬件资源状态参数以及S3500中的当前数据库配置参数,以及上述参数的历史记录值进行求差值,然后利用当前参数和所求差值参数的差值做混合表征,获取数据库状态混合表征向量。Step S31100: Calculate the difference according to the database performance parameters, hardware resource status parameters collected in step S31000, the current database configuration parameters in S3500, and the historical record values of the above parameters, and then use the current parameters and the obtained difference parameters. The difference is used for mixed representation, and the mixed representation vector of the database state is obtained.
步骤S31200:将生成的数据库状态混合表征向量输入到自调优模块生成新的数据库配置参数。Step S31200: Input the generated database state hybrid representation vector into the self-tuning module to generate new database configuration parameters.
其中,所生成的数据库配置参数包括但是不限于,如表3所示:The generated database configuration parameters include, but are not limited to, as shown in Table 3:
表3数据库配置参数类型Table 3 Database configuration parameter types
Figure PCTCN2021102782-appb-000004
Figure PCTCN2021102782-appb-000004
Figure PCTCN2021102782-appb-000005
Figure PCTCN2021102782-appb-000005
步骤S31300:根据步骤S31000中采集到的各个数据库状态参数及其历史记录值来计算当前数据库配置参数的奖励值r,计算公式如下:Step S31300: Calculate the reward value r of the current database configuration parameter according to each database state parameter and its historical record value collected in step S31000. The calculation formula is as follows:
Figure PCTCN2021102782-appb-000006
Figure PCTCN2021102782-appb-000006
Δperfor=cur_perfor-hist_perfor;Δperfor=cur_perfor-hist_perfor;
Δcpu_rate=cur_cpu_rate-hist_cpu_rate;Δcpu_rate=cur_cpu_rate-hist_cpu_rate;
Δmen_rate=cur_men_rate-hist_men_rate;Δmen_rate=cur_men_rate-hist_men_rate;
其中,α、β、γ为加权值,r为当前数据库配置参数的奖励值,cur_perfor为当前数据库性能参数,hist_perfor为前次或者历史数据库性能参数,cur_cpu_rate为当前CPU利用率,hist_cur_cpu_rate为前次或者历史CPU利用率,cur_men_rate为当前内存利用率,hist_men_rate为前次或者历史内存利用率,△perfor为当前数据库性能参数和前次或者历史数据库性能参数的差值,△cpu_rate为当前CPU利用率和前次或者历史CPU利用率的差值,△men_rate为当前内存利用率和前次或者历史内存利用率的差值。Among them, α, β, γ are weighted values, r is the reward value of the current database configuration parameter, cur_perfor is the current database performance parameter, hist_perfor is the previous or historical database performance parameter, cur_cpu_rate is the current CPU utilization, and hist_cur_cpu_rate is the previous or Historical CPU utilization, cur_men_rate is the current memory utilization, hist_men_rate is the previous or historical memory utilization, △perfor is the difference between the current database performance parameters and the previous or historical database performance parameters, and △cpu_rate is the current CPU utilization and previous The difference between the current or historical CPU utilization, and △men_rate is the difference between the current memory utilization and the previous or historical memory utilization.
其中,cur_perfor和hist_perfor参数可以是数据库吞吐量TPS、查询时延等参数;Among them, the cur_perfor and hist_perfor parameters can be parameters such as database throughput TPS and query delay;
步骤S31400:根据步骤S31300中计算的当前数据库配置参数的奖励值大小记录最佳数据库配置参数;Step S31400: Record the optimal database configuration parameter according to the reward value of the current database configuration parameter calculated in step S31300;
步骤S31500:将前次数据库状态参数、当前数据库配置参数、当前数据库配置参数的奖励值、当前数据库状态参数当作一个交互样本存储到经验池中,其中数据库状态参数包括数据库硬件资源状态参数、数据库性能参数。Step S31500: Store the previous database state parameters, current database configuration parameters, the reward value of the current database configuration parameters, and the current database state parameters as an interactive sample in the experience pool, where the database state parameters include database hardware resource state parameters, database performance parameters.
步骤S31600:对样本池进行批采样,并对步骤S31200中的自调优模块进行优化。Step S31600: Perform batch sampling on the sample pool, and optimize the self-tuning module in step S31200.
具体的自调优模块优化过程如步骤S1270中描述,此处不再赘述。The specific self-tuning module optimization process is as described in step S1270, which is not repeated here.
步骤S31700:根据步骤S31200中生成的数据库配置参数更新当前数据库配置参数,以及,对步骤S31000中获得的数据库状态参数对当前数据库状态记录值进行更新,其中的数据库状态参数包括数据库性能参数和数据库硬件资源状态参数。Step S31700: Update the current database configuration parameters according to the database configuration parameters generated in step S31200, and update the current database status record value for the database status parameters obtained in step S31000, where the database status parameters include database performance parameters and database hardware. Resource status parameters.
步骤S31800:若是当前迭代计数器iter值不大于最大迭代值max_iter则返回到S3500步骤,将数据库配置参数配置到PG10.11数据库中,继续迭代过程;否则执行步骤S31900。Step S31800: If the current iteration counter iter value is not greater than the maximum iteration value max_iter, return to step S3500, configure the database configuration parameters in the PG10.11 database, and continue the iterative process; otherwise, go to step S31900.
步骤S31900:将最佳的数据库配置参数和相应的数据库性能参数返回给数据库管理员,由数据库管理员决定是否将模型推荐的数据库配置参数配置到服务器的目标数据库PG10.11中。Step S31900: Return the optimal database configuration parameters and corresponding database performance parameters to the database administrator, and the database administrator decides whether to configure the database configuration parameters recommended by the model into the target database PG10.11 of the server.
步骤S32000:保存当前数据库自调优模块参数。Step S32000: Save the parameters of the current database self-tuning module.
在一些实施例中,本实施例提供了另一种应用场景下执行的数据库参数调整情况,如表4;In some embodiments, this embodiment provides another database parameter adjustment situation performed in an application scenario, as shown in Table 4;
表4实施例物理环境Table 4 Example physical environment
数据库版本Database version PG10.11数据库PG10.11 database
CPU核数Number of CPU cores 4848
内存RAM 128G128G
磁盘存储disk storage 1T1T
数据库配置参数调试模式Database Configuration Parameters Debug Mode 在线online
参照图14,本实施例采用的是两台数据库服务器的模式,其中一台为备份数据库服务器102,另一台为业务数据库服务器104,两台服务器均是PG10.11数据库服务器,通过在备份数据库服务器102中寻找数据库较优配置参数然后再将配置参数推荐给业务数据库服务器104进行配置,避免调优过程中干扰到业务数据的正常运行。Referring to FIG. 14, this embodiment adopts the mode of two database servers, one of which is the backup database server 102 and the other is the business database server 104, both of which are PG10.11 database servers. The server 102 searches for optimal configuration parameters of the database, and then recommends the configuration parameters to the business database server 104 for configuration, so as to avoid interfering with the normal operation of business data during the tuning process.
数据库配置调试系统由数据库调优服务器101(数据库调优服务器101内置有数据库调优模块)、数据库查询压力模拟服务器103、备份数据库服务器102和业务数据库服务器104四部分组成,其中数据库调优服务器101负责数据库调优模块的运行、对数据库用户查询压力模拟服务器103的控制、与备份数据库服务器102的交互、对业务数据库服务器104的参数配置。备份数据库服务器102负责交互数据库的运行,对数据库运行的硬件资源进行限定,接收数据库用户查询压力模拟服务器103的查询,与数据库调优服务器101交互。数据库查询压力模拟服务器103负责压测工具的运行、与数据库调优服务器101交互。上述服务器之间通过网线连接,但是不限于以上连接方式。The database configuration and debugging system is composed of four parts: a database tuning server 101 (the database tuning server 101 has a built-in database tuning module), a database query pressure simulation server 103, a backup database server 102 and a business database server 104, wherein the database tuning server 101 It is responsible for the operation of the database tuning module, the control of the database user query pressure simulation server 103, the interaction with the backup database server 102, and the parameter configuration of the business database server 104. The backup database server 102 is responsible for running the interactive database, limiting the hardware resources for running the database, receiving queries from the database user query pressure simulation server 103 , and interacting with the database tuning server 101 . The database query pressure simulation server 103 is responsible for running the pressure measurement tool and interacting with the database tuning server 101 . The above servers are connected through network cables, but are not limited to the above connection methods.
执行上述步骤S3100至步骤S32000的数据库配置参数调整方法。Execute the database configuration parameter adjustment method from steps S3100 to S32000 above.
第三方面,本申请实施例提供了一种电子设备。In a third aspect, an embodiment of the present application provides an electronic device.
在一些实施例中,参照图15,上述电子设备包括一个或多个处理器201;存储装置202,用于存储一个或多个程序,当上述一个或多个程序被上述一个或多个处理器执行,使得上述一个或多个处理器实现:如第一方面的数据库配置参数调整方法;或者,如第二方面的数据库配置参数调整方法。In some embodiments, referring to FIG. 15 , the above-mentioned electronic device includes one or more processors 201; a storage device 202 is used to store one or more programs, when the above-mentioned one or more programs are processed by the above-mentioned one or more processors The execution causes the above one or more processors to implement: the method for adjusting database configuration parameters in the first aspect; or, the method for adjusting database configuration parameters in the second aspect.
第四方面,本申请实施例提供了一种计算机可读存储介质。In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium.
在一些实施例中,上述计算机可读存储介质存储有计算机可执行指令,上述计算机可执行指令用于执行:如第一方面中的数据库配置参数调整方法;或者,如第二方面的数据库配置参数调整方法。In some embodiments, the above-mentioned computer-readable storage medium stores computer-executable instructions, and the above-mentioned computer-executable instructions are used to perform: as the database configuration parameter adjustment method in the first aspect; or, as the database configuration parameter in the second aspect adjustment method.
本申请实施例包括:获取来自数据库服务器的数据库状态混合表征参数;将所述数据库状态混合表征参数输入到深度强化学习模型中生成目标数据库配置参数;将所述目标数据库配置参数发送至数据库服务器。本申请实施例能够利用深度强化学习模型将获取到的数据库状态混合表征参数进行处理后生成目标数据库配置参数,并将生成的数据库配置参数发送到数据库服务器进行配置,从而克服了数据库配置自动化程度低、速度慢、效率低的问题,有效提高了数据库配置的自动化程度、速度和效率。The embodiments of the present application include: acquiring database state mixed representation parameters from a database server; inputting the database state mixed representation parameters into a deep reinforcement learning model to generate target database configuration parameters; and sending the target database configuration parameters to the database server. In the embodiment of the present application, a deep reinforcement learning model can be used to process the obtained database state mixed representation parameters to generate target database configuration parameters, and the generated database configuration parameters can be sent to the database server for configuration, thereby overcoming the low degree of database configuration automation. , slow speed and low efficiency, which effectively improves the automation, speed and efficiency of database configuration.
以上所描述的装置实施例仅仅是示意性的,其中作为分离部件说明的单元可以是或者也可以不是物理上分开的,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。The apparatus embodiments described above are only illustrative, and the units described as separate components may or may not be physically separated, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
本领域普通技术人员可以理解,上文中所公开方法中的全部或某些步骤、系统可以被实施为软件、固件、硬件及其适当的组合。某些物理组件或所有物理组件可以被实施为由处理器,如中央处理器、数字信号处理器或微处理器执行的软件,或者被实施为硬件,或者被实施为集成电路,如专用集成电路。这样的软件可以分布在计算机可读介质上,计算机可读介质可以包括计算机存储介质(或非暂时性介质)和通信介质(或暂时性介质)。如本领域普通技术人员公知的,术语计算机存储介质包括在用于存储信息(诸如计算机可读指令、数据结构、程序模块或其他数据)的任何方法或技术中实施的易失性和非易失性、可移除和不可移除介质。计算机存储介质包括但不限于RAM、ROM、EEPROM、闪存或其他存储器技术、CD-ROM、数字多功能盘(DVD)或其他光盘存储、磁盒、磁带、磁盘存储或其他磁存储装置、或者可以用于存储期望的信息并且可以被计算机访问的任何其他的介质。此外,本领域普通技术人员公知的是,通信介质通常包含计算机可读指令、数据结构、程序模块或者诸如载波或其他传输机制之类的调制数据信号中的其他数据,并且可包括任何信息递送介质。Those of ordinary skill in the art can understand that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware, and appropriate combinations thereof. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit . Such software may be distributed on computer-readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). As known to those of ordinary skill in the art, the term computer storage media includes both volatile and nonvolatile implemented in any method or technology for storage of information, such as computer readable instructions, data structures, program modules or other data flexible, removable and non-removable media. Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cartridges, magnetic tape, magnetic disk storage or other magnetic storage devices, or may Any other medium used to store desired information and which can be accessed by a computer. In addition, communication media typically embodies computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and can include any information delivery media, as is well known to those of ordinary skill in the art .
以上是对本申请的一些实施进行了具体说明,但本申请并不局限于上述实施方式,熟悉本领域的技术人员在不违背本申请范围的前提下还可做出种种的等同变形或替换,这些等同的变形或替换均包含在本申请权利要求所限定的范围。The above is a specific description of some implementations of the application, but the application is not limited to the above-mentioned embodiments. Those skilled in the art can also make various equivalent modifications or replacements without departing from the scope of the application. These Equivalent modifications or substitutions are included within the scope defined by the claims of the present application.

Claims (15)

  1. 一种数据库配置参数调整方法,应用于数据库调优模块,包括:A method for adjusting database configuration parameters, applied to a database tuning module, comprising:
    获取来自数据库服务器的数据库状态混合表征参数;Get the database state hybrid representation parameters from the database server;
    将所述数据库状态混合表征参数输入到深度强化学习模型中生成目标数据库配置参数;Inputting the database state mixed representation parameters into the deep reinforcement learning model to generate target database configuration parameters;
    将所述目标数据库配置参数发送至数据库服务器。The target database configuration parameters are sent to the database server.
  2. 根据权利要求1所述的方法,其中,所述数据库状态混合表征参数包括以下的一种或多种:数据库性能参数、当前数据库配置参数、硬件资源参数、硬件资源状态参数。The method according to claim 1, wherein the database state mixed characterization parameters include one or more of the following: database performance parameters, current database configuration parameters, hardware resource parameters, and hardware resource state parameters.
  3. 根据权利要求1所述的方法,其中,所述深度强化学习模型包括混合表征模块和自调优模块,所述混合表征模块连接所述自调优模块;The method of claim 1, wherein the deep reinforcement learning model comprises a hybrid representation module and a self-tuning module, the hybrid representation module is connected to the self-tuning module;
    所述将所述数据库状态混合表征参数输入深度强化学习模型生成目标数据库配置参数,包括:The described database state mixed representation parameters are input into the deep reinforcement learning model to generate target database configuration parameters, including:
    将所述数据库状态混合表征参数输入到混合表征模块;inputting the database state mixed characterization parameters into the mixed characterization module;
    所述混合表征模块利用神经网络模型对所述数据库状态混合表征参数处理,得到混合表征向量;The hybrid characterization module uses a neural network model to process the database state hybrid characterization parameters to obtain a hybrid characterization vector;
    将所述混合表征向量输入到所述自调优模块,所述自调优模块利用加强学习模型对所述混合表征向量处理得到目标数据库配置参数。The mixed representation vector is input to the self-tuning module, and the self-tuning module uses a reinforcement learning model to process the mixed representation vector to obtain target database configuration parameters.
  4. 根据权利要求3所述的方法,其中,当所述数据库状态混合表征参数包括数据库性能参数、当前数据库配置参数、硬件资源参数、硬件资源状态参数时;The method according to claim 3, wherein, when the database state mixed characterization parameters include database performance parameters, current database configuration parameters, hardware resource parameters, and hardware resource state parameters;
    所述将所述混合表征模块利用神经网络模型对所述数据库状态混合表征参数处理,得到混合表征向量,包括:The described hybrid characterization module uses a neural network model to process the database state hybrid characterization parameters to obtain a hybrid characterization vector, including:
    获取当前所述数据库性能参数和前次所述数据库性能参数;以及,获取所述当前数据库配置参数和前次所述数据库配置参数;以及,获取当前所述硬件资源状态参数和前次所述硬件资源状态参数;以及,获取所述硬件资源参数;Acquire the current database performance parameters and the previous database performance parameters; and, acquire the current database configuration parameters and the previous database configuration parameters; and, acquire the current hardware resource status parameters and the previous hardware resource status parameters; and, acquiring the hardware resource parameters;
    根据当前所述数据库性能参数获得当前所述数据库性能参数特征向量;根据前次所述数据库性能参数获得前次所述数据库性能参数特征向量;根据所述当前数据库配置参数获得所述当前数据库配置参数特征向量;根据前次所述数据库配置参数获得前次所述数据库配置参数特征向量;根据当前所述硬件资源状态参数获得当前所述硬件资源状态参数特征向量;根据前次所述硬件资源状态参数获得前次所述硬件资源状态参数特征向量;根据所述硬件资源参数获得所述硬件资源参数特征向量;Obtain the current database performance parameter feature vector according to the current database performance parameter; obtain the previous database performance parameter feature vector according to the previous database performance parameter; obtain the current database configuration parameter according to the current database configuration parameter feature vector; obtain the previous database configuration parameter feature vector according to the previous database configuration parameter; obtain the current hardware resource state parameter feature vector according to the current hardware resource state parameter; obtain the current hardware resource state parameter feature vector according to the previous hardware resource state parameter Obtain the hardware resource state parameter feature vector of the previous time; obtain the hardware resource parameter feature vector according to the hardware resource parameter;
    根据当前所述数据库性能参数特征向量和前次所述数据库性能参数特征向量,计算得到数据库性能参数差值特征向量;根据所述当前数据库配置参数特征向量和前次所述数据库配置参数特征向量,计算得到数据库配置参数差值特征向量;根据当前所述硬件资源状态参数特征向量和前次所述硬件资源状态参数特征向量,计算得到硬件资源状态参数差值特征向量;According to the current database performance parameter feature vector and the previous database performance parameter feature vector, calculate the database performance parameter difference value feature vector; according to the current database configuration parameter feature vector and the previous database configuration parameter feature vector, Calculate and obtain the database configuration parameter difference feature vector; according to the current hardware resource state parameter feature vector and the previous hardware resource state parameter feature vector, calculate and obtain the hardware resource state parameter difference feature vector;
    将所述数据库性能参数特征向量、所述数据库性能参数差值特征向量、所述数据库配置参数特征向量、所述数据库配置参数差值特征向量、所述硬件资源状态参数特征向量、所述硬件资源状态参数差值特征向量、所述硬件资源参数特征向量输入到所述神经网络模型中,利用所述神经网络模型输出混合表征向量。The database performance parameter feature vector, the database performance parameter difference feature vector, the database configuration parameter feature vector, the database configuration parameter difference feature vector, the hardware resource status parameter feature vector, the hardware resource The state parameter difference feature vector and the hardware resource parameter feature vector are input into the neural network model, and the neural network model is used to output a mixed representation vector.
  5. 根据权利要求3所述的方法,其中,所述深度强化学习模型还包括数据库配置参数奖励函数模块;The method of claim 3, wherein the deep reinforcement learning model further comprises a database configuration parameter reward function module;
    所述将所述数据库状态混合表征参数输入深度强化学习模型生成数据库配置参数,还包括:Said inputting the database state mixed representation parameters into the deep reinforcement learning model to generate database configuration parameters, further comprising:
    将所述数据库状态混合表征参数分别输入到混合表征模块和数据库配置参数奖励函数模块,生成奖励策略;Inputting the database state mixed characterization parameters into the mixed characterization module and the database configuration parameter reward function module, respectively, to generate a reward strategy;
    将所述奖励策略存储到样本池中;storing the reward strategy in the sample pool;
    对所述样本池采样获得采样数据;sampling the sample pool to obtain sampling data;
    利用所述采样数据,对所述数据库调优模块进行优化。Using the sampled data, the database tuning module is optimized.
  6. 根据权利要求5所述的方法,其中,当所述数据库状态混合表征参数包括数据库性能参数、 当前数据库配置参数、硬件资源参数、硬件资源状态参数时,所述将所述数据库状态混合表征参数分别输入到混合表征模块和数据库配置参数奖励函数模块,生成奖励策略,包括:The method according to claim 5, wherein when the database state mixed characterization parameters include database performance parameters, current database configuration parameters, hardware resource parameters, and hardware resource state parameters, said mixing the database state characterization parameters respectively Input to the hybrid representation module and the database configuration parameter reward function module to generate a reward strategy, including:
    将当前所述数据库性能参数与前次数据库性能参数差值、当前所述硬件资源状态参数与前次所述硬件资源状态参数差值归一化处理后输出当前数据库配置参数的奖励值;After normalizing the difference between the current database performance parameter and the previous database performance parameter, and the difference between the current hardware resource state parameter and the previous hardware resource state parameter, output the reward value of the current database configuration parameter;
    所述归一化处理为,计算所述当前所述数据库性能参数与前次数据库性能参数差值在所述前次数据库性能参数中的占比;以及,当前所述硬件资源状态参数与前次所述硬件资源状态参数差值在所述前次所述硬件资源状态参数的占比,并对所述占比乘以相应的加权值求和后输出所述当前数据库配置参数的奖励值;The normalization process is to calculate the ratio of the difference between the current database performance parameter and the previous database performance parameter in the previous database performance parameter; and, the current hardware resource status parameter and the previous time. The ratio of the hardware resource state parameter difference in the previous hardware resource state parameter, and the reward value of the current database configuration parameter is output after multiplying the ratio by the corresponding weighted value and summing up;
    根据所述当前数据库配置参数的奖励值、所述当前数据库配置参数、当前所述数据库性能参数、当前所述硬件资源状态参数、前次所述数据库性能参数、前次所述硬件资源状态参数,生成所述奖励策略。According to the reward value of the current database configuration parameter, the current database configuration parameter, the current database performance parameter, the current hardware resource status parameter, the previous database performance parameter, and the previous hardware resource status parameter, The reward policy is generated.
  7. 根据权利要求5所述的方法,其中,所述自调优模块包括:当前动作网络、当前评价网络、目标动作网络、目标评价网络;所述当前动作网络被设置成根据数据库状态混合表征参数生成目标数据库配置参数并发送到所述数据库服务器;所述采样数据包括当前数据库配置参数、当前数据库状态参数、下次数据库状态参数、当前数据库配置参数的奖励值;The method according to claim 5, wherein the self-tuning module comprises: a current action network, a current evaluation network, a target action network, and a target evaluation network; the current action network is configured to generate a hybrid representation parameter according to a database state The target database configuration parameters are sent to the database server; the sampled data includes the current database configuration parameters, the current database state parameters, the next database state parameters, and the reward value of the current database configuration parameters;
    所述利用所述采样数据,对所述自调优模块进行优化,包括:The using the sampled data to optimize the self-tuning module includes:
    将所述当前数据库状态参数输入到当前动作网络中,并生成下次数据库配置参数;Inputting the current database state parameters into the current action network, and generating the next database configuration parameters;
    将所述下次数据库配置参数和所述当前数据库状态参数输入到当前评价网络,以确定第一损失函数值;inputting the next database configuration parameter and the current database state parameter into the current evaluation network to determine the first loss function value;
    根据所述第一损失函数值对所述当前动作网络进行优化;根据所述当前动作网络输出的参数对目标动作网络进行软更新;The current action network is optimized according to the first loss function value; the target action network is soft-updated according to the parameters output by the current action network;
    将所述下次数据库状态参数输入到所述目标动作网络中,生成下次数据库配置参数;Inputting the next database state parameters into the target action network to generate the next database configuration parameters;
    将所述当前数据库配置参数和所述当前数据库状态参数输入到当前评价网络中,生成当前动作评估值;Inputting the current database configuration parameters and the current database state parameters into the current evaluation network to generate a current action evaluation value;
    将所述下次数据库配置参数和所述下次数据库状态参数到目标评价网络中,生成下次动作评估值;adding the next database configuration parameter and the next database state parameter to the target evaluation network to generate the next action evaluation value;
    根据所述当前动作评估值、所述下次动作评估值和所述当前数据库配置参数的奖励值计算得到第二损失函数值;Calculate the second loss function value according to the current action evaluation value, the next action evaluation value and the reward value of the current database configuration parameter;
    利用所述第二损失函数值优化当前评价网络,同时通过当前评价网络输出的参数对所述目标评价网络进行软更新。The current evaluation network is optimized by using the second loss function value, and at the same time, the target evaluation network is soft-updated through the parameters output by the current evaluation network.
  8. 根据权利要求1所述的方法,其中,所述数据服务器包括备份数据库服务器和业务数据库服务器,所述获取来自数据库服务器的数据库状态混合表征参数,包括:The method according to claim 1, wherein, the data server comprises a backup database server and a service database server, and the obtaining the database state hybrid representation parameters from the database server comprises:
    获取备份服务器的数据库状态混合表征参数;Obtain the hybrid representation parameters of the database state of the backup server;
    将所述目标数据库配置参数发送至数据库服务器,包括:Send the target database configuration parameters to the database server, including:
    将所述目标数据库配置参数发送至业务数据库服务器。Send the target database configuration parameters to the service database server.
  9. 根据权利要求1-8任一项所述的方法,其中,所述获取来自数据库服务器的数据库状态混合表征参数;将所述数据库状态混合表征参数输入到深度强化学习模型中生成目标数据库配置参数,包括:获取来自数据库服务器的数据库状态混合表征参数;The method according to any one of claims 1-8, wherein the obtaining the database state mixed representation parameters from a database server; inputting the database state mixed representation parameters into a deep reinforcement learning model to generate target database configuration parameters, Including: obtaining the mixed representation parameters of the database state from the database server;
    将所述数据库状态混合表征参数输入到深度强化学习模型中生成中间数据库配置参数;Inputting the database state mixed representation parameters into the deep reinforcement learning model to generate intermediate database configuration parameters;
    将中间数据库配置参数发送至数据库服务器,并重复执行上述步骤N次,直至得到目标数据库配置参数。Send the intermediate database configuration parameters to the database server, and repeat the above steps N times until the target database configuration parameters are obtained.
  10. 一种数据库配置参数调整方法,应用于数据库服务器,包括:A database configuration parameter adjustment method, applied to a database server, includes:
    发送数据库状态混合表征参数给调优模块,以使调优模块执行如权利要求1-9任一项所述的方法;Sending the database state mixed representation parameter to the tuning module, so that the tuning module executes the method according to any one of claims 1-9;
    接收来自所述数据库调优模块发送的目标数据库配置参数;receiving the target database configuration parameters sent from the database tuning module;
    根据所述数据库配置参数对数据库服务器进行参数配置。The database server is configured with parameters according to the database configuration parameters.
  11. 根据权利要求10所述的方法,其中,所述数据库状态混合表征参数包括以下的一种或多种:数据库性能参数、当前数据库配置参数、硬件资源参数、硬件资源状态参数。The method according to claim 10, wherein the database state mixed characterization parameters include one or more of the following: database performance parameters, current database configuration parameters, hardware resource parameters, and hardware resource state parameters.
  12. 根据权利要求10所述的方法,其中,所述发送数据库状态混合表征参数给数据库调优模块,以使数据库调优模块执行如权利要求1-9任一项所述的方法之前,还包括:The method according to claim 10, wherein before the sending the database state mixed representation parameter to the database tuning module, so that the database tuning module executes the method according to any one of claims 1-9, the method further comprises:
    获取第一次数据库状态混合表征参数;Obtain the first mixed representation parameters of the database state;
    获取来自压力模拟服务器的工作负载压力信号;Obtain workload stress signals from stress simulation servers;
    根据所述工作负载压力信号对数据库服务器进行加压操作;performing a pressurization operation on the database server according to the workload pressure signal;
    所述加压操作结束后,获取第二次数据库状态混合表征参数。After the pressurization operation is completed, the second database state mixing characterization parameter is obtained.
  13. 根据权利要求10所述的方法,所述数据库服务器包括备份数据库服务器和业务数据库服务器,所述发送数据库状态混合表征参数给数据库调优模块,以使数据库调优模块执行如权利要求1-9任一项所述的方法;包括:The method according to claim 10, wherein the database server includes a backup database server and a business database server, and the sending the database state mixed representation parameter to the database tuning module, so that the database tuning module performs any of the tasks according to claims 1-9. The method of one; comprising:
    利用备份数据库服务器发送所述数据库状态混合表征参数给数据库调优模块执行如权利要求1-9任一项所述的方法生成目标数据库配置参数;Utilize the backup database server to send the database state mixed representation parameters to the database tuning module to execute the method according to any one of claims 1-9 to generate target database configuration parameters;
    利用业务服务器接收所述目标数据库配置参数;Utilize the business server to receive the target database configuration parameter;
    根据所述目标数据库配置参数对业务数据库服务器进行参数配置。Parameter configuration is performed on the service database server according to the target database configuration parameters.
  14. 电子设备,包括:Electronic equipment, including:
    至少一个处理器,以及,at least one processor, and,
    与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein,
    所述存储器存储有指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器执行所述指令时实现如权利要求1至9任一项所述的方法或如权利要求10至13任一项所述的方法。the memory stores instructions which are executed by the at least one processor such that when the at least one processor executes the instructions, a method as claimed in any one of claims 1 to 9 or as claimed in claim 1 is implemented The method of any one of 10 to 13.
  15. 计算机可读存储介质,存储有计算机可执行指令,其中,所述计算机可执行指令用于使计算机执行如权利要求1至9任一项所述的方法或如权利要求10至13任一项所述的方法。A computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to cause a computer to perform the method as claimed in any one of claims 1 to 9 or the method as claimed in any one of claims 10 to 13 method described.
PCT/CN2021/102782 2020-06-30 2021-06-28 Database configuration parameter adjustment method, and device and storage medium WO2022001965A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010618107.8 2020-06-30
CN202010618107.8A CN113872788A (en) 2020-06-30 2020-06-30 Database configuration parameter adjusting method, device and storage medium

Publications (1)

Publication Number Publication Date
WO2022001965A1 true WO2022001965A1 (en) 2022-01-06

Family

ID=78981855

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/102782 WO2022001965A1 (en) 2020-06-30 2021-06-28 Database configuration parameter adjustment method, and device and storage medium

Country Status (2)

Country Link
CN (1) CN113872788A (en)
WO (1) WO2022001965A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116401232A (en) * 2023-03-24 2023-07-07 天云融创数据科技(北京)有限公司 Database parameter configuration optimization method and device, electronic equipment and storage medium
CN117234711A (en) * 2023-09-05 2023-12-15 合芯科技(苏州)有限公司 Dynamic allocation method, system, equipment and medium for Flink system resources
WO2024066635A1 (en) * 2022-09-30 2024-04-04 北京柏睿数据技术股份有限公司 Method and system for intelligently optimizing database performance

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116594981A (en) * 2023-05-18 2023-08-15 合芯科技(苏州)有限公司 Database system parameter optimization method and device and electronic equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120143847A1 (en) * 2009-04-24 2012-06-07 Nhn Business Platform Corporation Database management method and system
US20190065985A1 (en) * 2017-08-23 2019-02-28 Sap Se Machine learning based database management
CN110019151A (en) * 2019-04-11 2019-07-16 深圳市腾讯计算机系统有限公司 Database performance method of adjustment, device, equipment, system and storage medium
CN110134665A (en) * 2019-04-17 2019-08-16 北京百度网讯科技有限公司 Database self-learning optimization method and device based on traffic mirroring
CN110134697A (en) * 2019-05-22 2019-08-16 南京大学 A kind of parameter automated tuning method, apparatus, system towards key-value pair storage engines
US20200125545A1 (en) * 2018-10-18 2020-04-23 Oracle International Corporation Automated configuration parameter tuning for database performance

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11586905B2 (en) * 2017-10-11 2023-02-21 Arizona Board Of Regents On Behalf Of Arizona State University Systems and methods for customizing kernel machines with deep neural networks

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120143847A1 (en) * 2009-04-24 2012-06-07 Nhn Business Platform Corporation Database management method and system
US20190065985A1 (en) * 2017-08-23 2019-02-28 Sap Se Machine learning based database management
US20200125545A1 (en) * 2018-10-18 2020-04-23 Oracle International Corporation Automated configuration parameter tuning for database performance
CN110019151A (en) * 2019-04-11 2019-07-16 深圳市腾讯计算机系统有限公司 Database performance method of adjustment, device, equipment, system and storage medium
CN110134665A (en) * 2019-04-17 2019-08-16 北京百度网讯科技有限公司 Database self-learning optimization method and device based on traffic mirroring
CN110134697A (en) * 2019-05-22 2019-08-16 南京大学 A kind of parameter automated tuning method, apparatus, system towards key-value pair storage engines

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024066635A1 (en) * 2022-09-30 2024-04-04 北京柏睿数据技术股份有限公司 Method and system for intelligently optimizing database performance
CN116401232A (en) * 2023-03-24 2023-07-07 天云融创数据科技(北京)有限公司 Database parameter configuration optimization method and device, electronic equipment and storage medium
CN116401232B (en) * 2023-03-24 2024-01-30 天云融创数据科技(北京)有限公司 Database parameter configuration optimization method and device, electronic equipment and storage medium
CN117234711A (en) * 2023-09-05 2023-12-15 合芯科技(苏州)有限公司 Dynamic allocation method, system, equipment and medium for Flink system resources
CN117234711B (en) * 2023-09-05 2024-05-07 合芯科技(苏州)有限公司 Dynamic allocation method, system, equipment and medium for Flink system resources

Also Published As

Publication number Publication date
CN113872788A (en) 2021-12-31

Similar Documents

Publication Publication Date Title
WO2022001965A1 (en) Database configuration parameter adjustment method, and device and storage medium
Tang et al. 1-bit adam: Communication efficient large-scale training with adam’s convergence speed
US20220076154A1 (en) Control pulse generation method, system, device and storage medium
Zhang et al. A multi-agent reinforcement learning approach for efficient client selection in federated learning
CN112668128B (en) Method and device for selecting terminal equipment nodes in federal learning system
US20220027774A1 (en) Quantum control pulse generation method, device, and storage medium
CN113496285A (en) Data processing method and device based on quantum circuit, electronic device and medium
US20230267357A1 (en) Simulation method of quantum system, computing device and storage medium
US20220374776A1 (en) Method and system for federated learning, electronic device, and computer readable medium
Hodak et al. Towards power efficiency in deep learning on data center hardware
CN109961147B (en) Automatic model compression method based on Q-Learning algorithm
CN109784359A (en) Image generating method, device, equipment and readable storage medium storing program for executing
US7860700B2 (en) Hardware verification batch computing farm simulator
Sardana et al. Beyond chinchilla-optimal: Accounting for inference in language model scaling laws
Janke et al. Implicit generative copulas
CN114819168B (en) Quantum comparison method and device for matrix eigenvalues
US12093836B2 (en) Automatic multi-objective hardware optimization for processing of deep learning networks
US20220164346A1 (en) Query-oriented approximate query processing based on machine learning techniques
CN117435451A (en) Method for establishing power consumption and performance model of virtual computing unit in mobile edge computing
Chang et al. GraphCS: Graph-based client selection for heterogeneity in federated learning
US12050979B2 (en) Budgeted neural network architecture search system and method
US20240028974A1 (en) Edge-weighted quantization for federated learning
CN113743012B (en) Cloud-edge collaborative mode task unloading optimization method under multi-user scene
CN115062777A (en) Method for quantizing convolutional neural network, device, and storage medium
Bo et al. On optimal tracking portfolio in incomplete markets: The classical control and the reinforcement learning approaches

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21833394

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 19/05/2023)

122 Ep: pct application non-entry in european phase

Ref document number: 21833394

Country of ref document: EP

Kind code of ref document: A1