前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Shell Limits设置问题导致用户不能登录

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

原创
作者头像
沃趣科技
修改2018-07-02 15:35:36
7100
修改2018-07-02 15:35:36
举报
文章被收录于专栏:沃趣科技沃趣科技

|  故障现象

前几天,突然间某数据库主机不能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

3. 查看用户打开文件数。

[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’限制时错误。

[oracle@node1 /home/oracle]$ssh node1
oracle@node1's password:
-bash: ulimit: max user processes: cannot modify limit: Operation not permitted
-bash: /home/oracle/.bash_profile: Too many open files

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

[oracle@node1 /home/oracle]$ssh oracle@node1
oracle@node1's password:
-bash: ulimit: open files: cannot modify limit: Operation not permitted
-bash: fork: Resource temporarily unavailable

|  作者简介

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

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
数据库
云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档