| 故障现象
前几天,突然间某数据库主机不能su切换到grid用户。
发生故障的环境为:RHEL 6.7,ORACLE 11gR2 RAC,其中集群节点1发生此故障,而节点2状态正常。
故障现象如下:
点击(此处)折叠或打开
- 本地节点从oracle用户su到grid用户,错误如下:
- [oracle@node1 /home/oracle]$su - grid
- su: cannot set user id: Resource temporarily unavailable
- 通过集群中的另外一个节点错误提示如下:
- [grid@node2:/home/grid]$ssh node1
- Write failed: Broken pipe
- [oracle@node2:/home/oracle]$ssh node1
- Last login: Thu May 10 12:28:22 CST 2018
- 而oracle用户正常
- 通过远程连接工具使用grid用户登录错误提示如下:
- Connection closed by foreign host.
- /var/log/secure报错如下:
- su: pam_keyinit(su-l:session): Unable to change UID to 500 temporarily
- su: pam_keyinit(su-l:session): Unable to change UID to 500 temporarily
| 故障分析
参考MOS文档号:1174073.1,可能是limits设置不合理导致的,而Shell Limits会限制用户资源的使用。
同时根据文档788064.1,进行如下步骤诊断:
1. 查看集群状态,数据库状态以及相关日志信息。
检查结果:除了上述现象外,集群状态正常,数据库告警日志此段时间内没有任何错误,数据库中也没有发现异常的等待,客户的业务也正常。
2. 查看用户的进程数。
点击(此处)折叠或打开
- [oracle@node1 /home/oracle]#ps -u grid -L |wc -l
- 1560
点击(此处)折叠或打开
- [oracle@node1 /home/oracle]$ lsof -u grid | wc -l
- 4000
上述结果表明:当前环境中打开文件数较多,而通过检查用户的进程,并没有发现有异常的程序。那极有可能就是设置的limits过小导致。
4. 检查/etc/security/limits.conf,查看grid用户的nproc和nofile设置。
点击(此处)折叠或打开
- [grid@node1 /home/oracle]$cat /etc/security/limits.conf
- # /etc/security/limits.conf
- #
- #Each line describes a limit for a user in the form:
- #
- #<domain> <type> <item> <value>
- #
- #Where:
- #<domain> can be:
- # - an user name
- # - a group name, with @group syntax
- # - the wildcard *, for default entry
- # - the wildcard %, can be also used with %group syntax,
- # for maxlogin limit
- #
- #<type> can have the two values:
- # - "soft" for enforcing the soft limits
- # - "hard" for enforcing hard limits
- #
- #<item> can be one of the following:
- # - core - limits the core file size (KB)
- # - data - max data size (KB)
- # - fsize - maximum filesize (KB)
- # - memlock - max locked-in-memory address space (KB)
- # - nofile - max number of open files
- # - rss - max resident set size (KB)
- # - stack - max stack size (KB)
- # - cpu - max CPU time (MIN)
- # - nproc - max number of processes
- # - as - address space limit (KB)
- # - maxlogins - max number of logins for this user
- # - maxsyslogins - max number of logins on the system
- # - priority - the priority to run user process with
- # - locks - max number of file locks the user can hold
- # - sigpending - max number of pending signals
- # - msgqueue - max memory used by POSIX message queues (bytes)
- # - nice - max nice priority allowed to raise to values: [-20, 19]
- # - rtprio - max realtime priority
- #
- #<domain> <type> <item> <value>
- grid soft nproc 2048
- grid hard nproc 4096
- grid soft nofile 2048
- grid hard nofile 4096
- ……
/etc/security/limits.conf文件为每个用户设置系统资源的限制。从以上输出:从该设置和结合之前查询结果来看,当前
nproc和nofile这两个值设置得太小。这两个参数设置除需参照Oracle建议值外还需考虑是否符合实际环境。
| 解决方案
根据上述分析中得出:由于设置的nproc和nofile值太小而导致,因此需要修改这两个值。
1.手动修改/etc/security/limits.conf中的设置。
这两个值设置参考系统本身的资源情况以及业务情况。因此暂定该环境修改值如下:
点击(此处)折叠或打开
- [grid@node1 /home/oracle]$cat /etc/security/limits.conf
- grid soft nproc 16384
- grid hard nproc 16384
- grid soft nofile 16384
- 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.检查故障是否存在。
点击(此处)折叠或打开
- [oreacl@node1 /home/oracle]#su – grid
- Password:
- Last login: Thu May 10 13:28:22 CST 2018
通过oracle用户再次切换到grid用户时恢复正常。
3.查看用户limits。
点击(此处)折叠或打开
- [grid@node1:/home/grid] $ ulimit -Su
- 16384
- [grid@node1:/home/grid] $ ulimit -Hu
- 16384
- [grid@node1:/home/grid] $ ulimit –Sn
- 16384
- [grid@node1:/home/grid] $ ulimit -Hn
- 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/