您的位置:首页 > 数据库 > Oracle

在Linux环境上面,su切换到oracle时出现"-bash:fork:Resource temporarily unavailable"问题

2013-10-12 09:35 639 查看
"-bash:fork:Resource temporarily unavailable"错误信息,一般都是由于资源不足造成的问题。

按照以下几个步骤修改,应该都可以解决问题:

1、首先检查、内存都没问题



2、通过ulimit -a,得到结果

linux:~ # ulimit -a

core file size (blocks, -c) 0

data seg size (kbytes, -d) unlimited

file size (blocks, -f) unlimited

pending signals (-i) 147456

max locked memory (kbytes, -l) 32

max memory size (kbytes, -m) unlimited

open files (-n) 4096

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) 147456

virtual memory (kbytes, -v) unlimited

file locks (-x) unlimited



3、修改/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

oracle soft nproc 4094

oracle hard nproc 32768

oracle soft nofile 2048

oracle hard nofile 131072

# End of file



limits.conf的格式如下:

<domain> <type> <item> <value>


<domain>:设置需要被限制的用户名,组名前面加@和用户名区别。也可以用通配符*来做所有用户的限制。


type:有 soft,hard 和 -,soft 指的是当前系统生效的设置值。hard 表明系统中所能设定的最大值。soft 的最大值不能超过hard的值。用 – 就表明同时设置了 soft 和 hard 的值。

item:

core – 限制内核文件的大小

date – 最大数据大小

fsize – 最大文件大小

memlock – 最大锁定内存地址空间

nofile – 打开文件的最大数目

rss – 最大持久设置大小

stack – 最大栈大小

cpu – 以分钟为单位的最多 CPU 时间

noproc – 进程的最大数目

as – 地址空间限制

maxlogins – 此用户允许登录的最大数目

要使 limits.conf 文件配置生效,必须要确保 pam_limits.so 文件被加入到启动文件中。查看 /etc/pam.d/login 文件中有:

session required pam_limits.so



4、或者使用修改/etc/profile文件

选项 [options]含义例子
-H设置硬资源限制,一旦设置不能增加。ulimit – Hs 64;限制硬资源,线程栈大小为 64K。
-S设置软资源限制,设置后可以增加,但是不能超过硬资源设置。ulimit – Sn 32;限制软资源,32 个文件描述符。
-a显示当前所有的 limit 信息。ulimit – a;显示当前所有的 limit 信息。
-c最大的 core 文件的大小, 以 blocks 为单位。ulimit – c unlimited; 对生成的 core 文件的大小不进行限制。
-d进程最大的数据段的大小,以 Kbytes 为单位。ulimit -d unlimited;对进程的数据段大小不进行限制。
-f进程可以创建文件的最大值,以 blocks 为单位。ulimit – f 2048;限制进程可以创建的最大文件大小为 2048 blocks。
-l最大可加锁内存大小,以 Kbytes 为单位。ulimit – l 32;限制最大可加锁内存大小为 32 Kbytes。
-m最大内存大小,以 Kbytes 为单位。ulimit – m unlimited;对最大内存不进行限制。
-n可以打开最大文件描述符的数量。ulimit – n 128;限制最大可以使用 128 个文件描述符。
-p管道缓冲区的大小,以 Kbytes 为单位。ulimit – p 512;限制管道缓冲区的大小为 512 Kbytes。
-s线程栈大小,以 Kbytes 为单位。ulimit – s 512;限制线程栈的大小为 512 Kbytes。
-t最大的 CPU 占用时间,以秒为单位。ulimit – t unlimited;对最大的 CPU 占用时间不进行限制。
-u用户最大可用的进程数。ulimit – u 64;限制用户最多可以使用 64 个进程。
-v进程最大可用的虚拟内存,以 Kbytes 为单位。ulimit – v 200000;限制最大可用的虚拟内存为 200000 Kbytes。
我们可以通过以下几种方式来使用 ulimit:

在用户的启动脚本中

如果用户使用的是 bash,就可以在用户的目录下的 .bashrc 文件中,加入 ulimit –u 64,来限制用户最多可以使用 64 个进程。此外,可以在与 .bashrc 功能相当的启动脚本中加入 ulimt。

在应用程序的启动脚本中

如果用户要对某个应用程序 test进行限制,可以写一个简单的脚本 starttest。
ulimit -s 512

以后只要通过脚本 starttest来启动应用程序,就可以限制应用程序test 的线程栈大小为 512K。

直接在控制台输入
test@linux:~>ulimit -p 256

限制管道的缓冲区为 256K。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐