Shell Limits设置问题导致用户不能登录


| 故障现象

前几天,突然间某数据库主机不能su切换到grid用户。

发生故障的环境为:RHEL 6.7,ORACLE 11gR2 RAC,其中集群节点1发生此故障,而节点2状态正常。

故障现象如下:

点击(此处)折叠或打开

  1. 本地节点从oracle用户su到grid用户,错误如下:
  2. [oracle@node1 /home/oracle]$su - grid
  3. su: cannot set user id: Resource temporarily unavailable
  4. 通过集群中的另外一个节点错误提示如下:
  5. [grid@node2:/home/grid]$ssh node1
  6. Write failed: Broken pipe
  7. [oracle@node2:/home/oracle]$ssh node1
  8. Last login: Thu May 10 12:28:22 CST 2018
  9. 而oracle用户正常
  10. 通过远程连接工具使用grid用户登录错误提示如下:
  11. Connection closed by foreign host.
  12. /var/log/secure报错如下:
  13. su: pam_keyinit(su-l:session): Unable to change UID to 500 temporarily
  14. su: pam_keyinit(su-l:session): Unable to change UID to 500 temporarily

| 故障分析

参考MOS文档号:1174073.1,可能是limits设置不合理导致的,而Shell Limits会限制用户资源的使用。

同时根据文档788064.1,进行如下步骤诊断:

1. 查看集群状态,数据库状态以及相关日志信息。

检查结果:除了上述现象外,集群状态正常,数据库告警日志此段时间内没有任何错误,数据库中也没有发现异常的等待,客户的业务也正常。

2. 查看用户的进程数。

点击(此处)折叠或打开

  1. [oracle@node1 /home/oracle]#ps -u grid -L |wc -l
  2. 1560
  3. 查看用户打开文件数。

点击(此处)折叠或打开

  1. [oracle@node1 /home/oracle]$ lsof -u grid | wc -l
  2. 4000


上述结果表明:当前环境中打开文件数较多,而通过检查用户的进程,并没有发现有异常的程序。那极有可能就是设置的limits过小导致。

4. 检查/etc/security/limits.conf,查看grid用户的nproc和nofile设置。

点击(此处)折叠或打开

  1. [grid@node1 /home/oracle]$cat /etc/security/limits.conf
  2. # /etc/security/limits.conf
  3. #
  4. #Each line describes a limit for a user in the form:
  5. #
  6. #<domain> <type> <item> <value>
  7. #
  8. #Where:
  9. #<domain> can be:
  10. # - an user name
  11. # - a group name, with @group syntax
  12. # - the wildcard *, for default entry
  13. # - the wildcard %, can be also used with %group syntax,
  14. # for maxlogin limit
  15. #
  16. #<type> can have the two values:
  17. # - "soft" for enforcing the soft limits
  18. # - "hard" for enforcing hard limits
  19. #
  20. #<item> can be one of the following:
  21. # - core - limits the core file size (KB)
  22. # - data - max data size (KB)
  23. # - fsize - maximum filesize (KB)
  24. # - memlock - max locked-in-memory address space (KB)
  25. # - nofile - max number of open files
  26. # - rss - max resident set size (KB)
  27. # - stack - max stack size (KB)
  28. # - cpu - max CPU time (MIN)
  29. # - nproc - max number of processes
  30. # - as - address space limit (KB)
  31. # - maxlogins - max number of logins for this user
  32. # - maxsyslogins - max number of logins on the system
  33. # - priority - the priority to run user process with
  34. # - locks - max number of file locks the user can hold
  35. # - sigpending - max number of pending signals
  36. # - msgqueue - max memory used by POSIX message queues (bytes)
  37. # - nice - max nice priority allowed to raise to values: [-20, 19]
  38. # - rtprio - max realtime priority
  39. #
  40. #<domain> <type> <item> <value>
  41. grid soft nproc 2048
  42. grid hard nproc 4096
  43. grid soft nofile 2048
  44. grid hard nofile 4096
  45. ……

    /etc/security/limits.conf文件为每个用户设置系统资源的限制。从以上输出:从该设置和结合之前查询结果来看,当前  
   nproc和nofile这两个值设置得太小。这两个参数设置除需参照Oracle建议值外还需考虑是否符合实际环境。


  | 解决方案


   根据上述分析中得出:由于设置的nproc和nofile值太小而导致,因此需要修改这两个值。

1.手动修改/etc/security/limits.conf中的设置。

这两个值设置参考系统本身的资源情况以及业务情况。因此暂定该环境修改值如下:

点击(此处)折叠或打开

  1. [grid@node1 /home/oracle]$cat /etc/security/limits.conf
  2. grid soft nproc 16384
  3. grid hard nproc 16384
  4. grid soft nofile 16384
  5. grid hard nofile 16384

注:可以使用官方提供的oracle-validated包来修改/etc/security/limits.conf,这个包提供修改内核参数,用户limits等。该RPM包可以从http://oss.oracle.com网站获取。如果是运行在OL6/RHEL6中的Oracle database 11gR2该包名被替换为 oracle-rdbms-server-11gR2-preinstall。

2.检查故障是否存在。

点击(此处)折叠或打开

  1. [oreacl@node1 /home/oracle]#su – grid
  2. Password:
  3. Last login: Thu May 10 13:28:22 CST 2018

通过oracle用户再次切换到grid用户时恢复正常。

3.查看用户limits。

点击(此处)折叠或打开

  1. [grid@node1:/home/grid] $ ulimit -Su
  2. 16384
  3. [grid@node1:/home/grid] $ ulimit -Hu
  4. 16384
  5. [grid@node1:/home/grid] $ ulimit –Sn
  6. 16384
  7. [grid@node1:/home/grid] $ ulimit -Hn
  8. 16384

修改之后grid用户的nproc和nofile为最新值。

4.附录:当达到其他limits设置时出现的不同错误。

 A. 当达到’open files’限制时错误。


     B.当达到’max user processes’限制时错误。




| 作者简介

杨波,沃趣科技数据库技术专家
主要参与公司产品实施、测试、维护以及优化。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28218939/viewspace-2155099/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/28218939/viewspace-2155099/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值