Using Loader to Import Data from HDFS to ClickHouse
Scenario
Use Loader to import data from HDFS to ClickHouse.
Prerequisites
- You have obtained the service username and password for creating a Loader job.
- You have had the permission to access the HDFS directories and data involved in job execution.
- You have created a ClickHouse table, and you have operation permissions on the table during job execution.
- No disk space alarm is reported, and the available disk space is sufficient for importing and exporting data.
- When using Loader to import data from HDFS, the input paths and input path subdirectories of HDFS and the name of the files in these directories do not contain any of the special characters /"':;.
- If a configured task requires the Yarn queue function, the user must be authorized with related Yarn queue permission.
- The user who configures a task must obtain execution permission on the task and obtain usage permission on the related connection of the task.
Procedure
Setting Basic Job Information
- Access the Loader web UI.
- Log in to FusionInsight Manager. For details, see Accessing FusionInsight Manager.
- Choose Cluster > Services > Loader.
- Click LoaderServer(Node name, Active). The Loader web UI is displayed.
Figure 1 Loader web UI
- Click New Job to go to the Basic Information page and set basic job information.
Figure 2 Basic Information
- Set Name to the name of the job.
- Set Type to Import.
- Set Group to the group to which the job belongs. No group is created by default. You need to click Add to create a group and click OK to save the created group.
- Set Queue to the Yarn queue that executes the job. The default value is root.default.
- Set Priority to the priority of the Yarn queue that executes the job. The default value is NORMAL. The options are VERY_LOW, LOW, NORMAL, HIGH, and VERY_HIGH.
- In the Connection area, click Add to create a connection, set Connector to hdfs-connector, set connection parameters, and click Test to verify whether the connection is available. When "Test Success" is displayed, click OK.
Setting Data Source Information
- Click Next. On the displayed From page, set the data source information.
Table 1 Parameter description Parameter
Description
Example
Input Path
Input path of source files in HDFS
NOTE:You can use macros to define path parameters. For details, see Using Macro Definitions in Configuration Items.
/user/test
Path Filter
Wildcard for filtering the directories in the input paths of the source files. Input Path is not used for filtering. If there are multiple filter conditions, use commas (,) to separate them. If the parameter is empty, the directories are not filtered. The regular expression filtering is not supported.
*
File Filter
Wildcard for filtering the file names of the source files. If there are multiple filter conditions, use commas (,) to separate them. The value cannot be left blank. The regular expression filtering is not supported.
*
Encoding Type
Source file encoding format, for example, UTF-8. This parameter can be set only in text file import.
UTF-8
Suffix
File name extension added to a source file after the source file is imported. If this parameter is empty, no file name extension is added to the source file.
.log
Setting Data Transformation
- Click Next. On the displayed Transform page, set the transformation operations in the data transformation process. For details about how to select operators and set parameters, see Loader Operator Help and Table 2.
Table 2 Input and output parameters of the operator Input Type
Output Type
CSV File Input
ClickHouse Output
Figure 3 Operator operation procedure
Setting Data Storage Information and Executing the Job
- Click Next. On the displayed To page, set Storage type to CLICKHOUSE based on the actual situation.
Table 3 Parameter description Storage Type
Parameter
Description
Example
CLICKHOUSE
ClickHouse instance
ClickHouse service instance that Loader selects from all available ClickHouse service instances in the cluster. If the selected ClickHouse service instance is not added to the cluster, the ClickHouse job cannot be run properly.
ClickHouse
Clear data before import
Whether to clear data in the original table before importing data true indicates clearing data and false indicates not to clear data. If you do not set this parameter, the original table is not cleared by default.
NOTE:If you select true and the table to be imported is a ClickHouse distributed table, you need to manually delete the data from the local table corresponding to the ClickHouse distributed table before your import.
false
Extractors
Number of Maps that are started at the same time in a MapReduce task of a data configuration operation. The value must be less than or equal to 3000.
20
Extractor size
ClickHouse does not support this parameter. Please set Extractors.
-
Number
Number of Map tasks.
-
- Click Save and Run to save and run the job.
Checking the Job Execution Result
- Go to the Loader web UI. When Status is Succeeded, the job is complete.
Figure 4 Viewing job details
- On the ClickHouse client, check whether the data in the ClickHouse table is the same as that imported from HDFS.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot