oracle 10g/11g/11gR2自动启动关闭脚本
本文中使用的oracle是11gR2
第一个:设置环境变量
[oracle@tedb ~]$ cat /home/oracle/.11g
# .11g export DISPLAY=:0.0 xhost + export ORACLE_BASE=/db/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1 export ORACLE_SID=MISS export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
第二个:开起启动oracle脚本
[oracle@tedb ~]$ cat /home/oracle/start11g
#!/bin/bash source /home/oracle/.11g lsnrctl start; sqlplus / as sysdba < <EOF startup EOF
第三个:关闭oracle脚本
[oracle@tedb ~]$ cat /home/oracle/shutdown11g
#!/bin/bash source /home/oracle/.11g sqlplus / as sysdba < <EOF shutdown immediate EOF lsnrctl stop;
第四个:oracle开启关闭服务脚本
[root@tedb ~]# cat /etc/init.d/oracle
#! /bin/bash # # oracle Bring up/down oracle # # chkconfig: 2345 90 1 #90为启动权值较低 1为关闭权值最高,即保证oracle后开启早关闭 # description: oracle start at boot time. # . /etc/init.d/functions case "$1" in start) su - oracle -c "/home/oracle/start11g" ;; stop) su - oracle -c "/home/oracle/shutdown11g" ;; *) echo $"Usage: $0 {start|stop}" exit 1 esac
最后再添加三个脚本的执行权限并设置oracle开机启动
[root@tedb ~]# chmod +x /home/oracle/start11g [root@tedb ~]# chmod +x /home/oracle/shutdown11g [root@tedb ~]# chmod +x /etc/init.d/oracle [root@tedb ~]# chkconfig oracle on
10g和11g等版本设置类似!
到这里,你的oracle服务就会随着计算机的开关机而启动关闭啦!
更多oracle相关内容请点此查看http://www.icesr.com/index.php/archives/category/data/oracle
未经允许不得转载:SRE空间 » linux下建立oracle 10g/11g/11gR2自动启动关闭脚本
评论前必须登录!
注册