ORA-12514: TNS:listener&nbs…

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

After restarting the machine, the listener couldn't get up unexpectedly. After trying for a long time, I finally found the reason and solved it. I found that as long as I give my sister time, the problem can still be solved, haha. Very happy!

—————————————————————————

oracle monitor dynamic registration and static registration  

1. What is registration

Registration is to register the database as a service in the listener. The client does not need to know the database name and instance name, but only needs to know the service name provided by the database to apply for linking to the database. The service name can be the same as the database name, or it may be different.

In the process of starting the database service, the database server will register the corresponding service like the listener. Whenever the database is started, two pieces of information are registered to the listener by default, the instance and service corresponding to the database server, the client and the server Only need to provide a service name for the link between.

Two, distinguish between dynamic registration and static registration

(1) Use listener.ora file to judge

Dynamic registration

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (PROGRAM = extproc)
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = D:\oradata\orcl)
    )
  )

Static registration

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (PROGRAM = extproc)
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = D:\oradata\orcl)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = orcl)
      (ORACLE_HOME = D:\oradata\orcl)
      (SID_NAME = ORCL)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = orcl1)
      (ORACLE_HOME = D:\oradata\orcl)
      (SID_NAME = ORCL)
    )
  )

Although it can be roughly seen by looking at it, this method does not clearly describe the actual situation of the database at runtime.

(2) Use the lsnrctl status command

Third, the dynamic note book

Dynamic registration is that when the instance starts, the PMON (Process Monitor process monitor) process registers the instance and service to the listener according to the instance_name and service_name parameters in INIT.ORA.

The content of the listener.ora file during dynamic registration is as follows

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (PROGRAM = extproc)
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = D:\oradata\orcl)
    )
  )

Since the dynamic registration requires the pmon process, the monitoring must be started before the database is started, otherwise the dynamic registration will fail ; during the database operation, restarting the monitoring will also cause the dynamic registration to fail

Dynamic registration is just to register the default listener (name is listener, port is 1521, TCP protocol), if you need to register to a non-default listener, you need to change the local_listener parameter

Add the monitored information to the tnsnames.ora  file. Note that it is the tnsnames.ora file, because pmon needs to read relevant information from tnsnames.ora when dynamically registering and listening.

LISTENER =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = DaveDai)(PORT = 1522))

)

 Then run as the sys user:

SQL> alter system set local_listener=listener;

SQL> alter system register;

or:

SQL> alter system set LOCAL_LISTENER='(ADDRESS = (PROTOCOL = TCP)(HOST = DaveDai)(PORT = 1522))';

SQL> alter system register;

The advantage of dynamic registration is simple and convenient, but registration failure is prone to occur

Four, static registration

Static registration is to read the configuration of the listener.ora file when the instance starts, and register the instance and service to the listener

The contents of listener.ora during static registration are as follows

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (PROGRAM = extproc)
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = D:\oradata\orcl)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = orcl)
      (ORACLE_HOME = D:\oradata\orcl)
      (SID_NAME = ORCL)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = orcl1)
      (ORACLE_HOME = D:\oradata\orcl)
      (SID_NAME = ORCL)
    )
  )

golbal_dbname is the service name provided by the database, and sid_name is the instance name. This file indicates that the database is a single-instance database, the instance name is orcl, and two services orcl and orcl1 are provided.

The benefits of static registration can be summarized as

1. Monitoring is not the first to start

2. When the database is running, the monitor is sent to restart

3. The oracle instance is not open yet

When the above three situations occur, monitoring registration failure will not occur.

Guess you like

Origin blog.csdn.net/muzhiqian/article/details/52669924