ORA-12520 TroubleShooting

 

同事反馈他连接一个新搭建的测试数据库时,报ORA-12520: TNS: 监听程序无法为请求的服务器类型找到可用的处理程序错误,在解决他这个问题时,顺便分析、总结一下ORA-12520错误。下面重现一下这个场景:

 

Oracle Client段的tnsnames.ora的配置如下:

 

MY_TEST=
        (DESCRIPTION=
                (ADDRESS=(PROTOCOL=tcp)(HOST=10.10.5.37)(PORT=49161))
            (CONNECT_DATA=
           (SERVER = SHARED)
                  (SERVICE_NAME = XE)
            )
        )

 

 

客户端SQL*PLUS访问数据库报错:

 

 

C:\Users>sqlplus test/test123456@MY_TEST
 
SQL*Plus: Release 11.2.0.1.0 Production on 星期二 1月 8 23:30:47 2019
 
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
 
ERROR:
ORA-12520: TNS: 监听程序无法为请求的服务器类型找到可用的处理程序
 
 
请输入用户名:
 
 
请输入用户名:

 

ORA-12520 TroubleShooting_第1张图片

 

 

 

 

在服务器检查是否开启了shared server模式(注意,如果配置正确,但是没有开启共享服务器模式,也会报这个错误)

 

 

 

SQL> show parameter shared_servers
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
max_shared_servers                   integer     10
shared_servers                       integer     10
SQL> 

 

 

 

 

在服务器检查SERVICE_NAME的信息:

 

 

 

SQL> show parameter service_name;
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      XE
SQL> !

oracle@3c939f31e44b:~$ lsnrctl services

 

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 08-JAN-2019 15:33:45

 

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

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))

Services Summary...

Service "PLSExtProc" has 1 instance(s).

  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...

    Handler(s):

      "DEDICATED" established:0 refused:0

         LOCAL SERVER

Service "XE" has 1 instance(s).

  Instance "XE", status READY, has 1 handler(s) for this service...

    Handler(s):

      "DEDICATED" established:102 refused:0 state:ready

         LOCAL SERVER

Service "XEXDB" has 1 instance(s).

  Instance "XE", status READY, has 1 handler(s) for this service...

    Handler(s):

      "D000" established:4 refused:0 current:0 max:1022 state:ready

         DISPATCHER

         (ADDRESS=(PROTOCOL=tcp)(HOST=3c939f31e44b)(PORT=41385))

Service "XE_XPT" has 1 instance(s).

  Instance "XE", status READY, has 1 handler(s) for this service...

    Handler(s):

      "DEDICATED" established:102 refused:0 state:ready

         LOCAL SERVER

The command completed successfully

 

 

我们知道如果共享服务器模式连接数据库,是需要通过DISPATCHER的,那么要看看参数dispatchers是如何配置的。如下所示,dispatchers里面设置的是SERVIE_NAMEXEXDB,不是XE,难怪会出这个错误。

 

 

 

ORA-12520 TroubleShooting_第2张图片

 

 

ORA-12520 TroubleShooting_第3张图片

 

 

那么我们修改一下DISPATCHERS参数配置,将SERVICE_NAME改为XE

 

 

SQL> show parameter dispatcher;
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
dispatchers                          string      (PROTOCOL=TCP) (SERVICE=XEXDB)
max_dispatchers                      integer
 
SQL> ALTER SYSTEM SET DISPATCHERS ='(PROTOCOL=TCP) (SERVICE=XE)';
 
System altered.
 
SQL> show parameter dispatcher;
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
dispatchers                          string      (PROTOCOL=TCP) (SERVICE=XE)
max_dispatchers                      integer
SQL> 

 

 

 

OK,如下所示,问题解决。此时客户端可以顺利访问数据库了。

 

ORA-12520 TroubleShooting_第4张图片

 

 

 

说到这里,那么我们就不得不说一下SERVICE_NAME,服务名(SERVICE_NAME):指listener提供的对外的服务名,客户端可以通过配置tnsnmaes.ora连进行连接,tnsnmaes.ora文件中的service_name要等于服务器端listener所注册的服务名,服务名可以通过输入lsnrctl后,在输入service查看,一般的service_namelistener.ora文件中配置(静态注册),或者当没有listener.ora文件时,在初始化文件中配置instance_nameservice_names2个参数进行动态注册。但是无论采用那种注册方式,都可以通过lsnrctl-sevice来检查。上面案例中,配置都没有错,而是在于共享连接的分派器(DISPATCHER)的设置问题,因为共享连接的分派器(DISPATCHER)指定SERVICE_NAMEXEXDB,那么客户端访问数据库使用服务名XE的话,就只能使用专用连接服务器模式。

 

 

另外,我们看看如果数据库实例配置不改动的情况下,需要如何修改客户端的tnsnames.ora的条目(entry)需要如何修改。

 

 

注意: 下面所谓正确、错误配置,仅仅指服务器配置不改动的情况下,正确配置仅仅指客户端这种配置方式不会报错。而错误配置仅仅指这种配置方式报错。

 

我们先复原数据库实例的配置,如下所示,然后测试一下其它

ORA-12520 TroubleShooting_第5张图片

 

错误的配置:

 

 

MY_TEST=

        (DESCRIPTION=

                (ADDRESS=(PROTOCOL=tcp)(HOST=10.10.5.37)(PORT=49161))

            (CONNECT_DATA=

          (SERVER = SHARED)

                  (SERVICE_NAME = XE)

            )

        )

 

正确的配置

 

 

 

1:不指定共享连接服务器模式,那么默认使用专用连接服务器模式,那么也没有问题。

 

 

MY_TEST=

        (DESCRIPTION=

                (ADDRESS=(PROTOCOL=tcp)(HOST=10.10.5.37)(PORT=49161))

            (CONNECT_DATA=

                  (SERVICE_NAME = XE)

            )

 

 

2:使用专用连接服务器模式访问数据库

 

 

MY_TEST=

        (DESCRIPTION=

                (ADDRESS=(PROTOCOL=tcp)(HOST=10.10.5.37)(PORT=49161))

            (CONNECT_DATA=

                  (SERVER = DEDICATED)

                  (SERVICE_NAME = XE)

            )

        )

 

3:将SERVICE_NAME改为XEXDB,也可以解决问题。

 

MY_TEST=

        (DESCRIPTION=

                (ADDRESS=(PROTOCOL=tcp)(HOST=10.10.5.37)(PORT=49161))

            (CONNECT_DATA=

                  (SERVER = SHARED)

                  (SERVICE_NAME = XEXDB)

            )

        )

 

        )

 

 

4:将SERVICE_NAME改为改为ISD,也可以解决问题。

 

 

MY_TEST=

        (DESCRIPTION=

                (ADDRESS=(PROTOCOL=tcp)(HOST=10.10.5.37)(PORT=49161))

            (CONNECT_DATA=

                     (SERVER = DEDICATED)

                  (SID = XE)

            )

        )

 

 

另外,这个问题问题,我们稍微展开下,其实我们清楚,在下面情况下会关闭数据库实例的共享服务连接,

 

 

1 设置SHARED_SERVERS=0

 

 

2 关闭DISPATCH进程

 

 

ALTER SYSTEM SET DISPATCHERS = '';

 

 

 

设置SHARED_SERVERS=0

 

 

如下所示,SHARED_SERVERS=0的情况下:

 

ORA-12520 TroubleShooting_第6张图片

 

客户端访问数据库也会报ORA-12520错误

 

C:\Users>sqlplus test/test123456@MY_TEST

 

SQL*Plus: Release 11.2.0.1.0 Production on 星期四 1 10 22:55:18 2019

 

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

 

ERROR:

ORA-12520: TNS: 监听程序无法为请求的服务器类型找到可用的处理程序

 

 

请输入用户名:

 

 

 

关闭DISPATCH进程

 

 

SQL> alter system set shared_servers=10 scope=both;

 

System altered.

 

#此时,客户端访问数据库正常

 

SQL> ALTER SYSTEM SET DISPATCHERS = '';

 

System altered.

 

SQL>

 

#此时,客户端访问数据库报ORA-12520错误。

 

 

 

另外,需要注意的是在共享服务器模式下,local namingtnsnames.ora也可以配置成专用模式,需要注意的是如果使用参数DEDICATEDORACLE将单独派生进程进行客户端处理,也就是专用模式。其实如果你看懂了上面案例,那么我们再来看看官方文档对ORA-12520的描述,是否有茅塞顿开的感觉呢!

 

 

 

 

ORA-12520: Listener Could Not Find Available Handler for Requested Type of Server

 

This message indicates that the type of service handler requested by the client is incorrect or not registered for the requested SERVICE_NAME/INSTANCE_NAME parameters, or the database instance is not registered with the listener.

 

If you suspect the problem is the wrong type of service handler, then perform the following steps:

 

If (server=value) is set in the connect descriptor, then ensure that the value is set to the appropriate service handler type for the database, that is, dedicated for dedicated server or shared for dispatchers. You can use the Listener Control utility SERVICES command to see what service handlers are currently registered with the listener.

 

If the USE_DEDICATED_SERVER parameter is set to ON in the sqlnet.ora file, then ensure the database is configured to use dedicated servers. If it is not, then set this parameter to OFF.

 

Ensure that the database instance is running. If the instance not running, then start it so that it can register with the listener.

 

 

 

另外,如果运行正常的数据库服务器,突然报ORA-12520错误,一般是因为process不够引起的。需要增大processes参数的值。网上有许多资料,这里不做展开!在此略过。

 

 

 

 

 

 

 

 

你可能感兴趣的:(ORA-12520 TroubleShooting)