Operating system platform: RHEL 5
Shell Environment: Bash
Oracle:10g2
Function Description: Automatically switch to Oracle user at power-on, and launch multiple instances of Oracle. and record the startup of the database into a custom log file.
#!/bin/bash
Log_path= $HOME/oracle_initing.log
Log () {
If [$#-lt 1-a $#-gt 1];then
Exit 5
Fi
Case "[e-mail protected]" in
Success
echo ' Date +%b ' "%d" "%T '" "$PRO": Oracle instence \ "$ORACLE _sid\" starting up succefully ">> $LOG _path;
Failed
echo ' Date +%b ' "%d" "%T '" "$PRO": Oracle instence \ "$ORACLE _sid\" starting up FAILED ">> $LOG _path;
*)
echo ' Date +%b ' "%d" "%T '" "$PRO": "[email protected] >> $LOG _path;
Esac
}
Lsstart () {
# Stop stopping
# Start starting
Lsnrctl >> $LOG _path <<eof
Status
Start
Exit
Eof
}
Init_oracle () {
#lsstart Stop the Listen
# Lsstart
Hostname= ' HOSTNAME |awk-f. ' {print $} '
Pro=$0
oracle_sids= ' Sed-rn '/^ ([^#].*):/!d;p '/etc/oratab |awk-f: ' {printf $ ""} '
If [-Z ' $ORACLE _sids]; then
Exit 2
Else
Echo $ORACLE _sids
For Oracle_sid in $ORACLE _sids
Do
# echo $ORACLE _sid
#start or stop the Oracle databases
# Startup
# Shutdown Immediate
If Sqlplus-s/nolog >> $LOG _path <<eof
Conn/as SYSDBA
Startup
Eof
Then
Log success
Continue
Else
Log failed
Exit 3
Fi
Done
Fi
}
If [$ "$UID"-eq 0]; then
Su-oracle
Init_oracle
#lsstart Start the Listen
# Lsstart
Exit 0
elif ["$USER" = "Oracle"]; then
Init_oracle
#lsstart Start the Listen
# Lsstart
Exit 0
Else
Exit 4
Fi
http://wangxiaoyu.blog.51cto.com/922065/197630
Multi-instance boot script for Oracle database in Linux/unix environment (RPM)