注意:本文内容基本无sqlnet.ora的情况。关于sqlnet.ora,详见:监听中sqlnet.ora的作用
本地命名的配置:.本地名可以用简单的名称访问到所需的数据库或服务器所需的信息,而这些信息保存到了tnsnames.ora中.
LOCALNAME: 本地名称
ADDRESS: 服务器地址
PROTOCOL: 使用协议
HOST: IP地址
PORT: 监听端口
SERVICE_NAME: 数据库服务名称
首先要保证tnsnames.ora文件中的格式正确,如=号、空格、括号之类基本格式不出错
这个可以参考我的一篇tnsnames.ora各种模板:http://blog.csdn.net/q947817003/article/details/11180027
当我们发出一条命令:sqlplus bys/bys@test时,连接到数据库大致经过以下步骤:
1.首先在sqlplus程序的相关目录中查找tnsnames.ora
2.在tnsnames.ora中查找test=开头的字符串
3.根据tnsnames.ora中查找test=字符串中的:PROTOCOL = TCP)(HOST = 192.168.1.211) 这一句,查询相应的HOST,如是IP,则直接访问;如是域名,需要解析为IP
4.当可以与HOST =中描述的主机通讯后,再根据(PORT = 1521)这一句中的描述,在主机的1521这一端口使用TCP协议进行连接。
5.如果以上连接成功,则已经连接到数据库监听器。此时tnsnames.ora中查找test=字符串中的:SERVICE_NAME = bys1,这一句则再次指定了要连接到监听器的bys1服务上
6.如果以上连接成功,已经连接到监听器的bys1服务,则会根据监听器中服务所对应的实例,来连接到具体的实例。(在tnsnames.ora的test=字符串中也可以在SERVICE_NAME =这一句下面再指定具体实例--我实验中未指定;如不指定,则由监听器来分配;如监听器中同一服务下有多个实例(如RAC),由监听器来进行动态均衡分配连接)。
7.如果以上连接成功,则已经连接到实例。接下来就由数据库来验证用户名、密码的正确性了。
本篇的实验即使遵循以上的sqlplus bys/bys@test连接到数据库的步骤来对每一步进行错误演示
关于连接数据库的语句:sqlplus bys/[email protected]:1521/bys1 这种是不使用tnsnames.ora文件。连接到192.168.1.211主机的1521端口的bys1服务上。 关于SQLPLUS连接数据库的写法,更详细见:http://blog.csdn.net/q947817003/article/details/11180137
实验环境:LINUX--OLE 5.8;ORACLE -Oracle Database 11g Enterprise Edition Release 11.2.0.1.
##################################################################################
1.tnsnames.ora文件不存在或文件名写错,总之就是找不到这个文件。此时使用本地名来连接是不行的。
测试结果:
TNSPING报错为:TNS-03505: Failed to resolve name
SQLPLUS报错为:ORA-12154: TNS:could not resolve the connect identifier specified
实验数据
[oracle@bys001 admin]$ ls
listener.bak samples tnsnames.ora
listener.ora shrept.lst
[oracle@bys001 admin]$ mv tnsnames.ora tnsnames.oraa
[oracle@bys001 admin]$ tnsping bys1
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 08-NOV-2013 09:24:18
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
TNS-03505: Failed to resolve name
[oracle@bys001 admin]$ sqlplus bys/bys@bys1
SQL*Plus: Release 11.2.0.1.0 Production on Fri Nov 8 09:25:12 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
##################################################################################
2.tnsnames.ora 中test本地名对应的字段描述格式正确,数据库监听开启。但是使用TNSPING或SQLPLUS时所用的本地名不对。可能是test本地名前有空格。
(本地名指的是tnsnames.ora 中的描述字段:
test =
(DESCRIPTION = 这里;也即SQLPLUS BYS/BYS@TEST这里的TEST)
测试时:
TNSPING报错为:TNS-03505: Failed to resolve name
SQLPLUS报错为:ORA-12154: TNS:could not resolve the connect identifier specified
如果是test本地名前有空格,WIN下客户端报错可能如上,而LINUX下test本地名有空格时,TNSPING正常。
SQLPLUS报错:ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA
--如tnsnames.ora 的本地名中这一段:(SERVICE_NAME = bys1)单词拼错,如SERVER_NAME BYS9等也会报这个错
实验数据:
[oracle@bys001 admin]$ tnsping hello
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 07-NOV-2013 23:41:29
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
TNS-03505: Failed to resolve name
[oracle@bys001 admin]$ sqlplus bys/bys@hello
SQL*Plus: Release 11.2.0.1.0 Production on Thu Nov 7 23:42:36 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
#########################################################################################################
3.tnsnames.ora 中test本地名对应的字段描述格式正确,数据库监听开启。但是tnsnames.ora 中HOST = 字段指定的IP无法PING通。
测试结果:
TNSPING和SQLPLUS报错均为: TNS-12543: TNS:destination host unreachable
实验数据:
[oracle@bys001 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
bys1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.211)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = bys1)
)
)
test =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =
192.168.1.222)(PORT = 1521))
手动将HOST中的IP改为一个不存在的IP即可
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = bys1)
)
)
[oracle@bys001 ~]$
ping 192.168.1.222
PING 192.168.1.222 (192.168.1.222) 56(84) bytes of data.
From 192.168.1.211 icmp_seq=2 Destination Host Unreachable
From 192.168.1.211 icmp_seq=3 Destination Host Unreachable
[oracle@bys001 admin]$
tnsping test
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 07-NOV-2013 23:08:12
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.222)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = bys1)))
TNS-12543:
TNS:destination host unreachable
[oracle@bys001 admin]$
sqlplus bys/bys@test
SQL*Plus: Release 11.2.0.1.0 Production on Thu Nov 7 23:08:21 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-12543: TNS:destination host unreachable
#########################################################################################################
4.数据库监听正常。tnsnames.ora 中HOST = 字段指定的主机名无法解析(涉及/etc/hosts或DNS),总之主机名无法解析成IP。
测试结果:
TNSPING和SQLPLUS报错均为: ORA-12545: Connect failed because target host or object does not exist
实验数据:
[oracle@bys001 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
bys1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.211)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = bys1)
)
)
test =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =
bucunzai)(PORT = 1521))
手动将HOST指定的主机改为一个不存在的域名/主机名
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = bys1)
)
)
[oracle@bys001 admin]$
ping bucunzai
ping: unknown host bucunzai
[oracle@bys001 admin]$
tnsping test
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 07-NOV-2013 23:24:47
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = bucunzai)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = bys1)))
TNS-12545: Connect failed because target host or object does not exist ------这里需要等待一段时间。
[oracle@bys001 admin]$ sqlplus bys/bys@test
SQL*Plus: Release 11.2.0.1.0 Production on Thu Nov 7 23:26:08 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved. ------这里需要等待一段时间。
ERROR:
ORA-12545: Connect failed because target host or object does not exist
#########################################################################################################
5.数据库监听正常。tnsnames.ora 中HOST = 字段指定的IP或主机可以连接。但是PORT =字段指定的端口没有打开。
端口没打开:LINUX中即端口没有对应的程序或者叫程序不是在此端口打开。
测试结果:
TNSPING和SQLPLUS报错均为: ORA-12541: TNS:no listener
从报错中也可以理解出:
能连接到主机,但是相应的端口没有对应的程序,所以报错:没有监听器。
这种情况下,如果关闭监听器,使用TNSPING和SQLPLUS测试,报的也是:ORA-12541: TNS:no listener --见实验7。
实验数据:
[oracle@bys001 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
bys1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.211)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = bys1)
)
)
test =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.211)(PORT =
1522))
手动将此端口改为一个不存在的端口--即没对应的程序的端口
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = bys1)
)
)
[oracle@bys001 admin]$
tnsping test
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 07-NOV-2013 23:30:49
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.211)(PORT = 1522)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = bys1)))
TNS-12541: TNS:no listener
[oracle@bys001 admin]$ sqlplus bys/bys@test
SQL*Plus: Release 11.2.0.1.0 Production on Thu Nov 7 23:30:56 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-12541: TNS:no listener
#########################################################################################################
6.tnsnames.ora 中配置正确,监听正常,数据库服务器所在主机防火墙未开放监听所在的1521端口或者tnsnames.ora指定的端口与监听中不符,远程连接时报TIME OUT。
除了防火墙外,网络不稳定(包括网线质量问题)、ARP问题导致网络时通时不通、路由问题导致时通时不通等等问题都可能引起此错误。
测试结果: --tnsnames.ora中的端口与监听中端口不符也是报TIME OUT.
TNSPING报错为:TNS-12535: TNS:operation timed out
SQLPLUS报错为:ORA-12170: TNS:Connect timeout occurred
实验数据:
[root@bys001 ~]#
service iptables start --
-启动防火墙
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
[root@bys001 ~]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
[root@bys001 ~]# iptables -A INPUT -p tcp --dport 1521 -j DROP
--新增加一个策略,禁止连接1521端口
[root@bys001 ~]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP tcp -- anywhere anywhere tcp dpt:ncube-lm
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
[root@bys001 ~]# su - oracle
[oracle@bys001 ~]$
tnsping bys1 ---
bys1是我正常使用的,这里未贴出tnsnames.ora,可以参考实验5
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 08-NOV-2013 00:02:14
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.211)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = bys1)))
TNS-12535: TNS:operation timed out
[oracle@bys001 ~]$
sqlplus bys/bys@bys1
SQL*Plus: Release 11.2.0.1.0 Production on Fri Nov 8 00:00:07 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-12170: TNS:Connect timeout occurred
[oracle@bys001 ~]$ su -
Password:
[root@bys001 ~]#
service iptables stop ----及时关闭防火墙,以免影响后面实验
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
在其它主机上测试:
Last login: Thu Nov 7 23:56:04 2013
[oracle@dg1 ~]$ ping 192.168.1.211
PING 192.168.1.211 (192.168.1.211) 56(84) bytes of data.
64 bytes from 192.168.1.211: icmp_seq=1 ttl=64 time=2.47 ms
^C
--- 192.168.1.211 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 2.476/2.476/2.476/0.000 ms
[oracle@dg1 ~]$ telnet 192.168.1.211 1521
Trying 192.168.1.211...
telnet: connect to address 192.168.1.211: Connection timed out
telnet: Unable to connect to remote host: Connection timed out
[oracle@dg1 ~]$
sqlplus bys/[email protected]:1521/bys1
SQL*Plus: Release 11.2.0.1.0 Production on Thu Nov 7 23:57:50 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-12170: TNS:Connect timeout occurred
#########################################################################################################
7.数据库监听正常。tnsnames.ora 中HOST = 字段指定的IP/主机连通,PORT =字段指定的端口已打开。SERVICE_NAME指定服务名与监听中不符。
即tnsnames.ora 中test本地名对应的字段描述格式正确,监听开启,但是监听中不包括TNS中SERVICE_NAME =描述的服务名。也可能是动态监听时实例没注册到监听。 ---还有一种可能是,RAC服务器时,服务器使用的是SCANIP或VIP,客户端配置的HOST地址中IP与主机名对应有问题或未配置等。
测试结果:
TNSPING可以通。
SQLPLUS连接报错:ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
实验数据:
[oracle@bys001 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
bys1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.211)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = bys1)
)
)
test =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.211)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(
SERVICE_NAME = bys999) 手动改为一个不存在的服务名
bys999
)
)
[oracle@bys001 admin]$
lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 07-NOV-2013 23:10:38
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=bys001.oel.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 05-NOV-2013 16:10:23
Uptime 2 days 7 hr. 0 min. 15 sec
Trace Level off
Security ON: Password or Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/diag/tnslsnr/bys001/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=bys001.oel.com)(PORT=1521)))
Services Summary...
Service "bys1" has 1 instance(s).
Instance "bys1", status READY, has 1 handler(s) for this service...
Service "bys1XDB" has 1 instance(s).
Instance "bys1", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@bys001 admin]$
tnsping bys1
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 07-NOV-2013 23:10:43
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.211)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = bys1)))
OK (10 msec)
[oracle@bys001 admin]$
tnsping test ----
一个不存在的服务名,只要主机和端口正确,也是可以用TNSPING测通的。
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 07-NOV-2013 23:10:46
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.211)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED)
(SERVICE_NAME = bys999)))
OK (10 msec)
[oracle@bys001 admin]$
sqlplus bys/bys@bys1
SQL*Plus: Release 11.2.0.1.0 Production on Thu Nov 7 23:10:53 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
BYS@bys1>exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@bys001 admin]$
sqlplus bys/bys@test
服务名不对,测试时TNSPING可能测通,SQLPLUS不能连接
SQL*Plus: Release 11.2.0.1.0 Production on Thu Nov 7 23:10:59 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
#########################################################################################################
8.tnsnames.ora 中本地名及相关主机名、端口、服务名描述正常,数据库中监听未开启。--这步原理同实验4相同。
测试结果:
TNSPING和SQLPLUS报错均为: ORA-12541: TNS:no listener
从报错中也可以理解出:能连接到主机,但是相应的端口没有对应的程序,所以报错为:没有监听器。
实验数据:
[oracle@bys001 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 08-NOV-2013 09:10:00
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=bys001.oel.com)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
[oracle@bys001 ~]$
tnsping bys1
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 08-NOV-2013 09:10:26
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.211)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = bys1)))
TNS-12541: TNS:no listener
[oracle@bys001 ~]$
sqlplus bys/bys@bys1
SQL*Plus: Release 11.2.0.1.0 Production on Fri Nov 8 09:10:30 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-12541: TNS:no listener
#########################################################################################################
9.在客户端连接RAC或数据链连接其它库时,报错:ORA-12545:Connect failed because target host or object does not exist
有两种解决方法情况:
参考mos文档:Client Connection to RAC Intermittently Fails-ORA-12545 TNS: Host or Object Does not Exist (文档 ID 364855.1)
1.客户端使用SCANIP连接RAC数据库时的报错:ORA-12545: Connect failed because target host or object does not exist
解决方法是:修改RAC的local_listener参数,将参数值中HOST=的值改为当前节点的VIP或者scanip-
-注意是IP而不是hostname,客户端可以通过SCANIP或者VIP都可以连接到RAC数据库库
详见: http://blog.csdn.net/haibusuanyun/article/details/17737553
2.数据链连接其它库时,/etc/hosts中没有tnsnames.ora中的主机名与IP的对应,也无法通过DNS解析tnsnames.ora中的主机名。
详见:http://blog.csdn.net/haibusuanyun/article/details/17738631
10.ORA-12523: TNS:listener could not find instance appropriate for the client TNS共享服务器模式连到到静态监听
我遇到一次,tnsnames.ora里写的是连接模式共享服务器,连到的监听是静态的,报此错误。详情如下:
1.tnsnames.ora里共享服务器模式,连到到静态监听,报错:ORA-12523: TNS:listener could not find instance appropriate for the client
prod_s=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1)(PORT=1521))
(CONNECT_DATA=
(SERVER=shared)
(SERVICE_NAME=PROD)))
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.bys.com)(PORT=1521)))
Services Summary...
Service "PROD" has 1 instance(s).
Instance "PROD", status UNKNOWN, has 1 handler(s) for this service...
[oracle@ocm1 admin]$ sqlplus sys/oracle@prod_s as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sun Apr 27 12:20:07 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
ERROR:
ORA-12523: TNS:listener could not find instance appropriate for the client
connection
2.tnsnames.ora里共享服务器模式,连到到动态监听,正常
prod_s=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1)(PORT=1526))
(CONNECT_DATA=
(SERVER=shared)
(SERVICE_NAME=PROD)))
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.bys.com)(PORT=1526)))
Services Summary...
Service "PROD" has 1 instance(s).
Instance "PROD", status READY, has 4 handler(s) for this service...
[oracle@ocm1 admin]$ sqlplus sys/oracle@prod_s as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sun Apr 27 12:21:54 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>
11.tnsnames.ora 中本地名及相关主机名、端口、服务名描述正常。监听开启,可能因监听的配置文件出错或程序异常等,服务无法注册到监听或其它异常。
这个情况没遇到过,也不知道要怎么来演示了。
说下监听配置文件的注意事项:
1.监听分动态与静态监听,详细见:http://blog.csdn.net/q947817003/article/details/11136477
2.监听器的配置文件listener.ora:和tnsnames.ora同样在在:$ORACLE_HOME/network/admin 文件夹下
3.listener.ora内配置信息格式见:http://blog.csdn.net/q947817003/article/details/11180027
4.静态监听的一个用处是可以用来远程启动数据库。即实例未启动时,仍可以通过远程连接到空闲实例,发出STARTUP命令来启动数据库。
至于这种方式的安全问题,可以通过配置多个监听器,如L1配置为静态监听,L2配置为动态监听。同时在tnsnames.ora中通过配置不同本地名来使不同的业务连接不同的本地名,就最终连到不同监听来解决安全隔离问题。(以上个人理解)