Determining method and device for fragmentation rate of distributed database, equipment and medium
By deploying the interface between configuration management equipment and distributed database proxy equipment in the distributed database system, efficient fragmentation rate calculation of distributed database table space is achieved, and the problems of complex process, low efficiency and insufficient security in the existing technology are solved.
Patent Information
- Application Number
- CN202411722406.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-03-18
AI Technical Summary
The prior art is used to determine the table fragment space situation of distributed databases with complex process, low efficiency and insufficient security.
By deploying the first interface and the second interface in the distributed database proxy device in the configuration management device, the first interface is used to encapsulate the query parameters of different distributed database instances, and encapsulate the native interface of the distributed database cluster through the second interface, the spatial distribution information query and fragmentation rate calculation of the target table space are realized.
Improves the efficiency and security of determining table fragmented spaces, and users do not need to log in to distributed databases, making the processing process more efficient and secure.
Smart Images

Figure CN119646053A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method, device, equipment and medium for determining a fragmentation rate of a distributed database. Background Art
[0002] Distributed databases support horizontal expansion, high-availability multiple copies, and multi-center deployment. In the era of digital transformation, they are the key technical path to achieve high-availability replacement of critical information infrastructure in the financial industry.
[0003] In actual applications, distributed databases will constantly write and delete data during the reading and writing process, which will generate more and more idle space on the disk. These idle spaces are called "fragments". At present, administrators usually need to log in to the distributed database and enter specific query statements to query the table fragmentation space situation.
[0004] However, the existing method of determining table fragmentation space has a complex process and low efficiency and security. Summary of the invention
[0005] The embodiments of the present application provide a method, apparatus, device and medium for determining the fragmentation rate of a distributed database, so as to achieve the effect of improving the efficiency and security of determining table fragmentation space.
[0006] In a first aspect, an embodiment of the present application provides a method for determining a fragmentation rate of a distributed database, which is applied to a configuration management device of a distributed database system, and the method includes:
[0007] Determine, according to the first interface, a target query parameter corresponding to the target distributed database instance, wherein the target query parameter includes an identifier of at least one target shard corresponding to the target distributed database instance, and the first interface encapsulates query parameters corresponding to different distributed database instances;
[0008] According to the target query parameter, a spatial distribution query request is sent to a second interface of a distributed database proxy device of the distributed database system, where the second interface encapsulates a native interface of a distributed database cluster, and the spatial distribution query request is used to query spatial distribution information of a target table space corresponding to at least one target shard;
[0009] Acquire the spatial distribution information of the target tablespace returned by the second interface;
[0010] The fragmentation rate of the target tablespace is determined according to the spatial distribution information of the target tablespace.
[0011] In a second aspect, an embodiment of the present application provides a device for determining a fragmentation rate of a distributed database, which is applied to a configuration management device of a distributed database system, and the device includes:
[0012] A determination module, configured to determine a target query parameter corresponding to a target distributed database instance according to a first interface, wherein the target query parameter includes an identifier of at least one target shard corresponding to the target distributed database instance, and wherein the first interface encapsulates query parameters corresponding to different distributed database instances;
[0013] A sending module, configured to send a spatial distribution query request to a second interface of a distributed database proxy device of the distributed database system according to the target query parameter, wherein the second interface encapsulates a native interface of a distributed database cluster, and the spatial distribution query request is used to query spatial distribution information of a target table space corresponding to at least one target shard;
[0014] A receiving module, configured to receive the spatial distribution information of the target tablespace returned by the second interface;
[0015] The determination module is further used to determine the fragmentation rate of the target table space according to the spatial distribution information of the target table space.
[0016] In a third aspect, an embodiment of the present application provides a configuration management device, including: a memory, a processor;
[0017] The memory stores computer-executable instructions;
[0018] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the above first aspect and / or various possible implementations of the first aspect.
[0019] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the first aspect above and / or various possible implementations of the first aspect.
[0020] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the above first aspect and / or various possible implementation methods of the first aspect.
[0021] The fragmentation rate determination method, device, equipment and medium of the distributed database provided by the embodiment of the present application, in which the target query parameter corresponding to the target distributed database instance is determined according to the first interface. Afterwards, according to the target query parameter, a spatial distribution query request is sent to the second interface of the distributed database proxy device of the distributed database system, and the spatial distribution information of the target table space returned by the second interface is obtained; finally, according to the spatial distribution information of the target table space, the fragmentation rate of the target table space is determined. Among them, the target query parameter includes the identifier of at least one target shard corresponding to the target distributed database instance, and the first interface encapsulates the query parameters corresponding to different distributed database instances. The second interface encapsulates the native interface of the distributed database cluster, and the spatial distribution query request is used to query the spatial distribution information of the target table space corresponding to at least one target shard. In this technical solution, the fragmentation rate of the target table space corresponding to the target distributed database instance is queried through the first interface and the second interface, and the user does not need to log in to the distributed database, thereby ensuring the efficiency and security of the processing process. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0023] Figure 1 A schematic diagram of the structure of a distributed database system provided in an embodiment of the present application;
[0024] Figure 2 Schematic diagram of the process of determining the fragmentation rate of a distributed database provided in an embodiment of the present application Figure 1 ;
[0025] Figure 3 Schematic diagram of the process of determining the fragmentation rate of a distributed database provided in an embodiment of the present application Figure 2 ;
[0026] Figure 4 A schematic diagram of the structure of a device for determining a fragmentation rate of a distributed database provided in the present application;
[0027] Figure 5 A schematic diagram of the structure of the configuration management device provided in this application.
[0028] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0029] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0030] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0031] First, the terms involved in this application are explained:
[0032] Distributed database: A distributed database is a database system that stores data in multiple physical nodes (which can be different servers or storage devices) instead of storing it in a single node like a traditional database. These nodes are connected through a network and work together to provide data storage and management functions. They can effectively solve online transaction processing (OLTP) scenarios with ultra-large concurrency, ultra-high performance, and ultra-large capacity. Its core features are strong data consistency, high performance and low cost, linear horizontal expansion, financial-grade high availability, enterprise-level security, and convenient operation and maintenance.
[0033] GroupId: An identifier (ID) that uniquely identifies a distributed database instance.
[0034] Set: data node, shard, is the smallest data unit in a distributed database instance. A distributed database instance is composed of N Sets, each of which stores data in a different range, and all Sets together form a full copy of the data.
[0035] Next, the application scenarios involved in this application are explained:
[0036] Distributed databases support horizontal expansion, high-availability multiple copies, and multi-center deployment. In the era of digital transformation, they are the key technical path to achieve high-availability replacement of critical information infrastructure in the financial industry.
[0037] In actual applications, distributed databases, like traditional databases, involve constant writing and deletion of data during the reading and writing process. The writing operation is to add new data to the database, while the deleting operation is to remove data that is no longer needed from the database. Since the storage structure of the database is designed for overall performance and data management, when data is deleted, the subsequent records cannot all be moved forward to fill the free space as in a simple array structure. This is because doing so may involve a large number of data movement operations, which will consume a lot of time and system resources, and may also affect the correctness of the index and other structures that have been established in the database.
[0038] As data is deleted continuously in the database, more and more idle space will be generated on the disk. These idle spaces are called "fragments". For example, in a database table storing user information, if some user records are deleted frequently, many small idle spaces will appear in the disk area storing these user records. These small idle spaces are scattered throughout the disk storage area, forming disk fragments.
[0039] Disk fragmentation can cause data incoherence. When the database performs read and write operations, especially when reading data sequentially, the data is no longer stored continuously due to the existence of fragmentation. For example, a query needs to read a series of consecutive records in a table. Due to the existence of disk fragmentation, these records may be scattered in different locations on the disk. The database system needs to constantly jump to different areas of the disk to obtain these records, which increases the time to read data, thereby affecting the read and write speed of the database.
[0040] Furthermore, if there are too many fragments, disk space will be wasted. Although each fragment may not seem large individually, when there are many fragments, the total disk space they occupy may be considerable. For example, a disk partition has 100GB of space. Due to a large number of database deletion operations, many small fragments are generated. These fragments may occupy 10GB or even more space in total. Since these spaces are scattered everywhere, they cannot be effectively used to store new data.
[0041] In severe cases, disk fragmentation can affect the performance of database Structured Query Language (SQL) statements. When executing SQL statements, such as a complex multi-table join query or a query with sorting and grouping operations, the database needs to read data from the disk. Due to disk fragmentation, the data reading speed is slowed down, which will cause the query execution time to increase, and then cause production abnormal events.
[0042] In summary, like traditional databases, distributed databases cannot avoid the problem of database table space fragmentation. If too much fragmented space accumulates, a large amount of disk space will be wasted. In severe cases, it will affect the performance of database SQL statements, thereby causing production abnormalities and threatening the safe and stable operation of the system.
[0043] Currently, distributed databases are in the development stage, and technical solutions to solve the fragmentation problem of distributed databases are still being explored. In traditional databases, administrators are usually required to log in to the distributed database and enter specific query statements to query the table fragmentation space situation. The operation is cumbersome and not intuitive enough. For distributed database scenarios, the imperfections of this solution are:
[0044] (1) Logging in to the distributed database one by one to check is too much work, making it difficult to implement regular checks and prone to omissions;
[0045] (2) Logging into the database to complete the operation involves significant security and audit risks.
[0046] Therefore, the prior art has the problem that the process of calculating table fragment space is complicated, and the efficiency and security are low.
[0047] Based on the above technical problems, the technical concept of the present application is as follows: Considering that the methods of calculating the table fragmentation space conditions of different tablespaces are the same, what is different is the query parameters. Therefore, a first interface can be deployed in the configuration management device in advance, and the query parameters corresponding to different distributed database instances are encapsulated through the first interface. It is also necessary to deploy a second interface in the distributed database proxy device in advance, and encapsulate the native interface of the distributed database cluster through the second interface, so that the table fragmentation space conditions of the tablespace corresponding to the distributed database instance can be calculated according to the query parameters. For users, users only need to enter the identifier of the distributed database instance (GroupId), and they can query the table fragmentation space conditions of the tablespace corresponding to the GroupId through the first interface and the second interface, without logging in to the distributed database, thereby ensuring the efficiency and security of the processing process.
[0048] Figure 1 This is a schematic diagram of the structure of the distributed database system provided in the embodiment of the present application. Figure 1 As shown, the distributed database system runs on the hardware infrastructure of the data center, and the distributed database system includes a configuration management device, a distributed database proxy device, and a distributed database cluster.
[0049] Among them, the configuration management device is used to manage the configuration information of all physical machines, virtual machines, distributed database clusters and cloud resources in the data center.
[0050] Specifically, the configuration management device stores various configuration information of the distributed database cluster and provides an application programming interface (API) interface (ie, a first interface) for external query. Through the first interface, the query parameter corresponding to the GroupId can be obtained according to the GroupId.
[0051] Among them, the distributed database cluster provides an operation API interface (i.e., native interface) to the outside world to complete cluster operation and maintenance operations. A second interface is deployed in the distributed database proxy device, which encapsulates the native interface of the above-mentioned distributed database cluster, thereby making it more convenient for users to operate the distributed database cluster.
[0052] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0053] Figure 2 Schematic diagram of the process of determining the fragmentation rate of a distributed database provided in an embodiment of the present application Figure 1 ,like Figure 2 As shown, the distributed database fragmentation rate determination method is applied to Figure 1 The configuration management device of the distributed database system shown in the figure can be implemented by the following steps:
[0054] S21. Determine a target query parameter corresponding to a target distributed database instance according to the first interface.
[0055] The first interface encapsulates query parameters corresponding to different distributed database instances. In actual applications, the configuration management device can display a query box through a graphical user interface (GUI), and the user can enter the identifier (GroupId) of the target distributed database instance in the query box according to his or her own query needs. The configuration management device responds to the user's input operation and obtains the identifier of the target distributed database instance input by the user. Afterwards, the query parameters corresponding to different distributed database instances encapsulated by the first interface are used to determine the target query parameters corresponding to the target distributed database instance.
[0056] The target query parameter includes the identifier of at least one target shard corresponding to the target distributed database instance. Optionally, the target query parameter also includes the identifier of the target distributed database cluster, the identifier of the target distributed database instance, the identifier of the administrator, and the identifier of the application.
[0057] It should be understood that the administrator's identifier, the target shard's identifier, and the application's identifier may be one or more, and the embodiment of the present application does not limit the number of the administrator's identifier, the target shard's identifier, and the application's identifier.
[0058] In actual applications, the first interface may support conditional query and associated query, wherein the conditional query may be based on configuration information that can query a specific resource, and the associated query may query resource information associated with a specific resource.
[0059] Exemplarily, based on the identifier of the target distributed database instance input by the user, the identifier of the target distributed database cluster (cluster ID) corresponding to the identifier of the target distributed database instance can be obtained through an associated query, and the application name, shard identifier (SetId) and administrator to which the target distributed database instance belongs can be obtained through a conditional query.
[0060] S22. Send a spatial distribution query request to the second interface of the distributed database proxy device of the distributed database system according to the target query parameter.
[0061] In actual applications, after obtaining the target query parameters, the target query parameters are packaged to generate a spatial distribution query request, wherein the spatial distribution query request is used to query the spatial distribution information of the target table space corresponding to at least one target shard.
[0062] Among them, the distributed database provides a rich set of operation API interfaces for administrators to manage. These native interfaces can be further encapsulated into a second interface and deployed on a distributed database proxy device to provide a simpler calling mode. In other words, the second interface encapsulates the native interface of the distributed database cluster.
[0063] That is, after generating a spatial distribution query request, the second interface of the distributed database proxy device may be called to query the spatial distribution information of the target table space corresponding to at least one target shard.
[0064] Optionally, the spatial distribution information of the target tablespace includes the total volume of slices, the free volume of slices, and the actual data volume of each target slice in the target tablespace.
[0065] It should be understood that the target distributed database instance is divided into a non-distributed instance and a distributed instance. If the target distributed database instance is a non-distributed instance, the groupId in the spatial distribution query request is set to empty, and only setId needs to be passed in.
[0066] For the distributed database proxy device, after obtaining the spatial distribution query request, it interacts with the target distributed database cluster through the second interface to obtain the spatial distribution information of the target table space.
[0067] Specifically, after obtaining the spatial distribution query request, the distributed database proxy device determines the target distributed database cluster according to the identifier of the target distributed database cluster of the target query parameter. Then, according to the identifier of the target shard in the target query parameter, it is determined whether the identifier of the application corresponding to the identifier of the target shard in the target distributed database cluster and the target distributed database instance are consistent with those in the target query parameter. If they are consistent, the target table space corresponding to the identifier of the target shard is determined from the target distributed database cluster, and then the spatial distribution information of the target table space is obtained.
[0068] In this way, the accuracy of spatial distribution query can be greatly improved through step-by-step verification.
[0069] S23. Obtain the spatial distribution information of the target tablespace returned by the second interface.
[0070] S24. Determine the fragmentation rate of the target tablespace according to the spatial distribution information of the target tablespace.
[0071] In a possible implementation, it can be implemented through the following steps A and B:
[0072] Step A: For each target slice in the target table space, the fragmentation rate of the target slice is determined according to the total slice space, the slice free space and the actual data space of the target slice.
[0073] Specifically, for each target slice in the target tablespace, the total slice space of the target slice is subtracted from the slice free space to obtain a first space difference. Then, the actual data space of the target slice is subtracted from the first space difference to obtain a second space difference. Finally, the ratio between the second space difference and the total slice space is determined as the fragmentation rate of the target slice.
[0074] The total shard space is pre-allocated for the target shard, and the shard free space is the storage space in the target shard that has not been occupied by data, which is used to reflect the potential space capacity in the target shard that can be used to store new data. That is, the shard free space is the continuous storage space in the target shard that is not occupied by data, excluding fragmented space.
[0075] For example, if the total space of the shard is 10G and 2G of data is subsequently stored, the total space of the shard is 10G and the free space of the shard is 8G. If the data is subsequently deleted, the data is fragmented and 1.8G of data is stored in the shard. At this time, the free space of the shard is still 8G.
[0076] That is to say, in practical applications, the space where data is stored can be obtained by subtracting the free space of the shard from the total space of the shard. Since data is fragmented, the fragmented space of the target slice can be obtained by subtracting the actual data space from the space where data is stored, and then the ratio between the fragmented space and the total space of the shard is determined as the fragmentation rate of the target slice.
[0077] For example, a shard has a total of 100 GB, 30 GB of free space, and 70 GB of space for storing data. However, due to data fragmentation, the actual data may only occupy 60 GB, which means that the shard has 10 GB of fragmented space.
[0078] Step B: Determine the fragmentation rate of the target tablespace according to the fragmentation rate of each target slice in the target tablespace.
[0079] In a possible implementation, the average value of the fragmentation rate of each target slice may be determined as the fragmentation rate of the target tablespace.
[0080] In another possible implementation, a weighted average of the fragmentation rates of each target slice may be determined as the fragmentation rate of the target tablespace.
[0081] It should be understood that after obtaining the spatial distribution information of the target tablespace, it is also necessary to convert the units of the data contained therein to ensure that the units of the data are unified when subsequently calculating the fragmentation rate of the target tablespace, thereby ensuring the accuracy of the calculation process.
[0082] The method for determining the fragmentation rate of a distributed database provided in an embodiment of the present application is applied to a configuration management device of a distributed database system, and determines the target query parameters corresponding to the target distributed database instance according to the first interface. Afterwards, according to the target query parameters, a spatial distribution query request is sent to the second interface of the distributed database proxy device of the distributed database system, and the spatial distribution information of the target table space returned by the second interface is obtained; finally, according to the spatial distribution information of the target table space, the fragmentation rate of the target table space is determined. Among them, the target query parameters include the identifier of at least one target shard corresponding to the target distributed database instance, and the first interface encapsulates the query parameters corresponding to different distributed database instances. The second interface encapsulates the native interface of the distributed database cluster, and the spatial distribution query request is used to query the spatial distribution information of the target table space corresponding to at least one target shard. In this technical solution, the first interface and the second interface are used to query the fragmentation rate of the target table space corresponding to the target distributed database instance, and the user does not need to log in to the distributed database, thereby ensuring the efficiency and security of the processing process.
[0083] In some embodiments, the used space and total space of the target database table corresponding to the target slice may be determined based on the correspondence between the database table and the slice. Then, the fragmentation rate of the target database table may be determined based on the used space and total space of the target database table.
[0084] In actual applications, the data in the database table will be distributed to different shards according to certain rules, that is, there is a correspondence between the target database table and the target slice. According to the correspondence between the database table and the slice, the target database table corresponding to the target slice can be determined, and then the used space and total space of the target database table can be obtained by querying the system table or using specific management tools.
[0085] Furthermore, the third space difference value may be obtained by subtracting the used space from the total space, and then the ratio of the third space difference value to the total space is determined as the fragmentation rate of the target database table.
[0086] For example, if the total space of the target database table is 100MB and the used space is 60MB, then the fragmentation rate = (100-60) / 100 = 40%, which means that 40% of the space in the target database table may be fragmented, and operations such as defragmentation may be required to improve the efficiency of table space usage.
[0087] In the above embodiment, since the target tablespace is a logical storage unit for storing database objects, and the database table is a structure for storing actual data, it is the main carrier of data in the tablespace. Therefore, when calculating the fragmentation rate of the target tablespace, the fragmentation rate of the target database table included in the target tablespace can be further refined, so that it can be more accurately located which specific target database tables have serious fragmentation problems, thereby improving the efficiency of problem solving. For example, in a target tablespace containing multiple target database tables (such as order tables, user tables, product tables, etc.), the fragmentation rate of the overall tablespace may appear to be within an acceptable range. However, after refining each table, it may be found that the order table has a very high fragmentation rate due to frequent insertion and deletion operations, while the fragmentation rates of other target database tables are lower. This allows the administrator to accurately know that there is a problem with the storage structure of the order table and it needs to be dealt with first.
[0088] In some embodiments, when the fragmentation rate of the target database table is greater than the first fragmentation rate and the free space of the target database table is greater than the first preset space, a first reminder message is sent to the terminal device used by the administrator.
[0089] The first reminder information is used to remind the administrator to process the fragmented space of the target database table.
[0090] Exemplarily, the first fragmentation rate may be 40%, 50%, 60%, etc., which may be determined according to actual conditions, and the embodiments of the present application do not impose any specific limitation on this.
[0091] Exemplarily, the first preset space can be 5G, 10G, or 15G, which can also be determined according to actual conditions. The embodiments of the present application do not impose specific restrictions on this.
[0092] In some embodiments, the sum of the free spaces of all target slices in the target tablespace is determined as the free subspace of the target tablespace. If the free subspace in the target tablespace is larger than the second preset space, a second reminder message is sent to the terminal device used by the administrator.
[0093] The second reminder information is used to remind the administrator to determine whether the target table space has a problem of too many fragmented subspaces, and the second preset space is larger than the first preset space.
[0094] Exemplarily, the second preset space can be 50G, 55G, or 60G, which can also be determined according to actual conditions. The embodiments of the present application do not impose specific restrictions on this.
[0095] In actual applications, multiple statistical dimensions can be divided according to daily operation and maintenance needs. For tablespaces, three dimensions can be included: free subspace ≤ 50GB, 50GB < free subspace ≤ 100GB, and free subspace > 100GB; for database tables, free space greater than 10G and fragmentation rate greater than 50% can be included. Considering that the available capacity of the target tablespace is large, it means that there is a possibility that the fragmented subspace is mistakenly determined as the free subspace, so the administrator is reminded to check and confirm.
[0096] Optionally, when the fragmentation rate of the target database table is greater than the first fragmentation rate and the free space of the target database table is greater than the first preset space, the identifier of the target database table can be obtained; when the free subspace in the target tablespace is greater than the second preset space, the identifier of the target tablespace can be obtained. The identifier of the target database table and the identifier of the target tablespace are then stored in a report, uploaded to a system file manager, and the administrator is reminded to download and view the report.
[0097] It should be understood that the above-mentioned user and administrator may be the same person or different persons, which may be determined based on actual circumstances.
[0098] Figure 3 Schematic diagram of the process of determining the fragmentation rate of a distributed database provided in an embodiment of the present application Figure 2 ,like Figure 3 As shown, the method for determining the fragmentation rate of the distributed database includes the following steps:
[0099] S31. Obtain target query parameters corresponding to the target distributed database instance through the first interface.
[0100] S32: Encapsulate the target query parameters to generate a spatial distribution query request.
[0101] Among them, S31-S32 is the parameter encapsulation process.
[0102] S33. Send a spatial distribution query request to the second interface of the distributed database proxy device.
[0103] Among them, S33 is the parameter (spatial distribution information) request process.
[0104] S34. Obtain the spatial distribution information of the target table space returned by the second interface, and normalize the data units of the spatial distribution information.
[0105] S35. Determine the fragmentation rate of the target tablespace according to the spatial distribution information of the target tablespace.
[0106] S36. Count the identifiers of the target database tables and the identifiers of the target tablespaces that meet the preset conditions, and generate a report.
[0107] S37. Upload the generated report to the system file manager.
[0108] S38: Determine whether the upload is successful.
[0109] If successful, the process ends; if unsuccessful, the process proceeds to S39.
[0110] S39, prompt "Generation failed".
[0111] Among them, S33-S39 is the result processing process.
[0112] It should be understood that the implementation method and principle of each step in this embodiment have been explained in the above embodiment and will not be repeated here.
[0113] In the distributed database fragmentation rate determination solution proposed in any of the above embodiments, the query parameters are encapsulated through the first interface to implement batch query of each set corresponding to the distributed database instance, simplify parameter input, and improve query efficiency. At the same time, the user does not need to log in to the distributed database, thereby ensuring the efficiency and security of the processing process.
[0114] The following are device embodiments of the present application, which can be used to execute the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
[0115] Figure 4A schematic diagram of the structure of a fragmentation rate determination device for a distributed database provided in this application, such as Figure 4 As shown, the distributed database fragmentation rate determination device 40 provided in this embodiment is applied to a configuration management device of a distributed database system, and the distributed database fragmentation rate determination device 40 includes:
[0116] The determination module 41 is used to determine the target query parameters corresponding to the target distributed database instance according to the first interface. The target query parameters include the identifier of at least one target shard corresponding to the target distributed database instance. The first interface encapsulates the query parameters corresponding to different distributed database instances.
[0117] The sending module 42 is used to send a spatial distribution query request to the second interface of the distributed database proxy device of the distributed database system according to the target query parameters. The second interface encapsulates the native interface of the distributed database cluster. The spatial distribution query request is used to query the spatial distribution information of the target table space corresponding to at least one target shard.
[0118] The receiving module 43 is used to receive the space distribution information of the target table space returned by the second interface.
[0119] The determination module 41 is further configured to determine the fragmentation rate of the target table space according to the spatial distribution information of the target table space.
[0120] In a possible implementation, the spatial distribution information of the target tablespace includes the total volume of slices, the free volume of slices, and the actual data volume of each target slice in the target tablespace. The determination module 41 is specifically used to:
[0121] For each target slice in the target tablespace, the fragmentation rate of the target slice is determined according to the total slice space, the slice free space, and the actual data space of the target slice.
[0122] The fragmentation rate of the target tablespace is determined based on the fragmentation rate of each target slice in the target tablespace.
[0123] In a possible implementation, the determining module 41 is further configured to:
[0124] According to the correspondence between the target database table and the target slice, the used space and the total space of the target database table are determined.
[0125] Determine the fragmentation rate of the target database table based on the used space and total space of the target database table.
[0126] In a possible implementation, the sending module 42 is also used to send a first reminder message to a terminal device used by an administrator when the fragmentation rate of the target database table is greater than a first fragmentation rate, and the used space of the target database table is greater than a first preset space and the free space is greater than the first preset space. The first reminder message is used to remind the administrator to process the fragmented space of the target database table.
[0127] In a possible implementation, the sending module 42 is further configured to:
[0128] The sum of the free spaces of all target slices in the target tablespace is determined as the free subspace of the target tablespace.
[0129] If the free subspace in the target tablespace is larger than the second preset space, a second reminder message is sent to the terminal device used by the administrator. The second reminder message is used to remind the administrator to determine whether there is a problem of too many fragmented subspaces in the target tablespace. The second preset space is larger than the first preset space.
[0130] In a possible implementation, the target query parameter further includes an identifier of a target distributed database cluster, an identifier of a target distributed database instance, an identifier of an administrator, and an identifier of an application program.
[0131] In a possible implementation, the determination module 41 is specifically configured to:
[0132] For each target slice in the target tablespace, the slice free space is subtracted from the slice total space of the target slice to obtain a first space difference.
[0133] The actual data space of the target slice is subtracted from the first spatial difference to obtain a second spatial difference.
[0134] The ratio between the second spatial difference and the total space of the slice is determined as the fragmentation rate of the target slice.
[0135] The device for determining the fragmentation rate of a distributed database provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be described in detail here.
[0136] Figure 5 This is a schematic diagram of the configuration management device provided in this application. Figure 5 As shown, the configuration management device 50 provided in this embodiment includes: at least one processor 501 and a memory 502. Optionally, the configuration management device 50 also includes a communication component 503. The processor 501, the memory 502 and the communication component 503 are connected via a bus 504.
[0137] In a specific implementation process, at least one processor 501 executes the computer-executable instructions stored in the memory 502, so that at least one processor 501 executes the above method.
[0138] The specific implementation process of the processor 501 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0139] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0140] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (Non-volatile Memory, NVM), such as at least one disk memory.
[0141] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0142] The present application also provides a computer program product, including a computer program, which implements the above method when executed by a processor.
[0143] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the above method is implemented.
[0144] The above-mentioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0145] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.
[0146] The division of units is only a logical function division, and there may be other divisions in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.
[0147] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0148] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0149] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0150] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0151] Finally, it should be noted that those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention, which follow the general principles of the present invention and include common knowledge or customary technical means in the art not disclosed by the present invention, are not limited to the precise structure described above and shown in the drawings, and may be modified and changed in various ways without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
Claims
1. A method for determining the fragmentation rate of a distributed database, characterized in that: A configuration management device applied to a distributed database system, the method comprising: Determine, according to the first interface, a target query parameter corresponding to the target distributed database instance, wherein the target query parameter includes an identifier of at least one target shard corresponding to the target distributed database instance, and the first interface encapsulates query parameters corresponding to different distributed database instances; According to the target query parameter, a spatial distribution query request is sent to a second interface of a distributed database proxy device of the distributed database system, where the second interface encapsulates a native interface of a distributed database cluster, and the spatial distribution query request is used to query spatial distribution information of a target table space corresponding to at least one target shard; Acquire the spatial distribution information of the target tablespace returned by the second interface; The fragmentation rate of the target tablespace is determined according to the spatial distribution information of the target tablespace.
2. The method according to claim 1, characterized in that The spatial distribution information of the target tablespace includes the total volume of slices, the free volume of slices, and the actual data volume of each target slice in the target tablespace. Determining the fragmentation rate of the target tablespace according to the spatial distribution information of the target tablespace includes: For each target slice in the target tablespace, determine the fragmentation rate of the target slice according to the total slice space, the slice free space and the actual data space of the target slice; The fragmentation rate of the target tablespace is determined according to the fragmentation rate of each target slice in the target tablespace.
3. The method according to claim 2, characterized in that The method further comprises: Determine the used space and total space of the target database table corresponding to the target slice according to the correspondence between the database table and the slice; The fragmentation rate of the target database table is determined according to the used space and the total space of the target database table.
4. The method according to claim 3, characterized in that The method further comprises: When the fragmentation rate of the target database table is greater than the first fragmentation rate and the free space of the target database table is greater than the first preset space, a first reminder message is sent to a terminal device used by an administrator, and the first reminder message is used to remind the administrator to process the fragmented space of the target database table.
5. The method according to any one of claims 2 to 4, characterized in that: The method further comprises: Determine the sum of the free spaces of all target slices in the target tablespace as the free subspace of the target tablespace; If the free subspace in the target tablespace is larger than the second preset space, a second reminder message is sent to the terminal device used by the administrator, and the second reminder message is used to remind the administrator to determine whether there is a problem of too many fragmented subspaces in the target tablespace, and the second preset space is larger than the first preset space.
6. The method according to claim 4, characterized in that The target query parameters also include an identifier of a target distributed database cluster, an identifier of a target distributed database instance, an identifier of the administrator, and an identifier of an application program.
7. The method according to any one of claims 2 to 4, characterized in that: The determining, for each target slice in the target tablespace, the fragmentation rate of the target slice according to the total slice space, the slice free space, and the actual data space of the target slice, includes: For each target slice in the target tablespace, subtract the slice free space from the slice total space of the target slice to obtain a first space difference; Subtract the actual data space of the target slice from the first spatial difference to obtain a second spatial difference; The ratio between the second spatial difference and the total space of the slice is determined as the fragmentation rate of the target slice.
8. A device for determining the fragmentation rate of a distributed database, characterized in that: A configuration management device applied to a distributed database system, the device comprising: A determination module, configured to determine a target query parameter corresponding to a target distributed database instance according to a first interface, wherein the target query parameter includes an identifier of at least one target shard corresponding to the target distributed database instance, and wherein the first interface encapsulates query parameters corresponding to different distributed database instances; A sending module, configured to send a spatial distribution query request to a second interface of a distributed database proxy device of the distributed database system according to the target query parameter, wherein the second interface encapsulates a native interface of a distributed database cluster, and the spatial distribution query request is used to query spatial distribution information of a target table space corresponding to at least one target shard; A receiving module, configured to receive the spatial distribution information of the target tablespace returned by the second interface; The determination module is further used to determine the fragmentation rate of the target table space according to the spatial distribution information of the target table space.
9. A configuration management device, characterized in that: include: Memory, processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.
Citation Information
Cited By
Defragmentation method and device for GoldenDB database and medium
CN121901212A