A networked Hive table data loading method
By using the networked loading method in Hive table data loading, using the remote loading process and intelligent optimization mechanism, the problem of insufficient flexibility when the server cannot directly access the data storage node is solved, and efficient and safe data import is achieved, adapting to Different environments improve data processing efficiency and user satisfaction.
Patent Information
- Application Number
- CN202410866252.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-07-01
AI Technical Summary
In traditional Hive usage scenarios, when the server node cannot directly access the node where the data is stored, using Hive's load command to load data on the local disk into the Hive table will encounter the problem of insufficient flexibility, affecting the efficiency of data processing. and convenience, especially not effective enough in large-scale data and real-time data loading scenarios.
Provide a networked Hive table data loading method by adding server parameters to the configuration file of the client host, using encrypted username and password to modify the loading instruction format, and executing the remote loading process on the server, using SCP file transfer The protocol copies files from the client to the system path specified by the server, creates a subdirectory named by the session ID, realizes remote import of data, and intelligently optimizes data movement tasks and error recovery mechanisms by dynamically capturing and analyzing access exceptions.
Significantly improves the security and efficiency of data loading, improves the flexibility and reliability of operations, adapts to different operating environments, ensures that data is correctly and efficiently imported into Hive tables, reduces service interruptions due to insufficient permissions, and simplifies The data loading path setting and management process enhances the robustness and user-friendliness of the system.
Smart Images

Figure CN118410094B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of big data Hive technology, and in particular to a networked Hive table data loading method. Background Art
[0002] With the advent of the big data era, the amount of data has increased dramatically, and enterprises have an increasing demand for data processing and analysis. Hive, as a data warehouse tool in the Hadoop ecosystem, is used to query and manage big data stored in distributed file systems. However, in traditional Hive usage scenarios, when the server node cannot directly access the node where the data is stored, using Hive's load command to load data on the local disk into the Hive table will encounter limitations, which leads to insufficient flexibility in data loading and affects the efficiency and convenience of data processing.
[0003] Patent document with publication number CN114416853A discloses a data loading system and data loading method for importing massive data from Hive into Hbase. The method comprises: reading the data to be loaded in the Hive table through a Spark-HFile generation module configured on a big data offline scheduling system, and then using the Apache Spark distributed computing engine to configure the data to be loaded in the Hive table according to the mapping configuration of the Hive table field and the Hbase table, generating the underlying HFile file required by the Hbase table, and writing it into a specified HDFS directory; loading the HFile file in the HDFS directory in step 1 into the Hbase table online through an HFile online data loading module configured on the big data offline scheduling system, and providing user-oriented business query services. This method relies on the Apache Spark and Hadoop ecosystems, which limits its applicability in non-Spark or non-Hadoop environments. It may take some time to use Spark to generate HFile files and write them to HDFS, especially for large-scale data, which makes the data migration process time-consuming. The mapping configuration between Hive table fields and Hbase tables may be more complicated in actual operations and requires detailed mapping rules and conversion logic. This method is mainly aimed at batch data loading and is not effective for scenarios that require real-time or near real-time data loading. As the amount of data grows and business needs change, when the server node cannot directly access the node where the data is stored, the Hive load command cannot be used to load data on the local disk into the Hive table, resulting in poor flexibility in data loading. Summary of the invention
[0004] To this end, the present invention provides a networked Hive table data loading method to overcome the problem in the prior art that when the node where the server is located cannot directly access the node where the data is stored, the Hive load command cannot be used to load data on the local disk into the Hive table, resulting in poor flexibility in data loading.
[0005] To achieve the above object, the present invention provides a networked Hive table data loading method, comprising:
[0006] Step S1, in the configuration file of the client host, by adding a server parameter to save the system path of the file of the client host received by the server, and using a loading instruction to specify the system path of the file of the client host received by the server, and by adding the user name and password of the client host before the loading instruction to modify the format of the loading instruction of the client host;
[0007] Step S2, when the server receives the modified loading instruction, the encrypted user name and the password, the user name and the password are parsed, and when the client host name is inconsistent with the current server host name and the loading instruction carries the user name and the password, a remote loading process is executed, wherein the remote loading process includes using the SCP file transfer protocol to copy the file from the client host to the system path specified by the server, and creating a subdirectory named after the session ID of the client host, and after the file is copied, continuing to execute the remaining part of the loading instruction to import the file into the Hive table in the client host;
[0008] Step S3, after creating the subdirectory, use the server to try to access the subdirectory, capture the number of captures of abnormal accesses that occur during the access attempt, and when the number of captures is greater than the preset number of abnormal captures, use the server to check whether the specified subdirectory actually exists.
[0009] If the subdirectory does not exist, use the server to send an error message to the client host, and recreate the subdirectory, and when the server fails to access the recreated subdirectory again;
[0010] Adjust the number of exception captures according to the preset adjustment ratio coefficient;
[0011] Step S4, when the client host name is the same as the server host name, or the load instruction does not carry a user name and password, it is processed in a conventional local load manner, and data is directly read from the local directory and imported into the Hive table.
[0012] Furthermore, in step S3, the server is used to check whether the specified subdirectory actually exists.
[0013] The number of exception captures is set, and the server is used to extract the subdirectory from the load instruction received from the client, and check whether the subdirectory contains illegal characters according to the preset illegal character set. When it does not contain illegal characters, the server is used to try to access the subdirectory, and within the preset access time of trying to access, any exception or error thrown due to insufficient authority is captured, and the capture number is recorded, and the capture number is compared with the exception capture number.
[0014] If the number of captures is greater than the number of abnormal captures, using the server to send a prompt message of insufficient authority to the client host;
[0015] When the number of captures is less than or equal to the number of exception captures, the server is used to query the file system to confirm whether the subdirectory exists.
[0016] If the subdirectory does not exist, the server is used to send an error prompt message to the client host, and the recently used file list is checked. If the file list does not contain the subdirectory, the subdirectory is recreated, and the server is used to access the recreated subdirectory. If the capture count is greater than the abnormal capture count, it is determined that the abnormal capture count is set abnormally, and the abnormal capture count is reduced and adjusted.
[0017] X'=X×a, where X' is the adjusted number of exception captures, X is the set number of exception captures, and a is the adjustment ratio coefficient.
[0018] Furthermore, in the step S1, the server parameter hive.server2.loadfile.savedir is added to the configuration file hive-site.xml of the client host to save the system path of the file received by the server from the client host, and the load instruction is used to specify that the system path of the file received by the server from the client host is a subdirectory under the designated directory of the server, and the name of the subdirectory is the session ID of the client.
[0019] Furthermore, in the step S1, the format of the loading instruction of the client host is modified by adding the user name and password of the client host before the loading instruction, and when the client host executes the loading instruction, the user name and password are encrypted and sent to the server.
[0020] Further, in step S2, when the server receives the loading instruction, the user name and password of the client host are parsed through the SQL parser, and the client host name and the current server host name are obtained from the current session. When the client host name and the current server host name are inconsistent, it is determined whether the loading instruction carries the user name and password of the client host.
[0021] Furthermore, in step S2, when the client host name is inconsistent with the current server host name, the loading instruction is determined.
[0022] If the loading instruction does not carry the user name and password of the client host, the loading is determined to have failed, and a corresponding abnormal prompt message is issued;
[0023] If the loading instruction carries the user name and password of the client host, the server initiates an SSH request with the user name and password to the client host to copy the table data file, and verifies the user name and password during SSH remote login.
[0024] Furthermore, in step S2, when verifying the user name and password,
[0025] If the user name or password is incorrect, the client host sends a corresponding abnormal prompt message;
[0026] If the username and password are correct, the server initiates an SCP command to copy the table data file of the client host to a subdirectory under the specified directory of the server through the SSH protocol, where the destination directory name is the session ID of the current remote client. When executing the remote file copy, if the remote directory has no permission to copy, the corresponding exception prompt information is returned to the client host.
[0027] Furthermore, in step S5, when the client host name is different from the server host name and the loading instruction carries a user name and a password, the server generates a data movement task according to the loading instruction content, and the data movement task includes:
[0028] If the LOCAL keyword is specified in the load instruction, the data is first read from the local file system and uploaded to HDFS;
[0029] If the LOCAL keyword is not specified in the load instruction, data is moved directly from HDFS, the execution plan is converted into an actual task, and submitted to the computing framework for execution.
[0030] Furthermore, after generating the data movement task, the server will analyze the size of the data, the distance between the source and target HDFS directories, the network bandwidth, and the current HDFS load to generate the optimal data movement task.
[0031] Furthermore, in step S2, the server will monitor the status of file transfer in real time when executing the SCP file transfer protocol. The monitored status of file transfer includes the transmission rate, the transmission progress and all network errors that occur. If an error or file damage is detected during the transmission process, the server will start an error recovery mechanism. The error recovery mechanism includes retransmitting the file or providing an error log and prompt information to the client host.
[0032] Compared with the prior art, the beneficial effect of the present invention is that the risk of data leakage is reduced through encrypted transmission, and the security of data loading is significantly improved. At the same time, the efficiency of operation and the performance of data loading are improved through automated remote loading processes and intelligently optimized data movement tasks. The real-time monitoring and error recovery mechanism of the server further enhances the reliability of data loading, ensuring rapid response and resolution even when problems occur. In addition, the flexibility of the method allows it to adapt to different operating environments, and whether it is remote or local loading, it can ensure that data is correctly and efficiently imported into the Hive table.
[0033] Furthermore, by dynamically capturing and analyzing access exceptions, the server can intelligently identify and respond to file access permission issues, thereby reducing service interruptions caused by insufficient permissions. In addition, through communication with the client, users can obtain timely feedback on permission issues or file path errors, which helps users quickly locate and solve problems, improve the efficiency of the entire file loading process and user satisfaction, and adjust the mechanism of adjusting the number of exception captures. Allow the system to self-optimize according to actual conditions, avoid excessive or missed errors caused by fixed thresholds, and enhance the robustness and adaptability of the system. This approach not only speeds up problem solving, but also reduces the burden on system administrators, allowing them to focus more on other critical tasks. Overall, this intelligent exception handling strategy significantly improves the user-friendliness and reliability of the system.
[0034] Furthermore, by explicitly specifying the file receiving path of the server in the configuration file, the path setting and management process of data loading is simplified. Using the session ID as the sub-directory name, a unique file storage location is provided for each client session, which helps to distinguish data from different sessions to avoid confusion. Centralized management of file receiving paths and organization of data by session ID can enhance data security and privacy protection. When a loading error occurs, the data of a specific session can be quickly located by the session ID, which facilitates error tracking and debugging.
[0035] Furthermore, firstly, by encrypting the username and password, the security of the data loading process is enhanced, and the user credentials are protected from being intercepted and abused. Secondly, by embedding the credentials directly into the loading instructions, the server's verification process of the user's identity is simplified, making the data loading process smoother. In addition, this format of loading instructions enables the server to handle data loading requests from different clients more flexibly, while also providing a standardized method for interaction between clients and servers. Finally, this method also helps to reduce configuration errors and server load, because the server can directly authenticate by parsing the credentials in the loading instructions without the need for additional authentication steps.
[0036] Furthermore, by parsing and verifying the username and password, the server can confirm the legitimacy of the request and prevent unauthorized data access or potential security threats. In addition, this mechanism also provides flexibility, allowing remote clients to load data after authentication, while maintaining transparency and simplicity of operation.
[0037] Furthermore, by requiring the presence of a username and password, the server can ensure that only authorized users can initiate remote data loading requests, reducing the risk of data leakage and unauthorized access. At the same time, the use of the SSH protocol provides an encrypted channel for the data transmission process, further protecting the security of the data transmission process.
[0038] Furthermore, firstly, through the username and password verification mechanism, it is ensured that only users with correct credentials can access and transfer data, which greatly enhances the security of the system. Secondly, the use of SSH protocol and SCP command for data transmission not only ensures the security of the data transmission process, but also improves the efficiency and accuracy of data management through subdirectories named by session ID. In addition, the error prompts for permission issues help to quickly locate and solve problems that may occur during data transmission.
[0039] Furthermore, by providing a flexible data loading path, data can be directly loaded into the Hive table from the local file system or HDFS according to the actual situation. This method not only optimizes the data transmission process and reduces unnecessary data copying, but also improves the efficiency of data loading. Especially for large-scale data sets, directly moving data within HDFS can significantly reduce the overhead of network transmission, thereby speeding up the overall data loading speed.
[0040] Furthermore, firstly, by optimizing data movement tasks, the efficiency of data transmission can be significantly improved, especially when dealing with large amounts of data or transmitting across long distances. Secondly, consideration of network bandwidth and HDFS load helps avoid network congestion and system overload, ensuring that data movement does not interfere with other HDFS operations. In addition, this approach can also balance the use of system resources and improve the overall performance and stability of HDFS. Ultimately, these optimization measures help improve the reliability of data loading, ensure the smooth completion of data movement tasks, and provide a solid foundation for data analysis and processing.
[0041] Furthermore, through real-time monitoring, the server can quickly respond to problems during the transmission process, reducing the risk of data loss or corruption due to undetected errors. In addition, the existence of an error recovery mechanism ensures that even when problems occur, timely measures can be taken to try to recover or retransmit the file, thereby ensuring the continuity and integrity of the data loading process. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 This is a flow chart of the networked Hive table data loading method of this embodiment;
[0043] Figure 2 This is a decision logic diagram of the networked Hive table data loading method of this embodiment;
[0044] Figure 3 The following is a logic diagram for judging the load instruction in this embodiment;
[0045] Figure 4 This is the decision logic diagram for verifying the user name and password in this embodiment. DETAILED DESCRIPTION
[0046] In order to make the objects and advantages of the present invention more clearly understood, the present invention is further described below in conjunction with embodiments; it should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0047] The preferred embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.
[0048] It should be noted that, in the description of the present invention, terms such as "up", "down", "left", "right", "inside" and "outside" indicating directions or positional relationships are based on the directions or positional relationships shown in the drawings. This is merely for the convenience of description and does not indicate or imply that the device or element must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it cannot be understood as a limitation on the present invention.
[0049] In addition, it should be noted that in the description of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0050] See also Figure 1 As shown, it is a flowchart of the networked Hive table data loading method of this embodiment;
[0051] Please continue reading Figure 2 As shown, it is a decision logic diagram of the networked Hive table data loading method of this embodiment;
[0052] This embodiment provides a networked Hive table data loading method, including:
[0053] Step S1, in the configuration file of the client host, by adding a server parameter to save the system path of the file of the client host received by the server, and using a loading instruction to specify the system path of the file of the client host received by the server, and by adding the user name and password of the client host before the loading instruction to modify the format of the loading instruction of the client host;
[0054] Step S2, when the server receives the modified loading instruction, the encrypted user name and the password, the user name and the password are parsed, and when the client host name is inconsistent with the current server host name and the loading instruction carries the user name and the password, a remote loading process is executed, wherein the remote loading process includes using the SCP file transfer protocol to copy the file from the client host to the system path specified by the server, and creating a subdirectory named after the session ID of the client host, and after the file is copied, continuing to execute the remaining part of the loading instruction to import the file into the Hive table in the client host;
[0055] Step S3, after creating the subdirectory, use the server to try to access the subdirectory, capture the number of captures of abnormal accesses that occur during the access attempt, and when the number of captures is greater than the preset number of abnormal captures, use the server to check whether the specified subdirectory actually exists.
[0056] If the subdirectory does not exist, use the server to send an error message to the client host, and recreate the subdirectory, and when the server fails to access the recreated subdirectory again;
[0057] Adjust the number of exception captures according to the preset adjustment ratio coefficient;
[0058] Step S4, when the client host name is the same as the server host name, or the load instruction does not carry a user name and password, it is processed in a conventional local load manner, and data is directly read from the local directory and imported into the Hive table.
[0059] First, set the server parameters in the Hive client configuration file and specify the system path where the server receives the file. Next, modify the loading instruction format to include the encrypted username and password, and then send it to the server. After receiving the information, the server parses and verifies it. If the verification passes, the remote loading process is executed, the file is securely transferred to the specified path using the SCP protocol, and a subdirectory named after the session ID is created, and the data import is finally completed. If the client and server host names are the same or the loading instruction does not carry credentials, the server reads the data from the local directory in the usual way. In addition, the server will check the local path, the existence of the Hive table, and the legitimacy of the table partition information, and provide an exception prompt when an error occurs.
[0060] Encrypted transmission reduces the risk of data leakage and significantly improves the security of data loading. At the same time, automated remote loading processes and intelligently optimized data movement tasks improve operational efficiency and data loading performance. The real-time monitoring and error recovery mechanisms on the server further enhance the reliability of data loading, ensuring rapid response and resolution even when problems arise. In addition, the flexibility of this method allows it to adapt to different operating environments. Whether loading remotely or locally, it can ensure that data is correctly and efficiently imported into the Hive table.
[0061] Specifically, in step S1, the system path of the file accepted by the server from the client host is saved by adding the server parameter hive.server2.loadfile.savedir in the configuration file hive-site.xml of the client host, and a load instruction is used to specify that the system path of the file accepted by the server from the client host is a subdirectory under the designated directory of the server, and the name of the subdirectory is the session ID of the client.
[0062] Modify the client host's hive-site.xml configuration file to include a new server-side parameter, hive.server2.loadfile.savedir. This parameter is used to define a specific system path on the server, which is used by the server to receive files from the client host. Later, when performing data loading operations, use load instructions to explicitly specify this server-side system path. Specifically, the server-side path is set to a subdirectory with a name corresponding to the client host's session ID.
[0063] By explicitly specifying the file receiving path of the server in the configuration file, the path setting and management process of data loading is simplified. Using the session ID as the subdirectory name provides a unique file storage location for each client session, which helps to distinguish data from different sessions to avoid confusion. Centralized management of file receiving paths and organization of data by session ID can enhance data security and privacy protection. When a loading error occurs, the data of a specific session can be quickly located by the session ID, which facilitates error tracking and debugging.
[0064] Specifically, in step S1, the format of the loading instruction of the client host is modified by adding the user name and password of the client host before the loading instruction, and when the client host executes the loading instruction, the user name and password are encrypted and sent to the server.
[0065] Modify the traditional loading instruction format and add the client host's username and password in front of it to form a new loading instruction structure. This new loading instruction structure not only contains the data loading instruction, but also incorporates the security verification credentials. When executing this loading instruction, the client host will encrypt the username and password to ensure the security of the credentials during transmission, and then send the encrypted credentials together with the loading instruction to the server.
[0066] First, by encrypting usernames and passwords, security during the data loading process is enhanced, protecting user credentials from being intercepted and abused. Second, by embedding credentials directly into the loading instructions, the server's verification of user identity is simplified, making the data loading process smoother. In addition, this format of loading instructions enables the server to handle data loading requests from different clients more flexibly, while also providing a standardized method for interaction between clients and servers. Finally, this approach also helps reduce configuration errors and server load, because the server can directly authenticate by parsing the credentials in the loading instructions without the need for additional authentication steps.
[0067] Specifically, in step S2, when the server receives the loading instruction, the user name and password of the client host are parsed through the SQL parser, and the client host name and the current server host name are obtained from the current session. When the client host name and the current server host name are inconsistent, it is determined whether the loading instruction carries the user name and password of the client host.
[0068] After receiving the loading instruction from the Hive client, the server uses the SQL parser to parse the statement and extract the encrypted username and password. Subsequently, the server compares the client host name obtained in the current session with its own host name. If the two are inconsistent, it means that the request comes from a remote client, and the server will further check whether the loading instruction has carried the necessary username and password. This process is a key step in verifying the legitimacy of the data loading request, ensuring that only authenticated users can perform data loading operations.
[0069] By parsing and verifying the username and password, the server can confirm the legitimacy of the request and prevent unauthorized data access or potential security threats. In addition, this mechanism also provides flexibility, allowing remote clients to load data after authentication, while maintaining transparency and simplicity of operation.
[0070] See also Figure 3 As shown, it is a determination logic diagram of the load instruction in this embodiment;
[0071] Specifically, in step S2, when the client host name is inconsistent with the current server host name, the loading instruction is determined.
[0072] If the loading instruction does not carry the user name and password of the client host, the loading is determined to have failed, and a corresponding abnormal prompt message is issued;
[0073] If the loading instruction carries the user name and password of the client host, the server initiates an SSH request with the user name and password to the client host to copy the table data file, and verifies the user name and password during SSH remote login.
[0074] The server first checks whether the received load instruction contains the username and password of the client host. If these key authentication information are missing in the load instruction, the server will determine that the data load request is invalid and return an exception prompt to the client to avoid unauthorized data access. On the contrary, if the load instruction contains a username and password, the server will use these credentials to initiate a request to the client host through the SSH protocol to copy the required table data files. During the SSH remote login process, the server will verify the provided username and password to ensure that only legitimate users can successfully initiate data transfer.
[0075] By requiring the existence of a username and password, the server can ensure that only authorized users can initiate remote data loading requests, reducing the risk of data leakage and unauthorized access. At the same time, the use of the SSH protocol provides an encrypted channel for the data transmission process, further protecting the security of the data transmission process.
[0076] See also Figure 4 As shown, it is a decision logic diagram for verifying the user name and password in this embodiment;
[0077] Specifically, in step S2, when verifying the user name and password,
[0078] If the user name or password is incorrect, the client host sends a corresponding abnormal prompt message;
[0079] If the username and password are correct, the server initiates an SCP command to copy the table data file of the client host to a subdirectory under the specified directory of the server through the SSH protocol, where the destination directory name is the session ID of the current remote client. When executing the remote file copy, if the remote directory has no permission to copy, the corresponding exception prompt information is returned to the client host.
[0080] In the username and password verification process, the server first verifies the credentials provided by the client. If the credentials are incorrect, the server will immediately send an exception prompt message to the client host, clearly informing it of the verification failure, thereby avoiding the risk of illegal access or data leakage. Once the username and password verification is successful, the server will use the SSH protocol through the SCP command to safely copy the table data files on the client host to the directory specified by the server. The directory is named with the session ID of the current remote client to ensure the orderliness and uniqueness of the data. If a permission problem is encountered during the remote copy process, the server will also return an exception prompt message to the client host so that the client can understand the situation in time and take corresponding measures.
[0081] First, the username and password verification mechanism ensures that only users with the correct credentials can access and transfer data, which greatly enhances the security of the system. Secondly, the use of SSH protocol and SCP command for data transmission not only ensures the security of the data transmission process, but also improves the efficiency and accuracy of data management through subdirectories named by session ID. In addition, error prompts for permission issues help to quickly locate and solve problems that may occur during data transmission.
[0082] Specifically, in step S3, the server is used to check whether the specified subdirectory actually exists.
[0083] The number of exception captures is set, and the server is used to extract the subdirectory from the load instruction received from the client, and check whether the subdirectory contains illegal characters according to the preset illegal character set. When it does not contain illegal characters, the server is used to try to access the subdirectory, and within the preset access time of trying to access, any exception or error thrown due to insufficient authority is captured, and the capture number is recorded, and the capture number is compared with the exception capture number.
[0084] If the number of captures is greater than the number of abnormal captures, using the server to send a prompt message of insufficient authority to the client host;
[0085] When the number of captures is less than or equal to the number of exception captures, the server is used to query the file system to confirm whether the subdirectory exists.
[0086] If the subdirectory does not exist, the server is used to send an error prompt message to the client host, and the recently used file list is checked. If the file list does not contain the subdirectory, the subdirectory is recreated, and the server is used to access the recreated subdirectory. If the capture count is greater than the abnormal capture count, it is determined that the abnormal capture count is set abnormally, and the abnormal capture count is reduced and adjusted.
[0087] X'=X×a, where X' is the adjusted number of exception captures, X is the set number of exception captures, and a is the adjustment ratio coefficient.
[0088] When the server performs a file path check, it first extracts the subdirectory from the load instruction received from the client. The server then checks whether the path contains any pre-set illegal characters to ensure the legitimacy of the path. Once the path format is confirmed to be correct, the server will attempt to access the path and monitor and capture errors or exceptions caused by insufficient permissions within the specified access attempt duration. The server will record the number of occurrences of these exceptions and compare them with the preset threshold of the number of exception captures. If the number of captured exceptions exceeds the threshold, the server will send a prompt message to the client that the user needs to check the file access permissions. If the number of captured exceptions does not exceed the threshold, the server will query the file system to confirm whether the file path exists. If the path is found to not exist, the server will send an error prompt message to the client and check the recently used file list to determine whether the file has been moved or renamed. If the file is not in the recently used list, the server may recreate the subdirectory and try to access it again. If the number of exceptions captured during the retry process exceeds the threshold again, the server will determine that the current number of exception captures may be too high, and reduce and adjust the threshold according to the preset adjustment ratio factor a to more accurately reflect the actual permissions and access conditions.
[0089] By dynamically capturing and analyzing access exceptions, the server can intelligently identify and respond to file access permission issues, thereby reducing service interruptions caused by insufficient permissions. In addition, through communication with the client, users can obtain timely feedback on permission issues or file path errors, which helps users quickly locate and solve problems, improve the efficiency of the entire file loading process and user satisfaction, and adjust the mechanism of adjusting the number of exception captures. Allow the system to self-optimize according to actual conditions, avoid excessive or missed errors caused by fixed thresholds, and enhance the robustness and adaptability of the system. This approach not only speeds up problem solving, but also reduces the burden on system administrators, allowing them to focus more on other critical tasks. Overall, this intelligent exception handling strategy significantly improves the user-friendliness and reliability of the system.
[0090] The number of exception capture times refers to the number of times the system captures errors or exceptions caused by insufficient permissions or other reasons when trying to access a subdirectory. It depends on the system fault tolerance. The higher the system's fault tolerance, the more exception capture times that may be set. Some systems may start with a lower value, such as 5 times, and then adjust it according to actual operating conditions. In this embodiment, the number of exception capture times is set to 10 times, which can prevent users from receiving frequent error prompts due to accidental errors.
[0091] The adjustment proportional coefficient is a factor used to adjust the number of exception capture times. It is used to increase or decrease the number of exception capture times according to a certain ratio when the number of capture times exceeds the current threshold value. It depends on the system stability. If the system runs stably, the adjustment proportional coefficient may be set to a smaller value. The adjustment proportional coefficient is usually set to 0.5, 1 or 2, depending on whether the number of exception capture times needs to be increased or decreased. In this embodiment, the adjustment proportional coefficient is set to 0.5, which can automatically adjust the number of exception capture times according to actual conditions to improve adaptability.
[0092] The preset duration refers to the waiting time set by the system when trying to access a subdirectory. If the access cannot be made after this time, it is considered that the access has failed. Depending on the expected time of file access, the expected file access time will vary according to the performance of the file system and the network conditions. There is no fixed value for the preset duration, and it needs to be determined based on the actual application scenario and the above factors. For example, in a network file system NFS or a storage area network SAN, it may be set to a few seconds to tens of seconds. In this embodiment, the preset duration is set to 30 seconds, which can avoid the waste of resources that may be caused by long system waiting times.
[0093] The load instructions set the necessary precondition checks for data loading, thus avoiding errors and failures that may occur during the data loading process. By ensuring that the file exists, the server has appropriate read permissions, the Hive table exists, and the legitimacy of the partition information, the server can identify and resolve potential problems in advance, which significantly improves the success rate of data loading and the efficiency of the overall process.
[0094] Specifically, in step S2, when the client host name is different from the server host name and the loading instruction carries a user name and a password, the server generates a data movement task according to the loading instruction content, and the data movement task includes:
[0095] If the LOCAL keyword is specified in the load instruction, the data is first read from the local file system and uploaded to HDFS;
[0096] If the LOCAL keyword is not specified in the load instruction, data is moved directly from HDFS, the execution plan is converted into an actual task, and submitted to the computing framework for execution.
[0097] When the client host name is inconsistent with the server host name, and the load instruction contains a username and password, the server will generate the corresponding data movement task according to the content of the load instruction. If the LOCAL keyword is specified in the load instruction, the server will first read the data from the local file system and then upload the data to the Hadoop distributed file system HDFS. In contrast, if the LOCAL keyword is not specified in the load instruction, the server will directly move the data within HDFS, convert the data loading execution plan into an executable task, and submit it to the computing framework for processing.
[0098] By providing a flexible data loading path, data can be directly loaded into the Hive table from the local file system or HDFS according to the actual situation. This method not only optimizes the data transmission process and reduces unnecessary data copying, but also improves the efficiency of data loading. Especially for large-scale data sets, directly moving data within HDFS can significantly reduce the overhead of network transmission, thereby speeding up the overall data loading speed.
[0099] Specifically, after generating the data movement task, the server will analyze the size of the data, the distance between the source and target HDFS directories, the network bandwidth, and the current HDFS load to generate the optimal data movement task.
[0100] After generating a data movement task, the server will perform a series of analysis to ensure the efficiency and success rate of data movement. Specifically, the server will consider the size of the data, evaluate the distance between the source HDFS directory and the target HDFS directory, check the current network bandwidth, and evaluate the current load of HDFS. Based on the comprehensive consideration of these factors, the server can generate an optimal data movement task, which aims to minimize data transmission time, reduce network congestion, and avoid data operations when HDFS is under high load, thereby reducing the impact on HDFS system performance.
[0101] First, by optimizing data movement tasks, the efficiency of data transmission can be significantly improved, especially when dealing with large amounts of data or transmitting across long distances. Second, consideration of network bandwidth and HDFS load helps avoid network congestion and system overload, ensuring that data movement does not interfere with other HDFS operations. In addition, this approach can balance the use of system resources and improve the overall performance and stability of HDFS. Ultimately, these optimization measures help improve the reliability of data loading, ensure the smooth completion of data movement tasks, and provide a solid foundation for data analysis and processing.
[0102] Specifically, in step S2, when executing the SCP file transfer protocol, the server will monitor the status of the file transfer in real time, and the monitored file transfer status includes the transmission rate, the transmission progress and all the network errors that occur. If an error or file damage is detected during the transmission process, the server will start an error recovery mechanism, and the error recovery mechanism includes retransmitting the file or providing the error log and prompt information to the client host.
[0103] When executing the SCP file transfer protocol, the server will continuously monitor the status of the file transfer, including real-time tracking of the transfer rate, transfer progress, and recording all possible network errors. This detailed monitoring mechanism enables the server to capture any abnormal situation during the transfer process in a timely manner. Once an error or file corruption is found, the server will immediately start the error recovery mechanism, which may include retransmitting the file or providing detailed error logs and prompt information to the client host so that the client can understand the problem and take appropriate remedial measures.
[0104] Through real-time monitoring, the server can quickly respond to problems during the transmission process, reducing the risk of data loss or corruption due to undetected errors. In addition, the existence of an error recovery mechanism ensures that even when problems occur, timely measures can be taken to try to recover or retransmit the file, thereby ensuring the continuity and integrity of the data loading process.
[0105] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.
[0106] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A networked Hive table data loading method, characterized in that: include: Step S1, in the configuration file of the Hive client host, by adding a server parameter to save the system path of the file received by the server from the Hive client host, and using a load instruction to specify the system path of the file received by the server from the Hive client host; Step S2, modifying the format of the loading instruction of the Hive client host by adding the user name and password of the Hive client host before the loading instruction, and encrypting the user name and password and sending them to the server when the Hive client host executes the loading instruction; Step S3, when the server receives the modified loading instruction, the encrypted user name and the password, the server is equipped with the ability to parse the format of the modified loading instruction, and the user name and password are parsed and verified according to the server with the increased parsing ability. When the verification is passed, a remote loading process is executed, which includes using the SCP file transfer protocol to copy the file from the Hive client host to the system path specified by the server, and creating a subdirectory named after the session ID of the Hive client host. After the file is copied, the remaining part of the loading instruction is continued to be executed to import the file into the Hive table in the Hive client host. When the verification fails, the corresponding exception prompt information is returned to the Hive client host; Step S4, comparing the Hive client host name with the server host name, if the Hive client host name is the same as the server host name, or the load instruction does not carry a user name and password, then the conventional local load method is used to directly read data from the local directory and import it into the Hive table; In step S4, the server is also used to try to access the local path. When the capture number is greater than the preset exception capture number, the server is used to check whether the specified local file path actually exists. If the local file path does not exist, use the server to send an error prompt message to the Hive client host, recreate the local file path, and adjust the number of exception captures when the server fails to access the recreated local file path again; Step S5, when the Hive client host name is different from the server host name, and the loading instruction carries a user name and password, the server is used to continue to execute the remote loading process in step S3; In step S4, the server is used to check whether the specified local file path actually exists. The number of exception captures is set, and the server is used to extract the local file path from the load instruction received from the client, and check whether the local file path contains illegal characters according to the preset illegal character set. When it does not contain illegal characters, the server is used to try to access the local file path, and within the preset access time, any exception or error thrown due to insufficient authority is captured, and the capture number is recorded, and the capture number is compared with the exception capture number. If the number of captures is greater than the number of abnormal captures, the server sends a prompt message of insufficient authority to the Hive client host; When the number of captures is less than or equal to the number of exception captures, the server is used to query the file system to confirm whether the local file path exists. If the local file path does not exist, use the server to send an error prompt message to the Hive client host, check the recently used file list, if the file list does not contain the local file path, recreate the local file path, and use the server to access the recreated local file path. If the capture count is greater than the exception capture count, determine that the exception capture count is set abnormally, and reduce the exception capture count. X'=X×a, where X' is the adjusted number of exception captures, X is the set number of exception captures, and a is the adjustment ratio coefficient.
2. The networked Hive table data loading method according to claim 1 is characterized in that: In the step S1, the system path of the file accepted by the server from the Hive client host is saved by adding the server parameter hive.server2.loadfile.savedir in the configuration file hive-site.xml of the Hive client host, and a load instruction is used to specify that the system path of the file accepted by the server from the Hive client host is a subdirectory under the designated directory of the server, and the name of the subdirectory is the session ID of the client.
3. The networked Hive table data loading method according to claim 2 is characterized in that: In step S2, the format of the loading instruction of the Hive client host is modified by adding the user name and password of the Hive client host before the loading instruction, and when the Hive client host executes the loading instruction, the user name and password are encrypted and sent to the server.
4. The networked Hive table data loading method according to claim 3 is characterized in that: In step S3, when the server receives the loading instruction, the user name and password of the Hive client host are parsed by the SQL parser, and the Hive client host name obtained from the current session is compared with the current server host name. When the Hive client host name and the current server host name are inconsistent, it is determined whether the loading instruction carries the user name and password of the Hive client host.
5. The networked Hive table data loading method according to claim 4 is characterized in that: In step S3, when the client host name is inconsistent with the current server host name, the loading instruction is determined. If the loading instruction does not carry the username and password of the Hive client host, the loading is judged to have failed, and a corresponding abnormal prompt message is issued; If the load instruction carries the username and password of the Hive client host, the server initiates an SSH request with the username and password to the Hive client host to copy the table data file, and verifies the username and password during SSH remote login.
6. The networked Hive table data loading method according to claim 5, characterized in that: In step S3, when verifying the user name and password, If the username or password is incorrect, the Hive client host will issue a corresponding exception prompt message; If the username and password are correct, the server initiates an SCP command to copy the table data files of the Hive client host to a subdirectory under the specified directory of the server through the SSH protocol, where the destination directory name is the session ID of the current remote client. If the remote directory has no permission to copy when executing the remote file copy, the corresponding exception prompt information is returned to the Hive client host.
7. The networked Hive table data loading method according to claim 6 is characterized in that: In step S5, when the Hive client host name is different from the server host name and the load instruction carries a user name and a password, the server generates a data movement task according to the content of the load instruction, and the data movement task includes: If the LOCAL keyword is specified in the load instruction, the data is first read from the local file system and uploaded to HDFS; If the LOCAL keyword is not specified in the load instruction, data is moved directly from HDFS, the execution plan is converted into an actual task, and submitted to the computing framework for execution.
8. The networked Hive table data loading method according to claim 7, characterized in that: After generating the data movement task, the server will analyze the size of the data, the distance between the source and target HDFS directories, the network bandwidth, and the current HDFS load to generate the optimal data movement task.
9. The networked Hive table data loading method according to claim 1, characterized in that: In step S3, the server will monitor the status of file transfer in real time when executing the SCP file transfer protocol. The monitored file transfer status includes the transmission rate, the transmission progress and all network errors that occur. If an error or file damage is detected during the transmission process, the server will start an error recovery mechanism. The error recovery mechanism includes retransmitting the file or providing error logs and prompt information to the Hive client host.
