本人以验证,网上很多例子都不能用;
1.安装oracle 透明网关,创建监听端口为1521
2. 新增tg_1\tg4msql\admin\initbussel.ora
HS_FDS_CONNECT_INFO="SERVER=192.168.0.9;DATABASE=WANSHENG"
HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT=RECOVER
HS_FDS_RECOVERY_PWD=RECOVER
3. 修改tg_1\\NETWORK\ADMIN\listener.ora (根据自已情况修改,蓝色为添加的)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = C:\oracle\product\10.2.0\tg_1)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = bussel)
(ORACLE_HOME = C:\oracle\product\10.2.0\tg_1)
(PROGRAM = tg4msql)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 2003server)(PORT = 1522))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
3. 修改tg_1\\NETWORK\ADMIN\tnsnames.ora (蓝色为自添加部分,orcl为1521端口)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
bus =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 2003server)(PORT = 1522))
)
(CONNECT_DATA =
(SID = bussel)
)
(HS=OK)
)
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 2003server)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
4. lsnrctl 重启监听(stop,start) tnsping bus 测试成功;
5.创建dblink此处是关键;
create database link db1
connect to sa identified by "sunshine"
using '(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 2003server)(PORT = 1522))
)
(CONNECT_DATA =
(SID = bussel)
)(HS=OK)
)';
备注: using 'bus',经测试不可用,此连接方式测试可用;