Database switching method and device based on instant mounting mode

By dynamically switching the mount of database environment groups and file systems, and optimizing resource utilization based on database performance indicators, the problem of insufficient database performance and resource utilization in the existing technology is solved, and more efficient database performance and resource management is achieved.

CN118861009BActive Publication Date: 2024-11-22WUHAN STONE INFORMATION SERVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411348868.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2024-11-22
Estimated Expiration
2044-09-26

AI Technical Summary

Technical Problem

Existing database deployment schemes cannot switch based on database performance status when different numbers of data access requests, resulting in insufficient database performance and resource utilization.

Method used

Using the database switching method based on the instant mount method, by obtaining multiple pre-built database environment groups, determining the busyness according to the database performance indicators, and dynamically switching the mount of the database environment group and file system when the busyness is high and low to ensure resources efficient use.

Benefits of technology

Timely switch database environment groups when business is busy, improve database performance and resource utilization, avoid performance limitations in traditional database deployment methods, and reduce data consistency and high-cost maintenance requirements for distributed databases or high-availability modes .

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118861009B_ABST
    Figure CN118861009B_ABST
Patent Text Reader

Abstract

The present application discloses a database switching method and device based on an instant mounting method, wherein a plurality of different first database environment groups pre-built are obtained; one of the first database environment groups is mounted to a database file system to receive and process a database access request initiated by a user as a current database environment group; the data processing busyness is determined based on a plurality of database performance indicators when the current database environment group is running; when the data processing busyness of the current database environment group processing a database access request is higher than the first preset processing busyness corresponding to the current database environment group, the mounting between the current database environment group and the database file system is unloaded, and the first target database environment group is mounted to the database file system to process the database access request initiated by the user. The present application can effectively improve database performance and resource utilization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of database technology, and in particular to a database switching method and device based on an instant mounting mode. Background Art

[0002] At present, the deployment solutions for database environment mainly include: On-Premises: The database is directly installed and run on the local server of the enterprise. Full control over data, hardware and software, and can customize the configuration as needed. Cloud-Based: The database runs on the server of cloud service provider, such as Amazon RDS, Google Cloud SQL, Azure SQL Database, etc. No need to manage hardware and software updates, quickly expand resources, and reduce IT costs. High Availability Deployment: Ensure the high availability of the database by using replication, clustering, load balancing and other technologies. However, the existing technology cannot switch according to the performance status of the database when responding to different numbers of data access requests, resulting in insufficient utilization of database performance and resources. Summary of the invention

[0003] The embodiment of the present application provides a database switching method and device based on an instant mounting mode, which can fully utilize database performance and resources.

[0004] In a first aspect, the database switching method based on the instant mounting mode provided by the present application includes:

[0005] Acquire a plurality of different pre-built first database environment groups, wherein different first database environment groups include databases and operating systems where the databases are located, and different operating systems have different computing resources, wherein the computing resources include CPU main frequency and number of cores;

[0006] Mounting one of the first database environment groups to the database file system so as to receive and process a database access request initiated by a user as the current database environment group;

[0007] Determine the data processing busyness based on multiple database performance indicators when the current database environment group is running, wherein the multiple database performance indicators include read and write rates and request concurrency;

[0008] When the data processing busyness of the current database environment group for processing the database access request is higher than the first preset processing busyness corresponding to the current database environment group, the mount between the current database environment group and the database file system is unloaded, and the first target database environment group is mounted to the database file system to process the database access request initiated by the user, wherein the computing resources of the first target database environment group are greater than the computing resources of the current database environment group.

[0009] Optionally, the database switching method based on the instant mounting mode includes:

[0010] When the data processing busyness of the current database environment group for processing the database access request is not higher than the second preset processing busyness corresponding to the current database environment group, the mount between the current database environment group and the database file system is unloaded, and the second target database environment group is mounted to the database file system to process the database access request initiated by the user, wherein the computing resources of the second target database environment are not greater than the computing resources of the current database environment group.

[0011] Optionally, the obtaining of a plurality of different pre-built first database environment groups includes:

[0012] Acquire a plurality of different pre-built second database environment groups, wherein the CPU main frequencies of the plurality of second database environment groups are a geometric progression, and the number of cores of the plurality of second database environment groups is a geometric progression;

[0013] respectively determining the plurality of the second database environment groups as test database environment groups, and processing database access requests initiated by users;

[0014] When the response time of the test database environment group to the database access request is greater than a first preset duration, determining a first preset processing busyness of the test database environment group based on a plurality of database performance indicators of the test database environment group at a current time point;

[0015] When the response time of the test database environment group in responding to the database access request is less than a second preset duration, determining a second preset processing busyness of the test database environment group based on a plurality of database performance indicators of the test database environment group at a current time point;

[0016] Determine each of the second database environment groups as the test database environment group, obtain a first preset processing busyness and a second preset processing busyness of each of the second database environment groups, and obtain a busyness interval of each of the second database environment groups, wherein the busyness interval is an interval consisting of the first preset processing busyness and the second preset processing busyness;

[0017] Part of the second database environment groups are eliminated based on the busyness intervals of each of the second database environment groups to obtain a plurality of different first database environment groups.

[0018] Optionally, the removing of some of the second database environment groups based on the busyness intervals of each of the second database environment groups to obtain a plurality of different first database environment groups includes:

[0019] sorting the second database environment groups from small to large based on the median values ​​of the busyness intervals of the second database environment groups to obtain a plurality of sorted second database environment groups;

[0020] Determine each of the sorted plurality of second database environment groups as a second target database environment group, and determine a second database environment group that is subsequent to the second target database environment group and has an overlapping busyness interval with the second target database environment group as an overlapping database environment group;

[0021] The overlapping database environment groups between the second target database environment group and the last overlapping database environment group are eliminated to obtain a plurality of different first database environment groups.

[0022] Optionally, mounting one of the first database environment groups to a database file system to receive and process a database access request initiated by a user as the current database environment group includes:

[0023] Obtaining the historical usage frequency of each of the first database environment groups within a preset time period;

[0024] The first database environment group with the highest historical usage frequency is mounted to the database file system through FUSE, so as to receive and process database access requests initiated by users as the current database environment group.

[0025] Optionally, mounting the first database environment group with the highest historical usage frequency to a database file system by means of FUSE so as to receive and process a database access request initiated by a user as a current database environment group includes:

[0026] Get the database access requests initiated by users received by the current database environment group;

[0027] Sending the database access request to the FUSE daemon;

[0028] Obtain a database access result of the FUSE daemon based on the database access request.

[0029] Optionally, mounting one of the first database environment groups to a database file system to receive and process a database access request initiated by a user as the current database environment group includes:

[0030] Mount one of the first database environment groups to the database file system to serve as the current database environment group;

[0031] A virtual IP is set for the current database environment group and the database access request is received through the virtual IP.

[0032] In a second aspect, the database switching device based on the instant mounting method provided by the present application includes:

[0033] An acquisition module is used to acquire a plurality of different pre-built first database environment groups, wherein different first database environment groups include databases and operating systems where the databases are located, and different operating systems have different computing resources, wherein the computing resources include CPU main frequency and core number;

[0034] A mounting module, used to mount one of the first database environment groups to the database file system so as to receive and process database access requests initiated by users as the current database environment group;

[0035] A determination module, configured to determine the data processing busyness based on a plurality of database performance indicators when the current database environment group is running, wherein the plurality of database performance indicators include a read / write rate and a concurrent request amount;

[0036] A switching module is used to unload the mount between the current database environment group and the database file system when the data processing busyness of the current database environment group processing the database access request is higher than the first preset processing busyness corresponding to the current database environment group, and mount the first target database environment group to the database file system to process the database access request initiated by the user, wherein the computing resources of the first target database environment group are greater than the computing resources of the current database environment group.

[0037] Optionally, the database switching method based on the instant mounting mode includes:

[0038] When the data processing busyness of the current database environment group for processing the database access request is not higher than the second preset processing busyness corresponding to the current database environment group, the mount between the current database environment group and the database file system is unloaded, and the second target database environment group is mounted to the database file system to process the database access request initiated by the user, wherein the computing resources of the second target database environment are not greater than the computing resources of the current database environment group.

[0039] Optionally, the obtaining of a plurality of different pre-built first database environment groups includes:

[0040] Acquire a plurality of different pre-built second database environment groups, wherein the CPU main frequencies of the plurality of second database environment groups are a geometric progression, and the number of cores of the plurality of second database environment groups is a geometric progression;

[0041] respectively determining the plurality of the second database environment groups as test database environment groups, and processing database access requests initiated by users;

[0042] When the response time of the test database environment group to the database access request is greater than a first preset duration, determining a first preset processing busyness of the test database environment group based on a plurality of database performance indicators of the test database environment group at a current time point;

[0043] When the response time of the test database environment group in responding to the database access request is less than a second preset duration, determining a second preset processing busyness of the test database environment group based on a plurality of database performance indicators of the test database environment group at a current time point;

[0044] Determine each of the second database environment groups as the test database environment group, obtain a first preset processing busyness and a second preset processing busyness of each of the second database environment groups, and obtain a busyness interval of each of the second database environment groups, wherein the busyness interval is an interval consisting of the first preset processing busyness and the second preset processing busyness;

[0045] Part of the second database environment groups are eliminated based on the busyness intervals of each of the second database environment groups to obtain a plurality of different first database environment groups.

[0046] Optionally, the removing of some of the second database environment groups based on the busyness intervals of each of the second database environment groups to obtain a plurality of different first database environment groups includes:

[0047] sorting the second database environment groups from small to large based on the median values ​​of the busyness intervals of the second database environment groups to obtain a plurality of sorted second database environment groups;

[0048] Determine each of the sorted plurality of second database environment groups as a second target database environment group, and determine a second database environment group that is subsequent to the second target database environment group and has an overlapping busyness interval with the second target database environment group as an overlapping database environment group;

[0049] The overlapping database environment groups between the second target database environment group and the last overlapping database environment group are eliminated to obtain a plurality of different first database environment groups.

[0050] Optionally, mounting one of the first database environment groups to a database file system to receive and process a database access request initiated by a user as the current database environment group includes:

[0051] Obtaining the historical usage frequency of each of the first database environment groups within a preset time period;

[0052] The first database environment group with the highest historical usage frequency is mounted to the database file system through FUSE, so as to receive and process database access requests initiated by users as the current database environment group.

[0053] Optionally, mounting the first database environment group with the highest historical usage frequency to a database file system by means of FUSE so as to receive and process a database access request initiated by a user as a current database environment group includes:

[0054] Get the database access requests initiated by users received by the current database environment group;

[0055] Sending the database access request to the FUSE daemon;

[0056] Obtain a database access result of the FUSE daemon based on the database access request.

[0057] Optionally, mounting one of the first database environment groups to a database file system to receive and process a database access request initiated by a user as the current database environment group includes:

[0058] Mount one of the first database environment groups to the database file system to serve as the current database environment group;

[0059] A virtual IP is set for the current database environment group and the database access request is received through the virtual IP.

[0060] In a third aspect, the electronic device provided in the present application includes a memory and a processor, the memory stores a computer program, and the processor is used to run the computer program in the memory to implement the steps in the database switching method based on the instant mounting method provided in the present application.

[0061] In a fourth aspect, the computer-readable storage medium provided in the present application stores a plurality of instructions, which are suitable for loading by a processor to implement the steps in the database switching method based on the instant mounting mode provided in the present application.

[0062] In a fifth aspect, the computer program product provided in the present application includes a computer program or instructions, which, when executed by a processor, implements the steps in the database switching method based on the instant mount mode provided in the present application.

[0063] In the present application, compared with the related art, a plurality of different first database environment groups are pre-built, wherein the different first database environment groups include a database and an operating system where the database is located, and different operating systems have different computing resources, wherein the computing resources include a CPU main frequency and a number of cores; one of the first database environment groups is mounted to a database file system to receive and process database access requests initiated by users as the current database environment group; the data processing busyness is determined based on a plurality of database performance indicators when the current database environment group is running, wherein the plurality of database performance indicators include a read / write rate and a request concurrency; when the data processing busyness of the current database environment group for processing database access requests is higher than a first preset processing busyness corresponding to the current database environment group, the mount between the current database environment group and the database file system is unloaded, and the first target database environment group is mounted to the database file system to process database access requests initiated by users, wherein the computing resources of the first target database environment group are greater than the computing resources of the current database environment group. This application is different from the traditional database deployment method. There is no need to worry about the performance limitation of the current database when the business is busy. The database environment group can be switched in time when the business is busy. At the same time, there is no need to worry about the data consistency and high-cost maintenance corresponding to the distributed database or high-availability mode. It is only necessary to set the corresponding switching standards for different first database environment groups, switch according to the switching standards, and timely change the mount between the database environment group and the database file system by mounting and unmounting, which can effectively improve the database performance and resource utilization. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0065] Figure 1 It is a scenario diagram of a database switching system based on an instant mounting method provided in an embodiment of the present application;

[0066] Figure 2 It is a flowchart of an embodiment of a database switching method based on an instant mounting mode provided in an embodiment of the present application;

[0067] Figure 3It is a structural diagram of a database switching device based on an instant mounting method provided in an embodiment of the present application;

[0068] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0069] It should be noted that the principles of the present application are illustrated by implementing them in an appropriate computing environment. The following description is based on the illustrated specific embodiments of the present application and should not be considered as limiting other specific embodiments of the present application that are not described in detail herein.

[0070] In the following description of the present application, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it can be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0071] In the following description of the present application, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.

[0072] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0073] In order to improve the effect of database switching based on the instant mount mode, the embodiments of the present application provide a database switching method based on the instant mount mode, a database switching device based on the instant mount mode, an electronic device, a computer-readable storage medium, and a computer program product. The database switching method based on the instant mount mode can be executed by the database switching device based on the instant mount mode, or by an electronic device integrated with the database switching device based on the instant mount mode.

[0074] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0075] Please refer to Figure 1 , the present application also provides a database switching system based on instant mounting, such as Figure 1 As shown, the database switching system based on the instant mount mode includes an electronic device 100, a plurality of database environment groups and a database file system. The electronic device 100 is integrated with the database switching device based on the instant mount mode provided by the present application.

[0076] The database file system is a software structure used to store, manage and retrieve data in a database system. Although database systems and file systems have some similarities in data management and storage, they have significant differences in design, function and use. The file system is mainly responsible for organizing and managing files on disks or partitions, including operations such as creating, deleting, renaming, and moving files, and provides file protection and access control functions. The file system consists of software related to file management, managed files, and data structures required to implement file management. From a system perspective, the file system is a system that organizes and allocates file storage space, is responsible for file storage, and protects and retrieves stored files. The database system is a system composed of a database and database management software (such as a database management system DBMS), which is used to implement structured storage, management, and query of data. The database system has the characteristics of data structuring, high data sharing, low redundancy, easy expansion, and high data independence. The data in the database is no longer limited to a certain application, but is oriented to the entire organization. The data is connected, and the overall data can be structured. At the same time, the database system implements unified management and control of data through DBMS, including data security protection, integrity checking, concurrent access control, and fault recovery. In a database system, data files (such as .mdf files) are the main files that store database data and objects, indexes, and stored procedures. In addition, there are log files (such as .ldf files) that record all modification operations in the database, and backup files (such as .bak files) that are used to backup and restore the database. These files play an important role in the database system and ensure the reliability and integrity of the data.

[0077] Among them, the electronic device 100 can be any device equipped with a processor and has processing capabilities, such as mobile electronic devices with processors such as smart phones, tablet computers, PDAs, laptops, smart speakers, or fixed electronic devices with processors such as desktop computers, televisions, servers, industrial equipment, etc.

[0078] In addition, the database switching system based on the instant mounting method may also include a memory for storing original data, intermediate data and result data.

[0079] In the embodiment of the present application, the memory may be a cloud memory. Cloud storage is a new concept extended and developed from the concept of cloud computing. A distributed cloud storage system (hereinafter referred to as the storage system) refers to a storage system that uses cluster applications, grid technology, and distributed storage file systems to bring together a large number of storage devices of various types (storage devices are also called storage nodes) in the network through application software or application interfaces to work together and provide external data storage and business access functions.

[0080] At present, the storage method of the storage system is: create a logical volume, and when creating a logical volume, allocate physical storage space for each logical volume, and the physical storage space may be composed of disks of a storage device or several storage devices. The client stores data on a logical volume, that is, stores the data on the file system. The file system divides the data into many parts, each of which is an object. The object contains not only data but also additional information such as data identification (ID, ID entity). The file system writes each object into the physical storage space of the logical volume, and the file system records the storage location information of each object, so that when the client requests to access the data, the file system can allow the client to access the data according to the storage location information of each object.

[0081] The process of the storage system allocating physical storage space to a logical volume is as follows: based on the estimated capacity of the objects stored in the logical volume (this estimate often has a large margin relative to the actual capacity of the objects to be stored) and the grouping of independent redundant disk arrays (RAID, Redundant Array of Independent Disks), the physical storage space is divided into stripes in advance. A logical volume can be understood as a stripe, thereby allocating physical storage space to the logical volume.

[0082] It should be noted that Figure 1 The scenario diagram of the database switching system based on the instant mounting method shown is only an example. The database switching system based on the instant mounting method and the scenario described in the embodiment of the present application are for more clearly illustrating the technical solution of the embodiment of the present application, and do not constitute a limitation on the technical solution provided in the embodiment of the present application. A person of ordinary skill in the art can know that with the evolution of the database switching system based on the instant mounting method and the emergence of new business scenarios, the technical solution provided in the embodiment of the present application is also applicable to similar technical problems.

[0083] It should be noted that the serial numbers of the following embodiments are not intended to limit the preferred order of the embodiments.

[0084] Please refer to Figure 2 , Figure 2 FIG. 1 is a flow chart of an embodiment of a database switching method based on an instant mounting method provided in an embodiment of the present application. Figure 2 As shown, the process of the database switching method based on the instant mounting mode provided by this application is as follows:

[0085] 201. Obtain a plurality of different pre-built first database environment groups.

[0086] Among them, different first database environment groups include databases and operating systems where the databases are located, and different first database environment groups have different computing resources, wherein the computing resources include CPU main frequency and number of cores. Different operating systems have different CPU main frequency and number of cores. The database environment group can be a constructed virtual machine. A virtual machine (Virtual Machine) refers to a complete computer system with complete hardware system functions and running in a completely isolated environment that is simulated by software. All 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 CMOS, hard disk and operating system, and the virtual machine can be operated like a physical machine.

[0087] In a specific embodiment, the CPU main frequencies of the multiple different first database environment groups are a geometric progression, and the number of cores of the multiple first database environment groups is a geometric progression. For example, the number of first database environment groups is 3, the CPU main frequency of the first first database environment group is 4G, and the number of cores is 2 cores; the CPU main frequency of the second first database environment group is 8G, and the number of cores is 4 cores; the CPU main frequency of the third first database environment group is 16G, and the number of cores is 8 cores.

[0088] In order to avoid setting too many first database environment groups, in another specific embodiment, a plurality of different pre-built first database environment groups are obtained, including:

[0089] (1) Obtain a plurality of different pre-built second database environment groups, wherein the CPU main frequencies of the plurality of second database environment groups are a geometric progression, and the number of cores of the plurality of second database environment groups are a geometric progression.

[0090] For example, the number of first database environment groups is 3, the CPU main frequency of the first second database environment group is 4G, and the number of cores is 2 cores; the CPU main frequency of the second second database environment group is 8G, and the number of cores is 4 cores; the CPU main frequency of the third second database environment group is 16G, and the number of cores is 8 cores.

[0091] (2) The plurality of second database environment groups are respectively determined as test database environment groups, and database access requests initiated by users are processed.

[0092] (3) When the response time of the test database environment group to the database access request is greater than a first preset time length, determining a first preset processing busyness of the test database environment group based on multiple database performance indicators of the test database environment group at the current time point.

[0093] The first preset duration can be set according to the specific situation, for example, the first preset duration is 2s. When the response time of the test database environment group to the database access request is greater than the first preset duration, it indicates that a jam has occurred and the test database environment group cannot carry the request at this time. The first preset processing busyness of the test database environment group is determined based on multiple database performance indicators of the test database environment group at the current time point.

[0094] Specifically, the multiple database performance indicators include read and write rates and request concurrency. Based on the preset weight coefficient, the multiple database performance indicators when the test database environment group is running are weighted and summed to obtain the first preset processing busyness of the test database environment group. Among them, the preset weight coefficient of each database performance indicator can be set according to the specific situation.

[0095] For example, the preset weight coefficient of the read / write rate is 0.4, and the read / write rate is 10; the preset weight coefficient of the request concurrency is 0.6, and the request concurrency is 20, then the first preset processing busyness is: 0.4*10+0.6*20=16.

[0096] (4) When the response time of the test database environment group in responding to the database access request is less than a second preset time, determining a second preset processing busyness of the test database environment group based on a plurality of database performance indicators of the test database environment group at a current time point.

[0097] The second preset duration can be set according to specific circumstances, for example, the second preset duration is 0.2s. When the response time of the test database environment group to the database access request is less than the second preset duration, it indicates that the speed is very fast and the test database environment group is relatively idle. The second preset processing busyness of the test database environment group is determined based on multiple database performance indicators of the test database environment group at the current time point.

[0098] Specifically, the multiple database performance indicators include read and write rates and request concurrency. Based on the preset weight coefficient, the multiple database performance indicators when the test database environment group is running are weighted and summed to obtain the second preset processing busyness of the test database environment group. Among them, the preset weight coefficient of each database performance indicator can be set according to the specific situation.

[0099] (5) Determine each second database environment group as a test database environment group, obtain a first preset processing busyness and a second preset processing busyness of each second database environment group, and obtain a busyness interval of each second database environment group, wherein the busyness interval is an interval consisting of the first preset processing busyness and the second preset processing busyness. The maximum value of the busyness interval is the first preset processing busyness, and the minimum value of the busyness interval is the second preset processing busyness.

[0100] (6) Based on the busyness intervals of each second database environment group, some second database environment groups are eliminated to obtain multiple different first database environment groups.

[0101] In a specific embodiment, some of the second database environment groups in each second database environment group are removed at preset intervals to obtain a plurality of different first database environment groups. For example, one second database environment group is removed every three second database environment groups, and the remaining second database environment groups are determined as a plurality of different first database environment groups to obtain a plurality of different first database environment groups.

[0102] In another specific embodiment, some second database environment groups are eliminated based on the busyness intervals of each second database environment group to obtain multiple different first database environment groups, including:

[0103] (1) Sort the second database environment groups from small to large based on the median values ​​of the busyness intervals of the second database environment groups to obtain a plurality of sorted second database environment groups.

[0104] In the embodiment of the present application, the median value of the busyness interval of the second database environment group is the average value of the first preset processing busyness and the second preset processing busyness of the second database environment group.

[0105] (2) Determine each of the sorted plurality of second database environment groups as a second target database environment group, and determine a second database environment group that is subsequent to the second target database environment group and has an overlapping busyness interval with the second target database environment group as an overlapping database environment group.

[0106] (3) Eliminate the overlapping database environment groups between the second target database environment group and the last overlapping database environment group to obtain a plurality of different first database environments.

[0107] When there is no overlapping database environment group in the second target database environment group, a new second database environment group is added between the second target database environment group and the first second database environment group after the second target database environment group, and the busyness intervals of the newly added second database environment group overlap with those of the second target database environment group. This ensures that each second database environment group only retains one overlapping database environment group, so that there is only one database environment group with overlapping intervals before and after each second database environment group. On the one hand, it can avoid the lack of overlapping database environment groups, resulting in no matching database environment groups for users, and on the other hand, it can avoid setting too many database environment groups to cause waste of resources.

[0108] 202. Mount one of the first database environment groups to the database file system so as to receive and process a database access request initiated by a user as the current database environment group.

[0109] In a specific embodiment, the first database environment group with the smallest CPU main frequency and core number among multiple different first database environment groups is mounted to the database file system to receive and process database access requests initiated by users as the current database environment group.

[0110] In another specific embodiment, one of the first database environment groups is mounted to the database file system to receive and process database access requests initiated by users as the current database environment group, including: obtaining the historical usage frequency of each first database environment group within a preset time period; mounting the first database environment group with the highest historical usage frequency to the database file system to receive and process database access requests initiated by users as the current database environment group.

[0111] In another specific embodiment, historical access request information is obtained, wherein the historical access request information includes database access requests every day within a preset historical period, and the access time of each database access request is obtained, and the access time includes hours and minutes. For example, the access time of the database access request is 10:20. The database access requests of the historical access request information are clustered based on the access time of each database access request to obtain each first request cluster cluster, and the number of requests of each first request cluster cluster is obtained. The access time of the database access requests in the same first request cluster cluster is similar. The first request cluster clusters are sorted from large to small based on the size of the number of requests of each first request cluster cluster, and the sorted first request cluster clusters are obtained. A first database environment group is allocated to each first request cluster cluster. Among them, the CPU main frequency and core number of the first database environment group allocated to the first request cluster cluster with a larger number of requests are larger. Specifically, the database access requests of the historical access request information are clustered based on the access time of each database access request based on the k-means clustering algorithm to obtain each first request cluster cluster.

[0112] Furthermore, the database access requests of the historical access request information are clustered based on the access time of each database access request to obtain each first request clustering cluster, including: clustering the database access requests of the historical access request information of each day based on the access time of each database access request of each day to obtain multiple second request clustering clusters of each day. Obtaining the time mean of the access time of the database access requests of each second request clustering cluster, clustering each second request clustering cluster based on the time mean of each second request clustering cluster, to obtain multiple request clustering cluster sets, each request clustering cluster set includes multiple second request clustering clusters. Determining the request clustering cluster set as the first request clustering cluster, to obtain each first request clustering cluster corresponding to each request clustering cluster set.

[0113] In another specific embodiment, one of the first database environment groups is mounted to the database file system to receive and process database access requests initiated by users as the current database environment group, including: obtaining the historical usage frequency of each first database environment group within a preset time period; mounting the first database environment group with the highest historical usage frequency to the database file system through FUSE to receive and process database access requests initiated by users as the current database environment group.

[0114] FUSE (Filesystem in Userspace) is a framework that allows users to create their own file systems in user space in Unix-like systems. With FUSE, user space programs can provide access to file systems just like kernel modules, without actually modifying the kernel code. FUSE provides a series of APIs and tools that allow user space programs to "mount" a file system, just like mounting a normal disk partition or network file system. When a user space program receives file system requests from the kernel (such as read, write, open, close, etc.), it processes these requests and returns the corresponding results. FUSE is widely used. It can map database data files to FUSE file systems, and access and modify data in the database through file operations.

[0115] FUSE is a framework that allows user space programs to implement file systems. It consists of a kernel module and a user space library. When a FUSE file system is mounted, file system calls (such as open, read, write, etc.) are intercepted and forwarded to the FUSE daemon in user space. This daemon handles these calls and communicates with the kernel module to complete file system operations. There are the following points for mapping data files to FUSE file systems:

[0116] Define the file system structure: First, you need to define how to map the database data files to the directory and file structure of the FUSE file system. This may involve mapping each table in the database to a directory, mapping each row in the table to a file, or using other more complex mapping strategies.

[0117] Implementing a FUSE daemon: Then, you need to write a FUSE daemon to handle file system calls. This daemon needs to be able to parse the database data files and perform corresponding operations based on the file system calls. For example, when a file is opened, the daemon may need to retrieve the corresponding data from the database; when the file is written, the daemon may need to update the data back to the database.

[0118] Handling concurrency and performance: Since the database may be accessed with high concurrency, the FUSE daemon needs to be able to handle multiple file system calls efficiently. This may involve using multithreading, asynchronous I / O, or other techniques to optimize performance.

[0119] Security and permission management: The FUSE daemon also needs to implement appropriate security and permission management mechanisms to ensure that only authorized users can access and modify database data.

[0120] Once the FUSE daemon is implemented and tested, it can be mounted as a file system. This can be done by using the mounting tools provided by FUSE (such as fusermount). After mounting, users can access this database-based FUSE file system just like accessing a normal file system.

[0121] Specifically, the first database environment group with the highest historical usage frequency is mounted to the database file system in a FUSE manner to receive and process database access requests initiated by users as the current database environment group, including:

[0122] (1) Obtain database access requests initiated by users received by the current database environment group;

[0123] (2) Send the database access request to the FUSE daemon;

[0124] (3) Obtain the database access result of the FUSE daemon based on the database access request.

[0125] Furthermore, one of the first database environment groups is mounted to the database file system to serve as the current database environment group to receive and process database access requests initiated by users, including: mounting one of the first database environment groups to the database file system to serve as the current database environment group; setting a virtual IP for the current database environment group and receiving database access requests through the virtual IP.

[0126] 203. Determine the data processing busyness based on multiple database performance indicators when the current database environment group is running.

[0127] In the embodiment of the present application, the multiple database performance indicators include read and write rates and request concurrency. Based on the preset weight coefficient, the multiple database performance indicators when the current database environment group is running are weighted and summed to obtain the data processing busyness. Among them, the preset weight coefficient of each database performance indicator can be set according to the specific situation.

[0128] 204. When the data processing busyness of the current database environment group for processing database access requests is higher than the first preset processing busyness corresponding to the current database environment group, unmount the current database environment group and the database file system, and mount the first target database environment group to the database file system to process the database access requests initiated by the user.

[0129] The computing resources of the first target database environment group are greater than the computing resources of the current database environment group. The CPU main frequency and the number of cores of the first target database environment group are greater than those of the current database environment group.

[0130] In the embodiment of the present application, different database environment groups correspond to different first preset processing busynesses. The first preset processing busynesses corresponding to different database environment groups can be set according to specific circumstances and are not limited here.

[0131] Furthermore, after the first target database environment group is mounted to the database file system, the virtual IP is switched from the current database environment group to the first target database environment group, and database access requests initiated by users are received through the virtual IP.

[0132] Further, when the data processing busyness of the current database environment group for processing database access requests is not higher than the second preset processing busyness corresponding to the current database environment group, the mount between the current database environment group and the database file system is uninstalled, and the second target database environment group is mounted to the database file system to process the database access request initiated by the user, wherein the computing resources of the second target database environment are not greater than the computing resources of the current database environment group. The CPU main frequency and the number of cores of the second target database environment are both not greater than those of the current database environment group.

[0133] Furthermore, after the second target database environment group is mounted to the database file system, the virtual IP is switched from the current database environment group to the second target database environment group, and database access requests initiated by users are received through the virtual IP.

[0134] Further, the number of high-level environments of the first database environment group whose computing resources are higher than the first target database environment group and the number of low-level environments of the first database environment group whose computing resources are not higher than the first target database environment group are obtained. If the number of high-level environments is greater than the number of low-level environments, the computing resources of the first database environment group with the highest computing resources are released, and a new third database environment group is constructed, wherein the computing resources of the new third database environment group are less than the minimum computing resources among the multiple first database environment groups. If the number of high-level environments is less than the number of low-level environments, the computing resources of at least two first database environment groups with lower computing resource rankings are released, and a new fourth database environment group is constructed, wherein the computing resources of the new fourth database environment group are greater than the maximum computing resources among the multiple first database environment groups.

[0135] Further, if the number of high-level environments is greater than the number of low-level environments, it is determined whether the number of high-level environments is greater than a preset number. If the number of high-level environments is not greater than the preset number, the computing resources of the first database environment group with the highest computing resources are released, and a new third database environment group is constructed, wherein the computing resources of the new third database environment group are less than the minimum computing resources among the multiple first database environment groups. If the number of high-level environments is less than the number of low-level environments, it is determined whether the number of low-level environments is greater than a preset number. If the number of low-level environments is not greater than the preset number, the computing resources of at least two first database environment groups with lower computing resource rankings are released, and a new fourth database environment group is constructed, wherein the computing resources of the new fourth database environment group are greater than the maximum computing resources among the multiple first database environment groups. The preset number can be set according to the specific situation, for example, the preset number is 2.

[0136] In order to better implement the database switching method based on the instant mounting mode provided in the embodiment of the present application, the embodiment of the present application also provides a database switching device based on the instant mounting mode based on the above database switching method based on the instant mounting mode. The meanings of the terms are the same as those in the above database switching method based on the instant mounting mode. For specific implementation details, please refer to the description in the above method embodiment.

[0137] Please refer to Figure 3 , Figure 3 A schematic diagram of the structure of a database switching device based on an instant mounting method provided in an embodiment of the present application, the database switching device based on an instant mounting method may include:

[0138] The acquisition module 701 is used to acquire a plurality of different pre-built first database environment groups, wherein different first database environment groups include databases and operating systems where the databases are located, and different operating systems have different computing resources, wherein the computing resources include CPU main frequency and number of cores;

[0139] The mounting module 702 is used to mount one of the first database environment groups to the database file system so as to receive and process the database access request initiated by the user as the current database environment group;

[0140] A determination module 703 is used to determine the data processing busyness based on multiple database performance indicators when the current database environment group is running, wherein the multiple database performance indicators include a read and write rate and a concurrent request amount;

[0141] The switching module 704 is used to unload the mount between the current database environment group and the database file system when the data processing busyness of the current database environment group processing the database access request is higher than the first preset processing busyness corresponding to the current database environment group, and mount the first target database environment group to the database file system to process the database access request initiated by the user, wherein the computing resources of the first target database environment group are greater than the computing resources of the current database environment group.

[0142] Optionally, the database switching method based on the instant mounting mode includes:

[0143] When the data processing busyness of the current database environment group for processing the database access request is not higher than the second preset processing busyness corresponding to the current database environment group, the mount between the current database environment group and the database file system is unloaded, and the second target database environment group is mounted to the database file system to process the database access request initiated by the user, wherein the computing resources of the second target database environment are not greater than the computing resources of the current database environment group.

[0144] Optionally, the obtaining of a plurality of different pre-built first database environment groups includes:

[0145] Acquire a plurality of different pre-built second database environment groups, wherein the CPU main frequencies of the plurality of second database environment groups are a geometric progression, and the number of cores of the plurality of second database environment groups is a geometric progression;

[0146] respectively determining the plurality of the second database environment groups as test database environment groups, and processing database access requests initiated by users;

[0147] When the response time of the test database environment group to the database access request is greater than a first preset duration, determining a first preset processing busyness of the test database environment group based on a plurality of database performance indicators of the test database environment group at a current time point;

[0148] When the response time of the test database environment group in responding to the database access request is less than a second preset duration, determining a second preset processing busyness of the test database environment group based on a plurality of database performance indicators of the test database environment group at a current time point;

[0149] Determine each of the second database environment groups as the test database environment group, obtain a first preset processing busyness and a second preset processing busyness of each of the second database environment groups, and obtain a busyness interval of each of the second database environment groups, wherein the busyness interval is an interval consisting of the first preset processing busyness and the second preset processing busyness;

[0150] Part of the second database environment groups are eliminated based on the busyness intervals of each of the second database environment groups to obtain a plurality of different first database environment groups.

[0151] Optionally, the removing of some of the second database environment groups based on the busyness intervals of each of the second database environment groups to obtain a plurality of different first database environment groups includes:

[0152] sorting the second database environment groups from small to large based on the median values ​​of the busyness intervals of the second database environment groups to obtain a plurality of sorted second database environment groups;

[0153] Determine each of the sorted plurality of second database environment groups as a second target database environment group, and determine a second database environment group that is subsequent to the second target database environment group and has an overlapping busyness interval with the second target database environment group as an overlapping database environment group;

[0154] The overlapping database environment groups between the second target database environment group and the last overlapping database environment group are eliminated to obtain a plurality of different first database environment groups.

[0155] Optionally, mounting one of the first database environment groups to a database file system to receive and process a database access request initiated by a user as the current database environment group includes:

[0156] Obtaining the historical usage frequency of each of the first database environment groups within a preset time period;

[0157] The first database environment group with the highest historical usage frequency is mounted to the database file system through FUSE, so as to receive and process database access requests initiated by users as the current database environment group.

[0158] Optionally, mounting the first database environment group with the highest historical usage frequency to a database file system by means of FUSE so as to receive and process a database access request initiated by a user as a current database environment group includes:

[0159] Get the database access requests initiated by users received by the current database environment group;

[0160] Sending the database access request to the FUSE daemon;

[0161] Obtain a database access result of the FUSE daemon based on the database access request.

[0162] Optionally, mounting one of the first database environment groups to a database file system to receive and process a database access request initiated by a user as the current database environment group includes:

[0163] Mount one of the first database environment groups to the database file system to serve as the current database environment group;

[0164] A virtual IP is set for the current database environment group and the database access request is received through the virtual IP.

[0165] The specific implementation of each of the above modules can be found in the previous embodiments and will not be described in detail here.

[0166] An embodiment of the present application also provides an electronic device, including a memory and a processor, wherein the processor is used to execute the steps of the database switching method based on the instant mounting mode provided in this embodiment by calling a computer program stored in the memory.

[0167] Please refer to Figure 4 , Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0168] The electronic device may include components such as a processor 101 with one or more processing cores, a memory 102 with one or more computer-readable storage media, a power supply 103, and an input unit 104. Those skilled in the art will appreciate that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:

[0169] The processor 101 is the control center of the electronic device, which uses various interfaces and lines to connect various parts of the entire electronic device, and executes various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory 102, and calling data stored in the memory 102. Optionally, the processor 101 may include one or more processing cores; optionally, the processor 101 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 101.

[0170] The memory 102 can be used to store software programs and modules. The processor 101 executes various functional applications and data processing by running the software programs and modules stored in the memory 102. The memory 102 may mainly 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 (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 102 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 102 may also include a memory controller to provide the processor 101 with access to the memory 102.

[0171] The electronic device also includes a power supply 103 for supplying power to each component. Optionally, the power supply 103 can be logically connected to the processor 101 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 103 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0172] The electronic device may further include an input unit 104, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0173] Although not shown, the electronic device may also include a display unit, an image acquisition component, etc., which will not be described in detail here. Specifically in this embodiment, the processor 101 in the electronic device will load the executable code corresponding to one or more computer programs into the memory 102 according to the following instructions, and the processor 101 will execute the steps in the database switching method based on the instant mounting mode provided by the present application, such as:

[0174] Acquire multiple different pre-built first database environment groups, wherein different first database environment groups include databases and operating systems where the databases are located, and different operating systems have different computing resources, wherein the computing resources include CPU main frequency and number of cores; mount one of the first database environment groups to the database file system to receive and process database access requests initiated by users as the current database environment group; determine data processing busyness based on multiple database performance indicators when the current database environment group is running, wherein the multiple database performance indicators include read and write rates and request concurrency; when the data processing busyness of the current database environment group processing database access requests is higher than the first preset processing busyness corresponding to the current database environment group, unload the mount between the current database environment group and the database file system, and mount the first target database environment group to the database file system to process database access requests initiated by users, wherein the computing resources of the first target database environment group are greater than the computing resources of the current database environment group.

[0175] It should be noted that the electronic device provided in the embodiment of the present application and the database switching method based on the instant mounting method in the above embodiment belong to the same concept, and its specific implementation process is detailed in the above related embodiments and will not be repeated here.

[0176] The present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program stored therein is executed on the processor of the electronic device provided in the embodiment of the present application, the processor of the electronic device executes the steps in the database switching method based on the instant mounting mode provided in the present application. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0177] The present application also provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes various optional implementations of the database switching method based on the instant mount method.

[0178] The above is a detailed introduction to a database switching method and device based on instant mounting provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

[0179] It should be noted that when the above embodiments of the present application are applied to specific products or technologies, the relevant data of the user is involved, and the user's permission or consent is required, and the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

Claims

1. A database switching method based on instant mounting mode, It is characterized in that include: Acquire a plurality of different pre-built first database environment groups, wherein different first database environment groups include databases and operating systems where the databases are located, and different operating systems have different computing resources, wherein the computing resources include CPU main frequency and number of cores; Mounting one of the first database environment groups to the database file system so as to receive and process a database access request initiated by a user as the current database environment group; Determine the data processing busyness based on multiple database performance indicators when the current database environment group is running, wherein the multiple database performance indicators include read and write rates and request concurrency; When the data processing busyness of the current database environment group for processing the database access request is higher than the first preset processing busyness corresponding to the current database environment group, the mount between the current database environment group and the database file system is unloaded, and the first target database environment group is mounted to the database file system to process the database access request initiated by the user, wherein the computing resources of the first target database environment group are greater than the computing resources of the current database environment group.

2. According to the database switching method based on the instant mounting mode according to claim 1, It is characterized in that The database switching method based on the instant mounting mode includes: When the data processing busyness of the current database environment group for processing the database access request is not higher than the second preset processing busyness corresponding to the current database environment group, the mount between the current database environment group and the database file system is unloaded, and the second target database environment group is mounted to the database file system to process the database access request initiated by the user, wherein the computing resources of the second target database environment are not greater than the computing resources of the current database environment group.

3. According to the database switching method based on the instant mounting mode according to claim 2, It is characterized in that The step of obtaining a plurality of different pre-built first database environment groups includes: Acquire a plurality of different pre-built second database environment groups, wherein the CPU main frequencies of the plurality of second database environment groups are a geometric progression, and the number of cores of the plurality of second database environment groups is a geometric progression; respectively determining the plurality of the second database environment groups as test database environment groups, and processing database access requests initiated by users; When the response time of the test database environment group to the database access request is greater than a first preset duration, determining a first preset processing busyness of the test database environment group based on a plurality of database performance indicators of the test database environment group at a current time point; When the response time of the test database environment group in responding to the database access request is less than a second preset duration, determining a second preset processing busyness of the test database environment group based on a plurality of database performance indicators of the test database environment group at a current time point; Determine each of the second database environment groups as the test database environment group, obtain a first preset processing busyness and a second preset processing busyness of each of the second database environment groups, and obtain a busyness interval of each of the second database environment groups, wherein the busyness interval is an interval consisting of the first preset processing busyness and the second preset processing busyness; Part of the second database environment groups are eliminated based on the busyness intervals of each of the second database environment groups to obtain a plurality of different first database environment groups.

4. The database switching method based on instant mounting mode according to claim 3, It is characterized in that The removing of some of the second database environment groups based on the busyness intervals of each of the second database environment groups to obtain a plurality of different first database environment groups includes: sorting the second database environment groups from small to large based on the median values ​​of the busyness intervals of the second database environment groups to obtain a plurality of sorted second database environment groups; Determine each of the sorted plurality of second database environment groups as a second target database environment group, and determine a second database environment group that is subsequent to the second target database environment group and has an overlapping busyness interval with the second target database environment group as an overlapping database environment group; The overlapping database environment groups between the second target database environment group and the last overlapping database environment group are eliminated to obtain a plurality of different first database environment groups.

5. According to claim 4, the database switching method based on the instant mounting mode, It is characterized in that The step of mounting one of the first database environment groups to the database file system so as to receive and process a database access request initiated by a user as the current database environment group includes: Obtaining the historical usage frequency of each of the first database environment groups within a preset time period; The first database environment group with the highest historical usage frequency is mounted to the database file system through FUSE, so as to receive and process database access requests initiated by users as the current database environment group.

6. The database switching method based on instant mounting according to claim 5, It is characterized in that The step of mounting the first database environment group with the highest historical usage frequency to a database file system by means of FUSE so as to receive and process a database access request initiated by a user as the current database environment group includes: Get the database access requests initiated by users received by the current database environment group; Sending the database access request to the FUSE daemon; Obtain a database access result of the FUSE daemon based on the database access request.

7. The database switching method based on instant mounting mode according to claim 1, It is characterized in that The step of mounting one of the first database environment groups to the database file system so as to receive and process a database access request initiated by a user as the current database environment group includes: Mount one of the first database environment groups to the database file system to serve as the current database environment group; A virtual IP is set for the current database environment group and the database access request is received through the virtual IP.

8. A database switching device based on instant mounting mode, It is characterized in that include: An acquisition module is used to acquire a plurality of different pre-built first database environment groups, wherein different first database environment groups include databases and operating systems where the databases are located, and different operating systems have different computing resources, wherein the computing resources include CPU main frequency and core number; A mounting module, used to mount one of the first database environment groups to the database file system so as to receive and process a database access request initiated by a user as the current database environment group; A determination module, configured to determine the data processing busyness based on a plurality of database performance indicators when the current database environment group is running, wherein the plurality of database performance indicators include a read / write rate and a concurrent request amount; A switching module is used to unload the mount between the current database environment group and the database file system when the data processing busyness of the current database environment group processing the database access request is higher than the first preset processing busyness corresponding to the current database environment group, and mount the first target database environment group to the database file system to process the database access request initiated by the user, wherein the computing resources of the first target database environment group are greater than the computing resources of the current database environment group.

9. An electronic device, It is characterized in that It comprises a memory and a processor, wherein the memory stores a computer program, and the processor is used to run the computer program in the memory to execute the steps in the database switching method based on the instant mounting mode as described in any one of claims 1 to 7.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the database switching method based on the instant mounting mode according to any one of claims 1 to 7.