When an Oracle tenant in OceanBase Database needs to read and write data from a remote Oracle database through DBLink, it is necessary to install and configure the Oracle Call Interface (OCI) library.
Procedure
For OceanBase Database V4.2.1 and later, when you use the DBLink feature to access a remote Oracle database, refer to this documentation and configure OCI 12.2 on all OBServer nodes in the cluster.
The following example describes how to install and configure an OCI library on a single OBServer node.
Click here to go to the official website of OCI and download the OCI library of the corresponding version.
Log on to the OBServer node as the
adminuser, copy the downloaded RPM package to the OBServer node, and run the following command to install the OCI library:sudo rpm -ivh oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpmAfter the OCI library is installed, run the following command to obtain the OCI installation directory:
rpm -ql oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64The result is as follows:
/usr/lib/oracle/12.2/client64/bin/adrci /usr/lib/oracle/12.2/client64/bin/genezi /usr/lib/oracle/12.2/client64/lib/libclntsh.so.12.1 /usr/lib/oracle/12.2/client64/lib/libclntshcore.so.12.1 /usr/lib/oracle/12.2/client64/lib/libipc1.so /usr/lib/oracle/12.2/client64/lib/libmql1.so /usr/lib/oracle/12.2/client64/lib/libnnz12.so /usr/lib/oracle/12.2/client64/lib/libocci.so.12.1 /usr/lib/oracle/12.2/client64/lib/libociei.so /usr/lib/oracle/12.2/client64/lib/libocijdbc12.so /usr/lib/oracle/12.2/client64/lib/libons.so /usr/lib/oracle/12.2/client64/lib/liboramysql12.so /usr/lib/oracle/12.2/client64/lib/ojdbc8.jar /usr/lib/oracle/12.2/client64/lib/xstreams.jarConfigure the OCI library.
Check whether a
libdirectory exists in the OceanBase Database installation directory. If not, create one and specify privileges required to access thelibdirectory. If yes, skip this step.In this example, the OceanBase Database installation directory is
/home/admin/oceanbase.sudo mkdir /home/admin/oceanbase/libsudo chown admin:admin -R /home/admin/oceanbase/libGo to the OCI installation directory.
cd /usr/lib/oracle/12.2/client64/lib/Copy the following files from the OCI installation directory to the OceanBase Database installation directory:
libclntsh.so.12.1,libclntshcore.so.12.1,libipc1.so,libmql1.so,libnnz12.so,libociei.so, andlibons.so.You need to replace
$DIRwith the OceanBase Database installation directory, which is/home/admin/oceanbasein this example.Notice
You need to rename the
libclntsh.so.12.1file tolibclntsh.so.cp libclntsh.so.12.1 $DIR/lib/libclntsh.socp libclntshcore.so.12.1 $DIR/libcp libipc1.so $DIR/libcp libmql1.so $DIR/libcp libnnz12.so $DIR/libcp libociei.so $DIR/libcp libons.so $DIR/lib
Specify the
LD_LIBRARY_PATHvariable.To load the
libclntsh.sofile, OceanBase Database searches for dependent library files in the directory specified by theLD_LIBRARY_PATHvariable. Therefore, you need to set theLD_LIBRARY_PATHvariable to the directory of the OCI library.In this example, the OCI library is located in
home/admin/oceanbase/lib. Here is a sample command:export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/admin/oceanbase/lib:"Notice
You must append a colon (:) to
/home/admin/oceanbase/libwhen you configure environment variables.
Considerations
After you configure the OCI library on all OBServer nodes in the cluster, note that:
OceanBase Database requires dependent libraries to load the OCI library. After you configure the OCI library, you can run the
ldd libclntsh.socommand in the directory of the OCI library, which ishome/admin/oceanbase/libin this example, to query other Linux libraries on which the OCI library depends. If the required dependent libraries do not exist, contact OceanBase Technical Support for assistance.ldd libclntsh.soIn general, you do not need to restart the OBServer node after the OCI library is configured. However, if an error message is returned and indicates that OCI is not found, you need to restart the OBServer node.