1
0
Fork 0

- new ktune version 0.4-1

- added support for start and stop options to profile scripts calls
  - fixed CMDLINE_ELEVATOR test (rhbz#496940#c9)
- new README.ktune
This commit is contained in:
Thomas Woerner 2009-12-11 13:01:44 +01:00
parent 9d9984b180
commit 20ece57af8
3 changed files with 152 additions and 29 deletions

View file

@ -1,28 +1,141 @@
Overview
--------
ktune
===============================================================================
ktune provides the ktune service, which sets several kernel tuning parameters
to values suitable for certain system profiles. Currently, the only profile
provided is for large-memory systems running disk and network-intensive
applications. These settings do not override settings in /etc/sysctl.conf or
on the kernel command line. ktune may harm performance on some systems and
workloads, so it should be tested under production-like conditions prior to
production use. If ktune is found to harm performance, the settings may be
reverted without rebooting by stopping the ktune service.
This description will give you a quick overview of ktune and what it can do for
you.
Using ktune
-----------
1) What is ktune?
2) What it does
2.1) ktune start
2.2) ktune stop
3) How you can use it
4) How you can extend it
5) Planned features
To start ktune you can start the service with the service command:
service ktune start
1) What is ktune?
-------------------------------------------------------------------------------
The kernel in a Linux system is configured to fit the needs of a lot of
customers and use cases. But for certain use cases these defaults might not be
appropriate. For example there are use cases where much more shared memory
segments are needed as with others. Also the size of network buffers might be
important and also the elevator used for block devices to get maximum
performance.
If you want to enable the service in the system, use the chkconfig command:
Initially the service ktune was created to have a simple way to tune kernel
parameters according to a usage profile. Over time this service has been
expanded to support multiple profiles and provide more than kernel parameter
tuning as well as adding a way for customers to use their own tuning settings.
chkconfig ktune on
The package ktune provides a service init script together with a global config
file and a sysctl throughput settings file, a directory to store additional
profiles and some documentation.
More Information
----------------
/etc/rc.d/init.d/ktune
/etc/sysconfig/ktune
/etc/sysctl.ktune
/etc/ktune.d/
/usr/share/doc/ktune-0.4
/usr/share/doc/ktune-0.4/COPYING
/usr/share/doc/ktune-0.4/README
2) What it does
-------------------------------------------------------------------------------
ktune is a system service that is primarily managed by chkconfig. If the
service is enabled and started, it will use the configuration options from
/etc/sysconfig/ktune:
SYSCTL="/etc/sysctl.ktune"
USE_KTUNE_D="yes"
SYSCTL_POST="/etc/sysctl.conf"
ELEVATOR="deadline"
ELEVATOR_TUNE_DEVS="/sys/block/{sd,cciss}*/queue/scheduler"
SYSCTL is the primary ktune sysctl profile. If you comment it out, it will not
get applied.
USE_KTUNE_D is a switch, that enables or disabled the use of additional
profiles from the /etc/ktune.d directory. A profile has to have the extension
.conf to be used. If there is an additional file with the same name, but the
extension .sh it will be used as a profile script.
SYSCTL_POST references the system wide sysctl file for customer settings.
ELEVATOR is the I/O scheduler, ktune will set for ELEVATOR_TUNE_DEVS. If you
want to disable the setting of the I/O scheduler, just comment out the ELEVATOR
line. ktune will not apply any scheduler if a scheduler is set on the kernel
command line. It is safe to leave this on "deadline", but "as", "cfq", and
"noop" are also legal values. ELEVATOR_TUNE_DEVS references the devices which
should be tuned with the ELEVATOR.
2.1) ktune start
When the service starts, it is applying the sysctl settings from the SYSCTL
file and afterwards the sysctl settings from the conf files in the /etc/ktune.d
directory. For each sysctl settings, that will be modified, it will store the
original value in a save file to be able to restore the initial settings if the
service is stopped. This way it can easily be evaluated if settings are good or
bad for a specific environment. After a profile from the ktune.d directory has
been applied, the profile script will be called if available. The script will
get the service parameter, the service has been started with: If "service ktune
start" has been used, profile scripts will be called with the parameter
"start". This way custom settings, for which the sysctl settings file can not
be used, can be made.
After applying the sysctl settings, the elevators will be set.
2.2) ktune stop
When the service stopps, it applies the settings saved while starting.
3) How you can use it
-------------------------------------------------------------------------------
The service is managed by chkconfig and can be enabled or disabled for
automatic system start and stop. If you want to evaluate settings or want to
find te best settings for your system it is save to leave the service disabled
and to start or stop it manually with the service command.
To start or stop ktune you can use the service command:
service ktune <start|stop>
To enable or disable ktune for automatic system start, use the chkconfig
command:
chkconfig ktune <on|off>
4) How you can extend it
-------------------------------------------------------------------------------
To change the primary profile, use the SYSCTL variable in the ktune sysconfig
file. If you want to add additional profiles, put them into the /etc/ktune.d
directory altogether with a profile scrip if needed.
Skeleton of a profile scipt:
#!/bin/sh
case "$1" in
start)
# do something
RETVAL=$?
;;
stop)
# do something
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop}"
RETVAL=2
;;
esac
exit $RETVAL
5) Planned features
-------------------------------------------------------------------------------
* Readahead tuning for block devices
Please have a look at /etc/sysconfig/ktune and /etc/sysctl.ktune for tuning
parameters.

View file

@ -30,8 +30,6 @@ KERNEL_ELEVATOR="cfq"
CMDLINE_ELEVATOR=$?
SYS_BLOCK_SDX=$(eval LANG=C /bin/ls -1 ${ELEVATOR_TUNE_DEVS} 2>/dev/null)
CMDLINE_ARG1=$1
declare -a KTUNE_FILES
if [ -r "$SYSCTL" ]; then
KTUNE_FILES[0]="$SYSCTL"
@ -84,10 +82,11 @@ load_file() {
call_script() {
local script=$1
local option=$2
if [ -x "$script" ]; then
echo -n "Calling "$script": "
($script ${CMDLINE_ARG1})
echo -n "Calling '$script $option': "
("$script" "$option")
ret=$?
if [ $ret -eq 0 ]; then
@ -109,7 +108,7 @@ load_sysctl() {
for file in "${KTUNE_FILES[@]}"; do
echo -n $"$file: "
load_file "$file" 1
call_script "${file%.conf}.sh"
call_script "${file%.conf}.sh" start
done
# Apply general sysctl settings afterwards
@ -126,6 +125,12 @@ revert_sysctl() {
load_file "$SAVE_FILE" 0
/bin/rm -f "$SAVE_FILE"
fi
if [ ${#KTUNE_FILES[@]} -gt 0 ]; then
for file in "${KTUNE_FILES[@]}"; do
call_script "${file%.conf}.sh" stop
done
fi
}
start() {
@ -134,7 +139,7 @@ start() {
load_sysctl
# if no elevator on command line, apply the ktune elevator
if [ -n "$ELEVATOR" -a -n "$SYS_BLOCK_SDX" -a !$CMDLINE_ELEVATOR ]; then
if [ -n "$ELEVATOR" -a -n "$SYS_BLOCK_SDX" -a $CMDLINE_ELEVATOR -ne 0 ]; then
ret_e=0
echo -n $"Applying ${ELEVATOR} elevator: "
for i in $SYS_BLOCK_SDX; do
@ -164,7 +169,7 @@ stop() {
revert_sysctl
# if no elevator on command line, apply the default elevator
if [ -n "$ELEVATOR" -a -n "$SYS_BLOCK_SDX" -a !$CMDLINE_ELEVATOR ]; then
if [ -n "$ELEVATOR" -a -n "$SYS_BLOCK_SDX" -a $CMDLINE_ELEVATOR -ne 0 ]; then
ret_e=0
echo -n $"Reverting to ${KERNEL_ELEVATOR} elevator: "
for i in $SYS_BLOCK_SDX; do

View file

@ -14,7 +14,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildArch: noarch
Requires(post): chkconfig
Requires(preun): chkconfig
Requires: gawk
Requires: grep gawk
%description
ktune provides settings for server performance tuning. Please have a look at
@ -67,13 +67,18 @@ fi
%dir %attr(0755,root,root) %{_sysconfdir}/ktune.d
%changelog
* Fri Dec 11 2009 Thomas Woerner <twoerner@redhat.com> 0.4-1
- added support for start and stop options to profile scripts calls
- fixed CMDLINE_ELEVATOR test (rhbz#496940#c9)
- added requirement for grep again
* Fri Jul 24 2009 Thomas Woerner <twoerner@redhat.com> 0.3-2
- use /bin/ls with LANG=C
* Tue Jul 21 2009 Thomas Woerner <twoerner@redhat.com> 0.3-2
- added support for profile scripts
* Tue May 5 2008 Thomas Woerner <twoerner@redhat.com> 0.3-1
* Tue May 5 2009 Thomas Woerner <twoerner@redhat.com> 0.3-1
- added support for loading additional files: /etc/ktune.d/*.conf
Resolves: rhbz#496940