OceanBase Database now supports connecting to file systems using the Java SDK as a third-party data source for external tables. This feature leverages the JNI framework, so the corresponding OceanBase Database environment must include the Java SDK.
Environment configuration
Notice
If you need to use the HDFS/ODPS external table feature and OceanBase Database is deployed in distributed mode, you must perform the following deployment configurations for the Java environment and install dependencies on all corresponding server nodes. You cannot configure only one node.
Notice
All environment configuration and dependency installation operations must be performed as the admin user. To switch to the admin user, run the following command.
su - admin
Deploy and configure the Java environment
Download the OpenJDK Java installation package from the Download Center.
Notice
Use the latest version of OpenJDK 11.
This topic uses downloading OpenJDK 11.0.29+7 as an example. The specific procedure is as follows:
[admin@xxx /home/admin/rpm]# wget https://builds.openlogic.com/downloadJDK/openlogic-openjdk/11.0.29+7/openlogic-openjdk-11.0.29+7-linux-x64.tar.gzExtract the corresponding installation package normally.
Example:
[admin@xxx /home/admin/rpm]# tar -zxvf openlogic-openjdk-11.0.29+7-linux-x64.tar.gzThe installation path is as follows:
/home/admin/rpm/openlogic-openjdk-11.0.29+7-linux-x64Notice
This path is used to configure the Java Home directory on the current OBServer running node, that is, the value of the ob_java_home parameter.
Install dependencies
OceanBase Database's use of the HDFS/ODPS external table feature also depends on the following components:
devdeps-hdfs-sdk RPM package:
This package contains the dynamic link library files required for the runtime of external tables such as HDFS/ODPS, providing the core interface for interaction between the JVM environment and JNI (Java Native Interface). This component serves as a communication bridge between the Java Virtual Machine and the local external table Java SDK, ensuring the stable operation of the external table feature.
The devdeps-java-extensions RPM package:
This package integrates the core dependency libraries (JAR files) required for HDFS external tables and other external data sources (such as ODPS). This extension package contains a complete Java runtime dependency chain, ensuring compatibility and performance optimization for external table functionality in distributed scenarios.
Starting from version 1.0.6, this package also provides dependencies required for JDBC Catalog and JVM monitoring features.
Deploy the configured dependency HDFS.so dynamic library
Obtain the devdeps-hdfs-sdk RPM installation package.
- Enterprise Edition users: Please contact technical support to obtain the devdeps-hdfs-sdk RPM installation package.
- Open Source Edition users: On the Alibaba Cloud OceanBase Image page, click the
development-kit/directory to enter the development tools resource directory, and download the devdeps-hdfs-sdk RPM installation package.
After obtaining the installation package, install it using the following command.
sudo rpm -Uvh devdeps-hdfs-sdk-3.3.6-xxxxx.xxx.xxx.rpmExample:
sudo rpm -Uvh devdeps-hdfs-sdk-3.3.6-112024123116.el7.x86_64.rpmCheck whether the installation meets expectations.
The
libhdfs.soandlibhdfs.so.0.0.0files must be present, and the corresponding soft links must be valid.Example:
$ll /usr/local/oceanbase/deps/devel/lib total 376 lrwxrwxrwx 1 root root 16 Dec 24 19:49 libhdfs.so -> libhdfs.so.0.0.0 -rwxr-xr-x 1 root root 384632 Dec 24 19:09 libhdfs.so.0.0.0
Deploy the configured dependency JAR package path
Obtain the devdeps-java-extensions RPM installation package.
Enterprise Edition users: Please contact technical support to obtain the devdeps-java-extensions RPM installation package.
Open Source Edition users: On the Alibaba Cloud OceanBase Image page, click the
development-kit/directory to enter the development tools resource directory, and download the devdeps-java-extensions RPM installation package.Notice
- OceanBase Database V4.3.5 BP1 and earlier versions: Download the 1.0.0 version of the devdeps-java-extensions RPM installation package.
- OceanBase Database V4.3.5 BP2 and later versions: Download the 1.0.1 version of the devdeps-java-extensions RPM installation package.
- OceanBase Database V4.4.0: Download the 1.0.1 version of the devdeps-java-extensions RPM installation package.
- OceanBase Database V4.4.1: Download the 1.0.2 version of the devdeps-java-extensions RPM installation package.
- OceanBase Database V4.4.2 to V4.4.2 BP2: Download the 1.0.4 version of the devdeps-java-extensions RPM installation package.
- OceanBase Database V4.4.2 BP3: Download the 1.0.5 version of the devdeps-java-extensions RPM installation package.
- OceanBase Database V4.4.2 BP4 and later: Download the 1.0.6 version of the devdeps-java-extensions RPM installation package.
After obtaining the installation package, install it using the following command.
sudo rpm -Uvh devdeps-java-extensions-x.x.x-xxxxxxxxxxxx.xxx.xxxxxx.rpm --prefix=/user_install_directoryExample:
sudo rpm -Uvh devdeps-java-extensions-1.0.0-122025032514.el7.x86_64.rpm --prefix=/home/admin/oceanbaseCheck whether the installation meets expectations.
Check whether the
oceanbase-odps-connector-jar-with-dependencies.jarfile exists in the installation path/home/admin/oceanbase/jni_packages/v1.0.0.Example:
$ll /home/admin/oceanbase/jni_packages/v1.0.0 total 52756 drwxr-sr-x 4 root root 4096 Dec 24 20:25 hadoop drwxr-xr-x 3 root root 4096 Dec 24 20:25 lib -rw-r--r-- 1 root root 54008720 Dec 24 19:52 oceanbase-odps-connector-jar-with-dependencies.jarNotice
This path specifies the location of the executable dependency JAR files that the JVM used to start the OBServer node can load. It corresponds to the value of the ob_java_connector_path parameter.
(Optional) Restart the observer process
Note
- If you are using the Java SDK environment for the first time, you do not need to restart the observer process.
- Since the JNI-related parameters supported by the current OBServer cannot be set and take effect flexibly and promptly, if you need to try changing the configuration of related Java environment variables, you must restart the observer process for the changes to take effect.
When using the HDFS/ODPS external table feature, you need to configure the corresponding OBServer server. For the procedure, see the following section.
Notice
All of the following parameters are cluster-level configurations. Set them once, as they do not need to be configured individually on all nodes.
Step 1: Configure parameters for Java environment startup
Notice
All of the following settings are performed in the sys tenant.
Enable Java Env for SDK (Java SDK) access to external tables.
Example:
ALTER SYSTEM SET ob_enable_java_env = true;For more information about this setting, see ob_enable_java_env.
Set the Java Home directory on the current OBServer node.
Note
This path is derived from the OpenJDK installation directory.
Example:
ALTER SYSTEM SET ob_java_home = "/home/admin/rpm/openlogic-openjdk-11.0.29+7-linux-x64";For more information about this setting, see ob_java_home.
Set the JVM classpath for loading executable dependency JAR files when starting OBServer.
Note
This path is derived from the RPM installation directory of the JAR package.
Example:
ALTER SYSTEM SET ob_java_connector_path = "/home/admin/oceanbase/jni_packages/v1.0.0";For more information about this parameter, see ob_java_connector_path.
Set the parameters for starting the Java environment.
Create the corresponding log folder path.
mkdir -p /home/user/jvmlogs mkdir -p /home/user/jvmlogs/heapdumpsSet the JVM startup parameters for Java execution.
Example:
ALTER SYSTEM SET ob_java_opts="-Xmx2048m -Xms2048m -XX:-CriticalJNINatives -Djdk.lang.processReaperUseDefaultStackSize=true -Xrs -XX:+HeapDumpOnOutOfMemoryError -Xloggc:/home/admin/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/admin/heapdumps/ -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+CMSClassUnloadingEnabled -XX:+TieredCompilation -XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses ";For more information about this parameter, see ob_java_opts.
Notice
- Changing this parameter requires restarting the observer process. Since the current HDFS integration directly copies data from the HDFS stream to the C++ memory heap, you can appropriately reduce the
-Xmx2048m -Xms2048msetting. - GC log files are generated only if the configuration folder path exists; if the path does not exist, they will not be generated.
- Changing this parameter requires restarting the observer process. Since the current HDFS integration directly copies data from the HDFS stream to the C++ memory heap, you can appropriately reduce the
(Optional) Set the JAVA SDK parameters for ODPS.
Notice
This parameter is not required for the HDFS JAVA SDK; all other parameters are the same.
To use the JAVA SDK, set
_use_odps_jni_connectortotrue.ALTER SYSTEM SET _use_odps_jni_connector = true;
Step 2 (Optional): Decompress the hdfs-sdk package without sudo privileges
If you cannot execute the installation command with
sudoprivileges in the current environment, you can manually decompress the devdeps-hdfs-sdk RPM package using therpm2cpiocommand. You can then place the files in any desired directory.Example:
rpm2cpio devdeps-hdfs-sdk-3.3.6-xxxxx.xxx.xxx.rpm | cpio -idmvSpecify the target path.
After decompressing the package, use the
mvcommand to move the decompressed files to a custom accessible path (for example,~/hdfs_lib).Example:
mv ./usr/local/oceanbase/deps/devel/lib/* ~/hdfs_lib/Obtain and confirm the absolute path.
You can use the
realpathcommand to view the absolute path of the custom directory.Example:
realpath ~/hdfs_libThe result is as follows:
/home/${user_name}/hdfs_libConfigure the OceanBase database path variable.
Example:
Log in to the sys tenant and execute the following command to register the custom path in the system configuration.
Note
- Replace
${user_name}with the actual path in the example when executing the following statement. - The path must be an absolute path. Multiple paths must be separated with a colon
:and must not contain spaces.
ALTER SYSTEM SET _ob_additional_lib_path = '/home/${user_name}/hdfs_lib';- Replace
Step 3: Restart the observer process
Stop the observer process on all servers, then restart it.
Switch to the
adminuser.[admin@xxx /home/admin/oceanbase/etc]# su - adminStop the observer process.
-bash-4.2$ kill -9 `pidof observer`Restart the observer process.
-bash-4.2$ cd /home/admin/oceanbase && /home/admin/oceanbase/bin/observerNote
You do not need to specify startup parameters when restarting the observer process, because they have already been written into the parameter file.
References
For more information about creating an external table for ODPS, see Create an external table (MySQL-compatible mode) or Create an external table (Oracle-compatible mode).