PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Dienst im RL mit nice mit geringerer Priorität starten



pixel
21.02.07, 15:23
Hallo zusammen,

wir hatten am Anfang dieser Woche das Problem dass der Prozess unserer SQL-Datenbank (FirebirdSQL) 100% CPU beanspruchte und dadurch die anderen Dienste des Server nicht mehr erreichbar waren.

Das Problem resultierte aus einem Update von firebird-1.5 auf 2.x. Danach erzeugte ein Query das unter 1.5 problemlos ausgeführt wird o.g. Vollauslastung. Wir haben die Entwickler benachrichtig und diese konnten das Problem nachvollziehn. Solange habe ich wieder Version 1.5 installiert.

Um solche Probleme in Zukunft vermeiden zu können würde ich gerne verhindern das ein Prozess die ganze CPU in Anspruch nimmt. Bei der Suche im Forum habe ich 'nice' als mögliche Lösung gefunden. Mein Problem ist jetzt nur, wie kann ich ein Dienst der über den RL-Skript gestartet wird diese Prozes-Priorität mitgeben? Im Falle des FirebirdSQL heist der Prozess fbserver:

ps ax | grep fb
5107 ? S 0:00 /opt/firebird/bin/fbguard -forever
5213 ? S 7:14 /opt/firebird/bin/fbserver

Dieser wird über ein Startskript (siehe ganz unten) gestartet. Wo müsste ich das nice einbauen damit der Prozess z.B. max 50% CPU-Load erzeugen kann? Gibt es evtl. auch einen elegandere Lösung die Prozesspriorität der Dienste zu steuern?


#! /bin/sh
# Copyright (c) 2001 IBPhoenix
# Source SuSE config
if [ -r /etc/rc.config ]
then
. /etc/rc.config
fi

if [ -r /etc/sysconfig/firebird ]
then
. /etc/sysconfig/firebird
fi

# Determine the base and follow a runlevel link name.
base=${0##*/}
link=${base#*[SK][0-9][0-9]}

# Force execution if not called by a runlevel directory.
test $link = $base && START_FIREBIRD="yes"
test "$START_FIREBIRD" = yes || exit 0

FIREBIRD=/opt/firebird
FBRunUser=root

export FIREBIRD
# Check the file is there and is executable.
[ -x $FIREBIRD/bin/fbmgr ] || exit 5
[ -x $FIREBIRD/bin/fbguard ] || exit 5
[ -x $FIREBIRD/bin/fbserver ] || exit 5

# Shell functions sourced from /etc/rc.status:
. /etc/rc.status
# First reset status of this service
rc_reset

case "$1" in
start)
echo -n "Starting Firebird"
startproc -u $FBRunUser $FIREBIRD/bin/fbguard -forever

# Remember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting down Firebird"

ISC_USER=SYSDBA
ISC_PASSWORD=masterkey
$FIREBIRD/bin/fbmgr -shut -user $ISC_USER -password $ISC_PASSWORD 2>/dev/null
unset ISC_USER
unset ISC_PASSWORD

# Remember status and be verbose
rc_status -v
;;
try-restart)
## Stop the service and if this succeeds (i.e. the
## service was running before), start it again.
## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
$0 status >/dev/null && $0 restart

# Remember status and be quiet
rc_status
;;
restart|force-reload)
## Stop the service and regardless of whether it was
## running or not, start it again.
echo "Restarting service Firebird"
$0 stop
$0 start

# Remember status and be quiet
rc_status
;;
reload)

;;
status)
echo -n "Checking for Firebird: "
## Check status with checkproc(8), if process is running
## checkproc will return with exit status 0.

# NOTE: checkproc returns LSB compliant status values.
checkproc $FIREBIRD/bin/fbguard
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
exit 1
;;
esac
rc_exit

marcdevil
21.02.07, 17:00
musst den dienst nicht neustarten, geht auch mit "renice 5 $PID".
ansonsten in dem startscript einfach ein "nice -n 5" vor $FIREBIRD.