---
title: 使用 OBLOADER 导入数据-V3.2.4-OceanBase 数据库文档-分布式数据库使用文档
description: 分布式数据库OceanBase 企业版文档中心，提供关于使用 OBLOADER 导入数据的相关内容，方便用户更好的应用分布式数据库OceanBaseOceanBase 数据库
image: https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*OSPzQ6GUQF4AAAAAQHAAAAgAeiGDAQ/original
---
[OceanBase AI 数据大会](https://www.oceanbase.com/conference2026 "OceanBase AI 数据大会")文档反馈![](https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*P8CuR4UJ_FkAAAAAAAAAAAAADiGDAQ/original) OceanBase 数据库分布式版 - V 3.2.4 企业版 LTS

# 使用 OBLOADER 导入数据

更新时间：2026-06-26 09:36:33

OBLOADER 是一款使用 Java 开发的客户端导入工具。该工具提供了非常灵活的命令行选项，您可以在多种复杂的场景下，将结构和数据导入到 OceanBase 数据库中。OBLOADER 主要与 OBDUMPER 搭配使用。但是在外部业务中，OBLOADER 也支持如 Navicat、Mydumper 和 SQLDeveloper 等工具导出的 SQL 或 CSV 格式的文件导入。OBLOADER 充分利用 OceanBase 分布式系统的特性，重点优化了导入的性能。

#### 说明

请在 OceanBase 官方网站左上角，单击 **资源** > [下载中心](https://www.oceanbase.com/softwarecenter-enterprise) 获取 OceanBase 导数工具（包括导入工具 OBLOADER 和导出工具 OBDUMPER）的安装包。如果未找到对应版本的安装包，请联系技术支持获取。

## 产品功能

OBLOADER 提供向 OceanBase 数据库导入结构和数据的能力，主要具备以下功能特性：

- 支持导入 Schema 定义语句。
 - 支持导入 CSV 和 SQL 格式的数据文件。
 - 支持导入字节偏移量、字符串分隔和混合数据文件等复杂的数据格式。
 - 支持配置数据预处理的控制规则。
 - 支持配置文件与表之间的字段映射关系。
 - 支持限流、防导爆、断点恢复和自动重试等特性。
 - 支持指定自定义的日志目录、保存坏数据和冲突数据等特性。
 - 支持限制模式导入数据，限制模式不依赖系统租户下的任意账号信息。

  > **说明**
  >
  >  
  >
  > 如果是限制模式，导出的结构定义可能不完整。同时，导入导出的性能会比较低。

## 支持的 OceanBase 数据库

支持连接的 OceanBase 数据库版本如下表所示：

| **数据库** | **支持的版本** |
| --- | --- |
| OceanBase 数据库 Oracle 模式 | V2.0.x、V2.1.x、V2.2.20、V2.2.30、V2.2.50、V2.2.70、V2.2.71、V2.2.72、V2.2.76、V3.1.x |
| OceanBase 数据库 MySQL 模式 | V1.4.70、V1.4.72、V1.4.75、V1.4.78、V 1.4.79、V2.2.30、V2.2.50、V2.2.70、V2.2.71、V2.2.72、V2.2.76、V3.1.x |

## 注意事项

- 标准的 CSV 格式可以阅读 RFC 4180 规范，推荐导入导出严格遵从 RFC 4180 规范。
 - 导入导出大规模的数据量时，请在运行的脚本中修改虚拟机的内存参数（默认：-Xms4G -Xmx4G）。
 - 命令行参数指定的对象名、数据文件名、规则文件名要求大小写一致。Oracle 默认大写，MySQL 默认小写。
 - 导入的数据文件名要求满足格式 **表名.<任意字符>.后缀** 。
 - 数据库中存在有外键的表时，无法保证结构和数据按照依赖顺序导入，可能会导入失败。
 - 无主键的表，暂不支持中断续传。
 - 导入时，要求指定的对象名与数据文件名大小写一致。如果数据库中同时存在大写和小写的对象，那么小写的对象名和文件名需要使用双引号包含起来。
 - OBLOADER 支持的文件格式如下所示：

     - DDL 文件格式：文件中仅包含 DDL 语句。
     - SQL 文件格式：文件中的仅包含 `INSERT` 语句，记录不跨行。
     - MIX 混合文件格式：文件中包含 DDL 和 DML 等多种混合的语句。
     - POS 文件格式：文件中的数据是根据字节（非字符）偏移位置产生的。
     - CUT 文件格式：文件中的数据是根据字符串分隔，区别于 CSV 格式的单个字符分隔。

## 限制模式

OBLOADER 可以通过指定 `--public-cloud` 选项使用限制模式导入数据。限制模式只能适用于公有云部署的OceanBase 集群。对于私有云部署的 OceanBase 集群，需要指定 `--sys-password` 或者配置秘钥文件。

限制模式会牺牲掉一些导入的功能、性能以及稳定性。同时，OceanBase 数据库 V2.2.30 及以上版本才支持服务端限流的能力，所以在使用限制模式时通过以下命令调整服务端限流：

```sql
ALTER SYSTEM SET freeze_trigger_percentage=50;
ALTER SYSTEM SET minor_merge_concurrence=64;
ALTER SYSTEM SET writing_throttling_trigger_percentage=80 tenant='xxx';

```

## 使用示例

将表结构和数据导入 OceanBase 数据库时，建议将它们分开导入。 OBLOADER 命令帮助如下：

```shell
bin/obloader -h <主机IP> -P <端⼝> -u <⽤⼾> -p <密码>  --sys-user <sys 租户下的 root 用户或 proxyro 用户> --sys-password <sys 租⼾下的账⼾密码> -c <集群> -t <租⼾> -D <Schema 库名> [--ddl] [--csv|--sql] [--all|--table '表名'] -f<数据⽂件或者⽬录>

```

导入的时候 OBLOADER 需要取表结构元数据信息，也需要连接到 sys 租户下。推荐您使用用户 `proxyro`。

### 导入表结构

下文展示了将数据导出文件导入到租户 `obmysql` 的数据库 `test2` 下。

```shell
[root@obce-0000 ob-loader-dumper-3.0.0-SNAPSHOT]# bin/obloader -h 10.0.0.0 -P 2883 -u u_loader -p ****** --sys-user=proxyro --sys-password=******** -c obce-3zones -t obmysql -D test2 --ddl --all -f /tmp/obdumper
2021-09-29 21:26:05 [INFO] Parsed args:
-h[--host] 10.0.0.0
-P[--port] 2883
-u[--user] u_loader
-p[--password] ******
[--sys-user] proxyro
[--sys-password] ******
-c[--cluster] obce-3zones
-t[--tenant] obmysql
-D[--database] test2
[--ddl]
[--all]
-f[--file-path] /tmp/obdumper

2021-12-29 14:02:25 [INFO] The security certificate file: "/ob-loader-dumper-3.0.0-SNAPSHOT/conf/secure.crt" is not exists
2021-12-29 14:02:25 [INFO] No control files were defined in the path: "/tmp/obdumper"
2021-12-29 14:02:25 [INFO] Load jdbc driver class: "com.oceanbase.jdbc.Driver" finished
2021-12-29 14:02:25 [INFO] The manifest file: "/tmp/obdumper/data/MANIFEST.bin" has been saved
2021-12-29 14:02:26 [INFO] Init writer thread pool finished
2021-12-29 14:02:26 [WARN] The object type : "SEQUENCE" doesn't exist in the -schema.sql files
2021-12-29 14:02:26 [INFO] No.1 sql of the file: "/tmp/obdumper/data/test/TABLE/test1-schema.sql" exec  success . Elapsed: 141.6 ms
2021-12-29 14:02:26 [INFO] Load file: "test1-schema.sql" finished
2021-12-29 14:02:26 [INFO] No.1 sql of the file: "/tmp/obdumper/data/test/TABLE/test0-schema.sql" exec  success . Elapsed: 227.2 ms
2021-12-29 14:02:26 [INFO] Load file: "test0-schema.sql" finished
2021-12-29 14:02:26 [WARN] The object type : "VIEW" doesn't exist in the -schema.sql files
2021-12-29 14:02:26 [WARN] The object type : "FUNCTION" doesn't exist in the -schema.sql files
2021-12-29 14:02:26 [WARN] The object type : "PROCEDURE" doesn't exist in the -schema.sql files
2021-12-29 14:02:26 [WARN] The object type : "TRIGGER" doesn't exist in the -schema.sql files
2021-12-29 14:02:26 [WARN] The object type : "PACKAGE" doesn't exist in the -schema.sql files
2021-12-29 14:02:26 [WARN] The object type : "TYPE" doesn't exist in the -schema.sql files
2021-12-29 14:02:26 [WARN] The object type : "PACKAGE_BODY" doesn't exist in the -schema.sql files
2021-12-29 14:02:26 [WARN] The object type : "TYPE_BODY" doesn't exist in the -schema.sql files
2021-12-29 14:02:26 [WARN] The object type : "SYNONYM" doesn't exist in the -schema.sql files
2021-12-29 14:02:26 [WARN] The object type : "PUBLIC_SYNONYM" doesn't exist in the -schema.sql files
2021-12-29 14:02:27 [INFO] Close connection count: 1 of the DataSource. Key: 11_124_5_29_44564_857230679_test
2021-12-29 14:02:27 [INFO] Close connection count: 0 of the DataSource. Key: 11_124_5_29_44564_167438737_oceanbase
2021-12-29 14:02:27 [INFO] Shutdown task context finished
2021-12-29 14:02:27 [INFO]
Finished Tasks: 2 Running Tasks: 0 Progress: 100.00%
2021-12-29 14:02:27 [INFO]

All Load Tasks Finished:

----------------------------------------------------------------------------------------------------------------------------
        No.#        |        Type        |             Name             |            Count             |       Status
----------------------------------------------------------------------------------------------------------------------------
         1          |       TABLE        |            test0             |              1               |      SUCCESS
         2          |       TABLE        |            test1             |              1               |      SUCCESS
----------------------------------------------------------------------------------------------------------------------------

Total Count: 2  End Time: 2021-12-29 14:02:27

2021-12-29 14:02:27 [INFO] Load schema finished. Total Elapsed: 1.057 s
2021-12-29 14:02:27 [INFO] System exit 0

[root@obce-0000 ob-loader-dumper-3.0.0-SNAPSHOT]#

```

### 导入数据

```shell
[root@obce-0000 ob-loader-dumper-3.0.0-SNAPSHOT]# bin/obloader -h 10.0.0.0 -P 2883 -u u_loader -p ****** --sys-user=proxyro --sys-password=******** -c obce-3zones -t obmysql -D test2 --csv --all -f /tmp/obdumper
2021-09-29 21:27:53 [INFO] Parsed args:
-h[--host] 10.0.0.0
-P[--port] 2883
-u[--user] u_loader
-p[--password] ******
[--sys-user] proxyro
[--sys-password] ******
-c[--cluster] obce-3zones
-t[--tenant] obmysql
-D[--database] test2
[--csv]
[--all]
-f[--file-path] /tmp/obdumper

2021-12-29 14:07:21 [INFO] The security certificate file: "/ob-loader-dumper-3.0.0-SNAPSHOT/conf/secure.crt" is not exists
2021-12-29 14:07:21 [INFO] No control files were defined in the path: "/tmp/obdumper"
2021-12-29 14:07:21 [INFO] Load jdbc driver class: "com.oceanbase.jdbc.Driver" finished
2021-12-29 14:07:21 [INFO] The manifest file: "/tmp/obdumper/data/MANIFEST.bin" has been saved
2021-12-29 14:07:22 [INFO] Query the column metadata for the table: "test0" finished
2021-12-29 14:07:22 [INFO] Query the column metadata for the table: "test1" finished
2021-12-29 14:07:22 [INFO] Binding table: "test0" to the file: "/tmp/obdumper/data/test/TABLE/test0.0.0.csv" finished
2021-12-29 14:07:22 [WARN] File: "/tmp/obdumper/data/test/TABLE/test0-schema.sql" is unmatched on the suffix[.csv], ignore it
2021-12-29 14:07:22 [WARN] File: "/tmp/obdumper/data/test/TABLE/test1-schema.sql" is unmatched on the suffix[.csv], ignore it
2021-12-29 14:07:22 [WARN] File: "/tmp/obdumper/data/MANIFEST.bin" is unmatched on the suffix[.csv], ignore it
2021-12-29 14:07:22 [WARN] File: "/tmp/obdumper/data/CHECKPOINT.bin" is unmatched on the suffix[.csv], ignore it
2021-12-29 14:07:22 [INFO] Splitted 1 csv subfiles by 64.0 MB. Elapsed: 15.57 ms
2021-12-29 14:07:22 [INFO] Generate 1 subfiles finished
2021-12-29 14:07:22 [INFO] Ignore to clean any tables as --truncate-table or --delete-from-table is not specified
2021-12-29 14:07:22 [INFO] Ignore to query table entry for table: "test1" without datafiles. Remain: 1
2021-12-29 14:07:22 [INFO] Query table entry and primary key for table: "test0" finished. Remain: 0
2021-12-29 14:07:22 [INFO] Ignore to shuffle data files for table: "test1" without datafiles. Remain: 1
2021-12-29 14:07:50 [INFO] Query the leader location "test0" in multi unit finished. Elapsed: 73.12 ms
2021-12-29 14:07:50 [INFO] Query the leader location of "test0" finished. Remain: 0
2021-12-29 14:07:50 [INFO] Calculate leader: xx.xx.xx.xx:11141 of table: "test0", part: 0. Remain: 0
2021-12-29 14:07:50 [INFO] Waiting to refresh observer load status ......
2021-12-29 14:07:50 [INFO] Refresh the observer load status success. Table: "test0". Remain: 0
2021-12-29 14:07:50 [INFO] Refresh observer load status finished. Elapsed: 116.4 ms
2021-12-29 14:07:50 [INFO] Create 16384 slots for ring buffer finished. [xx.xx.xx.xx:11141]
2021-12-29 14:07:51 [INFO] Start 192 database writer threads finished. [xx.xx.xx.xx:11141]
2021-12-29 14:07:51 [INFO] Start 38 csv file reader threads successed
2021-12-29 14:07:51 [INFO] File: "/tmp/obdumper/data/test/TABLE/test0.0.0.csv" has been parsed finished
2021-12-29 14:07:55 [INFO]

1. Enqueue Performance Monitor:
-------------------------------------------------------------------------------------------------------
 Dimension \ Metric |             Tps              |          Throughput          |       Buffer
-------------------------------------------------------------------------------------------------------
     1.sec.avg      |       2.03 Records/sec       |          0.0 KB/sec          |      1 Slots
     1.min.avg      |       0.0 Records/min        |          0.0 KB/min          |      1 Slots
       Total        |          10 Records          |            0.0 KB            |      1 Slots
-------------------------------------------------------------------------------------------------------

2. Dequeue Performance Monitor:
-------------------------------------------------------------------------------------------------------
 Dimension \ Metric |             Tps              |          Throughput          |       Buffer
-------------------------------------------------------------------------------------------------------
     1.sec.avg      |       2.0 Records/sec        |          0.0 KB/sec          |      1 Slots
     1.min.avg      |       2.0 Records/min        |          2.0 KB/min          |      1 Slots
       Total        |          10 Records          |            0.0 KB            |      1 Slots
-------------------------------------------------------------------------------------------------------

2021-12-29 14:08:13 [INFO] Wait for the all the workers to drain of published events then halt the workers
2021-12-29 14:08:13 [INFO] Close connection count: 4 of the DataSource. Key: 11_124_5_29_44564_857230679_test
2021-12-29 14:08:14 [INFO] Close connection count: 17 of the DataSource. Key: 11_124_5_29_44564_167438737_oceanbase
2021-12-29 14:08:14 [INFO] Shutdown task context finished
2021-12-29 14:08:14 [INFO]
Finished Tasks: 1 Running Tasks: 0 Progress: 100.00%
2021-12-29 14:08:14 [INFO]

----------------------------------------------------------------------------------------------------------------------------
        No.#        |        Type        |             Name             |            Count             |       Status
----------------------------------------------------------------------------------------------------------------------------
         1          |       TABLE        |            test0             |           10 -> 10           |      SUCCESS
----------------------------------------------------------------------------------------------------------------------------

Total Count: 10  End Time: 2021-12-29 14:08:14

2021-12-29 14:08:14 [INFO] Load record finished. Total Elapsed: 2.05 s
2021-12-29 14:08:14 [INFO] System exit 0

```

### 检查导入的表结构和数据

```sql
MySQL [test]> SHOW create table test2.t1\G
*************************** 1. row ***************************
       Table: t1
Create Table: CREATE TABLE `t1` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `c1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 ROW_FORMAT = COMPACT COMPRESSION = 'zstd_1.3.8' REPLICA_NUM = 3 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
1 row in set

MySQL [test]> SELECT * FROM test2.t1;
+----+---------------------+
| id | c1                  |
+----+---------------------+
|  1 | 2021-09-29 21:16:03 |
|  2 | 2021-09-29 21:16:05 |
|  3 | 2021-09-29 21:16:05 |
|  4 | 2021-09-29 21:16:06 |
|  5 | 2021-09-29 21:16:06 |
|  6 | 2021-09-29 21:16:18 |
|  7 | 2021-09-29 21:16:18 |
|  8 | 2021-09-29 21:16:19 |
+----+---------------------+
8 rows in set

```

## 更多信息

关于 OBLOADER 的更多使用信息，请参见 [数据处理](https://www.oceanbase.com/docs/enterprise-oceanbase-dumper-loader-cn-10000000001499773)。

 上一篇 下一篇 ![有帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*y6ocSqN8cqsAAAAAAAAAAAAAARQnAQ)![无帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*BG9IQJyLHF8AAAAAAAAAAAAAARQnAQ)![反馈](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*eTWdQKCRKHwAAAAAAAAAAAAAARQnAQ) 咨询
