首页 > 代码库 > Teamcenter10 step-by-step installation in Linux env-Oracle services startup and shutdown

Teamcenter10 step-by-step installation in Linux env-Oracle services startup and shutdown

After following the first three posts about Oracle installation, you should finish installing Oracle successfully. We will further discuss how to start up and shutdown Oracle related services manually and automatically in this post.

Manually

1) Start up

Login as oracle user and start sqlplus utility.

image

SQL > startup

image

Start Oracle listener

image

Start emctl (Optional)

$ emctl start dbconsole

image

Start web browser and log into the console

image

2) Shutdown

Login as oracle user and start sqlplus utility.

image

Stop listener

image

Stop Oracle server

SQL > shutdown immediate

image

Stop emctl

$ emctl stop dbconsole

image

Automatically

1) Modify Oracle system configuration to enable dbstart and dbshut

$su - oracle   $vi /etc/oratab

 image

2) Create Oracle startup&shutdown script in /etc/init.d. The sample script is attached below.

#!/bin/sh#chkconfig: 35 80 99 # 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.ORA_HOME=/pdm/db/oracle/product/11.2.0/dbhome_1ORA_OWNER=oracleif [ ! -f $ORA_HOME/bin/dbstart ]then    echo "Oracle startup: cannot start"    exitficase "$1" instart)# Start the Oracle databases:echo "Starting Oracle Databases and listener ... "echo "-------------------------------------------------" >> /var/log/oracledate +" %T %a %D : Starting Oracle Databases as part of system up." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oraclesu - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME" >>/var/log/oracleecho "Done"# Start the Listener:#echo "Starting Oracle Listeners ... "#echo "-------------------------------------------------" >> /var/log/oracle#date +" %T %a %D : Starting Oracle Listeners as part of system up." >> /var/log/oracle#echo "-------------------------------------------------" >> /var/log/oracle#su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" >>/var/log/oracle#echo "Done."#echo "-------------------------------------------------" >> /var/log/oracledate +" %T %a %D : Finished." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oracletouch /var/lock/subsys/oracle;;stop)# Stop the Oracle Listener:#echo "Stoping Oracle Listeners ... "#echo "-------------------------------------------------" >> /var/log/oracledate +" %T %a %D : Stoping Oracle Listener and Server as part of system down." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oracle#su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" >>/var/log/oracle#echo "Done."rm -f /var/lock/subsys/oracle# Stop the Oracle Database:echo "Stoping Oracle Databases and Listener... "echo "-------------------------------------------------" >> /var/log/oracledate +" %T %a %D : Stoping Oracle Databases as part of system down." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oraclesu - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME" >>/var/log/oracleecho "Done."echo ""echo "-------------------------------------------------" >> /var/log/oracledate +" %T %a %D : Finished." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oracle;;restart)$0 stop$0 start;;esac

3)Change script mode to 755

# chmod 755 /etc/init.d/oracle

4) Add oracle service

# chkconfig –level 35 oracle on

5)Create symbolic links for oracle shutdown on run level 0 and 6

#for run level 0 (shutdown)
# ln -s /etc/init.d/oracle /etc/rc0.d/K99oracle   # for run level 6 (restart)
# ln -s /etc/init.d/oracle /etc/rc6.d/K99oracle

Reference Material

The following urls are useful about Oracle services startup and shutdown.

http://www.cnblogs.com/panjun-Donet/archive/2010/08/10/1796873.html   (Linux下chkconfig命令详解)

http://www.cnblogs.com/mchina/archive/2012/11/27/2782993.html (Linux Oracle服务启动&停止脚本与开机自启动)

http://www.linuxidc.com/Linux/2007-06/4892.htm (实现linux在关机或重启时自动执行某个任务)

http://wenku.baidu.com/link?url=sK_FphbS_rtO_BkbpshLzJRxLu76s3bWWrgtAqlh540f4CNnRcQr5PffiRGd-eVZCjffcBPs8_kmM3junDNrLenQel0ltaRWUSwI0OiuGRO

http://www.cnblogs.com/bangerlee/archive/2012/03/30/2412652.html (Linux进程托管与守护进程设置)