MySQL database tuning device, method, terminal and storage medium
By integrating hardware, operating system and database parameter tuning, it solves the problem of lack of uniformity and coverage of MySQL database tuning, achieves simplified tuning process and efficient performance improvement, and lowers the technical threshold for users.
Patent Information
- Application Number
- CN202210912382.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-29
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2042-07-29
AI Technical Summary
Existing MySQL database tuning methods lack uniformity and coverage, have high thresholds, are difficult to adapt to different business backgrounds and scenarios, and require in-depth understanding of computer systems and MySQL software.
Provide a MySQL database tuning device and method that integrates hardware tuning, operating system tuning and database parameter tuning. By setting the SMMU function and CPU prefetching function in the BIOS, configure the file system, close the irqbalance service, and bind the network card Interrupt, tune network and IO parameters, adjust database configuration file parameters, simplify the tuning process and lower the threshold.
It realizes MySQL database tuning from the bottom layer of the server to the upper layer, with clear logical structure, saving time, improving efficiency, simplifying environment construction, lowering the user threshold, and adapting to various business needs.
Smart Images

Figure CN115048360B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of MySQL database tuning, and in particular to a MySQL database tuning device, method, terminal and storage medium. Background Art
[0002] MySQL database is an open source relational database software. The technical principles and usage of the database itself are all in the source code and its official documents. The principles of database tuning are also based on these technical materials and source code interpretation and translation documents as the technical foundation.
[0003] The current tuning methods for MySQL databases have the following defects: (1) Based on the official documentation of MySQL, a relational database, different companies have different application levels and different requirements for business data regarding its usage principles and methods. The tuning methods have no fixed rules due to different purposes. The industry does not have a unified and fixed tuning parameter range. (2) In-depth study of MySQL also requires a lot of time to understand the scheduling of computer systems and MySQL software itself, and the threshold is relatively high. (3) At the same time, because the database technology involves the operating system, memory, and hard disk, they all affect the performance of the database itself and have an established relationship. However, due to different business backgrounds and scenarios, the current existing tuning methods do not cover the entire scope. Summary of the invention
[0004] To solve the above problems, the present invention provides a MySQL database tuning device, method, terminal and storage medium, which integrate the tuning from the underlying hardware of the server to the upper-level MySQL application. The logical structure is simple and clear, and each module from bottom to top is clear and concise, which saves time and improves efficiency. The environment is simple and easy to operate, and there is no need to have an in-depth understanding of the MySQL database, which reduces the user threshold and is convenient to use.
[0005] In a first aspect, the technical solution of the present invention provides a MySQL database tuning device, comprising:
[0006] Hardware tuning module: Tune the hardware of the server where the MySQL database is located, including:
[0007] Set the advanced options in BIOS and configure the start and stop of the SMMU function and CPU prefetch function in the advanced options;
[0008] Operating system tuning module: Tune the operating system of the server where the MySQL database is located, including:
[0009] File system tuning, shutting down irqbalance service, binding network card interrupts to cores, network parameter tuning, IO parameter tuning, and cache parameter tuning;
[0010] Database parameter tuning module: Tuning database parameters, including:
[0011] Tune the parameters in the database configuration file.
[0012] Furthermore, the hardware tuning module configures the start and stop of the SMMU function and the CPU prefetch function in the advanced options, including:
[0013] Disable CPU prefetching function;
[0014] Determine whether the server is a non-virtualized scenario;
[0015] If yes, disable the SMMU function; otherwise, enable the SMMU function.
[0016] Furthermore, the operating system tuning module includes a file system tuning unit, which is used to tune the file system, specifically including:
[0017] Use xfs file system;
[0018] Add the noatime option and the nobarrier option to the mount parameters of the xfs file system, and use the noatime option and the nobarrier option to mount the xfs file system.
[0019] Furthermore, the operating system tuning module includes a service shutdown unit, which is used to shut down the irqbalance service, specifically including:
[0020] Stop the irqbalance service;
[0021] Disable irqbalance service;
[0022] Check whether the irqbalance service status is closed;
[0023] If yes, the irqbalance service is shut down normally; otherwise, stop the irqbalance service again;
[0024] The operating system tuning module also includes an interrupt core binding unit, which is used to bind the network card interrupt core, specifically including:
[0025] Query the network card interrupt number;
[0026] According to the network card interrupt number, each interrupt is bound to a CPU core.
[0027] Furthermore, the operating system tuning module includes a network parameter tuning unit, which is used to tune the network parameters, specifically including:
[0028] Increase the maximum number of clients that the server can accept SYN synchronization packets;
[0029] Increase the maximum number of clients that the server can process data on;
[0030] Increase the maximum receive socket buffer size;
[0031] Increase the maximum send socket buffer size;
[0032] Increase the maximum value of the read buffer size, and set the minimum and middle values of the read buffer size to the default values;
[0033] Increase the maximum value of the write buffer size, and set the minimum and middle values of the write buffer size to the default values;
[0034] Increase the maximum number of TIME_WAIT sockets that the system can maintain simultaneously.
[0035] Furthermore, the operating system tuning module includes an IO parameter tuning unit, which is specifically used to tune the IO parameters, including:
[0036] Configure the IO scheduling policy as the deadline scheduling policy or the noop policy;
[0037] Improve disk throughput;
[0038] The operating system tuning module includes a cache parameter tuning unit, which is used to tune cache parameters, including:
[0039] Configure kernel page recycling parameters;
[0040] Configure the percentage of dirty data in memory to not exceed the preset value.
[0041] Furthermore, the database parameter tuning module tunes the parameters in the database configuration file, specifically including:
[0042] Set the page size, turn off SSL, set the maximum number of connections, set the number of session request caches, turn off performance mode, set one file for each table, set the log file size, set the number of log file groups, set the maximum number of open tables, set the buffer pool size, set the number of buffer pool instances, set the log buffer area size, set the synchronous write disk method to write binary logs, set the log buffer data to be written to the log file and flushed to disk each time a transaction is committed, turn on asynchronous IO, set the spin_wait_delay parameter and the number of spin_loops to prevent the system from spinning, set the open flush mode of innodb data files and redo logs, set the maximum iops upper limit per second for innodb background threads, set the maximum iops upper limit per second for innodb background threads under pressure, set the number of dirty pages flushed by the page cleaner thread each time, set the number of threads that write dirty data to disk, set dirty page flushing, set the number of write threads, set the number of read threads, and set the number of threads that recycle used and allocated undo pages.
[0043] In a second aspect, the technical solution of the present invention provides a MySQL database tuning method, comprising the following steps:
[0044] S1, tune the hardware of the server where the MySQL database is located, including:
[0045] Set the advanced options in BIOS and configure the start and stop of the SMMU function and CPU prefetch function in the advanced options;
[0046] S2: Tune the operating system of the server where the MySQL database is located, including:
[0047] File system tuning, shutting down irqbalance service, binding network card interrupts to cores, network parameter tuning, IO parameter tuning, and cache parameter tuning;
[0048] S3, tune the database parameters, including:
[0049] Tune the parameters in the database configuration file.
[0050] In a third aspect, the technical solution of the present invention provides a terminal, including:
[0051] A memory device for storing a MySQL database tuning program;
[0052] The processor is used to implement the steps of the above-mentioned MySQL database tuning method when executing the MySQL database tuning program.
[0053] In a fourth aspect, the technical solution of the present invention provides a computer-readable storage medium, on which a MySQL database tuning program is stored. When the MySQL database tuning program is executed by a processor, the steps of the above-mentioned MySQL database tuning method are implemented.
[0054] A MySQL database tuning device, method, terminal and storage medium provided by the present invention have the following beneficial effects compared with the prior art: integrating the tuning from the underlying hardware of the server to the upper-layer MySQL application, with a simple and clear logical structure, and each module from bottom to top is clear and concise, saving time, improving efficiency, and making the environment simple and easy to operate, without the need for in-depth understanding of the MySQL database, thereby lowering the user threshold and facilitating use. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the embodiments of the present application or the technical solutions of the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0056] Figure 1 It is a schematic diagram of the tuning architecture of the MySQL database tuning device provided in an embodiment of the present invention.
[0057] Figure 2 The present invention is a schematic block diagram of the structure of a MySQL database tuning device provided in an embodiment of the present invention.
[0058] Figure 3 The present invention is a block diagram showing the structure of an operating system tuning module in a MySQL database tuning device provided by an embodiment of the present invention.
[0059] Figure 4 The present invention provides a flow chart of a MySQL database tuning method.
[0060] Figure 5 It is a schematic diagram of the structure of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0061] Some English terms involved in the present invention are explained below.
[0062] MySQL: MySQL is a small relational database management system developed by MySQL AB of Sweden and currently a product of Oracle. MySQL is one of the most popular relational database management systems. In terms of WEB applications, MySQL is one of the best RDBMS (Relational Database Management System) application software. Compared with other large database management systems (such as Oracle, DB2, SQL Server, etc.), MySQL is small in scale and limited in functionality, but it is small in size, fast, low in cost, and the functions it provides are sufficient for slightly complex applications. These features make MySQL the most popular open source database in the world.
[0063] SQL language: statements for operating databases.
[0064] MySQL 8.0: is the latest stable (GA) release series, which is the series that will implement new features;
[0065] RDBMS: Relational Database Management System, a data management system that uses relational database software.
[0066] The function of SMMU is similar to that of MMU. It converts the DMA address request (IOVA) of the IO device into the system bus address (PA), implements functions such as address mapping, attribute conversion, and permission checking, and realizes the isolation of DMA address space of different devices.
[0067] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0068] Since there is an established connection between the MySQL database software and the hardware components and the entire system, the present invention provides a fixed but flexible MySQL database tuning device from the bottom layer to the upper layer of the server, including multiple tuning function modules and function units, which can tune multiple parameters. Users can select function modules or function units according to their needs to modify parameters, etc., to achieve efficient and fast tuning of the MySQL database. It should be noted that the present invention can be specifically applied to MySQL 8.0 database tuning.
[0069] Performance optimization must first accurately locate the problem, analyze the system performance bottleneck, and then select the optimization method according to its performance indicators and the level. The specific tuning ideas are as follows: In many cases, the stress test traffic does not fully enter the server, and the stress test results may not meet expectations due to various specifications (bandwidth, maximum number of connections, number of new connections, etc.) on the network; then see if the key indicators meet the requirements. If not, it is necessary to determine where the problem is. Generally, the server-side problem is more likely, and it may also be a client-side problem (this situation is relatively rare); for server-side problems, it is necessary to locate hardware-related indicators, such as CPU, Memory, Disk I / O, Network I / O. If there is a problem with a certain hardware indicator, it is necessary to conduct in-depth analysis; if there is no problem with the hardware indicators, it is necessary to check the database-related indicators, such as: wait events, memory hit rate, etc.; if the above indicators are normal, there may be problems with the application's algorithm, buffer, cache, synchronization or asynchrony, which requires specific and in-depth analysis.
[0070] Possible bottlenecks are as follows:
[0071] (1) Hardware / Specifications: Generally refers to issues related to the CPU, memory, and disk I / O, which are divided into server hardware bottlenecks and network bottlenecks (LAN bottlenecks can be ignored).
[0072] (2) Operating system: generally refers to Windows, UNIX, Linux and other operating systems. For example, when performing performance testing and physical memory is insufficient and the virtual memory settings are unreasonable, the virtual memory exchange efficiency will be greatly reduced, resulting in a significant increase in the response time of the behavior. At this time, it is considered that a performance bottleneck has occurred in the operating system.
[0073] (3) Database: Generally refers to issues related to database configuration. For example, if the database processing speed is slow due to unreasonable parameter configuration, it can be considered a problem at the database level.
[0074] Based on the above analysis, the present invention provides a MySQL database tuning device, such as Figure 1 The figure shows a schematic diagram of the device tuning architecture, which includes three aspects of tuning: hardware tuning, operating system tuning and database parameter tuning. Hardware tuning achieves better hardware devices through BIOS settings. Operating system tuning includes file system tuning, shutting down irqbalance service, binding network card interrupts to cores, network parameter tuning, IO parameter tuning and cache parameter tuning. Database parameter tuning is achieved by configuring configuration file parameters.
[0075] Figure 2It is a schematic block diagram of the structure of a MySQL database tuning device provided in an embodiment of the present invention, comprising a hardware tuning module 1, an operating system tuning module 2 and a database parameter tuning module 3, to achieve tuning of hardware, operating system and database parameters.
[0076] Hardware Tuning Module 1: Tuning the hardware of the server where the MySQL database is located, including:
[0077] Set advanced options in BIOS and configure the start and stop of the SMMU function and CPU prefetch function in the advanced options.
[0078] Operating system tuning module 2: Tune the operating system of the server where the MySQL database is located, including:
[0079] File system tuning, disabling irqbalance service, binding network card interrupts to cores, network parameter tuning, IO parameter tuning, and cache parameter tuning.
[0080] Database parameter tuning module 3: Tuning database parameters, including:
[0081] Tune the parameters in the database configuration file.
[0082] It should be noted that each functional module is displayed on the interactive interface of the display screen, and the user selects the parameters to be tuned according to needs, and then selects the corresponding functional module for tuning.
[0083] A MySQL database tuning device provided by an embodiment of the present invention integrates the tuning from the underlying hardware of the server to the upper-layer MySQL application. The logical structure is simple and clear, and each module from bottom to top is clear and concise, which saves time and improves efficiency. The environment construction is simple and easy to operate, and there is no need to have an in-depth understanding of the MySQL database, which reduces the user threshold and is convenient to use.
[0084] The following is a detailed description of each functional module.
[0085] 1. Hardware tuning module 1
[0086] Set advanced options in BIOS and configure the start and stop of the SMMU function and CPU prefetch function in the advanced options.
[0087] The specific tuning process includes the following:
[0088] Disable CPU prefetching function;
[0089] Determine whether the server is a non-virtualized scenario;
[0090] If yes, disable the SMMU function; otherwise, enable the SMMU function.
[0091] 2. Operating system tuning module 2
[0092] Figure 3 It is a schematic block diagram of the structure of the operating system tuning module 2, which tunes the server operating system where the MySQL database is located, and specifically includes a file system tuning unit 201, a service shutdown unit 202, an interrupt core binding unit 203, a network parameter tuning unit 204, an IO parameter tuning unit 205 and a cache parameter tuning unit 206, to achieve file system tuning, shutdown of the irqbalance service, network card interrupt core binding, network parameter tuning, IO parameter tuning and cache parameter tuning.
[0093] (1) File system tuning unit 201
[0094] Implement file system tuning, including:
[0095] Use xfs file system;
[0096] Add the noatime option and the nobarrier option to the mount parameters of the xfs file system, and use the noatime option and the nobarrier option to mount the xfs file system.
[0097] The command to add the noatime option and the nobarrier option is as follows (the data disk and data directory are subject to the actual situation): mount -o noatime,nobarrier / dev / sdb / data.
[0098] The above configuration can effectively improve server performance.
[0099] (2) Service shutdown unit 202
[0100] Used to disable the irqbalance service, including:
[0101] Stop the irqbalance service; the command is systemctl stop irqbalance.service;
[0102] Disable the irqbalance service; the command is systemctl disable irqbalance.service;
[0103] Check whether the irqbalance service status is closed; the command is systemctl statusirqbalance.service.
[0104] If yes, the irqbalance service is shut down normally; otherwise, stop the irqbalance service again.
[0105] (3) Interrupt binding core unit 203
[0106] Used to bind the network card interrupt to the core, including:
[0107] Query the network card interrupt number; cat / proc / interrupts|grep$eth|awk-F':”{print$1}'#Where $eth indicates the name of the service network port that needs to be optimized. For example: cat / proc / interrupts|grep eth1|awk-F':”{print$1}'.
[0108] Bind each interrupt to a CPU core according to the network card interrupt number. echo$cpunum> / proc / irq / $irq / smp_affinity_list#$cpunum indicates the target CPU serial number to be bound, and $irq indicates the result of step 1. If there are multiple serial numbers, you need to bind them one by one.
[0109] After the above configuration, the system network performance is optimized.
[0110] (4) Network parameter tuning unit 204
[0111] Used to tune network parameters, including: increasing the maximum number of clients that the server can accept SYN synchronization packets; increasing the maximum number of clients that the server can process data; increasing the maximum value of the receive socket buffer size; increasing the maximum value of the send socket buffer size; increasing the maximum value of the read buffer size, and configuring the minimum and middle values of the read buffer size as the default values; increasing the maximum value of the write buffer size, and configuring the minimum and middle values of the write buffer size as the default values; increasing the maximum number of TIME_WAIT sockets that the system can maintain at the same time.
[0112] During specific implementation, the network parameter tuning method in Table 1 below may be used.
[0113] Table 1 Network parameter tuning methods
[0114]
[0115]
[0116] For different operating systems, server performance can be effectively improved by adjusting some network parameter configurations at the OS level.
[0117] (5) IO parameter tuning unit 205
[0118] Used to tune IO parameters, including: configuring the IO scheduling policy to be the deadline scheduling policy or the noop policy; improving disk throughput.
[0119] During specific implementation, the IO parameter tuning method in Table 2 below may be used.
[0120] Table 2 IO parameter tuning methods
[0121]
[0122] For different IO devices, server performance can be effectively improved by adjusting some IO-related parameter configurations at the OS level.
[0123] (6) Cache parameter tuning unit 206
[0124] Used to tune cache parameters, including: configuring kernel page recycling parameters; configuring the percentage of dirty data in memory not to exceed a preset value.
[0125] During specific implementation, the cache parameter tuning method in Table 3 below may be used.
[0126] Table 3 Cache parameter tuning methods
[0127]
[0128] For memory usage of different systems, server performance can be effectively improved by adjusting some cache-related parameter configurations at the OS level.
[0129] 3. Database parameter tuning module 3
[0130] Implement parameter tuning in the database configuration file, including: setting page size, disabling SSL, setting the maximum number of connections, setting the number of session request caches, disabling performance mode, setting one file for each table, setting log file size, setting the number of log file groups, setting the maximum number of open tables, setting the buffer pool size, setting the number of buffer pool instances, setting the log buffer area size, setting the synchronous write disk method to write binary logs, setting each transaction to write log buffer data to the log file and flush it to disk, enabling asynchronous IO, setting the spin_wait_delay parameter and spin_loops number of cycles to prevent system spin, setting the open flush mode of innodb data files and redo logs, setting the maximum iops upper limit per second for innodb background threads, setting the maximum iops upper limit per second for innodb background threads under pressure, setting the number of dirty pages flushed by the page cleaner thread each time, setting the number of threads that write dirty data to disk, setting dirty page flushing, setting the number of write threads, setting the number of read threads, and setting the number of threads that recycle used and allocated undo pages.
[0131] During the specific implementation, use the following configuration file parameters to start the database. The default configuration file path is / etc / my.cnf. The MySQL software installation and data storage path are modified according to the actual situation.
[0132] [mysqld_safe]
[0133] log-error= / data / mysql-8.0.16 / mysql / log / mariadb.log
[0134] pid-file= / data / mysql-8.0.16 / mysql / run / mysqld.pid
[0135] [client]
[0136] socket= / data / mysql-8.0.16 / mysql / run / mysql.sock
[0137] default-character-set=utf8
[0138] [mysqld]
[0139] basedir= / home / mysql-8.0.16 / mysql
[0140] tmpdir= / data / mysql-8.0.16 / mysql / tmp
[0141] datadir= / data / mysql-8.0.16 / mysql / data
[0142] socket= / data / mysql-8.0.16 / mysql / run / mysql.sock
[0143] port=5306
[0144] user=root
[0145] default_authentication_plugin=mysql_native_password
[0146] innodb_page_size=4096#Set page size
[0147] ssl=0#disable ssl
[0148] [mysql]
[0149] max_connections = 2000 # Set the maximum number of connections
[0150] back_log = 2048#Set the number of session request caches
[0151] performance_schema=OFF#Turn off performance mode
[0152] max_prepared_stmt_count=128000
[0153] #file
[0154] innodb_file_per_table#Set one file per table
[0155] innodb_log_file_size=1500M#Set logfile size
[0156] innodb_log_files_in_group=32#Set the number of logfile groups
[0157] innodb_open_files=4000#Set the maximum number of open tables
[0158] #buffers
[0159] innodb_buffer_pool_size=230G#Set the buffer pool size, generally about 60% of the server memory
[0160] innodb_buffer_pool_instances=16#Set the number of buffer pool instances to improve concurrency
[0161] innodb_log_buffer_size=64M#Set the log buffer size
[0162] #tune
[0163] sync_binlog=1#Set each sync_binlog transaction to flush to disk
[0164] innodb_flush_log_at_trx_commit=1#MySQL will write the data in the log buffer every time a transaction is committed
[0165] Enter the log file and flush it to disk
[0166] innodb_use_native_aio=1#Enable asynchronous IO
[0167] innodb_spin_wait_delay=180#Set the spin_wait_delay parameter to prevent the system from spinning
[0168] innodb_sync_spin_loops = 25 #Set the number of spin_loops to prevent the system from spinning
[0169] innodb_flush_method = O_DIRECT #Set the opening and flushing mode of innodb data files and redo logs
[0170] innodb_io_capacity=20000#Set the maximum iops limit of innodb background thread per second
[0171] innodb_io_capacity_max=40000 #Set the maximum iops limit of innodb background threads per second under pressure
[0172] innodb_lru_scan_depth=9000#Set the number of dirty pages that the page cleaner thread flushes each time
[0173] innodb_page_cleaners = 16 # Set the number of threads that write dirty data to disk
[0174] #perf special
[0175] innodb_flush_neighbors = 0 # Check all pages in the extent where the page is located. If they are dirty pages, refresh them together. SSD turns off this function.
[0176] innodb_write_io_threads = 16 # Set the number of write threads
[0177] innodb_read_io_threads=16#Set the number of read threads
[0178] innodb_purge_threads = 32 # Set the number of threads for reclaiming used and allocated undo pages
[0179] sql_mode=STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_AUTO_VALUE_ON_ZERO,STRICT_ALL_TABLES
[0180] Each of the above parameters should be set according to the actual enterprise standard, and if the above parameters are used by default, the performance is very low and is not enough to support the enterprise database. Therefore, the adjustment of the above parameters can be found in the official documents. The above is the general tuning parameter range.
[0181] An embodiment of a MySQL database tuning device is described in detail above. Based on the MySQL database tuning device described in the above embodiment, an embodiment of the present invention further provides a MySQL database tuning method corresponding to the device.
[0182] Figure 4 FIG. 1 is a flow chart of a MySQL database tuning method provided by an embodiment of the present invention. Figure 4 As shown, the method includes the following steps.
[0183] S1, tune the hardware of the server where the MySQL database is located, including:
[0184] Set advanced options in BIOS and configure the start and stop of the SMMU function and CPU prefetch function in the advanced options.
[0185] S2: Tune the operating system of the server where the MySQL database is located, including:
[0186] File system tuning, disabling irqbalance service, binding network card interrupts to cores, network parameter tuning, IO parameter tuning, and cache parameter tuning.
[0187] S3, tune the database parameters, including:
[0188] Tune the parameters in the database configuration file.
[0189] The MySQL database tuning method of this embodiment is based on the aforementioned MySQL database tuning device, so the specific implementation method of this method can be seen in the embodiment part of the MySQL database tuning device in the previous text. Therefore, its specific implementation method can refer to the description of the corresponding embodiments of each part, which will not be introduced in detail here.
[0190] In addition, since the MySQL database tuning method of this embodiment is based on the aforementioned MySQL database tuning device, its function corresponds to that of the aforementioned device and will not be described in detail here.
[0191] Figure 5 A schematic diagram of the structure of a terminal device 500 provided in an embodiment of the present invention includes: a processor 510, a memory 520 and a communication unit 530. The processor 510 is used to implement the following steps when implementing the MySQL database tuning program stored in the memory 520:
[0192] S1, tune the hardware of the server where the MySQL database is located, including:
[0193] Set the advanced options in BIOS and configure the start and stop of the SMMU function and CPU prefetch function in the advanced options;
[0194] S2: Tune the operating system of the server where the MySQL database is located, including:
[0195] File system tuning, shutting down irqbalance service, binding network card interrupts to cores, network parameter tuning, IO parameter tuning, and cache parameter tuning;
[0196] S3, tune the database parameters, including:
[0197] Tune the parameters in the database configuration file.
[0198] The present invention integrates the optimization from the bottom hardware of the server to the upper MySQL application. The logical structure is simple and clear. Each module from bottom to top is clear and concise, which saves time and improves efficiency. The environment construction is simple and easy to operate, and there is no need to have an in-depth understanding of the MySQL database, which lowers the user threshold and is convenient to use.
[0199] The terminal device 500 includes a processor 510, a memory 520 and a communication unit 530. These components communicate via one or more buses. It can be understood by those skilled in the art that the structure of the server shown in the figure does not constitute a limitation of the present invention, and it can be a bus structure or a star structure, and can also include more or less components than shown in the figure, or combine some components, or arrange the components differently.
[0200] The memory 520 can be used to store the execution instructions of the processor 510. The memory 520 can be implemented by any type of volatile or non-volatile storage terminal or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. When the execution instructions in the memory 520 are executed by the processor 510, the terminal 500 can execute some or all of the steps in the following method embodiments.
[0201] The processor 510 is the control center of the storage terminal, and uses various interfaces and lines to connect various parts of the entire electronic terminal. It runs or executes software programs and / or modules stored in the memory 520, and calls data stored in the memory to perform various functions of the electronic terminal and / or process data. The processor can be composed of an integrated circuit (IC), for example, it can be composed of a single packaged IC, or it can be composed of a plurality of packaged ICs with the same or different functions. For example, the processor 510 can include only a central processing unit (CPU). In the embodiment of the present invention, the CPU can be a single computing core or multiple computing cores.
[0202] The communication unit 530 is used to establish a communication channel so that the storage terminal can communicate with other terminals, receive user data sent by other terminals or send user data to other terminals.
[0203] Embodiment 6
[0204] The present invention also provides a computer storage medium, wherein the storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM).
[0205] The computer storage medium stores a MySQL database tuning program, and when the MySQL database tuning program is executed by the processor, the following steps are implemented:
[0206] S1, tune the hardware of the server where the MySQL database is located, including:
[0207] Set the advanced options in BIOS and configure the start and stop of the SMMU function and CPU prefetch function in the advanced options;
[0208] S2: Tune the operating system of the server where the MySQL database is located, including:
[0209] File system tuning, shutting down irqbalance service, binding network card interrupts to cores, network parameter tuning, IO parameter tuning, and cache parameter tuning;
[0210] S3, tune the database parameters, including:
[0211] Tune the parameters in the database configuration file.
[0212] The present invention integrates the optimization from the bottom hardware of the server to the upper MySQL application. The logical structure is simple and clear. Each module from bottom to top is clear and concise, which saves time and improves efficiency. The environment construction is simple and easy to operate, and there is no need to have an in-depth understanding of the MySQL database, which lowers the user threshold and is convenient to use.
[0213] Those skilled in the art can clearly understand that the technology in the embodiments of the present invention can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution in the embodiments of the present invention, in essence or in other words, the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, and other media that can store program codes, including several instructions for enabling a computer terminal (which can be a personal computer, a server, or a second terminal, a network terminal, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention.
[0214] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0215] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0216] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0217] The above disclosure is only a preferred embodiment of the present invention, but the present invention is not limited thereto. Any non-creative changes that can be thought of by a person skilled in the art, as well as several improvements and modifications made without departing from the principle of the present invention, should fall within the protection scope of the present invention.
Claims
1. A MySQL database tuning device, characterized in that: include, Hardware tuning module: Tune the hardware of the server where the MySQL database is located, including: Set the advanced options in BIOS and configure the start and stop of the SMMU function and CPU prefetch function in the advanced options; Operating system tuning module: Tune the operating system of the server where the MySQL database is located, including: File system tuning, shutting down irqbalance service, binding network card interrupts to cores, network parameter tuning, IO parameter tuning, and cache parameter tuning; Database parameter tuning module: Tuning database parameters, including: Tune the parameters in the database configuration file; The operating system tuning module includes an IO parameter tuning unit, which is used to tune the IO parameters, including: Configure the IO scheduling policy as the deadline scheduling policy or the noop policy; Improve disk throughput; The operating system tuning module includes a cache parameter tuning unit, which is used to tune cache parameters, including: Configure kernel page recycling parameters; Configure the percentage of dirty data in memory to not exceed the preset value.
2. The MySQL database tuning device according to claim 1, characterized in that: The hardware tuning module configures the start and stop of the SMMU function and the CPU prefetch function in the advanced options, including: Disable CPU prefetching function; Determine whether the server is a non-virtualized scenario; If yes, disable the SMMU function; otherwise, enable the SMMU function.
3. The MySQL database tuning device according to claim 2, characterized in that: The operating system tuning module includes a file system tuning unit, which is used to tune the file system, including: Use xfs file system; Add the noatime option and the nobarrier option to the mount parameters of the xfs file system, and use the noatime option and the nobarrier option to mount the xfs file system.
4. The MySQL database tuning device according to claim 3, characterized in that: The operating system tuning module includes a service shutdown unit, which is used to shut down the irqbalance service, including: Stop the irqbalance service; Disable irqbalance service; Check whether the irqbalance service status is closed; If yes, the irqbalance service is shut down normally; otherwise, stop the irqbalance service again; The operating system tuning module also includes an interrupt core binding unit, which is used to bind the network card interrupt core, specifically including: Query the network card interrupt number; According to the network card interrupt number, each interrupt is bound to a CPU core.
5. The MySQL database tuning device according to claim 4, characterized in that: The operating system tuning module includes a network parameter tuning unit, which is used to tune network parameters, including: Increase the maximum number of clients that the server can accept SYN synchronization packets; Increase the maximum number of clients that the server can process data on; Increase the maximum receive socket buffer size; Increase the maximum send socket buffer size; Increase the maximum value of the read buffer size, and set the minimum and middle values of the read buffer size to the default values; Increase the maximum value of the write buffer size, and set the minimum and middle values of the write buffer size to the default values; Increase the maximum number of TIME_WAIT sockets that the system can maintain simultaneously.
6. The MySQL database tuning device according to claim 5, characterized in that: The database parameter tuning module tunes the parameters in the database configuration file, including: Set page size, turn off SSL, set maximum number of connections, set number of session request caches, turn off performance mode, set one file per table, set log file size, set number of log file groups, set maximum number of open tables, set buffer pool size, set number of buffer pool instances, set log cache size, set synchronous write to disk to write binary logs, set log buffer data to be written to log file and flushed to disk each time transaction is committed, turn on asynchronous IO, set spin_wait_delay parameter and spin_loops loop count to prevent system spin, set open flush mode for innodb data files and redo logs, set maximum iops upper limit per second for innodb background threads, set maximum iops upper limit per second for innodb background threads under pressure, set number of dirty pages flushed by page cleaner thread each time, set number of threads to write dirty data to disk, set dirty page flushing, set number of write threads, set number of read threads, set number of threads to recycle used and allocated undo pages.
7. A MySQL database tuning method, characterized in that: The following steps are involved: S1, tune the hardware of the server where the MySQL database is located, including: Set the advanced options in BIOS and configure the start and stop of the SMMU function and CPU prefetch function in the advanced options; S2: Tune the operating system of the server where the MySQL database is located, including: File system tuning, shutting down irqbalance service, binding network card interrupts to cores, network parameter tuning, IO parameter tuning, and cache parameter tuning; S3, tune the database parameters, including: Tune the parameters in the database configuration file; In step S2, the IO parameters are tuned, specifically including: Configure the IO scheduling policy as the deadline scheduling policy or the noop policy; Improve disk throughput; In step S2, the cache parameters are tuned, specifically including: Configure kernel page recycling parameters; Configure the percentage of dirty data in memory to not exceed the preset value.
8. A terminal, characterized in that: include: A memory device for storing a MySQL database tuning program; A processor is used to implement the steps of the MySQL database tuning method as claimed in claim 7 when executing the MySQL database tuning program.
9. A computer-readable storage medium, characterized in that: The readable storage medium stores a MySQL database tuning program, and when the MySQL database tuning program is executed by the processor, the steps of the MySQL database tuning method according to claim 7 are implemented.
Citation Information
Patent Citations
Method for optimizing IO performance of Smart Rack nodes
CN106020720A
Internet-of-things platform and internet-of-things equipment monitoring method
CN110609512A
Parallel file system IO optimization method and system
CN111338570A
Dynamic database memory management policies
US20080104319A1
