Next Previous Contents

6. Aytomato Anebasma (Startup) kai Katebasma (Shutdown)

6.1 dbstart & dbstop

To aytomato anebasma (Startup) kai katebasma (Shutdown) ths bashs dedomenwn Oracle mporei na epiteyx8ei (sthn 7.3.3.0.0) me ta arxeia dbstart kaidbshut, poy kai ta dyo parexontai apo thn Oracle. Ayta ta arxeia basizontai sthn uparjh toy arxeioy /etc/oratab gia na doylecoyn (an kai allazontas ta arxeia dbshut kai dbstart ayto mporei na metafer8ei).

To format toy arxeioy /etc/oratab einai ws akolou8ws:


SID:ORACLE_HOME:AUTO

Ena paradeigma:


orcl:/home/oracle/7.3.3.0.0:Y
leaveup:/home/oracle/7.3.2.1.0:N

6.2 init.d & rc.d

Gia na ekkinhsete kai stamathsete th bash dedomenwn otan to mhxanhma anebainei kai katebainei mporeite na allajete tis roytines ekkinhshs ths Linux mhxanhs sas. Einai arketa eukolo, an kai 8a h8ela na shmeiwsw edw, pws mporei na diaferei analoga me thn ekdosh Linux (slackware, debian, redhat, etc). 8a deijw paradeigmata poy doyleuoyn gia to Redhat Linux 5.0. Gia na ta tropopoihsete analoga, gia th dikia sas ekdosh toy Linux, diabaste thn tekmhriwsh toy Linux sas. (Parolo poy 8a prepei na stekei gia ka8e UNIX tupoy Sys V).

Prwta, xreiazetai na dhmioyrghsoyme to script poy 8a trexei tis dbshut kai dbstart sto directory /etc/rc.d/init.d. Dhmioyrghste to akoloy8o arxeio ws /etc/rc.d/init.d/oracle:


#!/bin/sh
#
# /etc/rc.d/init.d/oracle
# Description: Starts and stops the Oracle database and listeners
# See how we were called.
case "$1" in
  start)
        echo -n "Starting Oracle Databases: "
        echo "----------------------------------------------------" >> /var/log/oracle
        date +"! %T %a %D : Starting Oracle Databases as part of system up." >> /var/log/oracle
        echo "----------------------------------------------------" >> /var/log/oracle
        su - oracle -c dbstart >> /var/log/oracle
        echo "Done."
        echo -n "Starting Oracle Listeners: "
        su - oracle -c "lsnrctl start" >> /var/log/oracle
        echo "Done."
        echo ""
        echo "----------------------------------------------------" >> /var/log/oracle
        date +"! %T %a %D : Finished." >> /var/log/oracle
        echo "----------------------------------------------------" >> /var/log/oracle
        touch /var/lock/subsys/oracle
        ;;
  stop)
        echo -n "Shutting Down Oracle Listeners: "
        echo "----------------------------------------------------" >> /var/log/oracle
        date +"! %T %a %D : Shutting Down Oracle Databases as part of system down." >> /var/log/oracle
        echo "----------------------------------------------------" >> /var/log/oracle
        su - oracle -c "lsnrctl stop" >> /var/log/oracle
        echo "Done."
        rm -f /var/lock/subsys/oracle
        echo -n "Shutting Down Oracle Databases: "
        su - oracle -c dbshut >> /var/log/oracle
        echo "Done."
        echo ""
        echo "----------------------------------------------------" >> /var/log/oracle
        date +"! %T %a %D : Finished." >> /var/log/oracle
        echo "----------------------------------------------------" >> /var/log/oracle
        ;;
  restart)
        echo -n "Restarting Oracle Databases: "
        echo "----------------------------------------------------" >> /var/log/oracle
        date +"! %T %a %D : Restarting Oracle Databases as part of system up." >> /var/log/oracle
        echo "----------------------------------------------------" >> /var/log/oracle
        su - oracle -c dbstop >> /var/log/oracle
        su - oracle -c dbstart >> /var/log/oracle
        echo "Done."
        echo -n "Restarting Oracle Listeners: "
        su - oracle -c "lsnrctl stop" >> /var/log/oracle
        su - oracle -c "lsnrctl start" >> /var/log/oracle
        echo "Done."
        echo ""
        echo "----------------------------------------------------" >> /var/log/oracle
        date +"! %T %a %D : Finished." >> /var/log/oracle
        echo "----------------------------------------------------" >> /var/log/oracle
        touch /var/lock/subsys/oracle
        ;;
  *)
        echo "Usage: oracle {start|stop|restart}"
        exit 1
esac

Ajizei na elegx8ei pws to arxeio stamataei kai arxizei th bash pragmatika swsta, sto susthma sas. Koitajte to arxeio mhnymatwn (log file), /var/log/oracle gia mhnumata la8oys.

Afou to script ayto doyleuei, xreiazetai na dhmioyrghsoyme symbolikes enwseis (symbolic links) start kai kill sta antistoixa runlevel directories /etc/rc.d/rcX.d.

Oi epomenes entoles 8a ejasfalisoyn pws oi baseis dedomenwn 8a aneboyn sta runlevels 2,3 and 4:


$ ln -s ../init.d/oracle /etc/rc.d/rc2.d/S99oracle
$ ln -s ../init.d/oracle /etc/rc.d/rc3.d/S99oracle
$ ln -s ../init.d/oracle /etc/rc.d/rc4.d/S99oracle

Gia na stamathsete tis baseis dedomenwn se epanekkinhsh 8a xreiastoume ta akoloy8a links:


$ ln -s ../init.d/oracle /etc/rc.d/rc0.d/K01oracle          # Halting
$ ln -s ../init.d/oracle /etc/rc.d/rc6.d/K01oracle          # Rebooting


Next Previous Contents