前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ORA-12519的错误和解决

ORA-12519的错误和解决

作者头像
bisal
发布2019-11-18 13:52:32
1.6K0
发布2019-11-18 13:52:32
举报
文章被收录于专栏:bisal的个人杂货铺

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:https://blog.csdn.net/bisal/article/details/103077663

家中领导提了个问题,某系统和数据库交互的时候,提示ORA-12519,

640?wx_fmt=png
640?wx_fmt=png

ORA-12519的解释就是找不到合适的服务句柄,当前注册到监听的实例无法接收连接请求,

代码语言:javascript
复制
SQL> !oerr ora 12519
12519, 00000, "TNS:no appropriate service handler found"
// *Cause: The listener could not find any available service handlers that
// are appropriate for the client connection.
// *Action: Run "lsnrctl services" to ensure that the instance(s) have
// registered with the listener, and are accepting connections.

Troubleshooting Guide TNS-12519 TNS-12516 ORA-12519 ORA-12516 (Doc ID 552765.1)介绍,12516/12519错误最常见的原因就是到达了PROCESSES/SESSIONS参数指定的最大值限制,PMON进程会会告诉监听器当前配置的限制,有空闲连接时,才会允许新的连接进来,

One of the most common reasons for the TNS-12516 and/or TNS-12519 errors being reported is the configured maximum number of PROCESSES and/or SESSIONS limitation being reached. When this occurs, the service handlers for the TNS listener become "Blocked" and no new connections can be made. Once the TNS Listener receives an update from the PMON process associated with the Database instance telling the TNS Listener the thresholds are below the configured limit, and the database is now accepting connections connectivity resumes. By way of instance registration, PMON is responsible for updating the listener with information about a particular instance such as load and dispatcher information. Maximum load for dedicated connections is determined by the PROCESSES parameter. The frequency at which PMON provides SERVICE_UPDATE information varies according to the workload of the instance. The maximum interval between these service updates is 10 minutes. The listener counts the number of connections it has established to the instance but does not immediately get information about connections that have terminated. Only when PMON updates the listener via SERVICE_UPDATE is the listener informed of current load. Since this can take as long as 10 minutes, there can be a difference between the current instance load according to the listener and the actual instance load. When the listener believes the current number of connections has reached maximum load, it may set the state of the service handler for an instance to "blocked" and begin refusing incoming client connections with either of the following errors: ora-12519 or ora-12516

我们看下当前系统中的processes和sessions参数值,分别是150和247,

代码语言:javascript
复制
SQL> show parameter processes
NAME                     TYPE    VALUE
------------------------------------ ----------- ------------------------------
processes                 integer     150

SQL> show parameter sessions
NAME                     TYPE    VALUE
------------------------------------ ----------- ------------------------------
sessions                 integer     247

为了验证,我们减少processes的值,因为scope=spfile,所以需要重启数据库,注意虽然设置了processes=10,但实际允许processes=40,相应地,sessions会被设置成新值,

代码语言:javascript
复制
SQL> alter system set processes=10 scope=spfile;
System altered.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup;
ORACLE instance started.
Total System Global Area  521936896 bytes
Fixed Size            2254824 bytes
Variable Size          331352088 bytes
Database Buffers      184549376 bytes
Redo Buffers            3780608 bytes
Database mounted.
Database opened.

SQL> show parameter processes
NAME                     TYPE    VALUE
------------------------------------ ----------- ------------------------------
processes                 integer     40

SQL> show parameter sessions
NAME                     TYPE    VALUE
------------------------------------ ----------- ------------------------------
sessions                 integer     82

检索v$process和v$session视图,了解当前状态下,连接到数据库的进程总数,分别是23和20,

代码语言:javascript
复制
SQL> select count(*) from v$process;
  COUNT(*)
----------
    23

SQL> select count(*) from v$session;
  COUNT(*)
----------
    20

通过打开不同的sqlplus窗口,让连接到数据库的进程数,增加到临近processes的值,此时还剩1个空闲,

代码语言:javascript
复制
SQL> select count(*) from v$process;
  COUNT(*)
----------
    39

SQL> select count(*) from v$session;
  COUNT(*)
----------
    36

如果用Oracle NET的方式登陆数据库,则会提示ORA-12516,

代码语言:javascript
复制
[oracle@travelsky Desktop]$ sqlplus hr/oracle@test
SQL*Plus: Release 11.2.0.4.0 Production on Tue Nov 12 13:57:44 2019
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
ERROR:
ORA-12516: TNS:listener could not find available handler with matching protocol
stack

如果用操作系统认证的方式登陆,则会提示ORA-00020,显式指出了processes的值是40,

代码语言:javascript
复制
[oracle@travelsky Desktop]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Tue Nov 12 13:57:53 2019
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
ERROR:
ORA-00020: maximum number of processes (40) exceeded

从提示消息看,ORA-00020比ORA-12516更具可读性。但无论是什么,都和processes/sessions的限制,有些关系。

因此这个问题,解决方案有很多,例如重启,可以清除多余的连接,可以从应用层减少多余的连接,或者增加系统processes/sessions参数值。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/11/14 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
数据库
云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档