You can automatically start or stop an instance when the operating system on the database server is started or stopped.
Use the following procedure to configure automatic start and stop of an instance.
When you run an instance on a cluster system, the cluster system controls start and stop, so you do not need to use this feature.
Set the OS user account of the instance administrator.
If you logged in using the OS user account of the instance administrator, set the environment variables required for starting the instance. This setting is required for executing the "su -" command described later.
Create a shell script.
Create a shell script for reading the first argument and starting or stopping the instance.
The shell script should read the first argument and start the instance if "start" is specified, or stop the instance if "stop" is specified.
You must execute the "su -" command as the instance administrator to start or stop the instance.
Copy the shell script and set access permissions.
As the OS superuser, copy to /etc/rc.d/init.d the shell script you created in step 2, and then set the access permissions.
The following example creates an automatic start and stop script with the name "symfo_inst1".
# cp symfo_inst1 /etc/rc.d/init.d/ # chmod 755 /etc/rc.d/init.d/symfo_inst1
Register and enable automatic start and stop
As the OS superuser, execute the chkconfig command to register and enable the script.
Execute "chkconfig --add" to register the script, and execute "chkconfig --level" to set the run level and enable the script.
# chkconfig --add symfo_inst1 # chkconfig --level 25 symfo_inst1 on
#!/bin/sh # chkconfig: 2345 85 15 # description: Symfoware Server Open start / stop script ########################################################################## SYMDATA="/database/inst1" SYMUSER=symfo SYMLOG="$SYMDATA/serverlog" LOCKFILE=/var/lock/subsys/symfo_inst1 case "$1" in start) su - $SYMUSER -c "pg_ctl start -D '$SYMDATA' -w " >$SYMLOG 2>&1 if [ $? -eq 0 ];then touch $LOCKFILE fi ;; stop) su - $SYMUSER -c "pg_ctl stop -D '$SYMDATA' -m fast" >$SYMLOG 2>&1 if [ $? -eq 0 ];then rm -f $LOCKFILE fi ;; restart) su - $SYMUSER -c "pg_ctl restart -D '$SYMDATA' -m fast" >$SYMLOG 2>&1 if [ $? -eq 0 ];then touch $LOCKFILE fi ;; reload) su - $SYMUSER -c "pg_ctl reload -D '$SYMDATA'" >$SYMLOG 2>&1 ;; status) su - $SYMUSER -c "pg_ctl status -D '$SYMDATA'" ;; *) echo $"Usage: $0 {start|stop|restart|reload|status}" exit 2 ;; esac