When the environment where the data files are located cannot be directly accessed by OBServer, that is, when the network connection to OBServer is unavailable or it is inconvenient to copy the files to the local path of OBServer, you can use obloader to write the data to OceanBase.
Unlike executing SQL statements such as LOAD DATA and LOAD DATA FROM FILES on the OBServer side, obloader reads files in a client process and interacts with the storage layer through RPC, making it suitable for scenarios such as offline package delivery and cross-subnet data transfer.
Notice
obloader direct load supports connecting to OBServer or ODP. Version requirements:
- To connect to OBServer: OBServer V4.2.0 or later.
- To connect to ODP: ODP V4.3.0 or later, and OBServer V4.2.1 or later.
Application scenarios
- Files are inaccessible to OBServer: The exported files are located on a business server, jump server, or in an isolated subnet, and the network between OBServer and the data file location is unavailable, making it inconvenient to use the import method where OBServer directly reads the files.
If the files are already placed in a path accessible to OBServer or in object storage, you should first evaluate the path selection options described in LOAD DATA FROM FILES, LOAD DATA INFILE, and Overview of data import.
Command-line options
Refer to the Data import tool documentation and configure according to your actual environment.
Command-line option |
Description |
Cloud OceanBase Database & ODP |
OceanBase Database & ODP |
OceanBase Database & OBServer |
|---|---|---|---|---|
| --direct | Indicates that direct load is used. | Required | Required | Required |
| --parallel | Server-side concurrency. The default value is 1, which is recommended to match the tenant's CPU specification. It is recommended to specify this option to ensure stable performance. |
Optional | Optional | Optional |
| --rpc-port | Server-side inner RPC port. Obtaining the value:
|
Required | Required | Required |
| -u(--user) | The database username. | Required | Required | Required |
| -P(--port) | The port number of the SQL server. | Required | Required | Required |
| -t(--tenant) | The tenant name of the cluster. | Optional If left empty, partition calculation may be skipped. |
Required | Required |
| -c(--cluster) | The cluster name of the database. | Optional | Required | - |
| --public-cloud | Specify the cloud database OceanBase runtime environment. | Required | - | - |
| --no-sys | Used to identify tenants that do not depend on the sys tenant. This parameter is applicable only to OceanBase Database versions earlier than V4.0.0. | Optional | Optional | Optional |
| --sys-user | Identifies the user that depends on the sys tenant. If not specified, the default is root. This parameter is applicable only to OceanBase Database versions earlier than V4.0.0. | Optional Exclusive with --no-sys |
Optional Exclusive with --no-sys |
Optional Exclusive with --no-sys |
| --sys-password | The password used to identify the tenant that depends on the sys tenant. This parameter is applicable only to OceanBase Database versions earlier than V4.0.0. | Optional Exclusive with --no-sys |
Optional Exclusive with --no-sys |
Optional Exclusive with --no-sys |
Example
Execute the following command on the server where the CSV files are stored (the example uses an ODP and an Oracle-compatible tenant; replace with your actual address, port, user, and path):
bin/obloader -h <ODP or OBServer address> -P 2883 -u <user> -t <tenant name> -c <cluster name> -p \
-D <database name> --table LINEITEM --external-data --csv \
-f /data/tpch/bak/ \
--truncate-table --column-separator='|' \
--thread 16 --rpc-port 2885 --direct --parallel=16
Direct load accesses the RPC port, not the SQL port. By default, the SQL port of an OBServer node is 2881 and the RPC port is 2882. For ODP V4.3.0, the RPC port defaults to 2885. When obloader bypasses ODP to directly connect to OBServer and explicitly specifies the RPC port, it can use the direct load path.
Note that bypassing ODP to directly connect OBServer from the client is generally not recommended in production environments. When accessing through ODP, the location of the primary data replica is transparent to the client, and routing is handled uniformly by ODP. However, when directly connecting to a specific OBServer, if the primary replica of the target data is not on the current node, the write process may involve cross-node transaction coordination, increasing network and transaction overhead.
-fspecifies a readable data directory on the local machine. The tool reads files on the client and writes them via RPC bypass. It is not required that OBServer can access this path.--rpc-portmust match the RPC listening port of the current connection target (ODP or OBServer). Do not confuse it with the SQL port.- If connecting directly to a specific OBServer, you need to check whether the primary data replica resides on that node. Cross-machine bypassing may incur additional costs. Where reachable, prefer ODP to align with the production business access method. Specific routing and network policies shall comply with operational specifications.
When data volume reaches the TB level, direct load is more conducive to throughput. You can plan the import window considering tenant resources and the considerations outlined in Overview of data import and Full direct load, such as table locking and major compaction.
Direct load mode configuration file (optional)
You can configure the direct_path_load section in {ob-loader-dumper}/conf/session.config.json for settings like RPC timeout, retry, and task timeout. For example:
"direct_path_load": {
"rpc_connect_timeout": "15000",
"rpc_execute_timeout": "20000",
"runtime_retry_times": "5",
"runtime_retry_intervals": "50",
"task_timeout": "2592000000000",
"heartbeat_timeout": "60000000"
}
Field |
Description |
|---|---|
rpc_connect_timeout |
RPC connection timeout (in milliseconds). |
rpc_execute_timeout |
RPC execution timeout (in milliseconds). |
runtime_retry_times |
The maximum number of retries when the operation fails. If the operation fails for some reason, it will be retried according to this parameter. |
runtime_retry_intervals |
Retry interval (milliseconds). The length of time to wait before retrying an operation. |
task_timeout |
Task timeout (in microseconds). 0 indicates no limit. If an operation is not completed within the configured time limit, it is considered a timeout. |
heartbeat_timeout |
Heartbeat timeout (in microseconds), used to detect the activity status of import operations. 0 indicates not to enable. |
Considerations
Direct load uses the RPC port to transmit data, not the SQL protocol port.
Data is committed on a per-table basis, not at the session or transaction level.
Retry or resumable upload from a breakpoint are not currently supported.
Bit-type data is not currently supported.
Virtual generated columns are not currently supported.
For import tasks with a small amount of data, direct load is not recommended.
Specifying the
--replace-datacommand-line option does not handle unique index conflicts.The difference between the
--threadand--parallelcommand-line options:--threadspecifies the connection pool from the client to the server, which is maintained by the client.--parallelspecifies the number of worker threads that the OBServer can call for writing data and sorting.It is recommended to keep
--threadconsistent with--parallel.