Ora 12514 как исправить

от admin

Troubleshooting Guide for ORA-12514 TNS:listener could not resolve the service requested in connect descriptor (Doc ID 444705.1)

This error can occur when connecting directly to the database or when selecting across a database link (dblink). The troubleshooting steps outlined below are applicable to either situation.

Troubleshooting Steps

To view full details, sign in with your My Oracle Support account.

Don’t have a My Oracle Support account? Click to get started!

In this Document

Purpose
Troubleshooting Steps
References

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.

Oracle offers a comprehensive and fully integrated stack of cloud applications and platform services. For more information about Oracle (NYSE:ORCL), visit oracle.com. � Oracle | Contact and Chat | Support | Communities | Connect with us | | Twitter | Linked In | Legal Notices | Terms of Use

How to Resolve ORA-12514: TNS:listener does not currently know of service requested in connect

ORA-12514 in PL/SQL Developer

ORA-12514 means that the listener cannot find any matched service with yours, so it cannot establish the connection with the database for you. As a result, it responds ORA-12514 to alert the failed connection.

Only one thing that can be sure in ORA-12514 is that the target listener is up and running. That is to say, the listener is reachable.

For unknown requested SID, the listener throws ORA-12505: TNS:listener does not currently know of SID given in connect. It may have different error patterns from this post.

ORA-12514 in Common Situations

Let’s see how we get ORA-12514. First of all, we have to make sure the listener on the database server is reachable by using tnsping .

TNS Ping Utility for 64-bit Windows: Version 12.1.0.1.0 — Production on 22-JUL-2014 19:24:04

Copyright (c) 1997, 2013, Oracle. All rights reserved.

Used parameter files:
C:\oracle\app\client\ed\product\12.1.0\client_1\network\admin\sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle-11g-server)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORCL)))
OK (60 msec)

OK, the remote listener is up and reachable. Please note that, the message of successful tnsping did not indicate that the service name is existing on the remote listener.

Next, we test the connection to the database by sqlplus (SQL*Plus).

C:\Users\ed>sqlplus hr/hr@ora11g
.
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor

Cause

When the connection came, the listener found no matched service name registered with it. Consequently, the listener had no idea which database should be used to service the connection. Here are some possible causes of ORA-12514:

1. No instance

The database was not available or say idle, no any dynamic services registered with the listener. That’s why we saw ORA-12514.

2. Mismatched service name

The service name of the connect descriptor in tnsnames.ora did not match the service name in the listener. That is to say, the listener does not currently know of service requested in connect descriptor.

3. Not registered

If the database instance is up and running, the service name may not registered with the listener at specific port as you thought. By default, the service port of listener is 1521. But sometimes, it could switch to another port, say 1522.

Please note that, ORA-12514 is an error threw by the listener specifically for the client side. The database is no way to know such problem.

Solutions

The solutions to ORA-12514 are to make sure the following things:

1. The database is available

If there’s no instance, then no service name will register with the listener. You should startup the instance, then LREG will automatically register the service in 60 seconds.

If you are sure that the database is up and running and still got ORA-12514, things may be complicated. Let’s keep looking for other solutions.

2. The service names are matched

The service name in the connect descriptor of client’s tnsnames.ora shall match the service registered in the listener. Sometimes, it’s just a typo problem.

In short, the service names in the following 3 parties should be matched with each other in order to solve ORA-12514.

Service Names Shall Match for Solving ORA-12514

Service Names Shall Match for Solving ORA-12514

  • Connect descriptor.
  • The listener.
  • The database.

We talk about them respectively below.

Connect Descriptor

Let’s see an example of connect identifier. In which, the body is a connect descriptor.

]$ vi $ORACLE_HOME/network/admin/tnsnames.ora
.
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle-11g-server)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
( SERVICE_NAME = ORCL )
)
)

The Listener

The connect descriptor is easily checked, but how do we check the service names of the listener? See the following command:

]$ lsnrctl status
.
Services Summary.
Service «ORCL» has 1 instance(s).
Instance «ORCL», status READY, has 1 handler(s) for this service.

For a specific listener name, you should do this:

]$ lsnrctl status <listener_name>

The Database

If there’s no matched service name in the listener, we should check the service names of the instance by OS authentication. No credentials are needed.

]$ sqlplus / as sysdba
.
SQL> show parameter service_names

If both service names in the client and database are matched, but the listener showed a different service name or «The listener supports no services». The database may register a different listener, let’s keep reading this post.

3. The host and port are both right

Sometime, we may go for the wrong destination of the listener, either host or port was incorrect. As a result, we saw ORA-12514 because there’s no matched service name with that listener. We should check the host and port in the connect descriptor of the TNS name.

Chances are, the correct hostname may be resolved as the wrong IP address by DNS. Consequently, connections took us to the wrong database server. This could happen when we switched from an old machine to a new database server. So we should focus on name resolution problem first.

For those ORA-12514 caused by name resolution, we can use the IP address instead of hostname to connect the database for clients to work around it. Additionally, DBA should also check both values of HOST and PORT in listener.ora .

During the troubleshooting on the name resolution, you might see TNS-12545: Connect failed because target host or object does not exist temporarily.

4. Instance registers it services with the right listener

The instance may register with the another listener which services whatever port other than 1521. Consequently, no service name is supported by that listener.

That’s why we always see ORA-12514 only in clients or TNS-12514 in the listener’s log, the database instance will never know such problem.

Now we have a question: What listener is the instance using? If the database is using a different listener other than the default one, we can check a parameter named LOCAL_LISTENER for sure:

SQL> show parameter local_listener

If the default listener at port 1521 in the same machine is used, the value could be empty. Otherwise, we will see the listener description like the above.

ORA-12514 When Restart a Database

It’s pretty easy to explain why you got ORA-12514 when you restart a database. Please compare the following two cases.

Connect to the database through listener

]$ sqlplus /nolog
.
SQL> conn sys@orcl as sysdba
Enter password:
Connected.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

We saw ORA-12514 after we tried to startup the stopped database. Here is the reason: When you shutdown the instance, you lost the connection from the database and the service was unregistered from the listener, no more service information of the database on the listener. Therefore, ORA-12514 notified that you can’t do any further to this database in this way.

Читать:
Что собой представляет проблема в самом общем смысле

To solve ORA-12514 thoroughly, you should add a static service registration to the listener for your database. Otherwise, you have to connect to the database by OS authentication.

Let’s see how to avoid ORA-12514 if you are going to do critical jobs like shutdown or startup database through OS authentication.

Connect to the database through OS authentication

You don’t have to provide the password through OS authentication.

]$ sqlplus /nolog
.
SQL> conn / as sysdba
Connected.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.

Total System Global Area 1553305600 bytes
Fixed Size 2253544 bytes
Variable Size 956304664 bytes
Database Buffers 587202560 bytes
Redo Buffers 7544832 bytes
Database mounted.
Database opened.

Can you tell the difference? By this method, you can never lose your connection during down time no matter the listener is up or not. No ORA-12514 interrupts you.

By the way, I talked about how to connecting an idle, NOMOUNT or RESTRICT database from remote clients in another post. It may help you to clarify some concepts about ORA-12514.

ORA-12514 When Switchover to Standby

DGMGRL> switchover to standby;
Performing switchover NOW, please wait.
Operation requires a connection to instance «primary» on database «standby»
Connecting to instance «primary».
Connected.
New primary database «standby» is opening.
Operation requires startup of instance «primary» on database «primary»
Starting instance «primary».
Unable to connect to database
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

Failed.
Warning: You are no longer connected to ORACLE.

  1. The former standby is up and now playing the primary role.
  2. The former primary is down and going to play the standby role, but the data guard broker is unable to mount the instance due to the lost contact. As a result, we saw ORA-12514 in DGMGRL.

That is to say, the switchover is incomplete, but it does not mean a failure. This is because the former primary database is down and the broker lost the contact that caused ORA-12514.

Here are the actions that you have to take in order to complete the switchover. Please start up and mount the former «primary» database manually. After that, the data guard will automatically synchronize the data so as to complete the switchover.

The preventive action to ORA-12514 in an incomplete switchover is to add a very special static service in listener.ora for data guard broker to use.

ORA-12514 When Using a Database Link

A database link is just like a client which is trying to connect the remote database.

SQL> conn hr/hr
Connected.
SQL> select first_name from employees@ora11g_hr;
select first_name from employees@ora11g_hr
*
ERROR at line 1:
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

  • The remote database is down. This is the most common cause of ORA-12514.
  • The connect descriptor in the local tnsnames.ora has been changed.
  • The service name of the remote database has been changed.
  • Another listener is used for servicing the remote database.

Usually, this type of ORA-12514 does not complain about the database link, except that you defined the database link with its own connect descriptor.

For example, we can create a database link with a full connect descriptor like this:

SQL> create database link ora11g_hr connect to hr identified by hr using ‘ (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle-11g-server)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = ORCL))) ‘;

Database link created.

As you can see, we did not use a connect identifier, instead, we use a full connect descriptor. Therefore, if there’s anything wrong with the connect descriptor, we have to drop the database link then create a new one for solving ORA-12514.

ORA-12514 TNS:listener does not currently know of service requested in connect descriptor

We have an application running locally where we’re experiencing the following error:

ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

I’ve tested the connection using TNSPing which resolved correctly and I tried SQLPlus to try connecting, which failed with the same error as above. I used this syntax for SQLPlus :

We have verified that:

  • the TNS Listener on the server is running.
  • Oracle itself on the server is running.

We don’t know of any changes that were made to this environment. Anything else we can test?

Barbaros Özhan's user avatar

Jacques's user avatar

29 Answers 29

I had this issue and the fix was to make sure in tnsnames.ora the SERVICE_NAME is a valid service name in your database. To find out valid service names, you can use the following query in oracle:

Once I updated tnsnames.ora to:

Success! The listener is basically telling you that whatever service_name you are using isn’t a valid service according to the DB.

(*I was running sqlplus from Win7 client workstation to remote DB and blame the DBAs 😉 *)

I know this is an old question, but still unanswered. It took me a day of research, but I found the simplest solution, at least in my case (Oracle 11.2 on Windows 2008 R2) and wanted to share.

The error, if looked at directly, indicates that the listener does not recognize the service name. But where does it keep service names? In %ORACLE_HOME%\NETWORK\ADMIN\listener.ora

The «SID_LIST» is just that, a list of SIDs and service names paired up in a format you can copy or lookup.

I added the problem Service Name, then in Windows «Services» control panel, I did a «Restart» on the Oracle listener service. Now all is well.

For example, your listener.ora file might initially look like:

. And to make it recognize a service name of orcl , you might change it to:

Kevin's user avatar

In my circumstances the error was due to the fact the listener did not have the db’s service registered. I solved this by registering the services. Example:

My descriptor in tnsnames.ora :

So, I proceed to register the service in the listener.ora manually:

Finally, restart the listener by command:

manix's user avatar

I had this issue at Windows server 2008 R2 and Oracle 11g

go to Net Manager > Listener > select database services form the combox > «Global Database Name» must be same as «SID» and «Oracle Home Directory» must be correct.

If you don’t have any entry for database services, create one and set correct global database , sid and oracle home.

This really should be a comment to [Brad Rippe][1]’s answer, but alas, not enough rep. That answer got me 90% of the way there. In my case, the installation and configuration of the databases put entries in the tnsnames.ora file for the databases I was running. First, I was able to connect to the database by setting the environment variables (Windows):

and then connecting using

Next, running the command from Brad Rippe’s answer:

showed that the names didn’t match exactly. The entries as created using Oracle’s Database Configuration Assistant were originally:

Почему ошибка ORA-12514: TNS:listener does not currently know of service requested in connect descriptor?

Smithson

В общем в одной подсети инстансы oracle с одинаковыми service name и портами жить могут.

в listener.ora добавляем информацию о новом подключении по IP и меняем порт

В tnsnames.ora заносим информацию о новых экземплярах

После перезапускаем службы листенера и самой БД.

Проверяем командой
lsnrctl status

The command completed successfully

обязательно должна быть информация о

lsnrctl reload – переинициализировать листенер иногда помагает, когда инстанс не инициализовался листенером

Похожие статьи