TNS-12505:TNS:listener 在关闭其中一个数据库实例后当前不知道连接描述符中给出的 SID

Posted

技术标签:

【中文标题】TNS-12505:TNS:listener 在关闭其中一个数据库实例后当前不知道连接描述符中给出的 SID【英文标题】:TNS-12505: TNS:listener does not currently know of SID given in connect descriptor after shutting down one of the DB instance 【发布时间】:2019-02-11 10:47:45 【问题描述】:

我的数据库机器有三个实例,我只在 RMAN 界面中关闭了“EDWDBS1”(不是整个数据库)

shutdown immediate

但是当我想重新连接/启动“EDWDBS1”时,它会在 sqldeveloper、sqlplus 或 RMAN 中引发 ORA-12505 错误。 Alrd 尝试检查 tnsnames.ora 和 listener.ora,但我仍然不知道。

这是我的 listener.ora

# copyright (c) 1997 by the Oracle Corporation
# 
# NAME
#   listener.ora
# FUNCTION
#   Network Listener startup parameter file example
# NOTES
#   This file contains all the parameters for listener.ora,
#   and could be used to configure the listener by uncommenting
#   and changing values.  Multiple listeners can be configured
#   in one listener.ora, so listener.ora parameters take the form
#   of SID_LIST_<lsnr>, where <lsnr> is the name of the listener
#   this parameter refers to.  All parameters and values are
#   case-insensitive.

# <lsnr>
#   This parameter specifies both the name of the listener, and
#   it listening address(es). Other parameters for this listener
#   us this name in place of <lsnr>.  When not specified,
#   the name for <lsnr> defaults to "LISTENER", with the default
#   address value as shown below.
#
# LISTENER =
#  (ADDRESS_LIST=
#   (ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))
#   (ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))   

# SID_LIST_<lsnr>
#   List of services the listener knows about and can connect 
#   clients to.  There is no default.  See the Net8 Administrator's
#   Guide for more information.
#
# SID_LIST_LISTENER=
#   (SID_LIST=
#   (SID_DESC=
#           #BEQUEATH CONFIG
#          (GLOBAL_DBNAME=salesdb.mycompany)
#          (SID_NAME=sid1)          
#          (ORACLE_HOME=/private/app/oracle/product/8.0.3)
#           #PRESPAWN CONFIG
#         (PRESPAWN_MAX=20)
#     (PRESPAWN_LIST=
#           (PRESPAWN_DESC=(PROTOCOL=tcp)(POOL_SIZE=2)(TIMEOUT=1))
#         )
#        )
#       )

# PASSWORDS_<lsnr>
#   Specifies a password to authenticate stopping the listener.
#   Both encrypted and plain-text values can be set.  Encrypted passwords
#   can be set and stored using lsnrctl.  
#     LSNRCTL> change_password
#       Will prompt for old and new passwords, and use encryption both
#       to match the old password and to set the new one.
#     LSNRCTL> set password
#   Will prompt for the new password, for authentication with 
#       the listener. The password must be set before running the next
#       command.
#     LSNRCTL> save_config
#       Will save the changed password to listener.ora. These last two
#       steps are not necessary if SAVE_CONFIG_ON_STOP_<lsnr> is ON.
#       See below.
#
# Default: NONE
#
# PASSWORDS_LISTENER = 20A22647832FB454      # "foobar"

# SAVE_CONFIG_ON_STOP_<lsnr>
#   Tells the listener to save configuration changes to listener.ora when
#   it shuts down.  Changed parameter values will be written to the file,
#   while preserving formatting and comments.
# Default: OFF
# Values: ON/OFF
#
# SAVE_CONFIG_ON_STOP_LISTENER = ON

# USE_PLUG_AND_PLAY_<lsnr>
#   Tells the listener to contact an Onames server and register itself
#   and its services with Onames.
# Values: ON/OFF
# Default: OFF
#
# USE_PLUG_AND_PLAY_LISTENER = ON

# LOG_FILE_<lsnr>
#   Sets the name of the listener's log file.  The .log extension
#   is added automatically.
# Default=<lsnr>
#
# LOG_FILE_LISTENER = lsnr

# LOG_DIRECTORY_<lsnr>
#   Sets the directory for the listener's log file.
# Default: <oracle_home>/network/log
#
# LOG_DIRECTORY_LISTENER = /private/app/oracle/product/8.0.3/network/log

# TRACE_LEVEL_<lsnr>
#   Specifies desired tracing level.
# Default: OFF
# Values: OFF/USER/ADMIN/SUPPORT/0-16
#
# TRACE_LEVEL_LISTENER = SUPPORT

# TRACE_FILE_<lsnr>
#   Sets the name of the listener's trace file. The .trc extension
#   is added automatically.
# Default: <lsnr>
#
# TRACE_FILE_LISTENER = lsnr

# TRACE_DIRECTORY_<lsnr>
#   Sets the directory for the listener's trace file.
# Default: <oracle_home>/network/trace
#
# TRACE_DIRECTORY_LISTENER=/private/app/oracle/product/8.0.3/network/trace
# CONNECT_TIMEOUT_<lsnr>
#   Sets the number of seconds that the listener waits to get a 
#   valid database query after it has been started.
# Default: 10
#
# CONNECT_TIMEOUT_LISTENER=10

tnsnames.ora

EDWDBD1 = (DESCRIPTION = 
    (ADDRESS = (PROTOCOL = TCP)(HOST = HKHPEDWDBSDEV01)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = EDWDBD1)
    )
  )

EDWDBS1 = (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = HKHPEDWDBSDEV01)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = EDWDBS1)
    )
  )

EDWDBU1 = (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = HKHPEDWDBSDEV01)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = EDWDBU1)
    )
  )

EDWPDBD1 = (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = HKHPEDWDBSDEV01)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = EDWPDBD1)
    )
  )

lsnrctl 状态结果

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 11-FEB-2019 18:43:54

Copyright (c) 1991, 2016, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                11-FEB-2019 18:09:09
Uptime                    0 days 0 hr. 34 min. 45 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/HKHPEWDBSDEV01/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=HKHPEWDBSDEV01)(PORT=1521)))
Services Summary...
Service "7a114ab24bf177a5e055315d54627e2c" has 1 instance(s).
  Instance "edwdbd1", status READY, has 1 handler(s) for this service...
Service "EDWDBU1" has 1 instance(s).
  Instance "EDWDBU1", status READY, has 1 handler(s) for this service...
Service "EDWDBU1XDB" has 1 instance(s).
  Instance "EDWDBU1", status READY, has 1 handler(s) for this service...
Service "edwdbd1" has 1 instance(s).
  Instance "edwdbd1", status READY, has 1 handler(s) for this service...
Service "edwdbd1XDB" has 1 instance(s).
  Instance "edwdbd1", status READY, has 1 handler(s) for this service...
Service "edwpdbd1" has 1 instance(s).
  Instance "edwdbd1", status READY, has 1 handler(s) for this service...
The command completed successfully

【问题讨论】:

rman 用于备份,而不是“停止实例”。请edit您的问题并向我们展示您用来停止该实例的命令 提到 rman 只是想表明我在关闭实例后无法再连接到 edwdbs1。我使用 shutdown immediate 来停止 stat 实例。 【参考方案1】:

我猜您正在尝试远程启动您的实例。在您的 listener.ora 中,您没有配置静态服务,因此您无法远程(通过 TCP/IP)连接到该实例,因为侦听器不知道该实例。 为了启动实例,您应该在本地连接(通过 SSH)并设置所有必要的环境变量(ORACLE_HOME、ORACLE_SID、PATH)并使用操作系统身份验证(通常是 dba 组的成员)并运行:

sqlplus / as sysdba

startup;

您也可以使用密码文件身份验证,但这是另一回事。

【讨论】:

以上是关于TNS-12505:TNS:listener 在关闭其中一个数据库实例后当前不知道连接描述符中给出的 SID的主要内容,如果未能解决你的问题,请参考以下文章

TNS-12505: TNS:listener does not currently know of SID given in connect descriptor

Oracle TNS-12505 错误

ORA-12514: TNS:listener 当前不知道连接描述符中请求的服务

Oracle TNS Listener Remote Poisoning

java.sql.SQLException: TNS:listener 目前不知道连接描述符中给出的 SID

ORA-12528: TNS:listener: all appropriate instances are blocking new connections