一、背景介绍: 老环境达梦数据库版本为 v2.18,上面有两个dblink,可正常使用。新环境达梦数据库版本为 v3.26,通过dmrman恢复老环境数据至新环境,并按老环境dblink配置后,dblink报错“加载库文件失败”;
二、解决方法
下载oracle 19c客户端oci并配置,验证有效,步骤见下方 3.2 达梦v3.26
三、现回顾一下dblink配置方法。dblink配置有oci、odbc两种方法,因oci设置较为简单,也是众多网友推荐方法,所以本次使用oci方式。
3.1 达梦v2.18
1)、下载oracle客户端
在ORACLE官网中下载OCI
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
包含basic,sqlplus,sdk
-rw-r--r-- 1 root root 60704657 7月 4 17:03 instantclient-basic-linux.x64-11.2.0.4.0.zip
-rw-r--r-- 1 root root 643089 7月 4 17:03 instantclient-sdk-linux.x64-11.2.0.4.0.zip
-rw-r--r-- 1 root root 834491 7月 4 17:03 instantclient-sqlplus-linux.x64-11.2.0.4.0.zip
2)、上传至达梦服务器,(主备集群,只传主即可)
mkdir /opt/oracle
unzip instantclient-basic-linux.x64-11.2.0.4.0.zip
unzip instantclient-sdk-linux.x64-11.2.0.4.0.zip
unzip instantclient-sqlplus-linux.x64-11.2.0.4.0.zip
3)、拷贝so文件到达梦bin目录,修改属主属组为dmdba.dinstall
注:如果Instant Client安装包是18.3 之前的版本,还需要创建几个动态库的软链接。如下:
cd /opt/oracle/instantclient_11_2
ln -s libclntsh.so.11.1 libclntsh.so
ln -s libocci.so.11.1 libocci.so
cp instantclient_11_2/.so /dm8/bin
chown -R dmdba.dinstall libclntsh.so.11.1
chown -R dmdba.dinstall libnnz11.so
chown -R dmdba.dinstall libocci.so.11.1
chown -R dmdba.dinstall libociei.so
chown -R dmdba.dinstall libocijdbc11.so
chown -R dmdba.dinstall libsqlplusic.so
chown -R dmdba.dinstall libsqlplus.so
chown -R dmdba.dinstall libclntsh.so
4)添加dmdba .bash_profile
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/oracle/instantclient_11_2:/opt/dmdbms/bin"
source .bash_profile
5)重启达梦库(加载库文件)
cd /opt/dmdbms/bin
./DMSERVER restart
6)、达梦数据库创建dblink并验证
create public link test122 connect 'ORACLE' with TSS identified by "tss123" using '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.120)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))';
SQL> select * from v$version@test122;
行号 BANNER
1 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
2 PL/SQL Release 11.2.0.4.0 - Production
3 CORE 11.2.0.4.0 Production
4 TNS for Linux: Version 11.2.0.4.0 - Production
5 NLSRTL Version 11.2.0.4.0 - Production
已用时间: 419.797(毫秒). 执行号:2206.
3.2 达梦v3.26 ,步骤与上面类似,所以下方简写
1)下载oci
instantclient-basic-linux.x64-19.19.0.0.0dbru.zip
instantclient-sdk-linux.x64-19.19.0.0.0dbru.zip
instantclient-sqlplus-linux.x64-19.19.0.0.0dbru.zip
2)解压
unzip 3个
3)配置
[root@localhost ~]# echo /opt/oracle/instantclient_19_19 > /etc/ld.so.conf.d/oracle-instantclient.conf
[root@localhost ~]# cat /etc/ld.so.conf.d/oracle-instantclient.conf
/opt/oracle/instantclient_19_13
[root@localhost ~]# ldconfig
4)拷贝so文件至达梦bin
cd /opt/oracle/instantclient_19_19
cp *.so /opt/dmdbms/bin
chown dmdba.dinstall *.so
5)添加dmdba .bash_profile并生效
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/oracle/instantclient_19_19:/opt/dmdbms/bin"
source .bash_profile
6)重启数据库(加载库文件)
cd /opt/dmdbms/bin
./DMSERVER restart
7)验证(与上方一样)
文章
阅读量
获赞