打开core dumps [bash: ulimit: core file size: cannot modify limit: Operation not permitted]

5 篇文章 0 订阅
5 篇文章 0 订阅

Original Site: https://www.akadia.com/services/ora_enable_core.html

概述(Overview)

In most Linux Distributions core file creation is disabled by default for a normal user. However, it can be necessary to enable this feature for an application (e.g. Oracle). For example, if you encounter an ORA-7445 error in Oracle, then it must be possible to write a core file for the user «oracle».

To enable writing core files you use the ulimit command, it controls the resources available to a process started by the shell, on systems that allow such control.

If you try to enable writing core files, usually you run in the following problem. Normally SSH is used to logon to the server.

ssh oracle@ora-server
$ ulimit -a

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
pending signals                 (-i) 1024
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65536
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 16384
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Now, try (not as user root) to change the core file size to unlimited
在使用ulimit -c unlimited 命令来设置core文件大小为无限时,出现一下问题。

$ ulimit -c unlimited
-bash: ulimit: core file size: cannot modify limit: Operation not permitted

解决方法(Solution)

1. 检查ulimit的运行环境(Check Environment for ulimit)

检查当前用户下的任何一个shell配置文件,例如在$HOME/.bash_profile$HOME/.bashrc文件中是否设置了ulimit -c 0。如果文件中有该设置,则将该行注释掉。
(The first step is to check, that you don’t set ulimit -c 0 in any shell configuration files for this user, for example in $HOME/.bash_profile or $HOME/.bashrc. Uncomment it if you have such an entry.)

#
#Do not produce core dumps
#
#ulimit -c 0

2. 对所有用户(全局)打开Core Dump功能(Globally enable Core Dumps)

这一步骤必须以root用户来操作,通常是在/etc/security/limits.conf文件中进行设置。(最后一行* soft core unlimited)
(This must be done as user root, usually in /etc/security/limits.conf)

#/etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#<domain> <type> <item> <value>
#
*  soft  core  unlimited

3. 登出当前用户再登入并设置(Logoff and Logon again and set ulimit)

先在当前用户查看是否为unlimited,

ssh oracle@ora-server
$ ulimit -c
0

为0则表示不输出core dump文件。
此时先以root用户进行一次设置(Try to set the limit as user root first)

$ su -
$ ulimit -c unlimited
$ ulimit -c
  unlimited

再以自己的用户名, 例如oracle, 进行一次设置(Now you can set ulimit also for user oracle

$ su - oracle
$ ulimit -c unlimited
$ ulimit -c
  unlimited

Perhaps the last step number 3 is not necessary, but we have figured out, that this is the way which always work. The core file size limitation is usually also set in different configuration files. If you want to enable cores, you can uncomment them.

In /etc/profile (Redhat)

# No core files by default
# ulimit -S -c 0 > /dev/null 2>&1

In /etc/init.d/functions (Redhat)

# make sure it doesn't core dump anywhere unless requested
# ulimit -S -c ${DAEMON_COREFILE_LIMIT:-0} >/dev/null 2>&1

Now, from this current shell you can generate the core, so check ulimit before.

$ ulimit -a

core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
pending signals                 (-i) 1024
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65536
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 16384
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值