Many of the Linux shells (including BASH) implement certain
controls over certain critical resources like the number of
file descriptors that can be opened and the maximum number of
processes available to a user's session. In most cases, Oracle DBA will not
need to alter any of these shell limits, but you find yourself
getting errors when creating or maintaining the Oracle database,
you may want to read through this section.
You can use the following command to query these shell limits:
# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 16383
virtual memory (kbytes, -v) unlimited
Maximum Number of Open File Descriptors for Shell Session
Let's first talk about the maximum number of open file descriptors for
a user's shell session.
Ok, you are first going to tell me, "But
I've already altered my Linux environment by setting the system wide kernel
parameter /proc/sys/fs/file-max". Yes, this is correct, but there is still a
per user limit on the number of open file descriptors. This typically
defaults to 1024. To check that, use the following command:
% su - oracle
% ulimit -n
1024
If Oracle DBA wanted to change the maximum number of open file descriptors for
a user's shell session, you could edit the /etc/security/limits.conf
as the root account. For your Linux system, you would add the
following lines:
oracle soft nofile 4096
oracle hard nofile 101062
The first line above sets the soft limit, which is the
number of files handles (or open files) that the Oracle
user will have after logging in to the shell account. The
hard limit defines the maximum number of
file handles (or open files) are possible for the user's
shell account. If the oracle user account starts to
recieve error messages about running out of file handles, then
number of file handles should be increased for the
oracle using the user should increase the number of file handles
using the hard limit setting. You can increase
the value of this parameter to 101062 for the current session by using
the following:
% ulimit -n 101062
Keep in mind that the above command will only effect the current
shell session. If you were to log out and log back in, the value would
be set back to its default for that shell session.
We're not totally done yet. We still need to ensure that pam_limits
is configured in the /etc/pam.d/system-auth file. The steps defined
below sould already be performed with a normal Red Hat Linux installation, but
should still be validated!
The PAM module will read the /etc/security/limits.conf file. You should
have an entry in the /etc/pam.d/system-auth file as follows:
session required /lib/security/$ISA/pam_limits.so
I typically validate that my /etc/pam.d/system-auth file has the
following two entries:
session required /lib/security/$ISA/pam_limits.so
session required /lib/security/$ISA/pam_unix.so
Finally, let's test our new settings for the maximum number of open file descriptors for
the oracle shell session. Logout and log back in as the
oracle user account then run the following commands.
Let's first check all current soft shell limits:
$ ulimit -Sa
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 4096
pipe size (512 bytes, -p) 8
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 16383
virtual memory (kbytes, -v) unlimited
Finally, let's check all current hard shell limits:
$ ulimit -Ha
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 101062
pipe size (512 bytes, -p) 8
stack size (kbytes, -s) unlimited
cpu time (seconds, -t) unlimited
max user processes (-u) 16383
virtual memory (kbytes, -v) unlimited
The soft limit is now set to 4096 while the
hard limit is now set to 101062.
Maximum Number of Processes for Shell Session
This section is very similar to the previous section, "Maximum Number of Open File Descriptors
for Shell Session" and deals with the same concept of soft limits and hard limits
as well as configuring pam_limits. For most default Red Hat Linux installations,
you will not need to be concerned with the maximum number of user processes as this value
is generally high enough!
Let's start by querying the current limit of the maximum number of processes for the
oracle user:
% su - oracle
% ulimit -u
16383
If you wanted to change the soft and hard limits for the maximum
number of processes for the oracle user, (and for that matter, all users), you
could edit the /etc/security/limits.conf
as the root account. For your Linux system, you would add the
following lines:
oracle soft nproc 2047
oracle hard nproc 16384
Miscellaneous Notes
To check all current soft shell limits, enter the following command:
$ ulimit -Sa
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 4096
pipe size (512 bytes, -p) 8
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 16383
virtual memory (kbytes, -v) unlimited
To check maximum hard limits, enter the following command:
$ ulimit -Ha
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 101062
pipe size (512 bytes, -p) 8
stack size (kbytes, -s) unlimited
cpu time (seconds, -t) unlimited
max user processes (-u) 16383
virtual memory (kbytes, -v) unlimited
The file (blocks) value should be multiplied by 512 to obtain the
maximum file size imposed by the shell. A value of unlimited
is the operating system default and typically has a maximum value of 1 TB.