Using Loader to Export Data from HDFS to ClickHouse
This section applies to MRS 3.3.0 or later.
Scenario
Use Loader to export data from HDFS to ClickHouse.
Prerequisites
- A role has been created on FusionInsight Manager and granted the management permission on ClickHouse logical clusters and Loader job grouping permission. A service user for Loader jobs has been created, associated with the role, and added the user group yarnviewgroup.
- A replicated table and a distributed table have been created by referring to ClickHouse Client Practices and a user has been assigned the permission to perform operations on the tables during job execution. The replicated table has been selected when data is exported.
- No ClickHouse alarm is generated.
Procedure
Make preparations.
- Obtain the clickhouse-jdbc-*.jar file from the ClickHouse installation directory and save it to ${BIGDATA_HOME}/FusionInsight_Porter_*/install/FusionInsight-Sqoop-1.99.3/FusionInsight-Sqoop-1.99.3/server/webapps/loader/WEB-INF/ext-lib on the active and standby Loader nodes.
- Run the following command on the active and standby nodes as user root to modify the permission:
cd ${BIGDATA_HOME}/FusionInsight_Porter_*/install/FusionInsight-Sqoop-1.99.3/FusionInsight-Sqoop-1.99.3/server/webapps/loader/WEB-INF/ext-lib
chown omm:wheel JAR file name
chmod 600 JAR file name
- Log in to FusionInsight Manager and choose Cluster > Services > Loader. On the Dashboard tab page that is displayed, click More and select Restart Service. In the displayed dialog box, enter the administrator password to restart the Loader service.
Configure basic job information.
- Access the Loader web UI.
- Log in to 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. Configure basic job parameters on the Basic Information page displayed.
Figure 2 Basic Information page
- Enter a job name in Name.
- Set Type to Export.
- Set Group to the group to which the job belongs. There is no group created by default. Click Add, enter the group name, and click OK.
- 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 clickhouse-connector, configure connection parameters, and click Test to verify whether the connection is available. When "Test Success" is displayed, click OK. For details about parameter settings, see Table 1.
Table 1 clickhouse-connector connection parameters Parameter
Description
Example Value
Name
Name of a relational database connection
clickhouse_jdbc_test
ClickHouse Connection String
- Kerberos authentication has been enabled for the cluster. The JDBC connection string format is jdbc:clickhouse://Database IP address:Database port number/Database name?ssl=true&sslmode=none.
- Kerberos authentication is disabled for the cluster. The JDBC connection string format is jdbc:clickhouse://Database IP address:Database port number/Database name.
NOTE:- Database IP address: To obtain the IP address of the ClickHouseBalancer instance, log in to FusionInsight Manager, choose Cluster > Services > ClickHouse, and click Instance.
- Database port number:
- To obtain the port number of a cluster with Kerberos authentication enabled, log in to FusionInsight Manager, choose Cluster > Services, click Logical Cluster, view the logical cluster, and obtain the value of Ssl Port in HTTP Balancer Port.
- To obtain the port number of a cluster with Kerberos authentication disabled, log in to FusionInsight Manager, choose Cluster > Services, click Logical Cluster, view the logical cluster, and obtain the value of Port in HTTP Balancer Port.
- Kerberos authentication has been enabled for the cluster: jdbc:clickhouse://10.10.10.10:21426/test?ssl=true&sslmode=none
- Kerberos authentication is disabled for the cluster: jdbc:clickhouse://10.10.10.10:21423/test?ssl=false&sslmode=none
Username
Username for connecting to the database
root
Password
Password for connecting to the database
xxxx
Configure data source information.
- Click Next. On the From page displayed, set Source type to HDFS.
Table 2 Input parameters Parameter
Description
Example Value
Input directory
Input path when data is exported from 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 directory is not used for filtering. Use commas (,) to separate multiple filter conditions. If this parameter is left blank, directories are not filtered. Regular expression filtering is not supported.
- ? matches a single character.
- * indicates multiple characters.
- Adding ^ before the condition indicates negated filtering, that is, file filtering.
*
File filter
Wildcard for filtering the file names of the source files. Use commas (,) to separate multiple filter conditions. This parameter cannot be left blank. Regular expression filtering is not supported.
- ? matches a single character.
- * indicates multiple characters.
- Adding ^ before the condition indicates negated filtering, that is, file filtering.
*
File type
File import type. The options are as follows:
- TEXT_FILE: imports a text file and saves it as a text file.
- SEQUENCE_FILE: imports a text file and saves it as a sequence file.
- BINARY_FILE: imports files of any format using binary streams but not to process the files.
NOTE:When the file import type is set to TEXT_FILE or SEQUENCE_FILE, Loader automatically selects a decompression method based on the file name extension to decompress a file.
TEXT_FILE
File split type
Whether to split source files by file name or size. The files obtained after the splitting are used as the input files of each Map in the MapReduce task for data export.
- FILE: indicates that the source file is split by file. That is, each Map processes one or multiple complete files, the same source file cannot be allocated to different Maps, and the source file directory structure is retained after data import.
- SIZE: indicates that the source file is split by size. That is, each Map processes input files of a certain size, and a source file can be divided and processed by multiple Maps. After data is stored in the output directory, the number of saved files is the same as that of Maps. The file name format is import_part_xxxx, where xxxx is a unique random number generated by the system.
FILE
Extractors
Number of Maps that are started at the same time in a MapReduce task of a data configuration operation. This parameter cannot be set when Extractor size is set. The value must be less than or equal to 3000.
20
Extractor size
Size of data processed by Maps that are started in a MapReduce task of a data configuration operation. The unit is MB. The value must be greater than or equal to 100. The recommended value is 1000. This parameter cannot be set when Extractors is set. When a relational database connector is used, Extractor Size is unavailable. You need to set Extractors.
-
Configure 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 3.
Table 3 Input and output parameters of the operator Input Type
Output Type
CSV File Input
Table Output
Figure 3 Operator selection
Set data storage information and execute the job.
- Click Next. On the displayed To page, set the data storage mode.
Table 4 Output parameters Parameter
Description
Example Value
Table Name
Name of a database table that is used to save the final data of the transmission
NOTE:You can use macros to define table names. For details, see Using Macro Definitions in Configuration Items.
test
- Click Save and Run to save and run the job.
View the job execution result.
- Go to the Loader web UI. When Status is Succeeded, the job is complete.
Figure 4 Viewing a job
- On the ClickHouse client, check whether the data in the ClickHouse table is the same as that in 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