When you use a DBLink in an Oracle tenant of OceanBase Database to read data from or write data to a remote Oracle database, you must install and configure the Oracle Call Interface (OCI) library.
Procedure
When you use a DBLink to access a remote Oracle database, if the local OceanBase database is of V4.2.1 or later, you must install and configure OCI 12.2 on all OBServer nodes in the cluster by referring to this topic.
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 in 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:
libclntshcore.so.12.1,libclntsh.so.12.1,libipc1.so,libmql1.so,libnnz12.so,libocci.so.12.1,libociei.so,libocijdbc12.so,libons.so, andliboramysql12.so.You need to replace
$DIRwith the OceanBase Database installation directory, which is/home/admin/oceanbasein this example.Notice
After you copy the
.sofiles from the OCI installation directory to the OceanBase Database installation directory, you need to copy thelibclntsh.so.12.1file in the OceanBase Database installation directory and rename the new file aslibclntsh.so, or you can create a soft link that points to thelibclntsh.so.12.1file in the installation directory and name the soft link aslibclntsh.so.cp libclntshcore.so.12.1 $DIR/libcp libclntsh.so.12.1 $DIR/libcp libclntsh.so.12.1 $DIR/lib/libclntsh.socp libipc1.so $DIR/libcp libmql1.so $DIR/libcp libnnz12.so $DIR/libcp libocci.so.12.1 $DIR/libcp libociei.so $DIR/libcp libocijdbc12.so $DIR/libcp libons.so $DIR/libcp liboramysql12.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.After you configure the OCI library and the
LD_LIBRARY_PATHenvironment variable, if the OBServer node fails to correctly load all the.sofiles of OCI, you need to restart the OBServer node. For more information, see Restart a node.If it is inconvenient to restart the OBServer node, you can run the
mvcommand to move all the 10.sofiles of the OCI library in the$DIR/lib/directory to the/lib64directory, and retain only thelibclntsh.sofile in the$DIR/lib/directory. Then, the OBServer node can load the OCI library without a restart.cd /home/admin/oceanbase/libmv libclntshcore.so.12.1 /lib64mv libclntsh.so.12.1 /lib64mv libipc1.so /lib64mv libmql1.so /lib64mv libnnz12.so /lib64mv libocci.so.12.1 /lib64mv libociei.so /lib64mv libocijdbc12.so /lib64mv libons.so /lib64mv liboramysql12.so /lib64
Considerations
After you configure the OCI library on all OBServer nodes in the cluster, take note of the following considerations:
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.soOn the x86 platform, OBServer nodes of V4.2.1 and later versions can only run OCI library files in the
oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpmpackage. If you use OCI library files of an earlier or later version or of multiple versions, processes may crash on the OBServer node.On the x86 platform, OBServer nodes of a version earlier than V4.2.1 can only run library files of OCI 11.2. For more information, see Install and configure OCI 11.2.
On the ARM platform, OBServer nodes can only run OCI library files in the
oracle-instantclient19.10-basic-19.10.0.0.0-1.aarch64.rpmpackage. To download theoracle-instantclient19.10-basic-19.10.0.0.0-1.aarch64.rpmpackage, click oracle-instantclient19.10-basic-19.10.0.0.0-1.aarch64.rpm.The process for configuring the OCI library on the ARM platform is similar to that of the x86 platform. You can configure all the
.sofiles in theoracle-instantclient19.10-basic-19.10.0.0.0-1.aarch64.rpmpackage by referring to this topic.