Öncelike oracle kullanıcısı ile login olup .bash_profile Dosyamızda gerekli tanımlamaları yapmalıyız.
#vi .bash_profile
# Oracle bash_profile Tanımlamaları
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_HOSTNAME=dbserver.veys.com; export ORACLE_HOSTNAME
ORACLE_UNQNAME=DB11G; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
ORACLE_SID=DB11G; export ORACLE_SID
DB_HOME=$ORACLE_BASE/product/11.2.0/db_1;export DB_HOME
ORACLE_TERM=xterm; export ORACLE_TERM
BASE_PATH=/usr/sbin:$PATH; export BASE_PATH
PATH=$ORACLE_HOME/bin:$BASE_PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
alias oraenv='. /home/oracle/.bash_profile'
# vi /etc/init.d/dbora
#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database software.
ORA_OWNER=oracle
case "$1" in
'start')
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c "/home/oracle/scripts/startup.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1"
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 "/home/oracle/scripts/shutdown.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1"
rm -f /var/lock/subsys/dbora
;;
esac
#chmod 750 /etc/init.d/dbora#chkconfig --add dbora
# mkdir -p /home/oracle/scripts
# chown oracle.oinstall /home/oracle/scripts
İzinlerini ayarladıktan sonra scriptlerin oluşturulacağı klasörleri oluşturduk.Daha sonra bu dizinde startup scriptini oluşturuyoruz
# vi /home/oracle/scripts/startup.sh
#!/bin/bash
export ORACLE_SID=DB11G
ORAENV_ASK=NO
. oraenv
ORAENV_ASK=YES
# Start Listener
lsnrctl start
# Start Database
sqlplus / as sysdba << EOF
STARTUP;
EXIT;
EOF
# Start Enterprise Manager
emctl start dbconsole
#Shutdown scriptini oluşturuyoruz
# vi /home/oracle/scripts/shutdown.sh
#!/bin/bash
export ORACLE_SID=DB11G
ORAENV_ASK=NO
. oraenv
ORAENV_ASK=YES
# Stop Enterprise Manager
emctl stop dbconsole
# Stop Listener
lsnrctl stop
# Stop Database
sqlplus / as sysdba << EOF
SHUTDOWN IMMEDIATE;
EXIT;
EOF
# chmod u+x /home/oracle/scripts/startup.sh
# chmod u+x /home/oracle/scripts/shutdown.sh
# chown oracle.oinstall /home/oracle/scripts/startup.sh
# chown oracle.oinstall /home/oracle/scripts/shutdown.sh
Service dbora start/stop komutuyla yazdığımız scripti kontrol ediyoruz.
iyi Çalışmalar
0 yorum:
Yorum Gönder