Linux under the boot from the start oracle service

If the operating system should be carried out each time you restart the above operation good trouble, then how to make Oracle as a system service start automatically at boot time?

Oracle provides a number of scripts for database operations at $ ORACLE_HOME / bin, which can dbstart and dbshut are used to start and shut down the database. Note that this script already contains two listeners turned on or off, but not for EM related operations. Use the following command:

/opt/oracle/11g/bin/dbstart /opt/oracle/11g #启动数据库实例(包含监听器)
/opt/oracle/11g/bin/dbshut /opt/oracle/11g #关闭数据库实例(包括监听器)

The above command to successfully start the database instance Oracle had to open a checkpoint set: vi / etc / oratab, modify the line:

orcl:/opt/oracle/11g:Y #默认为orcl:/opt/oracle/11g:N

The establishment of start-up script oracle service as root: vi /etc/init.d/oracle, add the following script:

#!/bin/sh
#chkconfig: 2345 20 80
#description: Oracle dbstart / dbshut
#以上两行为chkconfig所需
ORA_HOME=/opt/oracle/11g
ORA_OWNER=oracle
LOGFILE=/var/log/oracle.log
echo "#################################" >> ${LOGFILE}
date +"### %T %a %D: Run Oracle" >> ${LOGFILE}
if [ ! -f ${ORA_HOME}/bin/dbstart ] || [ ! -f ${ORA_HOME}/bin/dbshut ]; then
    echo "Error: Missing the script file ${ORA_HOME}/bin/dbstart or ${ORA_HOME}/bin/dbshut!" >> ${LOGFILE}
    echo "#################################" >> ${LOGFILE}
    exit
fi
start(){
    echo "###Startup Database..."
    su - ${ORA_OWNER} -c "${ORA_HOME}/bin/dbstart ${ORA_HOME}"
    echo "###Done."
    echo "###Run database control..."
    su - ${ORA_OWNER} -c "${ORA_HOME}/bin/emctl start dbconsole"
    echo "###Done."
}
stop(){
    echo "###Stop database control..."
    su - ${ORA_OWNER} -c "${ORA_HOME}/bin/emctl stop dbconsole"
    echo "###Done."
    echo "###Shutdown Database..."
    su - ${ORA_OWNER} -c "${ORA_HOME}/bin/dbshut ${ORA_HOME}"
    echo "###Done."
}
case "$1" in
    'start')
        start >> ${LOGFILE}
    ;;
    'stop')
        stop >> ${LOGFILE}
    ;;
    'restart')
        stop >> ${LOGFILE}
        start >> ${LOGFILE}
    ;;
esac
date +"### %T %a %D: Finished." >> ${LOGFILE}
echo "#################################" >> ${LOGFILE}
echo ""

 

/Etc/init.d/oracle use the following command to set the executable file:

chmod a+x /etc/init.d/oracle

So far, the oracle can be started on and off using the following command

/etc/init.d/oracle start #启动oracle(包括数据库实例、监听器、EM)
/etc/init.d/oracle stop #关闭oracle
/etc/init.d/oracle restart #重启oracle

Adding to chkconfig oracle in:

chkconfig --add oracle

You can use the following commands to view and set the boot oracle service levels:

chkconfig | grep oracle #查看oracle服务的开机启动级别
chkconfig --level 24 oracle off #修改oracle服务的开机启动级别
chkconfig --level 35 oracle on

At this point you can use the following command to enable or disable the oracle of the management

service oracle start #启动
service oracle stop #关闭
service oracle restart #重启

 establish connection:

ln -s /etc/init.d/oracle /etc/rc0.d/K01oracle   #关机执行
ln -s /etc/init.d/oracle /etc/rc6.d/K01oracle   #重启执行

Reproduced in: https: //my.oschina.net/u/204616/blog/544976

Guess you like

Origin blog.csdn.net/weixin_34220179/article/details/91989258