ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
在配置oracle监听的时候竟然报了错:ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA
以下是我报错的配置:
listener.ora的配置:
-
[oracle@sm2 admin]$ cat listener.ora
-
LISTENER = (
-
DESCRIPTION_LIST = (
-
DESCRIPTION =
-
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.137.82)(PORT = 1521))
-
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
-
)
-
)
-
-
SID_LIST_LISTENER = (
-
SID_LIST = (
-
SID_DESC =
-
(GLOBAL_DBNAME = sm2)
-
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
-
(SID_NAME=sm2)
-
)
-
)
-
ADR_BASE_LISTENER = /u01/app/oracle
tnsname.ora的配置:
-
[oracle@sm2 admin]$ cat tnsnames.ora
-
sm2 = (
-
DESCRIPTION = (
-
ADDRESS_LIST = (
-
ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.137.82)(PORT = 1521)
-
)
-
)
-
(ONNECT_DATA =
-
(SERVICE_NAME = sm2)
-
(SERVER = DEDICATED)
-
)
-
)
-
[oracle@sm2 admin]$ lsnrctl status
-
-
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 29-JUL-2014 12:33:23
-
-
Copyright (c) 1991, 2011, Oracle. All rights reserved.
-
-
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.137.82)(PORT=1521)))
-
STATUS of the LISTENER
-
------------------------
-
Alias LISTENER
-
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
-
Start Date 29-JUL-2014 11:44:04
-
Uptime 0 days 0 hr. 49 min. 19 sec
-
Trace Level off
-
Security ON: Local OS Authentication
-
SNMP OFF
-
Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
-
Listener Log File /u01/app/oracle/diag/tnslsnr/sm2/listener/alert/log.xml
-
Listening Endpoints Summary...
-
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.137.82)(PORT=1521)))
-
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
-
Services Summary...
-
Service "SM2XDB" has 1 instance(s).
-
Instance "sm2", status READY, has 1 handler(s) for this service...
-
Service "sm2" has 2 instance(s).
-
Instance "sm2", status UNKNOWN, has 1 handler(s) for this service...
-
Instance "sm2", status READY, has 1 handler(s) for this service...
-
The command completed successfully
-
[oracle@sm2 admin]$ tnsping sm2
-
-
TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 29-JUL-2014 12:27:30
-
-
Copyright (c) 1997, 2011, Oracle. All rights reserved.
-
-
Used parameter files:
-
/u01/app/oracle/product/11.2.0/db_1/network/admin/sqlnet.ora
-
-
-
Used TNSNAMES adapter to resolve the alias
-
Attempting to contact ( DESCRIPTION = ( ADDRESS_LIST = ( ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.137.82)(PORT = 1521))) (ONNECT_DATA = (SERVICE_NAME = sm2) (SERVER = DEDICATED)))
-
OK (20 msec)
-
[oracle@sm2 admin]$ sqlplus sys/oracle@sm2 as sysdba
-
-
SQL*Plus: Release 11.2.0.3.0 Production on Tue Jul 29 12:27:48 2014
-
-
Copyright (c) 1982, 2011, Oracle. All rights reserved.
-
-
ERROR:
-
ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA
说明:其实上面出现这样的情况是在tnsname.ora中配置错了,将tnsname.ora中的ADDRESS_LIST参数去掉就行了。
最终的tnsname.ora中的配置变为:
-
[oracle@sm2 admin]$ cat tnsnames.ora
-
-
sm2 = (
-
DESCRIPTION = (
-
ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.137.82)(PORT = 1521)
-
)
-
(CONNECT_DATA =
-
(SERVER = DEDICATED)
-
(SERVICE_NAME = sm2)
-
)
-
)
验证:
-
[oracle@sm2 admin]$ sqlplus sys/oracle@sm2 as sysdba
-
-
SQL*Plus: Release 11.2.0.3.0 Production on Tue Jul 29 12:39:45 2014
-
-
Copyright (c) 1982, 2011, Oracle. All rights reserved.
-
-
-
Connected to:
-
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
-
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-
-
SQL>