Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

Linux dbstart & dbshut scripts 

Expert Oracle Database Tips by Donald BurlesonMarch 22, 2015

Using the dbstart and dbshut Scripts

Oracle provides you with the scripts dbstart and dbshut to start and stop multiple databases on the system.  As mentioned in earlier chapters, these scripts rely on the /etc/oratab file to determine what databases should be started.

11g_db1:/u01/app/oracle/product/11.1.0/db_1:N
TEST:/u01/app/oracle/product/11.1.0/db_1:Y

Entries where the third field is Y are started when dbstart is run; entries with an N in this field are ignored by dbstart.  Note that there is no way to pick and choose which scripts should be started and stopped with these scripts other than indicating it in the oratab file.  If you want to start or stop an individual database, you will need to do it through sqlplus by connecting as sysdba and issuing the startup command.

The dbstart and dbshut commands are intended for use at system startup and shutdown in a script like the oracle_db script provided in the code depot for this book.  It is possible to run these commands directly from the command line as the oracle user, but keep in mind that they will affect all databases indicated with Y in the oratab file.

The root user can also use the service command in the format service oracle_db start or service oracle_db stop command to start or stop all Oracle services just as they would be at startup or shutdown.  This is preferred to running the dbstart and dbshut commands since it will invoke the script from /etc/init.d and will manage the lock file in /var/lock/subsys which is used to track the status of the service.

In Oracle 10gR2, it is possible to use dbstart to start a listener along with the databases.  The dbstart commandmust be modified so the line defining the variable ORACLE_HOME_LISTENER points to the Oracle home containing the listener you would like to manage.

# Set this to bring up Oracle Net Listener
ORACLE_HOME_LISTENER=/u01/app/oracle/product/10.2.0/db_1

In 10gR2, the dbshut command does not contain logic to stop the listener.  It can be stopped using the lsnrctl command.  For consistency, it may be more desirable to start and stop the listener using the lsnrctl command in 10g.

In Oracle 11g, both the dbstart and dbshut commands can now be used to start and stop an Oracle listener.  No modification of the scripts is required; instead, the Oracle home for the listener you want to start is passed as an argument to the dbstart or dbshut commands.  The resulting startup command would look like this:

$ dbstart /u01/app/oracle/product/11.1.0/db_1

This can be included in the oracle_db script called at system startup instead of running the lsnrctl command.

As of 11g, the dbstart and dbshut commands also have some additional logging.  There is now a startup.log, shutdown.log and listener.log all contained within the Oracle home directory.  These contain the output of the corresponding commands and can help with troubleshooting startup and shutdown issues.  The alert logs for each database will also have information on startup and shutdown activities.

Different Ways to Start Processes

Some processes start automatically when the system starts up.  The init scripts, as described in Chapter 6, control these processes.  Each time a command is run, a process is created to carry out that command. Even then, there is some control over how the command will be handled.

Starting and Managing Background Jobs

Normally a command is expected to start, do some work, and then exit gracefully, usually in a short period of time.  During that time, typically nothing else can be done with the shell session that command was executed, but there is an alternative.

By following a command with an ampersand (&), that command can be made to run in the background.  The shell reports a job number in brackets and the process number for the backgrounded command.

$ dbstart &
 
[1] 11022
Processing Database instance "TEST": log file
/u01/app/oracle/product/11.1.0/db_1/startup.log

Things can become very confusing if you have a bunch of background processes writing to your terminal, so it is best to background processes with little or no output or redirect the output to a file or other resource using > or >> and a file name.

Now that you have a process running in the background, you might want to know when it completes.  The shell typically reports a Done message with the job number when a process completes, but if you want to check what is going on in the meantime, use the jobs commandto check the status.

$ jobs

[1]+  Running                 dbstart &

The jobs command reports back the job number, status and command for any processes currently running or stopped in the background.  The status is indicated as Running if the process is running in the background, Stopped if the process is waiting for input or has been stopped with the control-z commandor Done if the process has just finished running.

If a process is started normally without an ampersand and there is a  need to either pause the execution or have the process run in the background instead of canceling the process and restarting it with an ampersand, use the control-z command to stop the process and manipulate the job from there.

$ dbshut
control-z
 
[1]+  Stopped                 dbshut
 
$ jobs
 
[1]+  Stopped                 dbshut
 
$ bg 1
 
[1]+ dbshut &
 
$ jobs
 
[1]+  Running                 dbshut &
 
Once the job is stopped, it shows up in the job list with a status of Stopped.  To start the job executing in the background, use the bg command with the job number.  As seen above, this changes the status to Running and the job will continue to run as if it were started with an ampersand.

Whether a job is stopped or running in the background, it can be brought back to the foreground with the fg command.  This allows interacting with the program just as if it were started normally. You get your prompt back when the command completes or you get tired of waiting and background it again with the control-z command.

$ dbstart &

[1] 2599
Processing Database instance "oss": log file
/u01/app/oracle/product/10.2.0/Db_1/startup.log

$ jobs
 
[1]+  Running                 dbstart &
 
$ fg 1
 
dbstart
 
$

Here is a table for a quick reference to these job control commands.  Job control can allow you to get multiple things running at once, but watch out for commands which might interfere with each other and make sure you can keep track of the output.

Command

Action

&

Append to the end of a command to start it running in the background

jobs

Display all backgrounded jobs whether running or stopped

control-z

Stop the job running in the current shell and background it

bg 1

Start running job 1 in the background

fg 1

Move job 1 to the foreground, moving it into the current shell
Table 10.3:  Job Control Commands

 

 

 

 

 
 
 
Get the Complete Details on
Linux System Management for Oracle DBAs  


The landmark book "Linux for the Oracle DBA: The Definitive Reference" provides comprehensive yet specific knowledge on administering Oracle on Linux.   A must-have reference for every DBA running or planning to run Oracle on a Linux platform.

Buy it for 30% off directly from the publisher.
 


 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster