今天做Linux下DG配置的时候,遇到一个现象。tnsname.ora文件配置都正常,tnsping也正常,监听也正常。可是仍然报ORA-12514错误:

SQL> set lin 130 pages 130 
SQL> select dest_id,error from v$archive_dest;

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

         3
         4
         5
         6
         7
         8
         9
        10

--查看主库监听
SQL> !lsnrctl status

LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 08-OCT-2014 12:31:46

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=prd)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Start Date                08-OCT-2014 10:34:51
Uptime                    0 days 1 hr. 56 min. 54 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=prd)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "prd" has 1 instance(s).
  Instance "prd", status READY, has 1 handler(s) for this service...
Service "prdXDB" has 1 instance(s).
  Instance "prd", status READY, has 1 handler(s) for this service...
Service "prd_XPT" has 1 instance(s).
  Instance "prd", status READY, has 1 handler(s) for this service...
The command completed successfully

--tnsnames.ora文件内容
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

PRD =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = prd)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = prd)
    )
  )

STD =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = std)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = prd)
    )
  )

--主库tnsping測试网络服务名是否正常
SQL> !tnsping prd

TNS Ping Utility for Linux: Version 10.2.0.5.0 - Production on 08-OCT-2014 12:32:35

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

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = prd)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = prd)))
OK (10 msec)

SQL> !tnsping std

TNS Ping Utility for Linux: Version 10.2.0.5.0 - Production on 08-OCT-2014 12:32:43

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

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = std)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = prd)))
OK (20 msec)

--查看备库监听
[oracle@std ~]$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 08-OCT-2014 12:29:52

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=std)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Start Date                08-OCT-2014 09:41:41
Uptime                    0 days 2 hr. 48 min. 11 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=std)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "std" has 1 instance(s).
  Instance "prd", status READY, has 1 handler(s) for this service...
Service "std_XPT" has 1 instance(s).
  Instance "prd", status READY, has 1 handler(s) for this service...
The command completed successfully

--查看备库远程归档路径
SQL> set lin 130 pages 130 
SQL> col error for a20
SQL> select dest_id,error,status from v$archive_dest;

   DEST_ID ERROR                STATUS
---------- -------------------- ---------
         1                      VALID
         2                      VALID
         3                      INACTIVE
         4                      INACTIVE
         5                      INACTIVE
         6                      INACTIVE
         7                      INACTIVE
         8                      INACTIVE
         9                      INACTIVE
        10                      INACTIVE
        11                      VALID

--备库tnsping測试网络server名是否正常
SQL> !tnsping prd

TNS Ping Utility for Linux: Version 10.2.0.5.0 - Production on 08-OCT-2014 12:39:40

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

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = prd)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = prd)))
OK (20 msec)

SQL> !tnsping std

TNS Ping Utility for Linux: Version 10.2.0.5.0 - Production on 08-OCT-2014 12:39:44

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

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = std)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = prd)))
OK (10 msec)

tnsping測试下来也都是通的,这就比較奇怪了,可是ORA-12514错误非常明显是指监听方面的问题。导致服务名无法解析,因为主备库採用的是同一个实例名,因此两边的instance_name用的都是prd,乍一看好像非常正常,可是解析确实出现了问题,那么怎么办呢?

之前只不过给server配置了一个动态监听,内容例如以下:

--主库监听listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = prd)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )

--主库监听listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = std)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )

能够看到。差别不过主机名不同而已。一个是prd,还有一个是std,静态监听并未配置,即SID_LIST_LISTENER这一项里面的栏目,那么如今为主备库都配置一个监听。

静态监听能够用netmgr配置,这里为了方便,不再进入图形界面运行该命令。而是直接通过改动listener.ora文件来达到目的。其效果是一样的。在原来的listener.ora文件里的SID_LIST_LISTENER中加入例如以下内容(红色部分):


SID_LIST_LISTENER =
  (SID_LIST =
   (SID_DESC =
      (GLOBAL_DBNAME = prd)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
      (SID_NAME = prd)
    )
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = std)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )

注意,加上的内容中。SID_NAME,即instance_name,而GLOBAL_DBNAME,即tnsnames.ora中的SERVICE_NAME,因为tnsnames.ora中的SERVICE_NAME都是prd,因此这里的两个名字是一样的,不会有什么影响,把改动好的文件替换掉原文件。再又一次载入监听文件

SQL> !
[oracle@prd ~]$ lsnrctl reload

LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 08-OCT-2014 12:55:17

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=prd)(PORT=1521)))
The command completed successfully
[oracle@prd ~]$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 08-OCT-2014 12:55:24

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=prd)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Start Date                08-OCT-2014 10:34:51
Uptime                    0 days 2 hr. 20 min. 33 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=prd)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "prd" has 2 instance(s).
  Instance "prd", status UNKNOWN, has 1 handler(s) for this service...
  Instance "prd", status READY, has 1 handler(s) for this service...
Service "prdXDB" has 1 instance(s).
  Instance "prd", status READY, has 1 handler(s) for this service...
Service "prd_XPT" has 1 instance(s).
  Instance "prd", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@prd ~]$ 

注意,这个UNKNOW的prd实例相应的服务名prd就是刚才我们通过静态监听发现的服务名,同那样地,备库也又一次载入监听:

[oracle@std ~]$ lsnrctl reload

LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 08-OCT-2014 12:57:15

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=std)(PORT=1521)))
The command completed successfully
[oracle@std ~]$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 08-OCT-2014 12:57:25

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=std)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Start Date                08-OCT-2014 09:41:41
Uptime                    0 days 3 hr. 15 min. 44 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=std)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "prd" has 1 instance(s).
  Instance "prd", status UNKNOWN, has 1 handler(s) for this service...
Service "std" has 1 instance(s).
  Instance "prd", status READY, has 1 handler(s) for this service...
Service "std_XPT" has 1 instance(s).
  Instance "prd", status READY, has 1 handler(s) for this service...
The command completed successfully

能够看到。此时备库也多了一个UNKNOWN的,和实例名prd相应的服务prd

--再次查看主库远程归档路径状态
SQL> select dest_id,status,error from v$archive_dest_status;

   DEST_ID STATUS    ERROR
---------- --------- --------------------
         1 VALID
         2 VALID
         3 INACTIVE
         4 INACTIVE
         5 INACTIVE
         6 INACTIVE
         7 INACTIVE
         8 INACTIVE
         9 INACTIVE
        10 INACTIVE

原来dest_id=2的那个远程归档路径的ORA-12514的问题攻克了。此时归档日志就能够通过网路远程传输到备库对应的归档路径中了,再运行redo apply也不会有不论什么问题了。


总结:

这个案例是因为主备库都採用了同一个实例名产生的问题,当我们仅仅配置一个默认的动态监听。会发现主库无法监听到远程备库的相应服务,通过静态监听手动加入上与实例名相应的服务。才干解决问题。

使用静态监听的还有一个优点是,当Oracle数据库实例还没有启动的时候,就会先把相应的服务和实例名。通过静态配置的监听文件给启动起来。而不是等启动实例后由pmon进程再去启动。这样速度更快。不用再等待若干秒,我们的client就能够通过静态监听马上脸上数据库server了。也就是说,能够不依赖server进程,完毕监听的工作。









配置静态监听解决ORA-12514错误的案例的更多相关文章

  1. 配置静态监听解决ORA-12514错误的案例(转)

    今天做Linux下DG配置的时候,遇到一个现象,tnsname.ora文件配置都正常,tnsping也正常,监听也正常,但是仍然报ORA-12514错误:   SQL> set lin 130 ...

  2. Oracle静态监听与动态监听概念全解析

    基于11g,linux5.5做出的测试,单实例数据库做出的测试. 1.注册 Instance到监听器去注册自己的Instance_name与ORACLE_HOME,还可以选择添加global_dbna ...

  3. Oracle静态监听和动态监听

    一.静态注册 静态注册指实例启动时读取listener.ora配置文件,将实例和服务注册到监听程序.无论何时启动一个数据库,默认都有两条信息注册到监听器中:实例和服务.SID_LIST_LISTENE ...

  4. Oracle 静态监听注冊具体解释

    Oracle 静态监听注冊具体解释 网上有非常多关于oracle 监听静态注冊的文章.但大多都是简单说说,并没有具体的样例.这里,将结合linux as4 下的oracle 10gR2.0.1 举一个 ...

  5. 配置Tomcat监听80端口、配置Tomcat虚拟主机、Tomcat日志

    6月27日任务 16.4 配置Tomcat监听80端口16.5/16.6/16.7 配置Tomcat虚拟主机16.8 Tomcat日志扩展邱李的tomcat文档 https://www.linuser ...

  6. 配置Tomcat监听80端口 配置Tomcat虚拟主机 Tomcat日志

    配置Tomcat监听80端口 • vim /usr/local/tomcat/conf/server.xml Connector port=" protocol="HTTP/1.1 ...

  7. CentOS7 配置 SSH监听多个端口方法

    一.修改ssh默认端口,防止暴力破解,让系统安全多一点点: i. 在配置文件/etc/ssh/sshd_config文件中修改 Port #AddressFamily any #ListenAddre ...

  8. Linux centosVMware 配置Tomcat监听80端口、配置Tomcat虚拟主机、Tomcat日志

    一.配置Tomcat监听80端口 关闭tomcat报错 [root@davery src]# /usr/local/tomcat/bin/shutdown.sh 重装tomcat即可 vim /usr ...

  9. Tomcat介绍、安装jdk、安装Tomcat、配置Tomcat监听80端口

    1.Tomcat介绍 2.安装jdk下载:wget -c http://download.oracle.com/otn-pub/java/jdk/10.0.1+10/fb4372174a714e6b8 ...

随机推荐

  1. [BZOJ5109][LOJ #6252][P4061][CodePlus 2017 11月赛]大吉大利,今晚吃鸡!(最短路+拓扑排序+传递闭包+map+bitset(hash+压位))

    5109: [CodePlus 2017]大吉大利,晚上吃鸡! Time Limit: 30 Sec  Memory Limit: 1024 MBSubmit: 107  Solved: 57[Sub ...

  2. [BZOJ4542] [JZYZOJ2014][Hnoi2016] 大数(莫队+离散化)

    正经题解在最下面 http://blog.csdn.net/qq_32739495/article/details/51286548 写的时候看了大神的题解[就是上面那个网址],看到下面这段话 观察题 ...

  3. Week Four

    2018.12.18 1.[USACO Platinum C] 2.[Gym 102028H] 3.[BZOJ 2750] 4.[BZOJ 3238] 5.[BZOJ 4310] 6.[BZOJ 38 ...

  4. bzoj 2045: 双亲数

    2045: 双亲数 Description 小D是一名数学爱好者,他对数字的着迷到了疯狂的程度. 我们以d = gcd(a, b)表示a.b的最大公约数,小D执著的认为,这样亲密的关系足可以用双亲来描 ...

  5. java 环境变量设定

    ​     1   新建系统环境  新建  弹出“新建系统变量”对话框,分别输入变量名“JAVA_HOME”和变量值(java安装路径)“C:\Java\jdk1.7.0_03”,其中变量值是笔者的J ...

  6. poj 1984 并查集

    题目意思是一个图中,只有上下左右四个方向的边.给出这样的一些边, 求任意指定的2个节点之间的距离. 就是看不懂,怎么破 /* POJ 1984 并查集 */ #include <stdio.h& ...

  7. Android 出现java.lang.NoClassDefFoundError错误

    项目中用到了Retrofit在android4.4以下版本发生的问题 因为项目的build.gradle文件沿用于一个项目的,在defaultConfig z中已经声明了 multiDexEnable ...

  8. Educational Codeforces Round 10 D. Nested Segments 离线树状数组 离散化

    D. Nested Segments 题目连接: http://www.codeforces.com/contest/652/problem/D Description You are given n ...

  9. Codeforces Round #202 (Div. 1) D. Turtles DP

    D. Turtles Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/547/problem/B ...

  10. 读书笔记_Effective_C++_条款二十六:尽可能延后变量定义式的出现时间

    这个条款从字面意思还是很好理解的,就是在使用这个变量前才去定义,而不是很早就定义了它,而在很后面的时候才去使用.这个条款只适用于对变量声明位置没有要求的语言,比如C++.对于像C或者一些脚本语言,语法 ...