Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2929
  • Last Modified:

Dbshut, Dbstart Oracle 9i Rel 2

Does anyone know where I can get directions on how to use

$ORACLE_HOME/bin/dbshut
$ORACLE_HOME/bin/dbstart

scripts?  I looked online at Oracle's website with no luck.
0
lcor
Asked:
lcor
  • 2
  • 2
  • 2
  • +4
2 Solutions
 
ljianCommented:
You do not need these IMHO
All you have to do in 9i is to use sqlplus in sysdba mode like this:


cmd prompt
>sqlplus /nolog

sql>connect sys/<pwd>@<sid> as sysdba

sql>shutdown [immediate]   --to shut down the DB


....

sql> startup          --to start the DB

   
0
 
geotigerCommented:
This is the script that I am using for my 8i db. It should be usable for 9i as well.  Before I put it to use, I made the following change:

1. I change the "shutdown normal" to "shutdown immediate" so the script can be used during system shutdowns and reboots.
2. Use oratab to manage instances to be used with the script. It is located at /var/opt/oracle on my system
3. Place the script under /etc/init.d
4. Link the script to proper system run level

(/etc)> ls -al  rc[0-9].d/*ora*
lrwxrwxrwx   1 root     other         17 Jun 12  2002 rc0.d/K84oradb8i -> ../init.d/oradb8i
lrwxrwxrwx   1 root     other         19 Jun 12  2002 rc0.d/K84oralsnr8i -> ../init.d/oralsnr8i
lrwxrwxrwx   1 root     other         17 Jun 12  2002 rc2.d/S84oradb8i -> ../init.d/oradb8i
lrwxrwxrwx   1 root     other         19 Jun 12  2002 rc2.d/S84oralsnr8i -> ../init.d/oralsnr8i

#!/bin/ksh
# File name: oradb8i
# check and set Oracle home
if test -z "$ORA_HOME"; then
    ORA_HOME=/opt/app/oracle/product/8.1.7
fi
if test -z "$ORA_OWNER"; then ORA_OWNER=oinstall; fi

case "$1" in
  start) PRG=$ORA_HOME/bin/dbstart
    if [ ! -f $PRG ]; then echo "Oracle: can not run $PRG"; exit; fi
    echo "Starting up Oracle databases..."
    su - $ORA_OWNER -c "$PRG $1 &"
  ;;
  stop) PRG=$ORA_HOME/bin/dbshut
    if [ ! -f $PRG ]; then echo "Oracle: can not run $PRG"; exit; fi
    echo "Shuting down Oracle databases..."
    su - $ORA_OWNER -c "$PRG $1 &"
  ;;
esac

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
helpneedCommented:
0
 
schwertnerCommented:
There are some errors in these scripts in the 9i version.
Changes:
In dbstart, line 55
change
PFILE= .....init${ORACLE_SID}.ora
to
PFILE= .....spfile${ORACLE_SID}.ora
In dbshut, line 85
change
shutdown
to
shutdown immediate

Make spare copies ot the scripts before this.


How to use the scripts? Good question!

Configuring Linux for Automated Startup/Shutdown of Oracle Database
-------------------------------------------------------------------
 
1. Update 'oratab' (under /etc or /var/opt/oracle) as:
 
   <SID>:<ORACLE_HOME>:Y
 
where Y states that the database can be started up and shutdown using  
dbstart/dbshut.
 
2. Create the service script:
 
     /etc/init.d/dbora
 
Note: In Red Hat Advanced Server 2.1, the /etc/init.d is is a symbolic link to  
      /etc/rc.d/init.d  
 
Content of the script is as follows:
 
  #!/bin/bash
  #
  # chkconfig: 35 99 10    
  # description: Starts and stops Oracle processes
  #
  # Set ORA_HOME to be equivalent to the $ORACLE_HOME
  # from which you wish to execute dbstart and dbshut;
  #
  # Set ORA_OWNER to the user id of the owner of the
  # Oracle database in ORA_HOME.
  #
  ORA_HOME=<Type your ORACLE_HOME in full path here>
  ORA_OWNER=<Type your Oracle account name here>
 
  case "$1" in
    'start')
       # Start the Oracle databases:
       # The following command assumes that the oracle login
       # will not prompt the user for any values
       su - $ORA_OWNER -c $ORA_HOME/bin/dbstart
       # Start the TNS Listener
       su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
       # Start the Intelligent Agent
       if [ -f $ORA_HOME/bin/agentctl ]; then
          su - $ORA_OWNER -c "$ORA_HOME/bin/agentctl start"
       else
          su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl dbsnmp_start"
       fi
       # Start Management Server
       if [ -f $ORA_HOME/bin/oemctl ]; then
          su - $ORA_OWNER -c "$ORA_HOME/bin/oemctl start oms"
       fi
       # Start HTTP Server
       if [ -f $ORA_HOME/Apache/Apache/bin/apachectl ]; then
          su - $ORA_OWNER -c "$ORA_HOME/Apache/Apache/bin/apachectl start"
       fi
       touch /var/lock/subsys/dbora
       ;;
    'stop')
       # Stop HTTP Server
       if [ -f $ORA_HOME/Apache/Apache/bin/apachectl ]; then
          su - $ORA_OWNER -c "$ORA_HOME/Apache/Apache/bin/apachectl stop"
       fi
       # Stop Management Server
       if [ -f $ORA_HOME/bin/oemctl ]; then
          su - $ORA_OWNER -c "$ORA_HOME/bin/oemctl stop oms sysman/<password>"
       fi
       # Stop the Intelligent Agent
       if [ -f $ORA_HOME/bin/agentctl ]; then
          su - $ORA_OWNER -c "$ORA_HOME/bin/agentctl stop"
       else
          su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl dbsnmp_stop"
       fi
       # Stop the TNS Listener
       su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
       # Stop the Oracle databases:
       # The following command assumes that the oracle login
       # will not prompt the user for any values
       su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
       rm -f /var/lock/subsys/dbora
       ;;
  esac
  # End of script dbora
 
NOTE 1:
The lines:
 
  # chkconfig: 35 99 10    
  # description: Starts and stops Oracle database
 
are mandatory since they describe the characteristics of the service where:
 
  35 means that the service will be started in init levels 3 and 5 and will be stopped in other levels.
  99 means that the service will be started at the near end of the init level processing
  10 means that the service will be stopped at the near end of the init level processing
 
NOTE 2:  
The Management Server is not shut down during service stop since it requires interaction and there is no harm in system killing the processes since the database is shut down already.
 
 
3. Set script permissions:
 
    chmod 755 /etc/init.d/dbora
 
 
3. Register the Service
 
    /sbin/chkconfig --add dbora
 
This action registers the service to the Linux service mechanism. On SuSE SLES7 and Red Hat Advanced Server 2.1 it will arrange symbolic links under  
rc<runlevel>.d directories to /etc/init.d/dbora script.
 
NOTE 3:
The chkconfig utility calls 'insserv' to register and add services. The 'insserv'
version shipped with SUSE SLES8 is using the following header to define run level  
and start/shutdown order.
 
    ### BEGIN INIT INFO
    # Provides:       dbora      
    # Required-Start: $local_fs $remote_fs $netdaemons
    # Required-Stop:
    # Default-Start:  3 5
    # Default-Stop:   0 1 2 3 4 5 6
    # Description:    Oracle Startup
    ### END INIT INFO
 
On SuSE SLES7 the following symbolic links are created:
 
/etc/init.d/rc0.d/K10dbora
/etc/init.d/rc1.d/K10dbora
/etc/init.d/rc2.d/K10dbora
/etc/init.d/rc3.d/S99dbora
/etc/init.d/rc4.d/K10dbora
/etc/init.d/rc5.d/S99dbora
/etc/init.d/rc6.d/K10dbora
 
 
On Red Hat Advanced Server 2.1 the following symbolic links are created:
 
/etc/rc.d/rc0.d/K10dbora
/etc/rc.d/rc1.d/K10dbora
/etc/rc.d/rc2.d/K10dbora
/etc/rc.d/rc3.d/S99dbora
/etc/rc.d/rc4.d/K10dbora
/etc/rc.d/rc5.d/S99dbora
/etc/rc.d/rc6.d/K10dbora
 
 
The symbolic links are not created in United Linux 1.0 (SuSE SLES8 Edition)  
with the 'chkconfig -add' command.  
To have the symbolic links created run the following in addition:
 
   /sbin/chkconfig --set dbora 35
 
After this action, the following symbolic links will be created pointing  
to /etc/init.d/dbora script:
 
/etc/init.d/rc3.d/S01dbora
/etc/init.d/rc3.d/K22dbora
/etc/init.d/rc5.d/S01dbora
/etc/init.d/rc5.d/K22dbora
 
 
In all cases, the 'dbora' service will be running in runlevels 3,5 and it will  
be stopped in other runlevels (i.e. 0,1,2,4,6).
0
 
ljianCommented:
I must say that I was out of range with my answer.
Schwertner : You rock! Step by step instructions!!!! excelent post!
0
 
kripa_odbaCommented:
Once the installation is over you can configure for automatic startup and shutdown of the database using dbstart and dbshut scripts provided by oracle .But for that scripts to work follow the steps given below......


First thing you need to do is change the entry in ORATAB file located at /etc

oratab file will contain one etry for each  databases in ur server.

You can find an entry like this in /etc/oratab file

dev920:/u01/app/oracle/product/9.2.0:N    

You have to change the N to Y and save the file.
It should look like this...

dev920:/u01/app/oracle/product/9.2.0:N    


After you changed the oratab file create a file called dbora in /etc/rc.d/init.d.The script should contain these entries...


#!/bin/sh
        ORA_HOME=/u01/app/oracle/product/9.2.0
        ORA_OWNER=oracle
        HTTP_OWNER=apache
        if [ ! -f $ORA_HOME/bin/dbstart ]
        then
          echo "Oracle startup: cannot start"
          exit
        fi
        case "$1" in
           'start') # Start the Oracle databases and listeners
                    su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart"
                    su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
                    ;;
           'stop')  # Stop the Oracle databases and listeners
                    su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
                    su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut"
                    ;;
        esac


Check execution permission is there for the file which you have created just now.........

After creating the dbora file, you need to link it to the various /etc/rc.d/rcN.d directories
 
        $ ln -s /etc/rc.d/init.d/dbora /etc/rc.d/rc0.d/K10dbora
        $ ln -s /etc/rc.d/init.d/dbora /etc/rc.d/rc1.d/K10dbora
        $ ln -s /etc/rc.d/init.d/dbora /etc/rc.d/rc2.d/K10dbora
        $ ln -s /etc/rc.d/init.d/dbora /etc/rc.d/rc3.d/S99dbora
        $ ln -s /etc/rc.d/init.d/dbora /etc/rc.d/rc4.d/K10dbora
        $ ln -s /etc/rc.d/init.d/dbora /etc/rc.d/rc5.d/S99dbora
        $ ln -s /etc/rc.d/init.d/dbora /etc/rc.d/rc6.d/K10dbora



Once its done... i think you can test whether the database is starting up while starting up the server.
0
 
lcorAuthor Commented:
Everyone had great input but I ultimately used  kripa_odba's solution
0
 
geotigerCommented:

I agree with LiJian that schwertner should get credits on this one as well.

GT
0
 
lcorAuthor Commented:
OK.  I'll re-open and give credit accordingly.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now