LINUX_book
456 pág.

LINUX_book


DisciplinaLinux712 materiais1.839 seguidores
Pré-visualização50 páginas
Notification feature. This can be a useful feature in problem determination in
that you can have a program watch a specific directory and be notified
immediately of any change to it. See /usr/src/linux/Documentation/dnotify.txt
for more information and for a sample program.
3.4.1.2 file-nr This read-only file contains statistics on the number of files
presently opened and available on the system. The file shows three separate
3.4 System Information and Manipulation
114 The /proc Filesystem Chap. 3
values. The first value is the number of allocated file handles, the second is the
number of free file handles, and the third is the maximum number of file
handles.
penguin> cat /proc/sys/fs/file-nr
2858 177 104800
On my system I have 2858 file handles allocated; 177 of these handles are
available for use and have a maximum limit of 104800 total file handles. The
kernel dynamically allocates file handles but does not free them when they're
no longer used. Therefore the first number, 2858, is the high water mark for
total file handles in use at one time on my system. The maximum limit of file
handles is also reflected in the /proc/sys/fs/file-max file.
3.4.1.3 file-max This file represents the system wide limit for the number
of files that can be open at the same time. If you're running a large workload
on your system such as a database management system or a Web server, you
may see errors in the system log about running out of file handles. Examine
this file along with the file-nr file to determine if increasing the limit is a valid
option. If so, simply do the following as root:
echo 104800 > /proc/sys/fs/file-max
This should only be done with a fair degree of caution, considering an overly
excessive use of file descriptors could indicate a programming error commonly
referred to as a file descriptor leak. Be sure to refer to your application's
documentation to determine what the recommended value for file-max is.
3.4.1.4 aio-max-nr, aix-max-pinned, aix-max-size, aio-nr, and
aio-pinned These files are not included as part of the 2.4.24 and 2.6.0 mainline
kernels. They provide additional interfaces to the Asynchronous I/O feature,
which is a part of the 2.6.0 mainline kernel but not 2.4.24.
3.4.1.5 overflowgid and overflowuid These files represent the group
IDs and user IDs to use on remote systems that have filesystems that do not
support 32-bit gids and uids as Linux does. It is important to make a mental
note of this because NFS is very commonly used even though diagnosing NFS-
related problems can be very tricky. On my system, these values are defined as
follows:
penguin> cat overflowgid
65534
penguin> cat overflowuid
65534
115
3.4.2 /proc/sys/kernel
This directory contains several very important files related to kernel tuning
and information. Much of the information here is low-level and will never need
to be examined or changed by the average user, so I'll just highlight some of
the more interesting entries, especially pertaining to problem determination.
3.4.2.1 core_pattern This file is new in the 2.6 kernel, but some
distributions such as SuSE have back ported it to their 2.4 kernels. Its value is
a template for the name of the file written when an application dumps its core.
The advantage of using this is that with the use of % specifiers, the
administrator has full control of where the core files get written and what
their names will be. For example, it may be advantageous to create a directory
called /core and set the core_pattern with a command something like the
following:
penguin> echo "/core/%e.%p" > core_pattern
For example, if the program foo causes an exception and dumps its core, the
file /core/foo.3135 will be created.
3.4.2.2 msgmax, msgmnb, and msgmni These three files are used to
configure the kernel parameters for System V IPC messages. msgmax is used
to set the limit for the maximum number of bytes that can be written on a
single message queue. msgmnb stores the number of bytes used to initialize
subsequently created message queues. msgmni defines the maximum number
of message queue identifiers allowed on the system. These values are often
very dependent on the workload that your system is running and may need to
be updated. Many applications will automatically change these values but some
might require the administrator to do it.
3.4.2.3 panic and panic_on_oops The panic file lets the user control
what happens when the kernel enters a panic state. If the value of either file is
0, the kernel will loop and therefore the machine will remain in the panic state
until manually rebooted. A non-zero value represents the number of seconds
the kernel should remain in panic mode before rebooting. Having the kernel
automatically reboot the system in the event of a panic could be a very useful
feature if high availability is a primary concern.
3.4 System Information and Manipulation
116 The /proc Filesystem Chap. 3
The panic_on_oops file is new in the 2.6.0 mainline kernel and when set
to 1, it informs the kernel to pause for a few seconds before panicking when
encountering a BUG or an Oops. This gives the klogd an opportunity to write
the Oops or BUG Report to the disk so that it can be easily examined when the
system is returned to a normal state.
3.4.2.4 printk This file contains four values that determine how kernel
error messages are logged. Generally, the default values suffice, although
changing the values might be advantageous when debugging the kernel.
3.4.2.5 sem This file contains four numbers that define limits for System V
IPC semaphores. These limits are SEMMSL, SEMMNS, SEMOPM, and
SEMMNI respectively. SEMMSL represents the maximum number of
semaphores per semaphore set; SEMMNS is the maximum number of
semaphores in all semaphore sets for the whole system; SEMOPM is the
maximum number of operations that can be used in a semop(2) call; and
SEMMNI represents the maximum number of semaphore identifiers for the
whole system. The values needed for these parameters will vary by workload
and application, so it is always best to consult your application's documentation.
3.4.2.6 shmall, shmmax, and shmmni These three files define the
limits for System V IPC shared memory. shmall is the limit for the total number
of pages of shared memory for the system. shmmax defines the maximum shared
memory segment size. shmmni defines the maximum number of shared memory
segments allowed for the system. These values are very workload-dependent
and may need to be changed when running a database management system or
a Web server.
3.4.2.7 sysrq This file controls whether the "kernel magic sysrq key" is
enabled or not. This feature may have to be explicitly turned on during
compilation. If /proc/sys/kernel/sysrq exists, the feature is available; otherwise,
you\u2019ll need to recompile your kernel before using it. It is recommended to have
this feature enabled because it can help to diagnose some of the tricky system
hangs and crashes.
The basic idea is that the kernel can be interrupted to display certain
information by bypassing the rest of the operating system via the ALT-SysRq
hotkey combination. In many cases where the machine seems to be hung, the
ALT-SysRq key can still be used to gather kernel information for examination
and/or forwarding to a distribution cause\u2019s support area or other experts.
To enable this feature, do the following as root:
penguin> echo 1 > /proc/sys/kernel/sysrq
117
To test the kernel magic, switch to your first virtual console. You need not log
in because the key combination triggers the kernel directly. Hold down the
right ALT key, then press and hold the PrtSc/SysRq key, then press the number
5. You should see something similar to the following:
SysRq : Changing Loglevel
Loglevel set to 5
If you do not see this message, it could be that