This topic explains how to install X2Doris and use it to import data into ApsaraDB for SelectDB.
Tool overview
X2Doris is a key tool for importing offline data into ApsaraDB for SelectDB.
-
Key benefits:
-
Automatically creates tables and imports data in one step.
-
Uses a visual platform. Simple and easy to use.
-
-
Supported data sources: Doris, Hive, Kudu, StarRocks, and ClickHouse.
Import Hive Source Data
Install X2Doris
Important notes
-
The server where you install X2Doris must be a node in your Hadoop cluster or have a Hadoop gateway environment. This means the server can run Hadoop and Hive commands and access the Hadoop and Hive clusters normally.
-
The machine where you deploy X2Doris must have Hadoop environment variables configured. Set
HADOOP_HOME,HADOOP_CONF_DIR, andHIVE_CONF_DIR. Example:ImportantThe
HADOOP_CONF_DIRorHIVE_CONF_DIRdirectory must containhive-site.xml.export HADOOP_HOME=/opt/hadoop # Hadoop installation directory export HADOOP_CONF_DIR=/etc/hadoop/conf # Hadoop configuration directory export HIVE_HOME=$HADOOP_HOME/../hive export HIVE_CONF_DIR=$HADOOP_HOME/conf export HBASE_HOME=$HADOOP_HOME/../hbase export HADOOP_HDFS_HOME=$HADOOP_HOME/../hadoop-hdfs export HADOOP_MAPRED_HOME=$HADOOP_HOME/../hadoop-mapreduce export HADOOP_YARN_HOME=$HADOOP_HOME/../hadoop-yarn
Installation environment
This topic uses Linux as an example. Choose the appropriate commands for your system and environment.
Procedure
-
Select an X2Doris version.
With Spark installed
Go to the jars directory in the Spark installation directory, locate JAR files that start with spark-yarn, and identify the Scala version that corresponds to the Spark dependency package. The following example shows how to do this:
For spark-yarn_2.12-3.2.4.jar, the corresponding Scala version is 2.12.

Without Spark installed
Choose the X2Doris package for Scala 2.12.
-
Download X2Doris.
-
x64 (Spark 3)
wget https://enterprise-doris-releases.oss-cn-beijing.aliyuncs.com/x2doris/v1.2.2/selectdb-x2doris-v1.2.2_2.12-x86-bin.tar.gz -
ARM64 (Spark 3)
wget https://enterprise-doris-releases.oss-cn-beijing.aliyuncs.com/x2doris/v1.2.2/selectdb-x2doris-v1.2.2_2.12-arm64-bin.tar.gz
For more versions, see X2Doris tool.
-
-
Extract the package.
-
x64 (Spark 3)
tar -zxvf selectdb-x2doris-v1.2.2_2.12-x86-bin.tar.gz -
ARM64 (Spark 3)
tar -zxvf selectdb-x2doris-v1.2.2_2.12-arm64-bin.tar.gz
-
-
Initialize metadata.
X2Doris supports two metadata storage options: the built-in H2 database and a self-managed MySQL database. We recommend MySQL.
Self-managed MySQL
If you need persistent metadata storage, use MySQL.
-
Install MySQL.
sudo yum install mysql -
Log on to MySQL.
mysql -h<IP> -P<port> -u<user_name> -p<password>; -
Run scripts.
-
Run mysql-schema.sql to initialize table schemas.
abs_pathis the absolute path to themysql-schema.sqlfile in the installation directory of X2Doris.source <abs_path>/mysql-schema.sql;After running this script, MySQL creates a database named
x2doris. Runshow databases;to verify. -
Run
mysql-data.sqlto initialize table data.abs_path is the absolute path to the
mysql-data.sqlfile in the X2Doris installation directory.source <abs_path>/mysql-data.sql;
-
-
Change X2Doris to use MySQL.
Go to the
confdirectory in your X2Doris installation. Editapplication.ymland setspring.profiles.activetomysql.vim application.yml
-
Configure MySQL connection details.
Go to the
confdirectory in your X2Doris installation. Editapplication-mysql.ymlto configure the data source.vim application-mysql.yml
H2
The default H2 database stores data in local files.
-
-
Start X2Doris.
Go to the
bindirectory in your X2Doris installation. Runbash startup.sh.
Import data
Prerequisites
-
Add the IP addresses of your source data and the X2Doris server to the ApsaraDB for SelectDB whitelist. For details, see Configure the whitelist.
-
The access port for X2Doris is now open.
NoteThe default port is 9091. Check application.yml in your X2Doris installation directory for the actual port number.
Notes
If your data source is Hive, check the environment on the machine where X2Doris is installed. For environment requirements, see Environment requirements.
Procedure
-
Configure how to retrieve Hive metadata.
Edit the X2Doris configuration file
conf/application-hive.yamlto set how to retrieve Hive metadata.vim application-hive.yaml
Parameter descriptions
Parameter Name
Description
client
How to get Hive metadata.
-
Metastore: Default method. Use this if your Hive is standard Apache Hive.
-
JDBC: If you cannot use the
metastoreapproach because of permission restrictions or other issues, you can use the JDBC approach and set the client to JDBC. -
DLF: Use this if your Hive is Alibaba Cloud Hive. Set
dlf.
jdbc
If the client is configured with JDBC, you must configure the relevant JDBC parameters.
-
jdbcurl: JDBC connection string for your Hive source.
-
userName: Hive username.
-
password: Logon password.
aliyun.dlf
If the client is configured to use DLF, you must also configure its parameters.
-
accesskeyId: Alibaba Cloud account AccessKey ID.
-
accessKeySecret: Alibaba Cloud account AccessKey secret.
-
An endpoint is the domain name for accessing the external services of DLF.
-
regionId: Region where the DLF data center is located.
-
catalogId: DLF data catalog.
-
-
Log on to the X2Doris console.
Default URL:
http://<IP>:9091.Note-
IP is the IP address of the X2Doris server.
-
9091 is the default port. If you changed it in application.yml, use your custom port.
-
Default username:
admin. Default password:admin.
-
-
Configure system settings.
In the X2Doris console, click System Settings in the navigation pane on the left. In the System Settings panel, complete the following steps.
-
Configure Hadoop user: Click Edit to the right of Hadoop user, enter the Hadoop user in the input field, and click Submit.
-
Configure Spark Home: Click Edit to the right of Spark Home, enter the Spark Home in the input box, and click Submit.
-
Set Hive metastore uris: Click Edit next to Hive metastore uris. Enter the URIs in the field. Click Submit.
Note-
Required when importing from Hive.
-
Get this value by running
SET hive.metastore.uris;in the Hive console.
-
-
Set Target doris info: Click Edit next to Target doris info. In the Doris/SelectDB Cloud Target Endpoint dialog box, configure the following items. Click OK after you finish.
Configuration item
Description
HTTP Nodes
HTTP endpoint.
Format:
<ip>:<port>.Note-
You can obtain the VPC Endpoint (or Public Endpoint) and HTTP Port from the ApsaraDB for SelectDB console under Instance Details > Network Information.
-
If the X2Doris instance and the ApsaraDB for SelectDB instance are in the same VPC, use the VPC endpoint. Otherwise, use the public endpoint.
Example:
selectdb-cn-4xl3jv1****.selectdbfe.rds.aliyuncs.com:8080MySQL Nodes
JDBC connection string.
Format:
<ip>:<port>.NoteYou can obtain the VPC Address (or Public Network Address) and HTTP Protocol Port from the Instance Details > Network Information page in the ApsaraDB for SelectDB console.
If the X2Doris instance and the ApsaraDB for SelectDB instance are in the same VPC, use the VPC endpoint. Otherwise, use the public endpoint.
Get the VPC endpoint (or public endpoint) and MySQL port from the ApsaraDB for SelectDB console: Instance Details > Network Information.
Example:
selectdb-cn-4xl3jv1****.selectdbfe.rds.aliyuncs.com:9030User
Username for your ApsaraDB for SelectDB instance.
Password
Password for your ApsaraDB for SelectDB instance.
-
-
-
Create a job.
-
In the navigation pane on the left, click Job Center to open the Job Center page.
-
Hover over New Job in the upper-right corner of the Job Center list. Select your data source to open the job configuration page.
-
In the left area of the page, select your source database.
-
Configure Field mapping. Click Next.
Configuration item
Description
DORIS field type
The system automatically maps Doris and Hive field types.
Note-
Automatic detection is enabled by default.
-
Specify the Doris table data type, especially for STRING fields.
DUPLICATE KEY
Columns used to sort underlying data.
NoteAt least one column must be set.
DISTRIBUTED BY
Columns used to bucket underlying data.
NoteAt least one column must be set.
-
-
Configure Partition mapping.
If the partition field in your Hive table is of type
STRING, decide whether to convert the corresponding ApsaraDB for SelectDB target table field to a time type based on your actual data. If you need conversion, set the partition range.Configuration item
Description
DORIS field type
The system automatically maps Doris and Hive field types.
Note-
By default, the system automatically detects it.
-
Specify the Doris table data type, especially for STRING fields.
DUPLICATE KEY
Columns used to sort underlying data.
NoteAt least one column must be set.
DISTRIBUTED BY
Columns used to bucket underlying data.
NoteAt least one column must be set.
-
-
Create a table.
If you already created the table in SelectDB, click Skip Table Creation to go to Job Settings.
If you did not create the table in SelectDB, click Create Table. Review the Doris DDL statement. Click Create Doris Table. Click Next to go to Job Settings.
-
Configure the following Job Settings items. Click Create Job.
Configuration item
Description
Job Name
Auto-generated name for the data import task.
Job Tag
Auto-generated tag for the data import task.
Master
Select local mode or YARN mode. This controls how X2Doris jobs run. Adjust based on your environment.
YARN Queue
Queue resource used by Spark jobs.
Resource Parameters
Memory parameters for Spark jobs, such as executor and driver core count and memory size. Adjust based on your environment.
Batch Write
Batch size for data writes. Adjust based on your data volume. For large datasets, set this to 500000 or higher.
Retry on Failure
Number of retries for failed jobs. Increase this value if your network is unstable.
Spark Parameters
Custom Spark parameters. Add them in
key=valueformat.You can use standard Spark parameters. For details, see Application Properties.
Connection Configurer
Optimization parameters for reading from your data source or writing to Doris. See the official Spark connector documentation for details.
You can use standard Doris Spark connector parameters. For details, see Common Configuration Items.
-
-
-
Start the sync job.
-
In the navigation pane on the left, click Job Center.
-
In the Job Center data list, find the target job and click the Start button
in the Actions column. -
In the Start Job dialog box, configure the following items.
Configuration item descriptions
Configuration item
Description
Example value
Query Condition
Filter condition for the data to import.
NoteDo not include the
WHEREkeyword. Only write the filter logic.name='Alice'
Clear Data
Delete existing data in the target table.
WarningThis operation is risky. Use with caution.
-
OFF (default): Do not delete.
-
ON: delete.
OFF
-
-
Click OK.
-
-
View the job.
-
In the navigation pane on the left, click Job Center to open the Job Center page.
-
Find your job. View the Migration Progress and Execution Status.
-
Import non-Hive source data
Install X2Doris
Installation environment
This topic uses Linux as an example. Choose the appropriate commands for your system and environment.
Procedure
-
Select an X2Doris version.
With Spark installed
Go to the jars directory in the Spark installation directory, locate JAR files that start with spark-yarn, and identify the Scala version that corresponds to the Spark dependency package. The following example shows how to do this:
For spark-yarn_2.12-3.2.4.jar, the corresponding Scala version is 2.12.

Without Spark installed
Choose the X2Doris package for Scala 2.12.
-
Download X2Doris.
-
x64 (Spark 3)
wget https://enterprise-doris-releases.oss-cn-beijing.aliyuncs.com/x2doris/v1.2.2/selectdb-x2doris-v1.2.2_2.12-x86-bin.tar.gz -
ARM64 (Spark 3)
wget https://enterprise-doris-releases.oss-cn-beijing.aliyuncs.com/x2doris/v1.2.2/selectdb-x2doris-v1.2.2_2.12-arm64-bin.tar.gz
For more versions, see X2Doris tool.
-
-
Extract the package.
-
x64 (Spark 3)
tar -zxvf selectdb-x2doris-v1.2.2_2.12-x86-bin.tar.gz -
ARM64 (Spark 3)
tar -zxvf selectdb-x2doris-v1.2.2_2.12-arm64-bin.tar.gz
-
-
Initialize metadata.
X2Doris supports two metadata storage options: the built-in H2 database and a self-managed MySQL database. We recommend MySQL.
Self-managed MySQL
If you need persistent metadata storage, use MySQL.
-
Install MySQL.
sudo yum install mysql -
Log on to MySQL.
mysql -h<IP> -P<port> -u<user_name> -p<password>; -
Run scripts.
-
Run mysql-schema.sql to initialize table schemas.
abs_pathis the absolute path to themysql-schema.sqlfile in the installation directory of X2Doris.source <abs_path>/mysql-schema.sql;After running this script, MySQL creates a database named
x2doris. Runshow databases;to verify. -
Run
mysql-data.sqlto initialize table data.abs_path is the absolute path to the
mysql-data.sqlfile in the X2Doris installation directory.source <abs_path>/mysql-data.sql;
-
-
Change X2Doris to use MySQL.
Go to the
confdirectory in your X2Doris installation. Editapplication.ymland setspring.profiles.activetomysql.vim application.yml
-
Configure MySQL connection details.
Go to the
confdirectory in your X2Doris installation. Editapplication-mysql.ymlto configure the data source.vim application-mysql.yml
H2
The default H2 database stores data in local files.
-
-
Start X2Doris.
Go to the
bindirectory in your X2Doris installation. Runbash startup.sh.
Import data
Prerequisites
-
Add the IP addresses of your source data and the X2Doris server to the ApsaraDB for SelectDB whitelist. For details, see Configure the whitelist.
-
The access port for X2Doris is now open.
NoteThe default port is 9091. Check application.yml in your X2Doris installation directory for the actual port number.
Procedure
-
Log on to the X2Doris console.
Default URL:
http://<IP>:9091.Note-
The IP address is that of the server where X2Doris is installed.
-
9091 is the default port. If you changed it in application.yml, use your custom port.
-
Default username:
admin. Default password:admin.
-
-
Configure system settings.
In the X2Doris console, click System Settings in the navigation pane on the left. In the System Settings panel, complete the following steps.
-
(Optional) Configure Hadoop user: Click Edit to the right of Hadoop user, enter the Hadoop user in the input box, and click Submit.
-
(Optional) Configure Spark Home: Click Edit to the right of Spark Home, enter the Spark Home in the input field, and click Submit.
-
(Optional) Set Hive metastore uris: Click Edit next to Hive metastore uris. Enter the URIs in the field. Click Submit.
-
Configure Target doris info: Click Edit to the right of Target doris info. In the Doris/SelectDB Cloud Target Endpoint Information pop-up dialog, configure the following configuration items. When you finish configuring, click OK.
Configuration item
Description
HTTP Nodes
HTTP endpoint.
Format:
<ip>:<port>.Note-
You can obtain the VPC Address (or Public Address) and the HTTP Port from the Instance Details > Network Information page in the ApsaraDB for SelectDB console.
-
If the X2Doris instance and the ApsaraDB for SelectDB instance are in the same VPC, use the VPC endpoint. Otherwise, use the public endpoint.
Example:
selectdb-cn-4xl3jv1****.selectdbfe.rds.aliyuncs.com:8080MySQL Nodes
JDBC connection string.
Format:
<ip>:<port>.NoteYou can obtain the VPC Address (or Public Network Address) and HTTP Port from the ApsaraDB for SelectDB console's Instance Details > Network Information section.
If the X2Doris instance and the ApsaraDB for SelectDB instance are in the same VPC, use the VPC endpoint. Otherwise, use the public endpoint.
Get the VPC endpoint (or public endpoint) and MySQL port from the ApsaraDB for SelectDB console: Instance Details > Network Information.
Example:
selectdb-cn-4xl3jv1****.selectdbfe.rds.aliyuncs.com:9030User
Username for your ApsaraDB for SelectDB instance.
Password
Password for your ApsaraDB for SelectDB instance.
-
-
-
Add a Data Source.
-
In the navigation pane on the left, click Data Sources to open the Data Sources page.
-
Hover over Add Data Source in the upper-right corner of the Data Sources list. Select your data source.
-
Complete the configuration in the panel. Click OK.
-
-
Create a job.
-
In the navigation pane on the left, click Job Center to open the Job Center page.
-
Hover over New Job in the upper-right corner of the Job Center list. Select your data source to open the job configuration page.
-
In the Select Data Source dialog box, find your data source. Click the
icon in the Use column. -
In the left area of the page, select your source data.
Note-
Select one table, multiple tables, or an entire database.
-
If you select one table, the DDL statement appears on the right side of the page.
-
If you select multiple tables, the system generates DDL using the default strategy. No DDL appears on the right side.
-
-
Click the appropriate button to go to Job Settings.
-
Skip Table Creation: Use this if the table already exists in the ApsaraDB for SelectDB target.
-
Create Table Only: Use this to create a table without creating a migration job.
-
Create Table and Job: Use this to create both a table and a migration job.
-
-
Configure the following Job Settings items. Click Create Job.
Configuration item
Description
Job Name
Name for the data migration task.
NoteAuto-generated. No manual input required.
Job Tag
Tag for the data import task.
NoteAuto-generated. No manual input required.
Master
How X2Doris jobs run.
NoteIf your X2Doris server has Hadoop and YARN, set this to yarn. Otherwise, set it to local.
YARN Queue
Queue resource used by Spark jobs.
Resource Parameters
Memory parameters for Spark jobs.
Examples: Executor and driver core count and memory size. For more parameters, see Spark Configuration.
Batch Write
Batch size for data writes.
For large datasets, set this to 500000 or higher.
Retry on Failure
Number of retries for failed jobs.
If your network is unstable, increase this value.
Spark Parameters
Custom Spark parameters.
NoteAdd extra Spark parameters in
key=valueformat. For more parameters, see Application Properties.Connection Configurer
Optimization parameters for reading from your data source or writing to SelectDB. For example, if your data source is Doris, see Spark Doris Connector.
-
-
-
Start the sync job.
-
In the navigation pane on the left, click Job Center.
-
In the Job Center data list, find the target job and click the Start button
in the Actions column. -
In the Start Job dialog box, configure the following items.
Configuration item descriptions
Configuration item
Description
Example value
Query Condition
Filter condition for the data to import.
NoteDo not include the
WHEREkeyword. Only write the filter logic.name='Alice'
Clear Data
Delete existing data in the target table.
WarningThis operation is risky. Use with caution.
-
OFF (default): Do not delete.
-
ON: delete.
OFF
-
-
Click OK.
-
In the navigation pane on the left, click Job Center to open the Job Center page.
-
Find your job. View the Migration Progress and Execution Status.
-
-
View the job.
-
In the navigation pane on the left, click Job Center to open the Job Center page.
-
Find your job. View the Migration Progress and Execution Status.
-
Parameter tuning guide
When importing data from Doris or StarRocks into ApsaraDB for SelectDB, you can improve read speed if your Doris or StarRocks resources are underutilized. In the Create Job Properties section, set these parameters:
doris.request.tablet.size=1 # If your data source is Doris
starrocks.request.tablet.size=1 # If your data source is StarRocks
This parameter sets the number of tablets per RDD partition. A smaller value creates more partitions, increasing Spark parallelism but also increasing load on Doris or StarRocks.
FAQ
How do I troubleshoot a failed job?
If a data import task fails, first check the operational logs of the X2Doris program, which are located in the log directory of the X2Doris installation directory. You can view the selectdb.out file to monitor and identify the program's operational status.
If the logs do not resolve the issue, collect the logs and context for the migration job. Then submit a ticket for support.
What Should I Do If Adding a Hive Data Source Fails?
When adding a Hive data source, the system checks the Hive connection. If the connection fails, you see an error message like this:
Check whether Hive metastore uris in System Settings can communicate with the X2Doris server.