Exzilla.net
Contact
Home -> Articles -> Startup and shutdown Oracle Database with unix shell scripts
 
Features
Forums
Files
Blogs
Startup and shutdown Oracle Database with unix shell scripts
April 7, 2001
Somchai P.
Author's Bio | E-Mail
2001 exzilla.net

Before making Oracle Database available for any valid user, you must start up a database,
create an instance of the database and choose the state in which the database starts.

Startup Database

1. Create an instance of the database and Startup database in normal mode

Before creating instance, we must check necessory variables first.

$ env | grep ORACLE

ORACLE_SID=viper

ORACLE_HOME=/oracle/OraHome1

And then startup Oracle database in normal mode with svrmgrl command (From 8.1.x, you can start oracle database with SQL*Plus)

$ svrmgrl

Oracle Server Manager Release 3.1.6.0.0 - Production

Copyright (c) 1997, 1999, Oracle Corporation. All Rights Reserved.

Oracle8i Enterprise Edition Release 8.1.6.0.0 - Production

With the Partitioning option

JServer Release 8.1.6.0.0 - Production

SVRMGR> connect internal

Connected.

SVRMGR> startup

ORACLE instance started.

Total System Global Area 376086952 bytes

Fixed Size 94632 bytes

Variable Size 49020928 bytes

Database Buffers 326791168 bytes

Redo Buffers 180224 bytes

Database mounted.

Database opened.

SVRMGR>

** Startup Oracle Database with default location of a parameter file $ORACLE_HOME/dbs/initviper.ora

2. Startup listener

The listener is a separate process that resides on the server.
The listener receives incoming client connection requests and hands these requests to the server.

Before client side can connect to Database server via Net8, we must start the listener process first.

$ lsnrctl start

LSNRCTL for DEC OSF/1 AXP: Version 8.1.6.0.0 - Production on 02-MAY-2001 05:59:37

(c) Copyright 1998, 1999, Oracle Corporation. All rights reserved.

Starting /oracle/OraHome1/bin/tnslsnr: please wait...

TNSLSNR for DEC OSF/1 AXP: Version 8.1.6.0.0 - Production

System parameter file is /oracle/OraHome1/network/admin/listener.ora

Log messages written to /oracle/OraHome1/network/log/listener.log

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dec4100.exzilla.net)(PORT=1521)))

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dec4100.exzilla.net)(PORT=2481))
(PROTOCOL_STACK=(PRESENTATION=GIOP)(SESSION=RAW)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))

STATUS of the LISTENER

------------------------

Alias LISTENER

Version TNSLSNR for DEC OSF/1 AXP: Version 8.1.6.0.0 - Production

Start Date 02-MAY-2001 05:59:38

Uptime 0 days 0 hr. 0 min. 0 sec

Trace Level off

Security OFF

SNMP OFF

Listener Parameter File /oracle/OraHome1/network/admin/listener.ora

Listener Log File /oracle/OraHome1/network/log/listener.log

Services Summary...

PLSExtProc has 1 service handler(s)

dare has 1 service handler(s)

venom has 1 service handler(s)

viper has 1 service handler(s)

The command completed successfully

$

3. Test connection

We test all configuration (tnsnames.ora,sqlnet.ora) files that can work with the listener process with TNSPING command.

$ tnsping viper

TNS Ping Utility for DEC OSF/1 AXP: Version 8.1.6.0.0 - Production on 02-MAY-2001 06:02:21

(c) Copyright 1997 Oracle Corporation. All rights reserved.

Attempting to contact (ADDRESS=(PROTOCOL=TCP)(HOST=dec4100.exzilla.net)(PORT=1521))

OK (310 msec)

$

Shutdown Database

1. Shutdown listener

$ lsnrctl stop

LSNRCTL for DEC OSF/1 AXP: Version 8.1.6.0.0 - Production on 02-MAY-2001 05:59:29

(c) Copyright 1998, 1999, Oracle Corporation. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))

The command completed successfully

$

2. Shutdown database

SVRMGR> connect internal

Connected.

SVRMGR> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SVRMGR>

Sample scripts for startup/shutdown Oracle database and listener process.

$ id

uid=404(orasys) gid=400(dba) groups=405(oinstall)

$

$ ls -l

total 3

-rwxr-x--- 1 orasys dba 298 Apr 13 20:40 SxxOracle.sh

-rwx------ 1 orasys dba 146 Apr 13 20:38 dbstart.sh

-rwx------ 1 orasys dba 158 Apr 13 20:38 dbstop.sh

$

The owner for each unix shell file must be oracle owner and have right to execute.

This is a sample start file for startup Oracle Database.

$ cat dbstart.sh

#!/bin/ksh

export ORACLE_HOME=/oracle/OraHome1

export ORACLE_SID=viper

svrmgrl << 0xff

connect internal

startup

exit

0xff

sleep 5

lsnrctl start

$

This is a sample start file for shutdown Oracle Database.

$

$ cat dbstop.sh

#!/bin/ksh

export ORACLE_HOME=/oracle/OraHome1

export ORACLE_SID=viper

lsnrctl stop

sleep 5

svrmgrl << 0xff

connect internal

shutdown immediate

exit

0xff

$

Create a main script file for automatic startup and shutdown with rc program.

$ cat SxxOracle.sh

#!/bin/ksh

#

PATH=/sbin:/usr/sbin:/usr/bin

export PATH

export ORACLE_HOME=/oracle/OraHome1

case "$1" in

'start')

su - orasys -c '$ORACLE_HOME/scripts/dbstart.sh' &

;;

'stop')

su - orasys -c '$ORACLE_HOME/scripts/dbstop.sh' &

;;

*)

echo "usage: $0 {start|stop}"

;;

esac

$

 

Download

Download all scipt files Click here

References:

1. Administrator’s Guide, Release 2 (8.1.6) Part No. A76956-01

2.Net8 Administrator’s Guide, Release 8.1.6 Part No. A76933-01

 

 
 
{exzilla.net -- e-development QuickStart --}



Copyright (c) 2001-2005 - Exzilla.net -  All Rights Reserved.
Contact Us | Privacy Policy | Terms & Conditions