当前位置: 首页 > 数据库 > oracle >

oracle数据库开机启动脚本

1. 启动数据库
 
[oracle@912616.cn ~]$ vim start10g
#!/bin/bash
source /home/oracle/.10g             #环境变量如果已写在.bash_profile里,这里可以去掉。下同
lsnrctl start;
sqlplus / as sysdba <<EOF
startup
EOF
[oracle@912616.cn ~]$ chmod +x ./start10g
 
2. 关闭数据库
 
[oracle@912616.cn ~]$ vim ./shutdown10g
#!/bin/bash
source /home/oracle/.10g          
sqlplus / as sysdba <<EOF
shutdown immediate
EOF
lsnrctl stop;
[oracle@912616.cn ~]$ chmod +x shutdown10g
 
3. 开机启动脚本
 
[root@912616.cn Desktop]# cp  /etc/init.d/network /etc/init.d/oracle
[root@912616.cn Desktop]# vi /etc/init.d/oracle
#! /bin/bash
#
# oracle       Bring up/down oracle
#
# chkconfig: 2345 90 1
# description: Activates/Deactivates all oracle  interfaces configured to
#              start at boot time.
#
 
# Source function library.
. /etc/init.d/functions
 
 
# See how we were called.
case "$1" in
  start)
su - oracle -c "source /home/oracle/start10g"
su - oracle -c "source /home/oracle/start11g"
;;
  stop)
su - oracle -c "source /home/oracle/shutdown10g"
su - oracle -c "source /home/oracle/shutdown11g"
;;
  *)
        echo $"Usage: $0 {start|stop}"
        exit 2
esac
 
exit $rc
[root@912616.cn Desktop]# chmod +x /etc/init.d/oracle
[root@912616.cn Desktop]# chkconfig oracle on
 
 
本地连接
 
[root@912616.cn Desktop]# su - oracle
[oracle@912616.cn ~]$ 10g
[oracle@912616.cn ~]$ ps -ef | grep ora_  | grep 10g
oracle    9915     1  0 14:32 ?        00:00:00 ora_pmon_wyzc10g
oracle    9917     1  0 14:32 ?        00:00:00 ora_psp0_wyzc10g
oracle    9919     1  0 14:32 ?        00:00:00 ora_mman_wyzc10g
oracle    9921     1  0 14:32 ?        00:00:00 ora_dbw0_wyzc10g
oracle    9923     1  0 14:32 ?        00:00:00 ora_lgwr_wyzc10g
oracle    9925     1  0 14:32 ?        00:00:00 ora_ckpt_wyzc10g
oracle    9927     1  0 14:32 ?        00:00:00 ora_smon_wyzc10g
oracle    9929     1  0 14:32 ?        00:00:00 ora_reco_wyzc10g
oracle    9931     1  0 14:32 ?        00:00:00 ora_cjq0_wyzc10g
oracle    9933     1  0 14:32 ?        00:00:00 ora_mmon_wyzc10g
oracle    9935     1  0 14:32 ?        00:00:00 ora_mmnl_wyzc10g
oracle    9937     1  0 14:32 ?        00:00:00 ora_d000_wyzc10g
oracle    9939     1  0 14:32 ?        00:00:00 ora_s000_wyzc10g
oracle    9949     1  0 14:32 ?        00:00:00 ora_qmnc_wyzc10g
oracle    9966     1  0 14:32 ?        00:00:00 ora_q000_wyzc10g
oracle    9968     1  0 14:32 ?        00:00:00 ora_q001_wyzc10g
oracle   12389     1  0 15:15 ?        
------分隔线----------------------------