Performance Tuning for Linux Servers [Electronic resources]

Sandra K. Johnson

نسخه متنی -صفحه : 227/ 221
نمايش فراداده

The sysctl Interface

The sysctl interface lets you configure kernel parameters at runtime. sysctl lists kernel parameters, modifies the parameters temporarily through the command-line interface, loads the settings from a file, or modifies the kernel parameters permanently by adding in a configuration file for loading at boot time.

The parameters are organized in a hierarchical, or tree, structure. For example, all the parameters related to devices start with dev. The parameters for a specific device, such as cdrom, are under dev.cdrom.

By default, kernel support for sysctl is enabled. To enable sysctl support when building a new kernel, use menuconfig, choose General Setup from the main menu, and select sysctl support. Alternatively, you can edit the configuration file to set the CONFIG_ SYSCTL option.

Using sysctl

The sysctl command usually resides in the /sbin directory. You can view the complete list of tunable parameters and their settings by executing the sysctl a command. To set a specific parameter, use the w option. For example, the following command sets the message queue identifiers to 32:

$ sysctl w kernel.shmmax=32

Note that this change is temporary and does not persist across system reboots.

To make a change that will persist across reboots, use the p option to load a set of values from a configuration file. In the following example, the values from the configuration file /etc/sysctl.conf are loaded:

$ sysctl p /etc/sysctl.conf

For more information on different usage options, refer to the sysctl(8) man page.

The sysctl Interface

The sysctl interface lets you configure kernel parameters at runtime. sysctl lists kernel parameters, modifies the parameters temporarily through the command-line interface, loads the settings from a file, or modifies the kernel parameters permanently by adding in a configuration file for loading at boot time.

The parameters are organized in a hierarchical, or tree, structure. For example, all the parameters related to devices start with dev. The parameters for a specific device, such as cdrom, are under dev.cdrom.

By default, kernel support for sysctl is enabled. To enable sysctl support when building a new kernel, use menuconfig, choose General Setup from the main menu, and select sysctl support. Alternatively, you can edit the configuration file to set the CONFIG_ SYSCTL option.

Using sysctl

The sysctl command usually resides in the /sbin directory. You can view the complete list of tunable parameters and their settings by executing the sysctl a command. To set a specific parameter, use the w option. For example, the following command sets the message queue identifiers to 32:

$ sysctl w kernel.shmmax=32

Note that this change is temporary and does not persist across system reboots.

To make a change that will persist across reboots, use the p option to load a set of values from a configuration file. In the following example, the values from the configuration file /etc/sysctl.conf are loaded:

$ sysctl p /etc/sysctl.conf

For more information on different usage options, refer to the sysctl(8) man page.