达梦数据库dblink
达梦数据库dblink
达梦-达梦
主机 |
DM(B) |
DMDBA(A) |
---|---|---|
ip |
10.0.0.78 |
10.0.0.79 |
实例名 |
DMSERVER02 |
DMSERVER01 |
修改配置文件dm.ini
创建dmmal.ini
[mal_inst1]
mal_inst_name = DMSERVER01
mal_host = 10.0.0.79
mal_port = 5282
[mal_inst2]
mal_inst_name = DMSERVER02
mal_host = 10.0.0.78
mal_port = 5283
在主机 A 上建表 test,如下所示:
CREATE TABLE TEST(C1 INT,C2 VARCHAR(20));
在 B 上建立到 A 的数据库链接 LINK01,使用链接进行插入、更新和删除操作。如下所示:
CREATE PUBLIC LINK LINK01 CONNECT WITH SYSDBA IDENTIFIED BY SYSDBA USING '127.0.0.1/5282';
INSERT INTO TEST@LINK01 VALUES(1,'A');
INSERT INTO TEST@LINK01 VALUES(2,'B');
UPDATE TEST@LINK01 SET C2='C' WHERE C1=1;
DELETE FROM TEST@LINK01 WHERE C1=2;
COMMIT;
在 B 上查询 A 服务器上表 test 的数据。如下所示:
select * from TEST@LINK01;
输出结果:
达梦-oracle
使用Oracle oci接口
环境准备 注意Oracle Instant Client高版本包对glibc版本有要求,需要glibc 2.14或者以上环境
[root@oracle11g ~]# rpm -qi glibc
Name : glibc
Version : 2.17
Release : 326.el7_9
Architecture: x86_64
Install Date: Mon 24 Jul 2023 12:52:22 PM CST
Group : System Environment/Libraries
Size : 14100922
License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+
Signature : RSA/SHA256, Thu 19 May 2022 08:50:28 PM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : glibc-2.17-326.el7_9.src.rpm
Build Date : Thu 19 May 2022 12:18:44 AM CST
Build Host : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://www.gnu.org/software/glibc/
Summary : The GNU libc libraries
Description :
The glibc package contains standard libraries which are used by
multiple programs on the system. In order to save disk space and
memory, as well as to make upgrading easier, common system code is
kept in one place and shared between programs. This particular package
contains the most important sets of shared libraries: the standard C
library and the standard math library. Without these two libraries, a
Linux system will not function.
Name : glibc
Version : 2.17
Release : 326.el7_9
Architecture: i686
Install Date: Mon 24 Jul 2023 12:52:26 PM CST
Group : System Environment/Libraries
Size : 15234218
License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+
Signature : RSA/SHA256, Thu 19 May 2022 08:51:20 PM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : glibc-2.17-326.el7_9.src.rpm
Build Date : Thu 19 May 2022 01:05:18 AM CST
Build Host : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://www.gnu.org/software/glibc/
Summary : The GNU libc libraries
Description :
The glibc package contains standard libraries which are used by
multiple programs on the system. In order to save disk space and
memory, as well as to make upgrading easier, common system code is
kept in one place and shared between programs. This particular package
contains the most important sets of shared libraries: the standard C
library and the standard math library. Without these two libraries, a
Linux system will not function.
检查是否有安装libaio包
[root@oracle11g ~]# rpm -qa|grep libaio
libaio-0.3.109-13.el7.x86_64
libaio-devel-0.3.109-13.el7.x86_64
libaio-devel-0.3.109-13.el7.i686
libaio-0.3.109-13.el7.i686
下载Oracle客户端驱动(Instant Client)
解压安装
mkdir /opt/oracle
unzip instantclient-odbc-linux.x64-19.20.0.0.0dbru.zip -d /opt/oracle/
unzip instantclient-basic-linux.x64-19.20.0.0.0dbru.zip -d /opt/oracle/
配置环境变量
echo /opt/oracle/instantclient_19_20 > /etc/ld.so.conf.d/oracle-instantclient.conf
cat /etc/ld.so.conf.d/oracle-instantclient.conf
/opt/oracle/instantclient_19_20
ldconfig
配置LDLIBRARYPATH环境变量
修改dmdba用户下的.bash_profile文件,添加如下内容:
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/oracle/instantclient_19_20"
生效
source .bash_profile
通过ORACLE OCI接口的方式访问
create link "LINKORA" connect 'oracle' with "orcl" identified by "oracle" using '10.0.0.136:orcl';
测试
oracle创建测试表
create user lidao identified by oracle;
grant dba to lidao;
conn lidao/oracle
create table lidao.T1
(
name VARCHAR2(20),
age INTEGER,
sex VARCHAR2(3),
grade INTEGER
);
insert into lidao.t1 values('丽丽',18,'女',10);
commit;
dm
创建dblink
create link "DBlinklidao" connect 'oracle' with "lidao" identified by "oracle" using '10.0.0.136:1521/orcl';
SELECT * FROM t1@DBlinklidao;
https://eco.dameng.com