Before running the data import/export tools, ensure you have a suitable runtime environment and permissions.
Runtime environment
Environment |
Requirements |
|---|---|
| System Version | Supported operating systems: Linux, macOS, and Windows 7 and later. |
| Java Environment | Install Oracle JDK 1.8.0_3xx, configureJAVA_HOMEEnvironment variables. |
| Character set | We recommend that you use the UTF-8 file encoding. |
| JVM parameters | Please editbin/obloaderandbin/obdumperscripts to modify JVM memory parameters and avoid insufficient JVM memory. |
Note
Some minor versions of OpenJDK 1.8 have severe garbage collector (GC) errors, which may cause out-of-memory exceptions or program freezes when running the import/export tools. To avoid these issues, we recommend installing the latest minor version of OpenJDK 1.8.
If you are using a domestic operating system such as Kylin, you need to change the GC collector in the JVM parameters (i.e., JAVA_OPTS) from G1 to CMS; otherwise, the JVM may crash.
If you are using OBLOADER/OBDUMPER versions earlier than V4.3.0, edit the bin/obloader or bin/obdumper file and change the GC parameter from -XX:+UseG1GC to -XX:+UseConcMarkSweepGC.
If you are using OBLOADER/OBDUMPER V4.3.0 or later, edit the bin/obloader or bin/obdumper file and modify the GC_OPTS parameter to -XX:+UseG1GC or -XX:+UseConcMarkSweepGC. For example, GC_OPTS="-XX:+UseG1GC".
Configure HDFS dependencies
Data import/export tools V4.3.0 and later depend on Hadoop components. When using OBLOADER/OBDUMPER on Windows, you must configure the HDFS dependency first; otherwise, an error HADOOP_HOME and hadoop.home.dir are unset. will occur.
- Go to the Code page and click Code > Download ZIP in the upper-right corner to download the zip package.
After extracting it, copy the current directory path.
This article uses the directory path
C:\User\chang\winutilsas an example. Please replace it with your actual path in the following steps.You can configure it in one of the following two ways. Choose the method that suits your needs.
Set the system environment variable directly:
HADOOP_HOME = C:\User\chang\winutils\hadoop-3.3.6, and append%HADOOP_HOME%\binto the user variable Path.Use Notepad to open
<tool_root_directory>\bin\windows\obdumper.batand find the following line:SET PROGRAM_OPTS=%PROGRAM_OPTS% "-Dtool.base.dir=%PARENT_PATH%"Add a new line above or below this line with the following command, save, and exit.
SET PROGRAM_OPTS=%PROGRAM_OPTS% "-Dhadoop.home.dir=C:\User\chang\winutils\hadoop-3.3.6"
Run OBLOADER/OBDUMPER again.
Runtime permissions
OBLOADER runtime permissions
When using OBLOADER to connect to an OceanBase database for data import, the account used to connect to the database must have execution permissions for commands such as CREATE, SELECT, INSERT, and UPDATE. You can view the privileges granted to a user using the SHOW GRANTS statement. Example statement:
obclient> SHOW GRANTS FOR user1;
+------------------------------------------+
| Grants for user1@% |
+------------------------------------------+
| GRANT CREATE ON *.* TO 'user1' |
| GRANT SELECT ON `db1`.* TO 'user1' |
| GRANT INSERT ON `db1`.* TO 'user1' |
| GRANT UPDATE ON `db1`.* TO 'user1' |
| GRANT SELECT ON `oceanbase`.* TO 'user1' |
+------------------------------------------+
2 rows in set
Note
If you are using the MySQL-compatible mode of OceanBase Database, you must have the query privilege on the
oceanbasedatabase before you import data. Example:GRANT SELECT ON `oceanbase`.* TO 'user1'.If you are using the Oracle-compatible mode of OceanBase Database, you must have the query privilege on the
SYSdatabase before you import data. Example:GRANT SELECT ON "SYS".* TO 'user1'.- We recommend that you use an account with the DBA role to connect to OceanBase Database in Oracle compatible mode when you use OBLOADER to import database object definitions and data.
OBDUMPER privileges
When you use OBDUMPER to connect to OceanBase Database for data export, the account used to connect to the database must have the privileges to execute commands such as CREATE and SELECT. You can run the SHOW GRANTS statement to view the privileges granted to a user. Example:
obclient> SHOW GRANTS FOR user1;
+------------------------------------------+
| Grants for user1@% |
+------------------------------------------+
| GRANT CREATE ON *.* TO 'user1' |
| GRANT SELECT ON `db1`.* TO 'user1' |
| GRANT SELECT ON `oceanbase`.* TO 'user1' |
+------------------------------------------+
2 rows in set
Note
- OBDUMPER requires privileges on system tables only when exporting non-table database objects.
If you are using the MySQL-compatible mode of OceanBase Database, you must have the query privilege on the
oceanbasedatabase before you export data. Example:GRANT SELECT ON `oceanbase`.* TO 'user1'.If you are using the Oracle-compatible mode of OceanBase Database, you must have the query privilege on the
SYSdatabase before you export data. Example:GRANT SELECT ON "SYS".* TO 'user1'.
- We recommend that you use an account with the DBA role to connect to OceanBase Database in Oracle compatible mode when you use OBDUMPER to export database object definitions. No role is required for the account used to connect to the database when you use OBDUMPER to export data.
Additional information
For OceanBase Database versions earlier than V4.0.0, you must specify the
--sys-userand--sys-passwordoptions on the command line of the data import/export tools.For more information, see OBLOADER command-line options and OBDUMPER command-line options.
The
--sys-userand--sys-passwordoptions require a user under the sys tenant that has the privilege to query system tables and views.For more information about privileges, see View user privileges, Overview of users and privileges, and Modify user privileges.