HBase full data import method, device, computer equipment and storage medium
By caching and deleting historical data files in the HBase database, the problem of server write amplification and service interruption when importing full data is solved, achieving stable online provision of data tables and reducing IO pressure.
Patent Information
- Application Number
- CN202011416521.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-04
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2040-12-04
AI Technical Summary
The existing HBase data import method causes server write amplification and service interruption when importing all offline data, affecting cluster stability. Especially when historical data increases, the service interruption time becomes longer.
Cache historical data files in the HBase database into memory containers and delete them after importing all data, avoiding merge operations and table clearing operations, and ensuring that data tables are always available online.
It avoids service interruption and write amplification problems, reduces database IO pressure, and ensures service stability and user experience.
Smart Images

Figure CN112395345B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a method, device, computer equipment and storage medium for importing full data into HBase. Background Art
[0002] Currently, the offline data import function of open source HBase provides two different data import methods. The first is to directly import offline data, and the second is to perform a table clearing operation and then import offline data.
[0003] Among them, the first data import method, when there is a large amount of historical data in the data table to be imported or the full amount of offline data is frequently imported, will cause the server to perform data merging operations, which will lead to server write amplification problems and seriously affect the stability of the HBase cluster; the second data import method requires importing offline data after clearing the data table, which will cause the data table to be unavailable during the clearing period. As the historical data of the table increases, the service interruption time will also increase accordingly.
[0004] In summary, it is urgent to propose a new data import method to solve the above problems. Summary of the invention
[0005] In order to solve the problems of the prior art, the embodiments of the present invention provide a method, apparatus, computer device and storage medium for importing full data of HBase, so as to overcome the problems existing in the prior art that the data table is unavailable during the table clearing period due to importing offline data after the table is cleared, and the service interruption time will be longer as the historical data of the table increases.
[0006] In order to solve one or more of the above technical problems, the technical solution adopted by the present invention is:
[0007] In a first aspect, a method for importing full data into HBase is provided, the method comprising the following steps:
[0008] Receive a data import request, and determine a target data table corresponding to the to-be-imported data in a target database according to the data import request, wherein the target database includes an HBase database;
[0009] Cache the historical data file corresponding to the target data table into a preset memory container;
[0010] Import the data to be imported into the target database;
[0011] The historical data file is deleted from the memory container.
[0012] Furthermore, caching the historical data file corresponding to the target data table into a preset memory container includes:
[0013] A memory container is determined in the target database, and the historical data file corresponding to the target data table is cached in the memory container.
[0014] Further, deleting the historical data file from the memory container includes:
[0015] Traverse the historical data files in the memory container to determine whether each of the historical data files is occupied. If not, physically delete the historical data file; otherwise, abandon the deletion operation.
[0016] Further, deleting the historical data file from the memory container includes:
[0017] After adding a write lock to the region of the target data table, the historical data file is deleted from the memory container.
[0018] Further, the data import request includes a historical data cleaning parameter, and the caching of the historical data file corresponding to the target data table into a preset memory container includes:
[0019] When it is identified that the data import request includes a historical data cleaning parameter, the historical data file corresponding to the target data table is cached in a preset memory container.
[0020] Furthermore, the method further comprises:
[0021] The data volume in the target database is detected periodically. If the data volume exceeds a preset threshold, a merge operation is performed on the data files in the target database, where the data files include the historical data files and the to-be-imported data that has been imported into the target database.
[0022] Further, the step of importing the data to be imported into the target database includes:
[0023] Write the data to be imported into the region directory corresponding to the target data table.
[0024] In a second aspect, a device for importing full data into HBase is provided, the device comprising:
[0025] A data table determination module is used to receive a data import request, and determine a target data table corresponding to the data to be imported in a target database according to the data import request, wherein the target database includes an HBase database;
[0026] A data cache module, used to cache the historical data files corresponding to the target data table into a preset memory container;
[0027] A data import module is used to import the data to be imported into the target database;
[0028] A data deletion module is used to delete the historical data file from the memory container.
[0029] In a third aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following steps are implemented:
[0030] Receive a data import request, and determine a target data table corresponding to the to-be-imported data in a target database according to the data import request, wherein the target database includes an HBase database;
[0031] Cache the historical data file corresponding to the target data table into a preset memory container;
[0032] Import the data to be imported into the target database;
[0033] The historical data file is deleted from the memory container.
[0034] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0035] Receive a data import request, and determine a target data table corresponding to the to-be-imported data in a target database according to the data import request, wherein the target database includes an HBase database;
[0036] Cache the historical data file corresponding to the target data table into a preset memory container;
[0037] Import the data to be imported into the target database;
[0038] The historical data file is deleted from the memory container.
[0039] The technical solution provided by the embodiment of the present invention has the following beneficial effects:
[0040] The full data import method, device, computer equipment and storage medium of HBase provided by the embodiments of the present invention receive a data import request, determine the target data table corresponding to the data to be imported in the target database according to the data import request, the target database includes an HBase database, cache the historical data file corresponding to the target data table in a preset memory container, import the data to be imported into the target database, delete the historical data file from the memory container, and do not need to perform a table clearing operation on the data table of the data to be imported, thereby ensuring that the data table is always online and provides services to the outside world, without user perception of the service, avoiding service interruption problems, and reducing merge operations in the database, greatly reducing the IO pressure on the server, preventing the problem of write amplification, and ensuring the stability of the service. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0042] Figure 1 is a working principle diagram of a full data import method in the prior art according to an exemplary embodiment;
[0043] Figure 2 is a working principle diagram of a full data import method of the present invention according to an exemplary embodiment;
[0044] Figure 3 is a flowchart of a method for importing full data into HBase according to an exemplary embodiment;
[0045] Figure 4 is a flowchart of a method for importing full data into HBase according to an exemplary embodiment;
[0046] Figure 5 is a structural schematic diagram of a device for importing full data into HBase according to an exemplary embodiment;
[0047] Figure 6 The figure is a schematic diagram showing the internal structure of a computer device according to an exemplary embodiment. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is only a part of the embodiment of the present invention, not all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0049] As described in the background technology, users on HBase need to import a large amount of full offline data regularly. Currently, there are two ways to import data: direct import and import after clearing the table. On the one hand, direct import of full data will trigger the merging (Compaction) operation of related data tables, occupying a large amount of IO resources of the server, resulting in high request latency or even blocking; on the other hand, Figure 1 is a working principle diagram of a full data import method in the prior art according to an exemplary embodiment, referring to Figure 1 As shown in the figure, since the table clearing operation requires the data table to be offline first and then online after the table clearing is completed, if the table is cleared and then imported, the data table will be unavailable during the table clearing period, resulting in service interruption.
[0050] To solve the above problems, an embodiment of the present invention creatively proposes a full data import method for HBase. When executing the full data import operation in the HBase database, the method first caches the historical data files in a predefined memory container, and then executes the import of the full offline data. After the import is completed, the historical data files in the memory container are cleared. This operation can directly avoid the server from performing a merging (Compaction) operation on the one hand, and on the other hand, there is no need to clear the data table, which can ensure that the data table of the data to be imported always provides services to the outside world, thereby ensuring the stability of the service. Figure 2 is a working principle diagram of the full data import method of the present invention according to an exemplary embodiment, referring to Figure 2 As shown, the system includes but is not limited to a client and an HBase cluster, wherein: Figure 1 and Figure 2 Some of the terms in the explanation are as follows
[0051] Client: The client refers to the machine where the user imports offline data.
[0052] rpc: The offline data import request initiated by the client to the RegionServer is implemented using rpc;
[0053] RegionServer: A role in the HBase cluster, responsible for the actual reading and writing of table data and managing the region of the table;
[0054] bulkload: A general term for the specific methods executed by RegionServer on the server side;
[0055] save: save the current historical data file;
[0056] move: file transfer operation, which transfers the offline data that the user needs to import to the region directory;
[0057] load: open and load the imported file;
[0058] clear: Delete the historical data file saved previously.
[0059] Embodiment 1
[0060] Figure 3 is a flowchart of a method for importing full data into HBase according to an exemplary embodiment. Figure 3 As shown, the above solution can be implemented through the following steps:
[0061] Step 1: Import offline data on the client and set the parameter switch for clearing historical data. The switch is off by default.
[0062] Specifically, a parameter switch for clearing historical data can be set by the client, and the parameter switch for clearing historical data can be sent to the server together with the data import request. The parameter switch is used to indicate whether historical data needs to be cleared. When the parameter switch is turned on, it means that historical data needs to be cleared, and when the parameter switch is turned off, it means that historical data does not need to be cleared. In an embodiment of the present invention, when a full data import operation needs to be performed, the parameter switch for clearing historical data is turned on, and the parameter switch for clearing historical data is turned off for other data import operations (such as incremental data import).
[0063] Step 2: The client initiates an offline data import request;
[0064] Specifically, when offline data needs to be imported, the user can initiate an offline data import request to the HBase cluster through the client. If it is full data, the clear historical data parameter switch carried in the data import request is turned on.
[0065] Further references Figure 2It can be seen that, as a preferred implementation method, in the embodiment of the present invention, the data import request can be implemented in the RPC mode, that is, the client and the server can communicate with each other through the corresponding RPC request of bulkload, so firstly, the RPC request needs to be modified so that it can support the setting of clearing historical data parameters. Secondly, when the user submits the data import time, it is through the command line, so it is necessary to add the setting method of clearing historical data parameters in the entry method of the command line.
[0066] Step 3: The server receives the user's offline data import request and checks the clear history data switch carried in the request.
[0067] Specifically, after receiving the data import request sent by the user through the client, the server parses the request and obtains the historical data clearing switch carried by the request from the parsing result. If it is on, it means that the historical data needs to be cleared, and if it is off, it means that the historical data does not need to be cleared. In addition, the target data table corresponding to the data to be imported needs to be determined according to the data import request.
[0068] Step 4: If it is detected that the historical data clearing switch is turned on, the historical data file is stored in a preset memory container;
[0069] Specifically, if it is detected that the switch for clearing historical data is on, it means that this data import request corresponds to a full data import, and the historical data files need to be cleared. On the one hand, directly importing the full data will cause the server to perform a large number of merge operations, which will lead to server write amplification problems and affect the stability of the service. On the other hand, since the data import is performed after the table is cleared, the data table will be unavailable during the table clearing period, causing service interruption. To solve the above problems, in an embodiment of the present invention, when executing the full data import, the historical data files will first be stored in a preset memory container. In specific implementation, a memory container (filesToClear) can be opened on the server side, and the historical data files can be cached in the memory container to avoid confusion between the historical data files and the currently imported offline data. When caching the historical data files in the memory container, all historical data files of the target data table in the current node region can be traversed and saved in the memory container.
[0070] Step 5: Execute offline data import;
[0071] Specifically, the data to be imported (hfile) is transferred to the current region of the target data table, and the hfile is loaded at the same time.
[0072] Step 6: Delete the historical data file from the memory container;
[0073] Specifically, after the data is imported, the historical data files in the memory container are traversed and each historical data file is processed.
[0074] Since the merge operation (compaction) is asynchronous, it may be triggered between saving the list of historical data files and deleting the files. Therefore, during the specific implementation, first check whether the historical data file still exists, because it is possible that the merge operation was automatically triggered during the offline data import and it has been automatically deleted by regionsever. Secondly, remove the historical data files that have been added to the container of files to be merged. During the offline data import, it is possible that regionsever triggered a merge operation. At this time, the historical data files to be merged will be referenced by the merge operation and will be added to the container of files to be merged. At this time, the historical data file cannot be deleted directly. It is necessary to wait until it is merged before deleting it to prevent errors. Finally, close all historical data files before deleting them.
[0075] Step 7: The server sends a successful response to the client.
[0076] Specifically, after completing the offline data import and historical data clearing, the server returns feedback information of successful execution to the client.
[0077] It should be noted here that there are usually two ways to trigger the merge (Compaction) operation in HBase. One is that the client actively calls the admin-related interface, and the other is the automatic detection of the scheduled task on the server (for example, it is executed every 10 seconds by default). If it is found in the scheduled task of Compaction that Compaction needs to be performed this time (for example, when the number of files exceeds the preset number, or the total size of the files exceeds the preset threshold), a merge task will be generated and asynchronously submitted to the thread pool for execution. The shorter the interval between the data import operation and the historical data cleanup operation, the lower the probability of triggering Compaction. According to the above steps, we can know that the operation between step five and step six is at the millisecond level, so the triggering probability of Compaction will be greatly reduced, thereby greatly reducing the IO pressure on the server, preventing write amplification problems, and improving the stability of the service.
[0078] Figure 4 is a flowchart of a method for importing full data into HBase according to an exemplary embodiment. Figure 4 As shown, the method comprises the following steps:
[0079] S1: receiving a data import request, and determining a target data table corresponding to the data to be imported in a target database according to the data import request, wherein the target database includes an HBase database;
[0080] S2: Cache the historical data file corresponding to the target data table into a preset memory container;
[0081] S3: Import the data to be imported into the target database;
[0082] S4: Delete the historical data file from the memory container.
[0083] Specifically, in an embodiment of the present invention, when a full data import operation is executed again, the historical data files corresponding to the target data table corresponding to the data to be imported are cached in a preset memory container to avoid confusion between the historical data files and the currently imported offline data. On the one hand, this can reduce the triggering of the server-side merge operation, and on the other hand, there is no need to perform a table clearing operation first, thereby avoiding service interruption caused by the unavailability of the data table.
[0084] As a preferred implementation, in an embodiment of the present invention, caching the historical data file corresponding to the target data table into a preset memory container includes:
[0085] A memory container is determined in the target database, and the historical data file corresponding to the target data table is cached in the memory container.
[0086] Specifically, the memory container can be a storage space opened in the target database (ie, the server), and the memory container can be released after the historical data files are deleted.
[0087] As a preferred implementation, in an embodiment of the present invention, deleting the historical data file from the memory container includes:
[0088] Traverse the historical data files in the memory container to determine whether each of the historical data files is occupied. If not, physically delete the historical data file; otherwise, abandon the deletion operation.
[0089] Specifically, since the compaction operation is asynchronous, it may be triggered between saving the historical data file list and deleting the file. Before clearing the historical data file, it is necessary to determine whether the historical data file is occupied by the compaction operation. If so, abandon the deletion operation and retain the historical data file to prevent errors. The historical data file occupied by the compaction operation will be automatically deleted after the compaction operation is completed. It should be noted here that in the embodiment of the present invention, physical deletion means that the magnetic storage area used for file storage is actually erased or cleared, so that the deleted files cannot be recovered.
[0090] As a preferred implementation, in an embodiment of the present invention, deleting the historical data file from the memory container includes:
[0091] After adding a write lock to the region of the target data table, the historical data file is deleted from the memory container.
[0092] Specifically, before deleting a file, it is necessary to obtain a write lock and block the user from reading it to prevent the user from misreading the historical data file that will be deleted later.
[0093] As a preferred implementation, in an embodiment of the present invention, the data import request includes a historical data cleaning parameter, and the caching of the historical data file corresponding to the target data table into a preset memory container includes:
[0094] When it is identified that the data import request includes a historical data cleaning parameter, the historical data file corresponding to the target data table is cached in a preset memory container.
[0095] Specifically, a parameter switch for clearing historical data may be set in the data import request, and the parameter switch is used to indicate whether historical data needs to be cleared. When the parameter switch is turned on, it indicates that historical data needs to be cleared, and when the parameter switch is turned off, it indicates that historical data does not need to be cleared. In an embodiment of the present invention, when a full data import operation needs to be performed, the parameter switch for clearing historical data is turned on, and the parameter switch for clearing historical data is turned off for other data import operations (such as incremental data import).
[0096] As a preferred implementation, in an embodiment of the present invention, the method further includes:
[0097] The data volume in the target database is detected periodically. If the data volume exceeds a preset threshold, a merge operation is performed on the data files in the target database, where the data files include the historical data files and the to-be-imported data that has been imported into the target database.
[0098] As a preferred implementation, in the embodiment of the present invention, the step of importing the data to be imported into the target database includes:
[0099] Write the data to be imported into the region directory corresponding to the target data table.
[0100] Figure 5 : is a schematic diagram of a structure of a device for importing full data into HBase according to an exemplary embodiment, the device comprising:
[0101] A data table determination module is used to receive a data import request, and determine a target data table corresponding to the data to be imported in a target database according to the data import request, wherein the target database includes an HBase database;
[0102] A data cache module, used to cache the historical data files corresponding to the target data table into a preset memory container;
[0103] A data import module is used to import the data to be imported into the target database;
[0104] A data deletion module is used to delete the historical data file from the memory container.
[0105] As a preferred implementation, in the embodiment of the present invention, the data cache module is specifically used for:
[0106] A memory container is determined in the target database, and the historical data file corresponding to the target data table is cached in the memory container.
[0107] As a preferred implementation, in the embodiment of the present invention, the data deletion module is specifically used for:
[0108] Traverse the historical data files in the memory container to determine whether each of the historical data files is occupied. If not, physically delete the historical data file; otherwise, abandon the deletion operation.
[0109] As a preferred implementation, in the embodiment of the present invention, the data deletion module is further specifically used for:
[0110] After adding a write lock to the region of the target data table, the historical data file is deleted from the memory container.
[0111] As a preferred implementation, in the embodiment of the present invention, the data cache module is further specifically used for:
[0112] When it is identified that the data import request includes a historical data cleaning parameter, the historical data file corresponding to the target data table is cached in a preset memory container.
[0113] As a preferred implementation, in the embodiment of the present invention, the device further includes:
[0114] The data merging module is used to periodically detect the amount of data in the target database. If the amount of data exceeds a preset threshold, a merging operation is performed on the data files in the target database, where the data files include the historical data files and the data to be imported that have been imported into the target database.
[0115] As a preferred implementation, in the embodiment of the present invention, the data import module is specifically used for:
[0116] Write the data to be imported into the region directory corresponding to the target data table.
[0117] Figure 6 is a schematic diagram of the internal structure of a computer device according to an exemplary embodiment. Figure 6 As shown, the computer device includes a processor, a memory and a network interface connected through a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, an optimization method for an execution plan is implemented.
[0118] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present invention, and does not constitute a limitation on the computer device to which the solution of the present invention is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0119] As a preferred implementation, in an embodiment of the present invention, a computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented:
[0120] Receive a data import request, and determine a target data table corresponding to the to-be-imported data in a target database according to the data import request, wherein the target database includes an HBase database;
[0121] Cache the historical data file corresponding to the target data table into a preset memory container;
[0122] Import the data to be imported into the target database;
[0123] The historical data file is deleted from the memory container.
[0124] As a preferred implementation, in the embodiment of the present invention, the processor further implements the following steps when executing the computer program:
[0125] A memory container is determined in the target database, and the historical data file corresponding to the target data table is cached in the memory container.
[0126] As a preferred implementation, in the embodiment of the present invention, the processor further implements the following steps when executing the computer program:
[0127] Traverse the historical data files in the memory container to determine whether each of the historical data files is occupied. If not, physically delete the historical data file; otherwise, abandon the deletion operation.
[0128] As a preferred implementation, in the embodiment of the present invention, the processor further implements the following steps when executing the computer program:
[0129] After adding a write lock to the region of the target data table, the historical data file is deleted from the memory container.
[0130] As a preferred implementation, in the embodiment of the present invention, the processor further implements the following steps when executing the computer program:
[0131] When it is identified that the data import request includes a historical data cleaning parameter, the historical data file corresponding to the target data table is cached in a preset memory container.
[0132] As a preferred implementation, in the embodiment of the present invention, the processor further implements the following steps when executing the computer program:
[0133] The data volume in the target database is detected periodically. If the data volume exceeds a preset threshold, a merge operation is performed on the data files in the target database, where the data files include the historical data files and the to-be-imported data that has been imported into the target database.
[0134] As a preferred implementation, in the embodiment of the present invention, the processor further implements the following steps when executing the computer program:
[0135] Write the data to be imported into the region directory corresponding to the target data table.
[0136] In an embodiment of the present invention, a computer-readable storage medium is further provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0137] Receive a data import request, and determine a target data table corresponding to the to-be-imported data in a target database according to the data import request, wherein the target database includes an HBase database;
[0138] Cache the historical data file corresponding to the target data table into a preset memory container;
[0139] Import the data to be imported into the target database;
[0140] The historical data file is deleted from the memory container.
[0141] As a preferred implementation, in the embodiment of the present invention, when the computer program is executed by the processor, the following steps are also implemented:
[0142] A memory container is determined in the target database, and the historical data file corresponding to the target data table is cached in the memory container.
[0143] As a preferred implementation, in the embodiment of the present invention, when the computer program is executed by the processor, the following steps are also implemented:
[0144] Traverse the historical data files in the memory container to determine whether each of the historical data files is occupied. If not, physically delete the historical data file; otherwise, abandon the deletion operation.
[0145] As a preferred implementation, in the embodiment of the present invention, when the computer program is executed by the processor, the following steps are also implemented:
[0146] After adding a write lock to the region of the target data table, the historical data file is deleted from the memory container.
[0147] As a preferred implementation, in the embodiment of the present invention, when the computer program is executed by the processor, the following steps are also implemented:
[0148] When it is identified that the data import request includes a historical data cleaning parameter, the historical data file corresponding to the target data table is cached in a preset memory container.
[0149] As a preferred implementation, in the embodiment of the present invention, when the computer program is executed by the processor, the following steps are also implemented:
[0150] The data volume in the target database is detected periodically. If the data volume exceeds a preset threshold, a merge operation is performed on the data files in the target database, where the data files include the historical data files and the to-be-imported data that has been imported into the target database.
[0151] As a preferred implementation, in the embodiment of the present invention, when the computer program is executed by the processor, the following steps are also implemented:
[0152] Write the data to be imported into the region directory corresponding to the target data table.
[0153] In summary, the technical solution provided by the embodiment of the present invention has the following beneficial effects:
[0154] The full data import method, device, computer equipment and storage medium of HBase provided by the embodiments of the present invention receive a data import request, determine the target data table corresponding to the data to be imported in the target database according to the data import request, the target database includes an HBase database, cache the historical data file corresponding to the target data table in a preset memory container, import the data to be imported into the target database, delete the historical data file from the memory container, and do not need to perform a table clearing operation on the data table of the data to be imported, thereby ensuring that the data table is always online and provides services to the outside world, without user perception of the service, avoiding service interruption problems, and reducing merge operations in the database, greatly reducing the IO pressure on the server, preventing the problem of write amplification, and ensuring the stability of the service.
[0155] It should be noted that: the full data import device for HBase provided in the above embodiment only uses the division of the above functional modules as an example when triggering the data import service. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the full data import device for HBase provided in the above embodiment and the full data import method embodiment for HBase belong to the same concept, that is, the device is based on the full data import method for HBase. The specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0156] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0157] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for importing full data into HBase, characterized in that: The method comprises the following steps: Receive a data import request, and determine a target data table corresponding to the to-be-imported data in a target database according to the data import request, wherein the target database includes an HBase database; Cache the historical data file corresponding to the target data table into a preset memory container; Import the data to be imported into the target database; Deleting the historical data file from the memory container; The step of caching the historical data file corresponding to the target data table into a preset memory container includes: Determine a memory container in the target database, and cache the historical data file corresponding to the target data table into the memory container; After the historical data file is deleted, the memory container can be released.
2. The method for importing full data into HBase according to claim 1, characterized in that: Deleting the historical data file from the memory container includes: Traverse the historical data files in the memory container to determine whether each of the historical data files is occupied. If not, physically delete the historical data file; otherwise, abandon the deletion operation.
3. The method for importing full data into HBase according to claim 1, characterized in that: Deleting the historical data file from the memory container includes: After adding a write lock to the region of the target data table, the historical data file is deleted from the memory container.
4. The method for importing full data into HBase according to claim 1, characterized in that: The data import request includes a historical data cleaning parameter, and the caching of the historical data file corresponding to the target data table into a preset memory container includes: When it is identified that the data import request includes a historical data cleaning parameter, the historical data file corresponding to the target data table is cached in a preset memory container.
5. The method for importing full data into HBase according to claim 1, characterized in that: The method further comprises: The data volume in the target database is detected periodically. If the data volume exceeds a preset threshold, a merge operation is performed on the data files in the target database, where the data files include the historical data files and the to-be-imported data that has been imported into the target database.
6. The method for importing full data into HBase according to claim 1, characterized in that: The step of importing the data to be imported into the target database comprises: Write the data to be imported into the region directory corresponding to the target data table.
7. A full data import device for HBase, characterized in that: The device comprises: A data table determination module is used to receive a data import request, and determine a target data table corresponding to the data to be imported in a target database according to the data import request, wherein the target database includes an HBase database; A data cache module, used to cache the historical data files corresponding to the target data table into a preset memory container; A data import module is used to import the data to be imported into the target database; A data deletion module, used to delete the historical data file from the memory container; The data cache module is specifically used to determine a memory container in the target database, and cache the historical data files corresponding to the target data table into the memory container, wherein the memory container can be released after the historical data files are deleted.
8. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
