暂无图片
暂无图片
7
暂无图片
暂无图片
暂无图片

数据库大量僵尸进程未自动清理

原创 问题归档 2019-03-20
1090

问题描述

os: SunOS bjdb03 5.10 Generic_144488-04 sun4u sparc SUNW,SPARC-Enterprise

database version :Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production

数据库出现客户端连接不上,查看alert日志

Wed Mar 13 09:21:50 2019
ORA-00020: No more process state objects available
ORA-20 errors will not be written to the alert log for
 the next minute. Please look at trace files to see all
 the ORA-20 errors.
Process J002 submission failed with error = 20
kkjcre1p: unable to spawn jobq slave process
Errors in file /export/home/u01/app/oracle/diag/rdbms///trace/_cjq0_25517.trc:
Wed Mar 13 09:22:20 2019
ORA-00020: No more process state objects available
ORA-20 errors will not be written to the alert log for
 the next minute. Please look at trace files to see all
 the ORA-20 errors.
Process W000 submission failed with error = 20
Wed Mar 13 09:24:41 2019
Thread 1 cannot allocate new log, sequence 511057
Wed Mar 13 09:34:27 2019
ORA-00020: maximum number of processes 800 exceeded
ORA-20 errors will not be written to the alert log for
 the next minute. Please look at trace files to see all
 the ORA-20 errors.

此时查看 v$process 为738个进程,参数process进程数设置为800.

以下语句查询结果为380

select count(*) from v$process where addr not in (select paddr from v$session);

杀掉这些进程,客户端可以正常连接。总体进程维持在400左右。

问题点:

  1. pmon为何没有清理掉这380个没有会话的进程。

  2. 是否有参数设置pmon清除僵尸进程的条件,比如空闲时间之类的。

专家解答

一般kill session后会出现这种情况,但是不会出现几百个的情况。

首先请检查是否存在频繁kill session的操作,和应用建立连接、断开连接的方式是否规范;

其次,临时将数据库的process参数调高,避免应用出错。

最后,提供一个自动清理僵尸process的脚本:

#!/bin/sh
. /home/oracle/.profile
sqlplus -s / as sysdba <<EOF
set pagesize 0 
set long 90000 
set feedback off 
set echo off 
spool killed_pid.txt
select spid from v\$process where program!= 'PSEUDO' and addr not in (select paddr from v\$session) and addr not in (select paddr from v\$bgprocess) and addr not in (select paddr from v\$shared_server);
spool off
exit;
EOF
echo ''>1.log
echo ''>kill_pid.sh
cat killed_pid.txt| while read line
do
if `ps -ef|grep $line|grep LOCAL=NO`
then echo `ps -ef|grep $line|grep LOCAL=NO`>>1.log
echo "kill -9  $line">>kill_pid.sh
fi
done
最后修改时间:2019-04-25 17:36:45
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论