ulimit: open files: cannot modify limit: Operation not permitted_MySQL, Oracle及数据库讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  MySQL, Oracle及数据库讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 1800 | 回复: 0   主题: ulimit: open files: cannot modify limit: Operation not permitted        下一篇 
solo9867
注册用户
等级:新兵
经验:61
发帖:71
精华:0
注册:2011-12-15
状态:离线
发送短消息息给solo9867 加好友    发送短消息息给solo9867 发消息
发表于: IP:您无权察看 2015-7-3 9:58:05 | [全部帖] [楼主帖] 楼主

在从root用户切换到oracle用户时,碰到了ulimit: open files: cannot modify limit: Operation not permitte的提示信息。字面意思来看即是打开文件受到了限制。同一服务器上,如仅有一个Oracle单实例且数据文件较少的情形应该不会出现该情形。多实例可能会碰到这个情况。由于多个实例都为Oracle用户所有,因此Oracle用户可操作的文件数为所有实例文件数的总和,超出了限制就收到错误提示。

1、故障描述

--在从root切换到oracle时,出现提示
oracle@v2013db02u:/u02/database> su - oracle
Password:
-bash: ulimit: open files: cannot modify limit: Operation not permitted
-bash: ulimit: open files: cannot modify limit: Operation not permitted


a、查看limits.conf配值文件

oracle@v2013db02u:~> more /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
#        - 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
#        - rtprio - max realtime priority
#
#<domain>      <type>  <item>         <value>
#
#*               soft    core            0
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#@student        -       maxlogins       4
# End of file
--limits.conf文件的注释信息给出了很好的描述信息,也即是我们可以基于用户或者组来配置soft及hare方面不同的item
--soft即是软限制,hard是硬限制。用户可以超过soft设置的值,但一定不能超过hard 的值。一般soft比hard小
--上面的这个文件中并未为Oracle用户配值任何信息,且通配符*也被注释了
--由于该服务器为一个新的UAT服务器,Oracle software为Infra安装并配置。从上可知,应该是Infra忘记或忽略了配值该文件
--在数据库实例较少且打开的文件数不多的情形则没有任何问题,随着上面运行的实例增大,现象随之出现


--下面查看一下当前用户的资源分配限制
--对于资源限制,也可以使用ulimit 指令,用来限制用户的资源分配,比如打开文件数,最多进程数,CPU的使用时间
--可以使用指令ulimit -a来查看当前用户的各项limit限制(ulimit用法: man ulimit)


b、查看当前用户的资源限制

oracle@v2013db02u:~> ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
pending signals                 (-i) 540672
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024        -->这里限制了打开的文件数为1024,明显不够
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 16384
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited


2、解决办法 
a、直接修改limits.conf配值文件,且使得永久生效

--修改文件/etc/security/limits.conf,添加
v2013db02u:~ # echo "
> oracle soft nproc 16384
> oracle hard nproc 16384
> oracle soft nofile 65536
> oracle hard nofile 65536
> oracle soft memlock 4000000
> oracle hard memlock 4000000
> " >> /etc/security/limits.conf
v2013db02u:~ # tail /etc/security/limits.conf
# End of file
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft nofile 65536
oracle hard nofile 65536
oracle soft memlock 4000000
oracle hard memlock 4000000
--Author : Robinson
--Blog   : http://blog.csdn.net/robinson_0612
--说明上面的配置中,为oracle用户配置了
--nproc:用户可用的最大进程数量
--nofile:用户可打开的最大文件总数
--memlock: 用户最大内存锁地址空间
v2013db02u:~ # su - oracle   -->再次切换到oracle用户,未出现之前的错误提示。配值后建议重启一下服务器
v2013db02u:~ # su - oracle
oracle@v2013db02u:~> ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
pending signals                 (-i) 540672
max locked memory       (kbytes, -l) 4000000
max memory size         (kbytes, -m) unlimited
open files                      (-n) 63536
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 16384
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited


b、使用ulimit命令来修改

--在使用ulimit命令方式来修改的话,当服务器被重启后会失效(临时性更改)
--ulimit 用于限制 shell 启动进程所占用的资源
--支持以下各种类型的限制:所创建的内核文件的大小、进程数据块的大小、Shell进程创建文件的大小、内存锁住的大小、常驻内存集的大小
--以及打开文件描述符的数量、分配堆栈的最大大小、CPU 时间、单个用户的最大线程数、Shell 进程所能使用的最大虚拟内存
--以及支持硬资源和软资源的限制
oracle@v2013db02u:~> ulimit -n 60000                  -->使用当前用户来修改,即oracle用户,我们将其改为60000
oracle@v2013db02u:~> ulimit -a | grep "open files"    -->可以看到该资源限制已经被修改
open files                      (-n) 60000
oracle@v2013db02u:~> cat /etc/security/limits.conf | grep nofile   -->但配值文件并未发生任何变化
oracle  soft    nofile  1024
oracle hard    nofile   65536
oracle@v2013db02u:~> ulimit -n 65537      
-->尝试修改到大于65536,收到错误提示
-bash: ulimit: open files: cannot modify limit: Operation not permitted
oracle@v2013db02u:~> ulimit -n 65535      
-->使用ulimit命令时,number的值不能大于配值文件中hard的值
oracle@v2013db02u:~> ulimit -a | grep "open files"
open files                      (-n) 65535
--其余参数都可以按上述方式依法炮制


--转自 北京联动北方科技有限公司




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论