su到Oracle用户报资源不足
[root@snaqi-test3 bin]# su - oracle
su: cannot set user id: Resource temporarily unavailable
检查如下参数,均未发现问题
[root@snaqi-test3 ~]# cat /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft memlock 33554432
oracle hard memlock 33554432
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
[root@snaqi-test3 ~]# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 62749
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 1024
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
执行 su - oracle
报错:su: cannot set user id: Resource temporarily unavailable
执行以下命令查看
ps -U oracle | wc -l
lsof | grep oracle | wc -l
多数情况是超过限制
解决办法
1。删掉无用的进程
2。修改 /etc/security/limits.conf
修改oracle的相关设置
[root@snaqi-test3 ~]# ps -ef | grep oracle | wc -l
89
[root@snaqi-test3 ~]# lsof | grep oracle | wc -l
49998
打开文件居然有这么多,太恐怖了
非常大的文件
[root@snaqi-test3 ~]# lsof | grep oracle > oracle.txt
[root@snaqi-test3 ~]# more oracle.txt
oracle 927 oracle mem REG 0,16 16777216 28080570 /dev/shm/ora_lottery_393218_52
Oracle是通过session连接到数据库,难道是session数超了?用plsql dev 登录Oracle,成功了
select count(*) from v$session
查询当前session是69
分析结果和session无关
[root@snaqi-test3 log]# netstat -anp | wc -l
12178
查看具体内容
[root@snaqi-test3 log]# netstat -anp
tcp 1 0 192.168.3.21:3938 192.168.3.21:34272 CLOSE_WAIT 18490/emagent
发现大量类似的连接,赶快查看emagent的个数
[root@snaqi-test3 log]# netstat -anp|grep emagent| wc -l
11608
12178-11608 如此接近,这时肯定有问题的,在等待关闭,处于没人管状态
因为这台机器安装了grid control 12c agent,而oms服务已经停止,根据这些推断,大致可以确定问题所在
root没有权限停止agent
[root@snaqi-test3 bin]# ./emctl status agent
Cannot execute /home/oracle/agent12c//core/12.1.0.1.0/bin/emctl.pl since its userid does not match yours.
[root@snaqi-test3 bin]# ps -ef|grep java
.........
oracle 5541 2512 0 Oct24 ? 00:23:38 /home/oracle/agent12c//core/12.1.0.1.0/jdk/bin/java -Xmx128M -server -Djava.security.egd=file:///dev/./urandom -Dsun.lang.ClassLoader.allowArraySyntax=true -XX:+UseLinuxPosixThreadCPUClocks -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+UseCompressedOops -Dwatchdog.pid=2512 -cp /home/oracle/agent12c//core/12.1.0.1.0/jdbc/lib/ojdbc5.jar:/home/oracle/agent12c//core/12.1.0.1.0/ucp/lib/ucp.jar:/home/oracle/agent12c//core/12.1.0.1.0/modules/oracle.http_client_11.1.1.jar:/home/oracle/agent12c//core/12.1.0.1.0/lib/xmlparserv2.jar:/home/oracle/agent12c//core/12.1.0.1.0/lib/jsch.jar:/home/oracle/agent12c//core/12.1.0.1.0/lib/optic.jar:/home/oracle/agent12c//core/12.1.0.1.0/modules/oracle.dms_11.1.1/dms.jar:/home/oracle/agent12c//core/12.1.0.1.0/modules/oracle.odl_11.1.1/ojdl.jar:/home/oracle/agent12c//core/12.1.0.1.0/modules/oracle.odl_11.1.1/ojdl2.jar:/home/oracle/agent12c//core/12.1.0.1.0/sysman/jlib/log4j-core.jar:/home/oracle/agent12c//core/12.1.0.1.0/jlib/gcagent_core.jar:/home/oracle/agent12c//core/12.1.0.1.0/sysman/jlib/emagentSDK-intg.jar:/home/oracle/agent12c//core/12.1.0.1.0/sysman/jlib/emagentSDK.jar oracle.sysman.gcagent.tmmain.TMMain
..........
[root@snaqi-test3 bin]# kill -9 5541
[root@snaqi-test3 bin]# kill -9 5541
-bash: kill: (5541) - No such process
[root@snaqi-test3 bin]# su - oracle
su: cannot set user id: Resource temporarily unavailable
大家还记得前面我们抓取的lsof 执行结果吗?查看那里到底是打开的哪些文件
more Oracle.txt
大量的mem信息
oracle 1093 oracle mem REG 0,16 16777216 28080414 /dev/shm/ora_lottery_360449_154
oracle 1093 oracle mem REG 0,16 16777216 28080415 /dev/shm/ora_lottery_360449_155
oracle 1093 oracle mem REG 0,16 16777216 28080416 /dev/shm/ora_lottery_360449_156
oracle 1093 oracle mem REG 0,16 16777216 28080417 /dev/shm/ora_lottery_360449_157
除了这些还有
emagent 18490 oracle 5713u IPv4 78422180 0t0 TCP snaqi-test3:dbcontrol_agent->snaqi-test3:26944 (CLOSE_WAIT)
emagent 18490 oracle 5714u IPv4 78424155 0t0 TCP snaqi-test3:dbcontrol_agent->snaqi-test3:27136 (CLOSE_WAIT)
emagent 18490 oracle 5715u IPv4 78425077 0t0 TCP snaqi-test3:dbcontrol_agent->snaqi-test3:27272 (CLOSE_WAIT)
emagent 18490 oracle 5716u IPv4 78427040 0t0 TCP snaqi-test3:dbcontrol_agent->snaqi-test3:27464 (CLOSE_WAIT)
emagent 18490 oracle 5717u IPv4 78427952 0t0 TCP snaqi-test3:dbcontrol_agent->snaqi-test3:27600 (CLOSE_WAIT)
emagent 18490 oracle 5718u IPv4 78429917 0t0 TCP snaqi-test3:dbcontrol_agent->snaqi-test3:27792 (CLOSE_WAIT)
emagent 18490 oracle 5719u IPv4 78430804 0t0 TCP snaqi-test3:dbcontrol_agent->snaqi-test3:27930 (CLOSE_WAIT)
emagent 18490 oracle 5720u IPv4 78432780 0t0 TCP snaqi-test3:dbcontrol_agent->snaqi-test3:28122 (CLOSE_WAIT)
emagent 18490 oracle 5721u IPv4 78433663 0t0 TCP snaqi-test3:dbcontrol_agent->snaqi-test3:28258 (CLOSE_WAIT)
emagent 18490 oracle 5722u IPv4 78435657 0t0 TCP snaqi-test3:dbcontrol_agent->snaqi-test3:28446 (CLOSE_WAIT)
emagent 18490 oracle 5723u IPv4 78436596 0t0 TCP snaqi-test3:dbcontrol_agent->snaqi-test3:28577 (CLOSE_WAIT)
发现大量的emagent,和我们netstat的结果一样
果断kill掉
[root@snaqi-test3 log]# ps -ef|grep 18490
root 9214 7039 0 00:52 pts/2 00:00:00 grep 18490
oracle 18490 8679 0 Sep19 ? 00:04:12 /home/oracle/product/11.2.0.3/db_1/bin/emagent
[root@snaqi-test3 log]# kill -9 18490
[root@snaqi-test3 log]# ps -ef|grep 18490
root 9216 7039 0 00:52 pts/2 00:00:00 grep 18490
oracle 18490 8679 0 Sep19 ? 00:11:08 /home/oracle/product/11.2.0.3/db_1/bin/emagent
[root@snaqi-test3 log]# ps -ef|grep 18490
root 9224 7039 0 00:52 pts/2 00:00:00 grep 18490
oracle 18490 8679 0 Sep19 ? 00:11:09 [emagent]
[root@snaqi-test3 log]# ps -A -o stat,ppid,pid,cmd | grep -e '^[Zz]'
[root@snaqi-test3 log]# ps -A -o stat,ppid,pid,cmd | grep -e '^[Zz]'
[root@snaqi-test3 log]# ps -ef|grep 18490
root 9259 7039 0 00:53 pts/2 00:00:00 grep 18490
[root@snaqi-test3 ~]# lsof | grep oracle | wc -l
31451
[root@snaqi-test3 log]# netstat -anp | wc -l
532
这次恢复正常
[root@snaqi-test3 bin]# su - oracle
[oracle@snaqi-test3 ~]$
[oracle@snaqi-test3 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Sat Nov 10 01:54:48 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning and Data Mining options
SQL>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12457158/viewspace-753400/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/12457158/viewspace-753400/