Operating System - HP-UX
1833738 Members
2467 Online
110063 Solutions
New Discussion

Re: Informix Startup Script

 
SOLVED
Go to solution
Amit Dixit_2
Regular Advisor

Informix Startup Script

Hi,
Is anybody having script that I can put on my
HP-UX server so that every time when i reboot
my INFORMIX server should get automatically
started and during shutdown it should down
the informix server properly.

Thanks
Amit

6 REPLIES 6
Sanjay Kumar Suri
Honored Contributor

Re: Informix Startup Script

You can create startup script using the template file in /sbin/init.d Following exmample illustrate the same:

Objective: Add script which starts scoupx subsystem when the system transitions up to run-level 3 and stops the scopux subsystem whenever the transitions down to run-level 2.

1. cd /sbin/init.d --> cp template scope_collect --> vi scope_collect
2. Edit start_msg and stop_msg statement.
3. Edit start statement: Change CONTROL_VARIABLE to SCOPE_COLLECT --> add command /opt/perf/bin/scope.start --> add command set_return.
4. Edit stop statement: Change CONTROL_VARIABLE to SCOPE_COLLECT --> add command /opt/perf/bin/scope.stop --> add command set_return.
5. vi /etc/rc.config.d/scopt_collect --> add single line, SCOPE_COLLECT=1.
6. ln -s /sbin/init.d/scope_collect /sbin/rc3.d/S900scope_collect
7. ln -s /sbin/init.d/scope_collect /sbin/rc2.d/K100scope_collect

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Pete Randall
Outstanding Contributor
Solution

Re: Informix Startup Script

Amit,

Here's what we use (/sbin/init.d/informix):

#!/sbin/sh
#
# @(#) $Revision: 72.5 $
#
# NOTE: This script is not configurable! Any changes made to this
# scipt will be overwritten when you upgrade to the next
# release of HP-UX.
#
# WARNING: Changing this script in any way may lead to a system that
# is unbootable. Do not modify this script.
#

#
# Informix start up
#

PATH=/sbin:/usr/sbin:/usr/bin:$INFORMIXDIR:$INFORMIXDIR/bin
export PATH

rval=0
set_return() {
x=$?
if [ $x -ne 0 ]; then
echo "EXIT CODE: $x"
rval=1
fi
}

case $1 in
start_msg)
echo "Start Informix daemon"
;;

stop_msg)
echo "Stop Informix daemon"
;;

'start')
if [ -f /etc/rc.config.d/informix ] ; then
. /etc/rc.config.d/informix
else
echo "ERROR: /etc/rc.config.d/informix defaults file MISSING"
fi

if [ "$INFORMIX" -eq 1 -a -x /opt/informix/bin/oninit ]; then
/opt/informix/bin/oninit && echo informix started
set_return
else
rval=2
fi

;;

'stop')
#
# Determine PID of process(es) to stop
#
if [ -x /opt/informix/bin/onmode ]; then
/opt/informix/bin/onmode -kyu && echo informix stopped
fi
;;

*)
echo "usage: $0 {start|stop}"
rval=1
;;
esac



The spacing will get truncated so I'll attach it as well. Along with that, you need to set any variables in /etc/rc.config.d/informix:

#!/sbin/sh
# @(#) $Revision: 72.3 $
#
# INFORMIX: Set to 1 to start Informix daemon.
#
INFORMIX=1
# KAIOON=1 6/30/97 experiment
export INFORMIXDIR=/opt/informix
export INFORMIXSERVER=m_tcp_1
export ONCONFIG=onconfig.DATABASE
#
# Look in "/sbin/init.d/informix" for INFORMIXSERVER change for "onprobe"
#



Finally, you need to establish the startup and shutdown links as follows:

lrwxrwxr-x 1 root sys 18 Oct 18 2002 /sbin/rc2.d/K100informix -> ../init.d/informix
lrwxrwxr-x 1 root sys 18 Oct 18 2002 /sbin/rc3.d/S998informix -> ../init.d/informix


That's all there is to it!


Pete

Pete
Amit Dixit_2
Regular Advisor

Re: Informix Startup Script

Hi,
I have written a script to startup and
shutdown the server, but dont know where
to put this script and by which name

Thanks,
Amit
Pete Randall
Outstanding Contributor

Re: Informix Startup Script

Amit,

The script goes in /sbin/init.d and can be called anything you like. The key is the links that I showed you earlier. As rc progresses up through the run levels on startup, all the scripts in the rc directory for that run level get parsed with an argument of "start". In this case, we want to startup Informix after everything else is up so we put the startup link in rc3.d as S998informix. Once again, you could call it anything you like but the sequence number governs the order in which it gets parsed. The same idea holds true on shutdown. We want Informix shut down first so we put the link in rc2.d with a low sequence number.

That's it!


Pete

Pete
Steve Lewis
Honored Contributor

Re: Informix Startup Script

Pete,

looking at your script, it mentions $INFORMIXDIR in the PATH at the top before you have sourced the informix script in rc.config.d.

Fortunately you put the full path in when you start and stop the database, so it works anyway.

Steve
Pete Randall
Outstanding Contributor

Re: Informix Startup Script

Good catch, Steve, I never noticed that. My DBA follows the Informix example of using variables all the time - I'm a full path guy - I like things spelled out.

I should also mention to Amit that not only the sequence number of the link is important - they have to begin with K for the shutdown and S for the startup. When rc switches run levels on the way up, it parses all the S* scripts in order and on the way down it parses all the K* scripts in order. I forgot to point that out.


Pete

Pete