su cannot set user id Resource temporarily unavailable故障解决

 
大家好!
 
今天和大家分享一个case,现象是这样的,centos6 当我用su - oracle时发生错误提示:su cannot set user id Resource temporarily unavailable ,但是我用plsql developer 登录是没有问题的,问题最终定位是因为该机器安装了grid control 12c agent导致系统资源不足,具体分析过程请看:
 

1.1.  现象描述

suOracle用户报资源不足

[root@snaqi-test3 bin]# su - oracle

su: cannot set user id: Resource temporarily unavailable

 

1.2.  分析问题

检查如下参数,均未发现问题

1.2.1 检查资源限制文件

[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

1.2.2 检查profile文件

if [ $USER = "oracle" ]; then

  if [ $SHELL = "/bin/ksh" ]; then

        ulimit -p 16384

        ulimit -n 65536

  else

        ulimit -u 16384 -n 65536

  fi

fi

1.2.3 检查ulimit限制

[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

1.3  google看是否有类似问题

执行 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的相关设置

 

1.4 根据上述命令,查询自己服务器

[root@snaqi-test3 ~]# ps -ef | grep oracle | wc -l

89

[root@snaqi-test3 ~]# lsof | grep oracle | wc -l

49998

打开文件居然有这么多,太恐怖了

1.4.1 查看打开文件的具体信息

非常大的文件

[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

1.4.2 为什么Oracle会打开这么多文件?

Oracle是通过session连接到数据库,难道是session数超了?用plsql dev 登录Oracle,成功了

select count(*) from v$session

查询当前session69

分析结果和session无关

1.4.3 茫然中,灵感在呼唤我,查询网络连接

[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 如此接近,这时肯定有问题的,在等待关闭,处于没人管状态

 

1.5 解决问题

因为这台机器安装了grid control 12c agent,而oms服务已经停止,根据这些推断,大致可以确定问题所在

1.5.1 先停止agent

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.

1.5.2 强力杀死agent

[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

1.5.3 测试su是否成功

[root@snaqi-test3 bin]# su - oracle

su: cannot set user id: Resource temporarily unavailable

1.5.4 问题没有解决,这是为什么呢?

大家还记得前面我们抓取的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

1.5.5 查看系统打开的文件数

[root@snaqi-test3 ~]# lsof | grep oracle | wc -l

31451

 

1.5.6 查看网络连接数

[root@snaqi-test3 log]# netstat -anp | wc -l

532

 

1.5.7 尝试su Oracle用户

这次恢复正常

[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/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值