1. 查看 tnsnames.ora中条目 :
bys3_dblk =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = bys3.bys.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = bys3)
)
)
/etc/hosts中不写bys3.bys.com与IP的对应,也无法通过DNS得到bys3.bys.com的IP。
2.创建数据链并使用---
BYS@ bysrac1>create database link bys3_db connect to test9 identified by test9 using 'bys3_dblk';
Database link created.
此时使用DBLINK: 执行了很长时间,报错:ORA-12545:Connect failed because target host or object does not exist
21:42:57 BYS@ bysrac1>select * from test9@BYS3_DB;
select * from test9@BYS3_DB
*
ERROR at line 1:
ORA-12545: Connect failed because target host or object does not exist
Elapsed: 00:02:40.25
###########3
3.查看日志中报错信息:
[oracle@bysrac1 ~]$ cat alert_bysrac1.log
创建和使用数据链时会有类似如下报错日志: --截取部分
Sat Dec 28 21:41:29 2013
***********************************************************************
Fatal NI connect error 12545, connecting to:
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=racdg)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=racdg)(CID=(PROGRAM=oracle)(HOST=bysrac1.bys.com)(USER=oracle))))
VERSION INFORMATION:
TNS for Linux: Version 11.2.0.1.0 - Production
TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.1.0 - Production
Time: 28-DEC-2013 21:41:29
Tracing not turned on.
Tns error struct:
ns main err code: 12545
TNS-12545: Connect failed because target host or object does not exist
ns secondary err code: 12560
nt main err code: 515
TNS-00515: Connect failed because target host or object does not exist
nt secondary err code: 110
nt OS err code: 0
###########
4.解决方法:
/etc/hosts中增加相应条目:
192.168.1.211 bys3.bys.com bys3
ping bys3.bys.com 测试正常。
BYS@ bysrac1>select * from test9@bys3_db;
AA
----------
dblink-ok
---此时重新登陆数据库,使用数据链正常: