By Default Oracle
donot Start Automatically(IN LINUX) when the PC is turned on. This is
becausethere is no entre regarding Oracle in the location "/etc/init.d/".
- The "runuser" Command - Methord 1
The Oracle 12c
recommends using the "runuser" command in the "dbora"
service. Create a file called "/etc/init.d/dbora" as the root user,
containing the following code, which is a modified version of the example from
the documentation, which doesn't work.
#!/bin/sh
#
chkconfig: 2345 99 10
#
description: Oracle auto start-stop script.
#
#
Change the value of ORACLE_HOME to specify the correct Oracle home
#
directory for your installation.
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
#
#
Change the value of ORACLE to the login name of the oracle owner at your
site.
#
ORACLE=oracle
HOST=`hostname`
PLATFORM=`uname`
PATH=${PATH}:$ORACLE_HOME/bin
export
ORACLE_HOME PATH
#
case $1
in
'start')
echo -n $"Starting Oracle:
"
runuser
-l $ORACLE -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME &"
touch /var/lock/subsys/dbora
;;
'stop')
echo -n $"Stoping Oracle:
"
runuser
-l $ORACLE -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
rm -f
/var/lock/subsys/dbora
;;
'restart')
echo -n $"Shutting down
Oracle: "
runuser
-l $ORACLE -c
"$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
rm -f
/var/lock/subsys/dbora
sleep 5
echo -n $"Starting Oracle:
"
runuser
-l $ORACLE -c
"$ORACLE_HOME/bin/dbstart $ORACLE_HOME" &
;;
*)
echo "usage: $0 {start|stop|restart}"
exit
;;
esac
# Exit
|
If you want the
service to wait while the startup completes, remove the "&". This
is specially important for shutdowns that take a long time, like when shutting
down WebLogic and Cloud Control services.
- The "su" Command
The following method for automating
database startup and shutdown of Oracle instances on Linux works equally well
for Oracle 9i, 10g, 11G and 12c. It can be used on any RHEL-style distribution,
including Oracle Linux, CentOS, up to an including RHEL7.
Create a file called "/etc/init.d/dbora" as the
root user, containing the following code:
#!/bin/sh
# chkconfig: 2345 99 10
# description: Oracle auto start-stop script.
#
# 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.
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
ORA_OWNER=oracle
export ORACLE_UNQNAME=db12c
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
# Remove "&" if you don't want startup as a background process.
su $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME" &
touch /var/lock/subsys/dbora
;;
'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 $ORA_HOME"
rm -f /var/lock/subsys/dbora
;;
esac
|
- Initializing the Start-up script
Use
the chmod command to set the privileges to 750. Associate the
"dbora" service with the appropriate run levels and set it to
auto-start using the following command.
chmod
750 /etc/init.d/dbora
chkconfig
--add dbora
- Starting / Stopping the DataBase
The DB will start and stop at
machine boot and shutdown. Or it can be manually controlled with:
[root@centos Desktop]# service dbora start
[root@centos Desktop]# service dbora stop
|
No comments:
Post a Comment