Database instruction processing system and control method thereof
By setting up the main database and replica database on virtual machines on different servers, and using virtualization platform management, the problem of limited performance of the ORACLE database when processing a large number of transactions is solved, improving database performance and efficient utilization of resources.
Patent Information
- Application Number
- CN202410703049.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-08-23
AI Technical Summary
When the ORACLE database processes a large number of transactions, the performance of a single-machine database is limited. Especially after a real-time application cluster (RAC) is built, the time consumed in data synchronization between nodes affects performance, leading to performance degradation.
By setting up the main database and the clone database on virtual machines on different servers, the master database parses the client instructions and sends them to the clone database for processing when the preset conditions are met, sharing the resource pressure of the main database and managing the master database through the virtualization platform. Database and clone database to optimize resource utilization and scalability.
It improves the overall performance and instruction processing efficiency of the database, reduces the resource pressure on the main database, avoids the performance bottleneck of a single database node limited by hardware, and improves resource utilization efficiency.
Smart Images

Figure CN118535549A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of databases, and in particular to a database instruction processing system and a control method thereof. Background Art
[0002] A database is a warehouse that organizes, stores and manages data according to data structures and can be used to process database transactions. ORACLE database has the characteristics of good portability, ease of use and powerful functions, so it is widely used in various microcomputer environments.
[0003] In the related art, ORACLE database can be installed on a physical server or a virtual machine in a virtualized environment. As the business volume increases, the database needs to process more and more database transactions, and the performance of a single-machine database cannot meet the requirements. ORACLE real-time application clusters (RAC) are built to process database transactions.
[0004] However, since ORACLE RAC includes multiple database nodes, the time consumed for data synchronization between database nodes affects database performance, thus limiting database performance. Summary of the invention
[0005] In view of this, the present invention provides a database instruction processing system and a control method thereof to solve the problem of limited database performance in the related art.
[0006] In a first aspect, the present invention provides a database instruction processing system, the system comprising:
[0007] A primary database disposed on a first virtual machine of a first server and a clone database disposed on a second virtual machine of a second server;
[0008] The primary database is used to receive a database instruction sent by a client, parse the database instruction, obtain an execution instruction, determine execution information of the execution instruction based on the execution instruction, and send the execution instruction to a target clone database that has a master-slave relationship with the primary database if the execution information meets a first preset condition;
[0009] The clone database is used to receive the execution instruction, process the execution instruction, obtain a first processing result, and feed back the first processing result to a target master database that has a master-slave relationship with the clone data, wherein the first server and the second server are different servers;
[0010] The main database is also used to receive a first processing result fed back by the target clone database, and feed back the first processing result to the client.
[0011] The database instruction processing system provided in this embodiment parses the database instruction through the main database to obtain the execution instruction, determines the execution information based on the execution instruction, and sends the execution instruction to the target clone database when the execution information meets the first preset condition. The clone database receives the execution instruction, processes the execution instruction, obtains the processing result, and feeds the processing result back to the target main database. The main database receives the processing result fed back by the target clone database and feeds the processing result back to the client. The main database and the clone database are set on virtual machines of different servers, and the clone database is used to process part of the execution instructions, which shares the resource pressure of the main database, improves the overall performance of the database, and also improves the processing efficiency of database instructions.
[0012] In an optional implementation, the master database is further used for:
[0013] When the execution information does not satisfy the first preset condition, the execution instruction is processed to obtain a second processing result, and the second processing result is fed back to the client.
[0014] The database instruction processing system provided in this embodiment uses the main database to process the execution instruction when the execution information does not meet the first preset condition, and uses the clone database to process the execution instruction when the execution information meets the first preset condition, thereby sharing the resource pressure of the main database and improving the overall performance of the database.
[0015] In an optional embodiment, the system further includes:
[0016] A virtualization platform is used to manage the main database and the clone database.
[0017] The database instruction processing system provided in this embodiment manages the main database and the clone database through a virtualization platform, provides more efficient resource utilization, flexibility and scalability, and improves the overall efficiency of the database.
[0018] In an optional implementation manner, the master database is specifically used for:
[0019] In the case where the execution information satisfies the first preset condition, determining whether there is a target clone database that has a master-slave relationship with the main database;
[0020] In the case that there is no target clone database in a master-slave relationship with the main database, sending a new clone database generation request to the virtualization platform;
[0021] In the case where there is a target clone database that is in a master-slave relationship with the primary database, obtaining resource usage information of the target virtual machine where the target clone database is located;
[0022] Determining whether the resource usage information of the target virtual machine meets a second preset condition;
[0023] When the resource usage information of the target virtual machine meets the second preset condition, sending the execution instruction to the target clone database;
[0024] When the resource usage information of the target virtual machine does not satisfy the second preset condition, sending a request for generating a new clone database to the virtualization platform;
[0025] The virtualization platform is specifically used for:
[0026] receiving the request for generating the new clone database, generating the new clone database on a virtual machine of a server different from the main database in response to the request for generating the new clone database, establishing a master-slave relationship between the main database and the new clone database, and feeding back the generation information of the new clone database to the main database;
[0027] The master database is also used for:
[0028] When the new avatar database generation information is received, the execution instruction is sent to the new avatar database.
[0029] In the database instruction processing system provided in this embodiment, the master data is used to further determine the resource usage information of the target virtual machine where the target clone database is located when the target clone database exists, and then determine whether a new clone database needs to be generated. The master data is used to send a new clone database generation request to the virtualization platform when the target clone database does not exist, and send the execution instruction to the new clone database. The virtualization platform is used to generate a new clone database and establish a master-slave relationship between the new clone database and the master database. The clone database is used to share the resource pressure of the master database, thereby improving the overall performance of the database.
[0030] In an optional implementation, the master database is further used for:
[0031] In the case where there is a target clone database that is in a master-slave relationship with the main database, determining whether the target clone database is started;
[0032] When the target avatar database is not started, sending a request to start the target avatar database to the virtualization platform;
[0033] The virtualization platform is specifically used for:
[0034] The request for starting the target clone database is received, and in response to the request for starting the target clone database, the target clone database is started.
[0035] The database instruction processing system provided in this embodiment starts the unstarted target clone database, uses the started clone database to share the resource pressure of the main database, and improves the overall performance of the database.
[0036] In an optional implementation, the avatar database is also used for:
[0037] After normal startup, obtaining the memory cache data of the target primary database;
[0038] The memory cache data is pre-read into the memory of the avatar database.
[0039] The database instruction processing system provided in this embodiment pre-reads the memory cache data of the target main database into the memory of the clone database when the clone database is started normally, so that when the clone database processes the execution instruction, the probability of hitting the data in the memory of the clone database is increased, thereby effectively improving the processing efficiency of the execution instruction.
[0040] In an optional implementation manner, the avatar database is specifically used for:
[0041] Acquire multiple addresses of the memory cache data in the data file of the target primary database;
[0042] Divide the addresses belonging to the same data file into one group to obtain multiple address groups;
[0043] Arrange the addresses in the multiple address groups in order to obtain multiple data block addresses;
[0044] Based on the multiple data block addresses, the memory cache data is pre-read into the memory of the clone database as target cache data.
[0045] The database instruction processing system provided in this embodiment pre-reads the memory cache data of the target main database into the memory of the clone database when the clone database is started normally, so that when the clone database processes the execution instruction, the probability of hitting the target cache data in the memory of the clone database is increased, thereby effectively improving the processing efficiency of the execution instruction.
[0046] In an optional implementation manner, the avatar database is specifically used for:
[0047] In the case where the multiple data block addresses are discontinuous, determining whether a difference between two adjacent data block addresses exceeds a preset address difference threshold;
[0048] When the difference between two adjacent data block addresses does not exceed a preset address difference threshold, determining the address between the two adjacent data block addresses as the address to be combined;
[0049] Combining the address to be combined with two adjacent data block addresses to obtain an address to be pre-read;
[0050] Based on the address to be pre-read, the target memory cache data corresponding to the address to be pre-read is pre-read into the memory of the clone database as the target cache data.
[0051] The database instruction processing system provided in this embodiment obtains the address to be combined between two adjacent data block addresses, combines the address to be combined with two adjacent database addresses, obtains the address to be pre-read, and based on the address to be pre-read, pre-reads the target memory cache data corresponding to the address to be pre-read into the memory of the clone database as the target cache data, thereby speeding up the reading speed of the target cache data in the data file and further improving the processing efficiency of the clone database processing execution instructions.
[0052] In an optional implementation manner, the avatar database is specifically used for:
[0053] determining data required to process the execution instruction;
[0054] In the case where the target cache data in the memory of the clone database does not cover the data required for processing the execution instruction, determining the data to be cached;
[0055] Acquire the data to be cached from the data file of the target primary database;
[0056] The execution instruction is processed based on the data to be cached and the target cache data in the memory of the clone database.
[0057] The database instruction processing system provided in this embodiment uses the clone database to process part of the execution instructions, thereby sharing the resource pressure of the main database and improving the overall performance of the database.
[0058] In an optional implementation, the master database is further used for:
[0059] In the case where there is a target clone database that is in a master-slave relationship with the primary database, determining whether the resource usage information of the target virtual machine meets a third preset condition;
[0060] When the resource usage information of the target virtual machine meets the third preset condition, determining the amount to be reduced of the target clone database;
[0061] Based on the amount of the target avatar database to be reduced, sending a request to close the avatar database to the virtualization platform;
[0062] The virtualization platform is also used for:
[0063] The clone database closing request is received, and in response to the clone database closing request, a closing operation is performed on the corresponding clone database.
[0064] The database instruction processing system provided in this embodiment reduces part of the target clone database according to the amount of the target clone database to be reduced when the resource usage information of the target virtual machine meets the third preset condition, thereby avoiding resource waste and improving resource utilization efficiency.
[0065] In a second aspect, the present invention provides a method for controlling a database instruction processing system, the method being used to control the database instruction processing system according to the first aspect or any corresponding embodiment thereof, the method comprising:
[0066] Using the main database to receive the database instruction sent by the client, parsing the database instruction to obtain an execution instruction, determining execution information of the execution instruction based on the execution instruction, and sending the execution instruction to a target clone database that has a master-slave relationship with the main database if the execution information meets a first preset condition;
[0067] Using the clone database to receive the execution instruction, processing the execution instruction to obtain a first processing result, and feeding back the first processing result to a target master database that has a master-slave relationship with the clone data;
[0068] The main database is used to receive the first processing result fed back by the target clone database, and the first processing result is fed back to the client, wherein the main database is set on the first virtual machine of the first server, and the clone database is set on the second virtual machine of the second server, and the first server and the second server are different servers.
[0069] In a third aspect, the present invention provides a computer device comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the database instruction processing system control method of the second aspect by executing the computer instructions.
[0070] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the database instruction processing system control method of the second aspect.
[0071] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions, wherein the computer instructions are used to enable a computer to execute the database instruction processing system control method of the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0073] Figure 1 is a schematic diagram of the structure of a database instruction processing system according to an embodiment of the present invention;
[0074] Figure 2 is a schematic diagram of the memory structure of an avatar database according to an embodiment of the present invention;
[0075] Figure 3 is a schematic diagram of the structure of another database instruction processing system according to an embodiment of the present invention;
[0076] Figure 4 is a flowchart of a method for processing a database instruction according to an embodiment of the present invention;
[0077] Figure 5 is a schematic diagram of a process of pre-reading target cache data into a clone database according to an embodiment of the present invention;
[0078] Figure 6 is a flowchart of a method for controlling a database instruction processing system according to an embodiment of the present invention;
[0079] Figure 7 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0080] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0081] Before introducing the embodiments of the present application, some terms or concepts involved in the embodiments of the present application are first explained. It should be understood that the present application does not specifically limit the naming of the following terms. The following terms may have other names. The renamed terms still meet the following related term explanations.
[0082] Virtualization: is a broad term. In computers, it usually refers to computing elements running on a virtual basis rather than a real basis. Virtualization technology can expand the capacity of hardware and simplify the reconfiguration process of software. The virtualization technology of the central processing unit (CPU) can simulate multiple CPUs in parallel with a single CPU, allowing a platform to run multiple operating systems at the same time, and applications can run in independent spaces without affecting each other, thereby significantly improving the work efficiency of the computer.
[0083] Virtual Machine (VM): refers to a complete computer system with complete hardware system functions that is simulated by software and runs in a completely isolated environment. Any work that can be done in a physical computer can be done in a virtual machine. When creating a virtual machine in a computer, part of the hard disk and memory capacity of the physical machine needs to be used as the hard disk and memory capacity of the virtual machine. Each virtual machine has an independent complementary metal oxide semiconductor (CMOS), hard disk and operating system, and the virtual machine can be operated like a physical machine.
[0084] Virtualization platform: a platform system for virtual machines to run, such as the Linux KVM system. This platform manages and runs several virtual machines, is responsible for the normal operation of virtual machines, divides the host's physical memory for virtual machines to use and manages the memory used by virtual machines, and converts the read and write of virtual machine memory into the read and write of material memory when the virtual machine uses the memory. The basis for the operation and management of platform-based virtual machines is the host machine of the virtual machine, which is responsible for the conversion of virtual memory addresses of virtual machines and material memory.
[0085] ORACLE database: a large relational database, also known as Oracle RDBMS, or simply Oracle. The system is portable, easy to use, and powerful, suitable for all types of large, medium, and small microcomputer environments. It is a highly efficient, reliable, and high-throughput database solution.
[0086] ORACLE database stand-alone: A stand-alone database generally refers to a database running on a single machine, that is, a database running on one node. It can use the server located in the center of the system to uniformly manage all shared resources and process requests from users.
[0087] ORACLE database RAC: is a cluster database technology that allows multiple computers to share the same database. Its features include: 1. High availability, through multi-node deployment, even if a node fails, other nodes can still continue to provide services to ensure the continuous availability of the database; 2. Scalability, by increasing or decreasing the number of nodes to increase or decrease the processing capacity of the system; 3. Scalability, by adding more nodes, the capacity and processing power of the database can be expanded to support more users and larger-scale data processing, etc.
[0088] ORACLE database memory structure and process structure: A normal ORACLE database includes a memory structure and a process structure. The memory structure includes the system global area and the program global area.
[0089] System Global Area (SGA): It is shared by all servers and background processes, including the shared pool, data cache, large pool, JAVA pool, stream pool, redo log buffer, etc.
[0090] Program Global Area (PGA): A memory area that contains data and control information for a server process or background process. PGA is a non-shared memory created by the server or background process when the database is started. The server process has exclusive access to the PGA, and each server process and background process has its own PGA.
[0091] The process structure includes two processes, a server process and a background process.
[0092] The ORACLE database will create a server process during a user session and handle requests from user processes connected to the instance. It can complete the following tasks: it is responsible for parsing and executing user SQL, it is responsible for finding the required data in the high-speed data buffer before transaction execution, it is responsible for reading the data from the data file into the cache if the data is not hit in the buffer, it is responsible for querying and sorting user data, it is responsible for returning the results of user transaction execution to the client, etc.
[0093] In order to maximize performance and meet the needs of multiple users, the multi-process ORACLE database system uses some database-attached processes called background processes. A database has multiple background processes. Common background processes include: database writer process (DBWn), log writer process (LGWR), checkpoint process (CKPT), system monitor process (SMON), process monitor process (PMON), recoverer process (RECO), archive process (ARCn), etc.
[0094] A database is a warehouse that organizes, stores and manages data according to data structures and can be used to process database transactions. ORACLE database has the characteristics of good portability, ease of use and powerful functions, so it is widely used in various microcomputer environments.
[0095] In the related art, there are two installation environments for ORACLE database. The first is a physical server, based on hardware servers such as X86 servers, IBM POWER mini, and HP mini. The second is a virtual machine based on a virtualized environment. Both of the above environments can be installed as a single machine or a RAC cluster. The processing efficiency of database transactions depends to a large extent on the CPU performance, memory size, storage system performance, etc. of the running host. Generally, when purchasing a server, the server hardware is configured based on the performance requirements of the database. During the initial period of operation of the database, the server hardware resources can meet the database business needs, but as the database business volume increases, the database needs to process more and more transactions, and the CPU, memory and other resources of the server host will gradually fail to meet the database business needs.
[0096] In the case where the installation environment of the ORACLE database is a physical server, there are two ways to solve the above problems: the first method is to expand or replace the original server hardware, replace a stronger CPU, increase memory, and replace a storage system with better performance. Among them, increasing physical memory is relatively easy, but this depends on how many free memory slots the server has. Replacing the CPU is relatively difficult, and not all high-performance CPUs can be used on the original server hardware. Replacing the storage system is the easiest to operate, and you only need to transfer the data from the original storage system to the new storage system. This can be done using database-level functions or storage copying. Although this method can achieve the expansion or reconfiguration of the original server hardware, this method has limited improvement in database performance and the investment cost is relatively high. The second method is to purchase a server with higher performance to replace the original server, which requires the original database system to be completely moved to the new server. This forward work is relatively complicated and time-consuming, which is not conducive to business continuity, and a lot of capital must be invested in purchasing new servers.
[0097] If the installation environment of the ORACLE database is a virtualized environment, if you need to increase the performance of the database virtual machine, you can directly increase the memory and CPU for the virtual machine through the virtualization platform. This operation only needs to be performed on the virtualization platform, which has little impact on the database system and does not require additional investment. However, even if the memory and CPU of the virtual machine are expanded, it cannot exceed the upper limit of the hardware configuration of the physical server where it is located. In addition, the physical server running the virtual machine must also run virtualization-related services, which will occupy additional server resources and consume the performance of the physical server. For the same two physical servers, running the database directly will have higher performance than running the database with a virtual machine after installing virtualization. Therefore, in a virtualized environment, although it is easier to expand the capacity of virtual machine resources, the performance improvement of the database brought about by the expansion is also limited because it cannot exceed the upper limit of the hardware configuration of the physical server.
[0098] When the performance of a single-machine database cannot meet the requirements, an ORACLE real-time application cluster (RAC) environment is usually built to increase the high availability of the database. Multi-node clusters can increase the throughput of the business system, but they cannot improve the performance of the database itself. Instead, they will reduce the performance of a single database because the time consumed by data synchronization between database nodes will affect database performance. Therefore, a two-node RAC system is usually used. If there are more than two nodes, the data synchronization between nodes will increase significantly, and the performance will be further reduced, seriously affecting the operation of the business system.
[0099] Due to the data synchronization mechanism between RAC cluster nodes, there is currently no effective way to solve the problem of data synchronization between cluster nodes. The more frequent the data synchronization between nodes, the larger the amount of synchronized data, and the greater the impact on performance. Even in the RAC environment, there is also the situation where the hardware resources cannot meet the business needs one day, and the problem of limited database performance still exists.
[0100] An embodiment of the present invention provides a database instruction processing system, which parses received database instructions into execution instructions when the main database is busy, the server pressure has affected the database performance, the main database runs many batch tasks and needs to shorten the time, and the database needs to disperse the computing pressure. The execution instructions are sent to a target clone database that has a master-slave relationship with the main database, and the clone database is used to process the execution instructions to share the pressure of the main database, so as to achieve the effect of improving the overall performance of the database.
[0101] According to an embodiment of the present invention, a database instruction processing system is provided. Figure 1 As shown, the system includes:
[0102] A main database 101 is set on a first virtual machine of a first server and a clone database 102 is set on a second virtual machine of a second server.
[0103] The main database includes complete database functions such as disk management, data file reading and writing, and client session requests. The clone database is relatively simple in function, and does not need to directly respond to client session requests, read and write redo logs (REDO), manage user sessions, or read data files. It only needs to retain functions such as reading data files, accessing the disk where the data files are located, basic transaction management, and processing execution instructions.
[0104] Compared with the main database, the clone database is a lightweight database function design with fewer redundant database functions and processes. It focuses on large data volume reading and operation processing, so the clone database has higher efficiency in memory management, memory data operation, process management, etc. There is a specially designed process (reps process) on the clone database to receive directly executable SQL instructions sent by the main database to the clone database, and to communicate and exchange data with the main database.
[0105] The clone database runs on the virtual machine. In a virtualized environment, the virtualization platform can easily generate a corresponding clone database on the virtual machine according to the configuration requirements. The main database pushes the database software to the virtual machine of the clone database for installing the clone database, and forms a master-slave relationship between the main database and the clone database.
[0106] The main database 101 is used to receive database instructions issued by the client, parse the database instructions, obtain execution instructions, determine execution information of the execution instructions based on the execution instructions, and send the execution instructions to the target clone database that has a master-slave relationship with the main database when the execution information meets the first preset condition.
[0107] The database instruction sent by the client may be a Structured Query Language (SQL) statement. The main database may also be used to receive SQL statements initiated by scheduled tasks.
[0108] After receiving the database instruction sent by the client, the master database needs to parse the database instruction to obtain the execution instruction. Since the database instruction is not an instruction that can be executed directly, the master database needs to parse the database instruction into an instruction that can be executed directly for processing. The execution instruction is an instruction that can be executed directly.
[0109] After obtaining the execution instruction, the main database determines the execution information of the execution instruction according to the execution instruction, wherein the execution information includes the CPU consumption of processing the execution instruction, the amount of data involved in processing the execution instruction, the execution time of processing the execution instruction, and other information.
[0110] Whether the main database transfers the execution instruction to the target clone database for processing needs to be judged according to the first preset condition. The first preset condition is that the execution information exceeds the preset parameter threshold. Specifically, when the CPU consumption of processing the execution instruction exceeds the CPU consumption threshold, and the amount of data involved in processing the execution instruction exceeds the data amount threshold, and the execution time of processing the execution instruction exceeds the execution time threshold, it is determined that the execution information meets the first preset condition. It should be noted that the CPU consumption threshold, data amount threshold and execution time threshold are determined by technical personnel.
[0111] The main database will process the execution instructions that take a long time to execute, tend to calculate after a large number of database reads, most of the data required for processing the execution instructions need to be read from the hard disk, and the processing of the execution instructions will consume a large amount of memory and CPU. The execution instructions are assigned to the target clone database that has a master-slave relationship with it for processing. In this way, the target clone database does not need to request too much data from the main database through the heartbeat network, and can share the pressure of the main database, so that the main database can retain more resources for executing business requests. At the same time, since the clone database can read data from the hard disk, the impact on the main database is further reduced.
[0112] Among them, the main database determines whether it is necessary to send the execution instruction to the target clone database for processing through the value of the following control parameters.
[0113] SQL statement CPU consumption comparison parameter (separated_db_sql_cpu_percent): This parameter value is a percentage, ranging from 0 to 100, which is the CPU consumption threshold. It is used to compare with the CPU consumption in the SQL statement execution plan, that is, to compare with the CPU consumption of processing execution instructions. If the CPU consumption in the SQL statement execution plan is higher than the value of separated_db_sql_cpu_percent, the CPU consumption requirement is met, that is, the CPU consumption of processing execution instructions exceeds the CPU consumption threshold.
[0114] SQL statement data volume comparison parameter (separated_db_sql_data_number): The parameter value unit is K, which indicates the amount of data involved in the SQL statement, that is, the data volume threshold. It is used to compare with the amount of data involved in the SQL statement execution plan, that is, it is used to compare with the amount of data involved in the processing and execution instructions. If the amount of data in the SQL statement execution plan is higher than the value of separated_db_sql_data_number, it meets the data volume requirement, that is, the amount of data involved in the processing and execution instructions exceeds the data volume threshold.
[0115] SQL statement execution time comparison parameter (separated_db_sql_exec_time): The parameter value unit is seconds, indicating the SQL execution time, that is, the execution time threshold, which is used to compare with the execution time in the SQL statement execution plan, that is, the execution time of processing the execution instruction. If the execution time in the SQL statement execution plan is higher than the value of separated_db_sql_exec_time, the execution time requirement is met, that is, the execution time of processing the execution instruction exceeds the execution time threshold.
[0116] It is understandable that the lower the above three parameter values are set, the greater the probability that the main database sends an execution instruction to the target clone database, because the threshold for sending the execution instruction is lowered.
[0117] The clone database 102 is used to receive execution instructions, process the execution instructions, obtain a first processing result, and feed back the first processing result to a target master database that has a master-slave relationship with the clone database, wherein the first server and the second server are different servers.
[0118] The memory structure of the clone database is relatively simpler than that of the main database. The clone database only retains the data cache, SQL executable instruction cache, session cache, etc., and the newly added result cache is used to store the processing results of the execution instructions. The memory structure of the traditional database is greatly simplified, eliminating many unnecessary memory structures for the clone database, and giving full play to the use of memory storage data blocks.
[0119] Figure 2 FIG. 1 is a schematic diagram of the memory structure of the avatar database according to an embodiment of the present invention. Figure 2As shown, Library Cache is a library cache area, a memory area, whose main function is to cache the parsing plans, parsing trees and other objects corresponding to the SQL statements and PL / SQL (including stored procedures, packages, functions, triggers) that have just been processed. When the same SQL statement or PL / SQL is executed again, the related objects in the library cache can be directly used without having to parse from the beginning again, which improves the execution efficiency of these statements.
[0120] Shared SQL Area is a shared statement area, which is mainly used to cache the execution plan of SQL statements, that is, to cache execution instructions, etc.
[0121] Result Pool is a result pool used to store the execution results of statements, that is, the processing results of execution instructions.
[0122] Database Buffer Cache is a data cache area, which is mainly used to cache data in the hard disk into the memory.
[0123] SGA is the system global cache area, PGA is the user process cache area, and Server Process is the service process.
[0124] Since the clone database does not need to write data files, does not need to write REDO files, and does not need to directly process customer sessions, it has many fewer database processes and only retains the relevant processes that maintain the normal operation of the database. In addition, some processes are added for communicating with the main database, including:
[0125] REPS process: It is used to receive various information sent from the main database. It is an important communication process between the main database and the clone database. After receiving the SQL instruction from the main database (the instruction is a directly executable instruction), reps caches it in the SQL executable instruction cache area, that is, caches it in the shared statement area. Start the Server Process and let it execute the SQL instruction. The Server Process checks whether the data required by the SQL instruction is in the memory of the clone database. If the data is not in the memory, the Server Process will read the corresponding data file and read the required data into the memory cache area. When the required data is in the memory, the data in the memory is processed according to the SQL instruction. The processed results will be placed in the Result pool cache area, and REPS will be notified to take the results out of the Result Pool and send them to the main database node.
[0126] It should be noted that the clone database may include n REPS processes, namely REPSn in the figure.
[0127] The main database 101 is also used to receive the first processing result fed back by the target avatar database, and feed back the first processing result to the client.
[0128] Among them, after receiving the first processing result fed back by the target clone database, the main database integrates the processing result and feeds it back to the client.
[0129] The database instruction processing system provided in this embodiment parses the database instruction through the main database to obtain the execution instruction, determines the execution information based on the execution instruction, and sends the execution instruction to the target clone database when the execution information meets the first preset condition. The clone database receives the execution instruction, processes the execution instruction, obtains the processing result, and feeds the processing result back to the target main database. The main database receives the processing result fed back by the target clone database and feeds the processing result back to the client. The main database and the clone database are set on virtual machines of different servers, and the clone database is used to process part of the execution instructions, which shares the resource pressure of the main database, improves the overall performance of the database, and also improves the processing efficiency of database instructions.
[0130] The main database can effectively reduce the pressure on the main database by moving some tasks that consume more CPU and memory and involve large amounts of data reading and calculation, such as batch running, to the clone database for execution. This allows the main database to have more available resources to maintain efficient response and processing of user transaction requests, while avoiding the performance bottleneck caused by the maximum hardware limitations of the physical server on a single database node.
[0131] According to an embodiment of the present invention, a database instruction processing system is provided. Figure 3 As shown, the system includes:
[0132] A main database 301 is set on a first virtual machine of a first server, and a clone database 302 and a virtualization platform 303 are set on a second virtual machine of a second server.
[0133] The main database 301 is used to receive the database instruction sent by the client, parse the database instruction, obtain the execution instruction, determine the execution information of the execution instruction based on the execution instruction, and send the execution instruction to the target clone database that has a master-slave relationship with the main database when the execution information meets the first preset condition. For details, please refer to the description of the main database 101 above, which will not be repeated here.
[0134] The clone database 302 is used to receive the execution instruction, process the execution instruction, obtain the first processing result, and feed back the first processing result to the target master database that has a master-slave relationship with the clone database, wherein the first server and the second server are different servers. For details, please refer to the description of the clone database 102 above, which will not be repeated here.
[0135] The main database 301 is also used to receive the first processing result fed back by the target avatar database, and feed back the first processing result to the client. For details, please refer to the description of the main database 101 above, which will not be repeated here.
[0136] The main database 301 is also used to process the execution instruction when the execution information does not meet the first preset condition, obtain a second processing result, and feed back the second processing result to the client.
[0137] Figure 4 FIG. 1 is a flow chart of a method for processing a database instruction according to an embodiment of the present invention. Figure 4 As shown, the master database reads the execution plan of the SQL, that is, the master database parses the database instruction to obtain the execution instruction, and determines the execution information of the execution instruction based on the execution instruction.
[0138] When the execution information does not meet the first preset condition, that is, the execution information does not fully meet the parameter requirements, that is, the CPU consumption of processing the execution instruction does not exceed the CPU consumption threshold, or the amount of data involved in processing the execution instruction does not exceed the data amount threshold, or the execution time of processing the execution instruction does not exceed the execution time threshold, it is determined that the execution information does not meet the first preset condition.
[0139] The execution information does not meet the first preset condition, which means that the execution command is more suitable to be executed in the main database, or the main database can meet its operation requirements and will not be sent to the clone database for execution. Instead, it will be executed by the main database to obtain the second processing result and feed the second processing result back to the client.
[0140] The virtualization platform 303 is used to manage the main database and the clone database.
[0141] Please refer to the above description of the virtualization platform for details, which will not be repeated here.
[0142] The database instruction processing system provided in this embodiment uses the main database to process the execution instruction when the execution information does not meet the first preset condition, and uses the clone database to process the execution instruction when the execution information meets the first preset condition, thereby sharing the resource pressure of the main database and improving the overall performance of the database.
[0143] In some optional implementations, the main database 301 is specifically used for:
[0144] When the execution information satisfies the first preset condition, it is determined whether there is a target clone database that has a master-slave relationship with the main database.
[0145] In the case that there is no target clone database that has a master-slave relationship with the main database, a request for generating a new clone database is sent to the virtualization platform.
[0146] In the case where there is a target clone database that has a master-slave relationship with the main database, resource usage information of the target virtual machine where the target clone database is located is obtained.
[0147] It is determined whether the resource usage information of the target virtual machine meets a second preset condition.
[0148] When the resource usage information of the target virtual machine meets the second preset condition, the execution instruction is sent to the target clone database.
[0149] When the resource usage information of the target virtual machine does not meet the second preset condition, a request for generating a new clone database is sent to the virtualization platform.
[0150] Among them, when the execution information meets the first preset condition, it is also necessary to determine whether there is a target clone database that has a master-slave relationship with the main database. If the target clone database does not exist, a new clone database needs to be generated to process the execution instruction, and the main database sends a new clone database generation request to the virtualization platform. If the target clone database exists, the resource usage information of the target virtual machine where the target clone database is located is obtained.
[0151] It should be noted that a primary database may have multiple target clone databases that have a primary-slave relationship with it, and the resource usage information of the target virtual machine where each target clone database is located is obtained.
[0152] The resource usage information of the target virtual machine is the resource usage of the target virtual machine CPU. When the resource usage of the target virtual machine CPU meets the second preset condition, the execution instruction is sent to the target clone database.
[0153] like Figure 4 As shown, the second preset condition is that the resource usage of the target virtual machine CPU meets the parameter requirements, that is, the resource usage of the target virtual machine CPU is less than or equal to the first CPU resource usage threshold. The first CPU resource usage threshold is determined by the technician and is not specifically limited here.
[0154] It is understandable that if the resource usage of the target virtual machine CPU meets the second preset condition, it means that the clone database resources can be used to process the execution instruction, and the execution instruction is sent to the target clone database for processing.
[0155] It should be noted that, when there are multiple target clone databases where the resource usage information of the target virtual machines meets the second preset condition, any one of the target clone databases is obtained as the first clone database, and the execution instruction is sent to the first clone database for processing.
[0156] Among them, if there are multiple target clone databases where the resource usage of the target virtual machine CPU meets the parameter requirements, then one of the target clone databases is randomly selected as the first clone database, and the execution instruction is sent to the first clone database, and the first clone database processes the execution instruction.
[0157] or,
[0158] When there are multiple target clone databases where the target virtual machines' resource usage information meets the second preset condition, the target clone database with the least resource usage of the target virtual machine is obtained from the multiple target clone databases as the first clone database, and the execution instruction is sent to the first clone database for processing.
[0159] Among them, if there are multiple target clone databases where the resource usage of the target virtual machine CPU meets the parameter requirements, the target clone database with the least resource usage of the target virtual machine CPU is selected as the first clone database, and the execution instruction is sent to the first clone database, which processes the execution instruction.
[0160] like Figure 4 As shown, when the resource usage of the target virtual machine's CPU does not meet the parameter requirements, that is, the resource usage of the target virtual machine's CPU does not meet the second preset condition, it means that the resource usage information of the target virtual machines where all target clone databases that have a master-slave relationship with the main database are located do not meet the second preset condition, that is to say, the resource usage of the target virtual machine's CPU exceeds the first CPU resource usage threshold, and the resources of the target virtual machine's CPU are already very tight and cannot meet the execution of the execution instruction. In this case, the main database will start or generate a new clone database to process the execution instruction.
[0161] Among them, the main database also determines whether it is necessary to send the execution instruction to the target clone database for processing through the value of the following control parameters.
[0162] CPU usage of the virtual machine of the clone database (separated_db_vm_cpu_percent): This parameter value is a percentage, ranging from 0 to 100, which is the first CPU resource usage threshold. The resource usage of the target virtual machine where the actual target clone database is located must be lower than this value before the main database will run the execution instruction on the clone database. The higher the parameter value, the higher the probability that the main database will send the execution instruction to the clone database.
[0163] The virtualization platform 303 is specifically used for:
[0164] Receive a request for generating a new clone database, respond to the request for generating the new clone database, generate a new clone database on a virtual machine of a server different from the main database, establish a master-slave relationship between the main database and the new clone database, and feed back the new clone database generation information to the main database.
[0165] When the target clone database does not exist or the resource usage information of the virtual machine where the target clone database is located does not meet the second preset condition, a new clone database needs to be generated to process the execution instruction.
[0166] The virtualization platform can be used to generate a new clone database on a virtual machine of a server different from the main database, and establish a master-slave relationship between the main database and the new clone database, so that the main database sends execution instructions whose execution information meets the first preset condition to the new clone database for processing.
[0167] It should be noted that the new avatar database generation request may include the number of new avatar databases that need to be generated, so that the virtualization platform generates a corresponding number of new avatar databases in response to the new avatar database generation request.
[0168] The main database 301 is also used for:
[0169] When the new avatar database generation information is received, the execution instruction is sent to the new avatar database.
[0170] Among them, if multiple new clone databases are generated that have a master-slave relationship with the main database, the execution instruction will be sent to a random new clone database for processing.
[0171] In the database instruction processing system provided in this embodiment, the master data is used to further determine the resource usage information of the target virtual machine where the target clone database is located when the target clone database exists, and then determine whether a new clone database needs to be generated. The master data is used to send a new clone database generation request to the virtualization platform when the target clone database does not exist, and send the execution instruction to the new clone database. The virtualization platform is used to generate a new clone database and establish a master-slave relationship between the new clone database and the master database. The clone database is used to share the resource pressure of the master database, thereby improving the overall performance of the database.
[0172] In some optional implementations, the main database 301 is also used for:
[0173] In the case where there is a target clone database that has a master-slave relationship with the main database, determine whether the target clone database is started.
[0174] When the target clone database is not started, a request to start the target clone database is sent to the virtualization platform.
[0175] Among them, if there is a target clone database that has a master-slave relationship with the main database, but the target clone database is not started, the target clone database cannot receive and process the execution instructions. The target clone database needs to be started first before it can receive and process the execution instructions.
[0176] The main database sends a request to start the target clone database to the virtualization platform, so that the virtualization platform starts the corresponding target clone database.
[0177] The virtualization platform 303 is specifically used for:
[0178] A request for starting a target clone database is received, and in response to the request for starting the target clone database, a start process is performed on the target clone database.
[0179] The request to start the target clone database includes the number of target clone databases to be started, and the virtualization platform responds to the request to start the target clone database and starts the corresponding number of target clone databases.
[0180] It is understandable that only the activated clone database can receive and process execution instructions.
[0181] The database instruction processing system provided in this embodiment starts the unstarted target clone database, uses the started clone database to share the resource pressure of the main database, and improves the overall performance of the database.
[0182] In some optional implementations, the avatar database 302 is also used to:
[0183] After normal startup, obtain the memory cache data of the target primary database.
[0184] Pre-read the memory cache data into the memory of the clone database.
[0185] Among them, the main database starts the target clone database as needed. In order to speed up the data calculation efficiency of the clone database, after the clone database is started normally, the data pre-reading process set in the clone database starts. The data pre-reading process starts, and the hot data in the main database memory is loaded into the clone database memory. Among them, the hot data is the data cached in the memory of the main database, that is, the memory cache data. These data can improve the memory data hit rate when the main database processes the execution instruction, and effectively improve the efficiency of processing the execution instruction. Loading the memory cache data in the main database into the memory of the clone database can also improve the memory data hit rate when the clone database processes the execution instruction, and effectively improve the efficiency of processing the execution instruction.
[0186] In some optional implementations, the avatar database 302 is specifically used for:
[0187] Get multiple addresses of memory cache data in the data files of the target primary database.
[0188] Addresses belonging to the same data file are divided into a group to obtain multiple address groups.
[0189] Arrange the addresses in the multiple address groups in order to obtain multiple data block addresses.
[0190] Based on multiple data block addresses, the memory cache data is pre-read into the memory of the clone database as target cache data.
[0191] in, Figure 5 FIG. 1 is a flow chart of pre-reading target cache data into the clone database according to an embodiment of the present invention. Figure 5 As shown, after the data pre-reading process is started, the memory cache data information in the main database is obtained, that is, multiple addresses of the memory cache data in the main database in the data file of the target main database are obtained. Among them, the main database includes many data files. After the clone database obtains multiple addresses of the memory cache data in the data file, it groups them according to the data file, that is, groups these addresses according to the data file they are in, that is, divides the addresses belonging to the same data file into one group, and obtains multiple address groups.
[0192] The addresses in each data file are sorted, that is, the addresses belonging to the same data file are sorted in order from the head of the data file to the tail of the data file, that is, the addresses in multiple address groups are arranged in order to obtain multiple data block addresses, wherein the default size of each data block is 8K.
[0193] All data files in the target master database are processed one by one, that is, multiple address groups are processed one by one, so that the addresses in each address group are arranged in sequence, until the addresses of the last address group are arranged in sequence, that is, until the last data file in the target master database is processed.
[0194] Based on multiple data block addresses, memory cache data is obtained from the data file, and the memory cache data is pre-read into the memory of the clone database as target cache data.
[0195] In some optional implementations, the avatar database 302 is specifically used for:
[0196] In the case where the addresses of the multiple data blocks are discontinuous, it is determined whether the difference between the addresses of two adjacent data blocks exceeds a preset address difference threshold.
[0197] When the difference between two adjacent data block addresses does not exceed a preset address difference threshold, the address between the two adjacent data block addresses is determined as the address to be combined.
[0198] The address to be combined is combined with the addresses of two adjacent data blocks to obtain the address to be pre-read.
[0199] Based on the address to be pre-read, the target memory cache data corresponding to the address to be pre-read is pre-read into the memory of the clone database as the target cache data.
[0200] like Figure 5 As shown, when multiple data block addresses are obtained, the data block addresses are sorted in order from the data file header to the data file tail, and it is determined whether the difference between each two adjacent data block addresses exceeds a preset address difference threshold.
[0201] The preset address difference threshold is the address value occupied by a preset number of data blocks. That is to say, it is determined whether the number of data blocks between each two adjacent data block addresses exceeds a preset number of data blocks. The preset number may be 5, which is specifically determined by the technicians. This is only an exemplary description and is not specifically limited.
[0202] When the difference between two adjacent data block addresses does not exceed the preset address difference threshold, the address between the two adjacent data block addresses is determined to be the address to be combined, that is, all data block identification bits between the adjacent addresses need to be pre-read into the data block in the memory.
[0203] After comparing the difference between each two adjacent data block addresses with the preset address difference threshold, that is, when one of the two adjacent data block addresses currently being compared is the last group of addresses of the data file group, the data block is read from the data file into the memory according to the address.
[0204] That is to say, the address to be combined is combined with its two adjacent data block addresses to obtain the address to be pre-read, and based on multiple addresses to be pre-read, the target memory cache data corresponding to the address to be pre-read is pre-read into the memory of the clone database as the target cache data.
[0205] It is understandable that two adjacent data block addresses may be separated by several data blocks. Reading such scattered and discontinuous data blocks will be much slower than reading continuous data blocks. Although these data blocks between two adjacent data block addresses are not in the memory of the main database for the time being, they may be used in the future. Therefore, when the data blocks between two adjacent data block addresses do not exceed 5 data blocks, the data blocks in the middle are marked as data blocks that need to be pre-read into the memory of the clone database. In this way, the adjacent discontinuous data blocks form a small range of continuous data blocks, which not only speeds up the reading speed of the data file, but also pre-reads a part of the data blocks that may become hot spots into the memory of the clone database, thereby improving the memory data hit rate of the clone database processing execution instructions.
[0206] In some optional implementations, the avatar database 302 is specifically used for:
[0207] Determines the data needed to process the execution of the instruction.
[0208] When the target cache data in the memory of the clone database does not cover the data required for processing the execution instruction, the data to be cached is determined.
[0209] Get the data to be cached from the data files of the target primary database.
[0210] The execution instruction is processed based on the data to be cached and the target cache data in the memory of the clone database.
[0211] Among them, the clone database processes the execution instruction, first determines the data required to process the execution instruction, and when the target cache data in the memory of the clone database does not cover the data required to process the execution instruction, determines the data to be cached, and the data to be cached needs to be obtained from the data file of the main database.
[0212] After obtaining the data to be cached, the execution instruction is processed according to the data to be cached and the target cache data in the memory of the clone database. That is, the clone database searches for the required data in the memory of the clone database according to the received execution instruction. The data that is not cached in the memory will directly find the corresponding data from the data file on the disk and read it into the memory of the clone database to process the execution instruction.
[0213] It should be noted that the clone database reads the data to be cached directly from the data file without excessively requesting data from the main database, minimizing data exchange with the main database. Only a small amount of changed data needs to obtain the latest data from the main database.
[0214] In the database instruction processing system provided in this embodiment, the clone database does not accept direct connections from the business system or the client, that is, it does not directly face the application system or the business client, and all its tasks are assigned by the main database system according to the operation status and needs of the main database system. The main database system assigns tasks to the clone database, and the clone database returns the results to the main database system after the task is executed. The clone database is used to share the tasks and pressure of the main database system to improve the performance of the overall database system. The main difference between the clone database and the multi-node database cluster is that the performance loss caused by the data exchange between nodes after the introduction of the clone database is far less than the performance improvement brought by the clone database. The clone database spends most of its time processing large tasks or calculations, and there is less data exchange between nodes, so the clone database has little negative impact on the main database system, and the clone database and the main database can be controlled to run on different servers, giving full play to the performance of multiple servers in the virtualized cluster environment and improving the overall performance of the database.
[0215] In some optional implementations, the main database 301 is also used for:
[0216] In the case that there is a target clone database that has a master-slave relationship with the main database, it is determined whether the resource usage information of the target virtual machine meets the third preset condition.
[0217] When the resource usage information of the target virtual machine meets the third preset condition, the amount to be reduced of the target clone database is determined.
[0218] Based on the amount of the target clone database to be reduced, a clone database closing request is sent to the virtualization platform.
[0219] The virtualization platform 303 is also used for:
[0220] Receive a clone database closing request, and in response to the clone database closing request, perform a closing operation on the corresponding clone database.
[0221] Among them, the third preset condition is that the resource usage information of the target virtual machine is less than the second CPU resource usage threshold. That is, the resource usage of the target virtual machine CPU is less than the second CPU resource usage threshold. When the resource usage information of the target virtual machine meets the third preset condition, it is determined that the relatively busy tasks on the target clone database have been completed and there are not many execution commands to be processed in a short time, then it is necessary to reduce the running target clone database.
[0222] The main database determines the amount of the target clone database to be reduced. It should be noted that the amount of the target clone database to be reduced is less than the total amount of the target clone database, that is, the target clone database will not be completely closed, and at least one or two target clone databases will be left running. The setting of the amount to be reduced is set by the technician and is not specifically limited here.
[0223] The main database sends a clone database closing request to the virtualization platform. The clone database closing request includes the number of target clone databases to be closed, that is, the amount of target clone databases to be reduced.
[0224] The virtualization platform responds to the clone database closing request and closes a corresponding number of target clone databases.
[0225] In some optional implementations, when so many clone databases are not needed in the virtualization environment, the main database determines the virtual machine corresponding to the clone database to be deleted, and sends an instruction to the virtualization platform to delete the virtual machine where the clone database is located. The virtualization platform deletes the virtual machine corresponding to the clone database to be deleted according to the instruction to delete the virtual machine where the clone database is located, and terminates the master-slave relationship between the main database and the deleted clone database.
[0226] It should be noted that the generation, destruction, CPU / memory parameter settings, etc. of the virtual machine where the clone database is located are all initiated by the main database sending instructions to the virtualization platform, and the virtualization platform performs configuration operations and status changes on the clone database based on the instructions.
[0227] The database instruction processing system provided in this embodiment reduces part of the target clone database according to the amount of the target clone database to be reduced when the resource usage information of the target virtual machine meets the third preset condition, thereby avoiding resource waste and improving resource utilization efficiency.
[0228] According to an embodiment of the present invention, a database instruction processing system control method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0229] In this embodiment, a method for controlling a database instruction processing system is provided, which is used to control the database instruction processing system shown in the above embodiment. The method can be used in mobile terminals, such as servers, central processing units, etc. Figure 6 is a flow chart of a method for controlling a database instruction processing system according to an embodiment of the present invention. Figure 6As shown, the process includes the following steps:
[0230] Step S601, use the main database to receive the database instructions sent by the client, parse the database instructions, obtain execution instructions, determine the execution information of the execution instructions based on the execution instructions, and when the execution information meets the first preset condition, send the execution instructions to the target clone database that has a master-slave relationship with the main database.
[0231] Step S602, using the clone database to receive the execution instruction, process the execution instruction, obtain a first processing result, and feed back the first processing result to the target master database that has a master-slave relationship with the clone data.
[0232] Step S603: Use the main database to receive the first processing result fed back by the target clone database, and feed back the first processing result to the client.
[0233] The main database is set on a first virtual machine of a first server, the clone database is set on a second virtual machine of a second server, and the first server and the second server are different servers.
[0234] The further description of each of the above steps is the same as that of the above corresponding embodiments and will not be repeated here.
[0235] The database instruction processing system control method provided in this embodiment parses the database instruction through the main database to obtain the execution instruction, determines the execution information based on the execution instruction, and sends the execution instruction to the target clone database when the execution information meets the first preset condition. The clone database receives the execution instruction, processes the execution instruction, obtains the processing result, and feeds the processing result back to the target main database. The main database receives the processing result fed back by the target clone database and feeds the processing result back to the client. The main database and the clone database are set on virtual machines of different servers, and the clone database is used to process part of the execution instructions, so as to share the resource pressure of the main database, improve the overall performance of the database, and also improve the processing efficiency of database instructions.
[0236] The main database can effectively reduce the pressure on the main database by moving some tasks that consume more CPU and memory and involve large amounts of data reading and calculation, such as batch running, to the clone database for execution. This allows the main database to have more available resources to maintain efficient response and processing of user transaction requests, while avoiding the performance bottleneck caused by the maximum hardware limitations of the physical server on a single database node.
[0237] The embodiment of the present invention also provides a computer device, see Figure 7 , Figure 7 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 7 As shown, the computer device includes: one or more processors 701, memory 702, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Each component utilizes different buses to communicate with each other, and can be installed on a common mainboard or installed in other ways as required. The processor can process the instructions executed in the computer device, including instructions stored in the memory or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides part of the necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 7 A processor 701 is taken as an example.
[0238] The processor 701 may be a central processing unit, a network processor or a combination thereof. The processor 701 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable logic gate array, a general purpose array logic or any combination thereof.
[0239] The memory 702 stores instructions executable by at least one processor 701, so that the at least one processor 701 executes the method shown in the above embodiment.
[0240] The memory 702 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 702 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 702 may optionally include a memory remotely arranged relative to the processor 701, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0241] The memory 702 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 702 may also include a combination of the above types of memory.
[0242] The computer device also includes a communication interface 703, which is used for the computer device to communicate with other devices or a communication network.
[0243] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0244] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0245] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A database instruction processing system, characterized in that: The system comprises: A primary database disposed on a first virtual machine of a first server and a clone database disposed on a second virtual machine of a second server; The primary database is used to receive a database instruction sent by a client, parse the database instruction, obtain an execution instruction, determine execution information of the execution instruction based on the execution instruction, and send the execution instruction to a target clone database that has a master-slave relationship with the primary database if the execution information meets a first preset condition; The clone database is used to receive the execution instruction, process the execution instruction, obtain a first processing result, and feed back the first processing result to a target master database that has a master-slave relationship with the clone data, wherein the first server and the second server are different servers; The main database is also used to receive a first processing result fed back by the target clone database, and feed back the first processing result to the client.
2. The system according to claim 1, characterized in that The master database is also used for: When the execution information does not satisfy the first preset condition, the execution instruction is processed to obtain a second processing result, and the second processing result is fed back to the client.
3. The system according to claim 1, characterized in that The system further comprises: A virtualization platform is used to manage the main database and the clone database.
4. The system according to claim 3, characterized in that The master database is specifically used for: In the case where the execution information satisfies the first preset condition, determining whether there is a target clone database that has a master-slave relationship with the main database; In the case that there is no target clone database in a master-slave relationship with the main database, sending a new clone database generation request to the virtualization platform; In the case where there is a target clone database that is in a master-slave relationship with the primary database, obtaining resource usage information of the target virtual machine where the target clone database is located; Determining whether the resource usage information of the target virtual machine meets a second preset condition; When the resource usage information of the target virtual machine meets the second preset condition, sending the execution instruction to the target clone database; When the resource usage information of the target virtual machine does not satisfy the second preset condition, sending a request for generating a new clone database to the virtualization platform; The virtualization platform is specifically used for: receiving the request for generating the new clone database, generating the new clone database on a virtual machine of a server different from the main database in response to the request for generating the new clone database, establishing a master-slave relationship between the main database and the new clone database, and feeding back the generation information of the new clone database to the main database; The master database is also used for: When the new avatar database generation information is received, the execution instruction is sent to the new avatar database.
5. The system according to claim 4, characterized in that The master database is also used for: In the case where there is a target clone database that is in a master-slave relationship with the main database, determining whether the target clone database is started; When the target avatar database is not started, sending a request to start the target avatar database to the virtualization platform; The virtualization platform is specifically used for: The request for starting the target clone database is received, and in response to the request for starting the target clone database, the target clone database is started.
6. The system according to claim 1, characterized in that The avatar database is also used for: After normal startup, obtaining the memory cache data of the target primary database; The memory cache data is pre-read into the memory of the avatar database.
7. The system according to claim 6, characterized in that The avatar database is specifically used for: Acquire multiple addresses of the memory cache data in the data file of the target primary database; Divide the addresses belonging to the same data file into one group to obtain multiple address groups; Arrange the addresses in the multiple address groups in order to obtain multiple data block addresses; Based on the multiple data block addresses, the memory cache data is pre-read into the memory of the clone database as target cache data.
8. The system according to claim 7, characterized in that The avatar database is specifically used for: In the case where the multiple data block addresses are discontinuous, determining whether a difference between two adjacent data block addresses exceeds a preset address difference threshold; When the difference between two adjacent data block addresses does not exceed a preset address difference threshold, determining the address between the two adjacent data block addresses as the address to be combined; Combining the address to be combined with two adjacent data block addresses to obtain an address to be pre-read; Based on the address to be pre-read, the target memory cache data corresponding to the address to be pre-read is pre-read into the memory of the clone database as the target cache data.
9. The system according to claim 1, characterized in that The avatar database is specifically used for: determining data required to process the execution instruction; In the case where the target cache data in the memory of the clone database does not cover the data required for processing the execution instruction, determining the data to be cached; Acquire the data to be cached from the data file of the target primary database; The execution instruction is processed based on the data to be cached and the target cache data in the memory of the clone database.
10. The system according to claim 4, characterized in that The master database is also used for: In the case where there is a target clone database that is in a master-slave relationship with the primary database, determining whether the resource usage information of the target virtual machine meets a third preset condition; When the resource usage information of the target virtual machine meets the third preset condition, determining the amount to be reduced of the target clone database; Based on the amount of the target avatar database to be reduced, sending a request to close the avatar database to the virtualization platform; The virtualization platform is also used for: The clone database closing request is received, and in response to the clone database closing request, a closing operation is performed on the corresponding clone database.
11. A method for controlling a database instruction processing system, characterized in that: The method is used to control the database instruction processing system according to any one of claims 1 to 10, and the method comprises: Using the main database to receive the database instruction sent by the client, parsing the database instruction to obtain an execution instruction, determining execution information of the execution instruction based on the execution instruction, and sending the execution instruction to a target clone database that has a master-slave relationship with the main database if the execution information meets a first preset condition; Using the clone database to receive the execution instruction, processing the execution instruction to obtain a first processing result, and feeding back the first processing result to a target master database that has a master-slave relationship with the clone data; The main database is used to receive the first processing result fed back by the target clone database, and the first processing result is fed back to the client, wherein the main database is set on the first virtual machine of the first server, and the clone database is set on the second virtual machine of the second server, and the first server and the second server are different servers.
