Monday, October 20, 2008

Automatic start & shutdown of oracle database with solaris system start/shutdown

The following is a basic steps for an automatic start up and

shutdown Oracle instances during SOLARIS system startup or shutdown.


The following are files which are invoked during system startup

and shutdown, respectively.



Script Description

-------------------------|---------------------------------------

$ORACLE_HOME/bin/dbstart |Ensures a clean startup of instance(s),

|even after system failure

-------------------------|---------------------------------------

$ORACLE_HOME/bin/dbshut |Ensures a clean shutdown for instances

-------------------------|---------------------------------------

/etc/init.d or |Contains a field that specifies whether

/var/opt/oracle/oratab |a particular instance should be brought

|up/down at system startup/shutdown time.

-------------------------|---------------------------------------

Relevant Files

- - - - - - - -

/etc/rc2.d/S99dbstart -- Link to the script /etc/init.d/priya_dbstart

/etc/rc0.d/K01dbshut -- Link to the script /etc/init.d/priya_dbstart

/etc/init.d/oratab -- Oracle oratab file

When an UNIX machine boots, it runs scripts beginning with

S in /etc/rc3.d. The number indicates the order

in which these scripts will be run. The is a reminder to

the Unix administrator as to the function of the script.

Similarly, on shutdown scripts named K are run from

/etc/rc0.d.


Setting Up:

-----------

1. Ensure the /var/opt/oracle/oratab file is complete and correct.

Database entries in the oratab file have the following format:

ORACLE_SID:ORACLE_HOME:Y

Where Y specifies you want to startup the database automatically.

2. Create the script /etc/init.d/priya_dbstart.

3. As root create the following links.

# ln -s /etc/init.d/priya_dbstart /etc/rc3.d/S99dbstart

# ln -s /etc/init.d/priya_dbstart /etc/rc0.d/K01dbstart


4. Test the script created in Step 2.

To test the script created above, without rebooting do the

following:

# su – root

# /etc/init.d/priya_dbstart start (for startup)

# /etc/init.d/priya_dbstart stop (for shutdown)



Script
Note :this script should be in /etc/init.d/'filename'

#!/bin/ksh
#--------------------------------------------------------------------------------
# Script Name : /etc/init.d/priya_dbstart
# Purpose : To start and shutdown databases while system startup/shutdown
# Version : 1.0
# Change log : Initial draft (10/20/2008)
#
#--------------------------------------------------------------------------------

ORACLE_BASE=/u01/oracle
ORACLE_HOME=$ORACLE_BASE/ORACLE/product/10.2.0
export ORACLE_BASE ORACLE_HOME

case "$1" in
'start')
# start Oracle databases
su - oracle -c "$ORACLE_HOME/bin/dbstart"
su - oracle -c "$ORACLE_HOME/bin/lsnrctl start "

for i in orcl ora10g
do
export ORACLE_SID=$i
su oracle -c "$ORACLE_HOME/bin/emctl start dbconsole "
done
;;
'stop')
# stop Oracle databases
for i in orcl ora10g
do
export ORACLE_SID=$i
su oracle -c "$ORACLE_HOME/bin/emctl stop dbconsole"
done
su - oracle -c "$ORACLE_HOME/bin/lsnrctl stop "
su - oracle -c "$ORACLE_HOME/bin/dbshut"
;;
esac

Wednesday, August 27, 2008

Unix commands for DBAs - Part 2


#----------------------------------------------------------------------------------
# VI edior shortcuts
#----------------------------------------------------------------------------------
Opening files:
#---------------
vi filename To open a file 'filename' with vi editor
vi + filename To open a file 'filename' with vi editor - In last line to append

Saving files:
#---------------
ESC :wq To save and exit the current open file
ESC :wq! To save and exit the current open file - forcefully (for read only files)

Modes:
#---------------
a To append after cursor
A To append at the end of line
i To insert before cursor
I To insert in beginning of line
o To add new line below cursor
O To add new line above cursor

Misc options:
#---------------
ESC :se nu To display line numbers in current open file
ESC :se nonu To turn off displaying line numbers in current open file






Tuesday, August 26, 2008

Unix commands for DBAs - Part 1


#----------------------------------------------------------------------------------
# LISTING FILES & DIRECTORIES
#----------------------------------------------------------------------------------
ls To list the contennts (files/directories) in current working directory
ls -l Long listing display (displays owner, group, type of file, modification date/time etc.)
ls -la Long list + hidden files and directories (starts with .)
ls -lar Long list + hidden files + sort by reverse modification date/time
ls -lR Recursive long list

#----------------------------------------------------------------------------------
# CHANGING DIRECTORIES
#----------------------------------------------------------------------------------
cd Move to home directory
cd .. Move to one dirctory back
cd ../.. Move two levels of back directory
cd /export/home/oracle Move to Oracle's home directory
cd ~oracle Move to Oracle's home directort (in KSH shell)
pwd Shows present working directory

#----------------------------------------------------------------------------------
# FINDING FILES (variuos examples)
#----------------------------------------------------------------------------------
find / -name filename
find / -name *.log
find / -name filename -type f
find / -name filename -size +10000c
find / -name filename -mtime +10
find / -name filename -xdev
find / -name filename -exec ls -l '{}' \;
find / -name filename -exec rm '{}' \;

#----------------------------------------------------------------------------------
# MISCELLENEOUS COMMANDS
#----------------------------------------------------------------------------------
mkdir abc Make directory 'abc' in current directory
mkdir -p /tmp/d1/d2/d3 Make recursive directories d1->d2->d3
cp source destination Make copy of 'source' file to 'destination' file
cp -r dir1 dir1 Make a directory copy (recursive copy)
cp -pr dir1 dir2 Make a directory copy with retaining date/time (recursive copy)
mv file1 file2 Rename 'file1' to 'file2'
mv dir1 dir2 Rename directory name from 'dir1' to 'dir2'

#----------------------------------------------------------------------------------
# FILES/DIRECTORY DELETION
#----------------------------------------------------------------------------------
rm file1 Delete 'file1'
rm -i file1 Delete 'file1' - interactively
rm -f file1 Delete 'file1' - forcefully
rm -r dir1 Delete 'dir1' directory - recursively
rmdir dir1 Delete an empty directory 'dir1'

Friday, August 15, 2008

Welcome

Hi,

I am the new DBA in making :-)

I am trying to put together some important tips and tricks related to Oracle Database administration. You may use this blog but ON YOUR OWN RESPONSIBILITY. (I am still learning :-))

Thanks,
The New Oracle DBA