This topic describes how to enable and disable the direct load port in the OceanBase Cloud console.
Overview
OceanBase Database allows inserting data into the database through direct load. This feature bypasses the traditional SQL layer interface and writes data directly to the database files, thereby improving the efficiency of data import. For more information, see Direct load overview.
Prerequisites
When you use direct load, check the following conditions. You can enable the direct load port only when the following conditions are met.
You have read and write permissions on the instance.
The instance is a transactional instance and is in the running state.
The tenant is in the running state.
The private network address of the primary address is in the running state.
Enable direct load
Log in to the OceanBase Cloud console.
On the Instances page, click the name of the target instance to go to the Overview page.
In the left-side navigation pane, click Database Proxy.
In the Database Proxy section, click Enable next to the Direct Import Port field.
In the confirmation dialog box, click OK.
Import data
Download the latest version of OceanBase Loader and Dumper.
For more information about OceanBase Loader and Dumper, see Product introduction.
View and set environment variables.
View Java and PATH related environment variables.
[root@iZbxxxx rpc]# env | grep JAVA JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.0.3.al8.x86_64 [root@iZbxxxx rpc]# env | grep PATH PATH=/root/ob-loader-dumper-4.3.0-RELEASE/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/binSet Java and PATH environment variables.
[root@iZbxxxx rpc]# export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.0.3.al8.x86_64 [root@iZbxxxx rpc]# export PATH=/root/ob-loader-dumper-4.3.0-RELEASE/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:$PATH
Import data by using direct load method.
Note
The content format of the imported file needs to comply with the specifications. For more information, see Supported file formats and encoding formats for Data Import.
[root@iZbxxxx rpc]# obloader -h<host> -u<user_name> -p<pass_word> -D <db_name> --table '<table_name>' -f output1 -t <tenant_name> --public-cloud --csv --direct --rpc-port 3307 -P3306
| Parameter | Description |
|---|---|
| -h | Specifies the host address of OceanBase Database. |
| -u | Username, tenant name, and cluster name used to connect to the OceanBase database, in the format <user>@<tenant>#<cluster>. For example, -u user@tenant#cluster. |
| -p | Specifies the user password for connecting to OceanBase Database. |
| -D | Specifies the name of database object definitions and tables to be imported in OceanBase Database. |
| --table | Operates on the specified table in OceanBase Database. For example, --table 'example'. |
| -f | Specifies the prefix of the file name to be imported. For example, this command indicates that the data to be imported is saved in a file named with the prefix output1. |
| -t | This parameter is used with --public-cloud to specify the tenant name for connecting to OceanBase Database. |
| --public-cloud | Used to identify importing database objects or table data from a cluster instance deployed by OceanBase Cloud. |
| --csv | Specifies that the data file format to be imported is CSV. You can specify according to the actual format of the data to be imported, such as --sql, --par, and --orc, etc. |
| --direct | Specifies to use direct load mode. This parameter is used with --rpc-port and --parallel. |
| --parallel | Used for the parallelism of loading data during direct load. This parameter is optional, the default value is 1, and it is used with --rpc-port and --direct. |
| --rpc-port 3307 | The port used to connect to OBServer RPC. It indicates that although the port for connecting to the database is 3306 (specified by -P3306), the actual data import is completed through the RPC service of port 3307 to improve import performance. |
| -P 3306 | Specifies the host port for connecting to OceanBase Database. |
Disable direct load
Log in to the OceanBase Cloud console.
In the Instances page, click the name of the target instance to go to the Overview page.
In the left-side navigation pane, click Database Proxy.
In the Database Proxy section on the page, click Disable next to the Direct Load Port field.
Notice
Before you disable the direct load port, make sure that no other services are connected to the port.
In the confirmation dialog box that appears, click OK.