Oracle10gr2 开机自启动脚本
【摘要】 目录
目录软件环境Oracle服务启动停止重启脚本
软件环境
操作系统 RHEL6.1软件 Oracle10gr2
Oracle服务启动、停止、重启脚本
su - oracle
cd /u01/oracle/bin
#进入到Oracle安装的home目录下bin目录中123
创建启动脚本: 在/u01/oracle/bin下创建启...
目录
软件环境
- 操作系统
- RHEL6.1
- 软件
- Oracle10gr2
Oracle服务启动、停止、重启脚本
su - oracle
cd /u01/oracle/bin
#进入到Oracle安装的home目录下bin目录中
- 1
- 2
- 3
创建启动脚本:
在/u01/oracle/bin
下创建启停脚本。
vim dbstartup
#!/bin/bash lsnrctl start #启动监听程序 sqlplus /nolog <<EOF connect / as sysdba startup #进入到Oracle并且连接到SYS管理员账户,执行启动Database EOF
- 1
- 2
- 3
- 4
- 5
- 6
- 7
vi dbstop
#!/bin/bash lsnrctl stop sqlplus /nolog <<EOF connect / as sysdba shutdown immediate EOF
- 1
- 2
- 3
- 4
- 5
- 6
赋予执行权限
chmod +x dbstartup
chmod +x dbstop
- 1
- 2
进入到root用户:
su - root
cd /etc/rc.d/init.d
- 1
- 2
创建oracle服务管理脚本:
oracle脚本调用了上面的dbstartup
和dbstop
脚本,可以实现在root用户下启动、停止、重启Oracle服务,并且能够通过/var/log/oracle
查看启动日志。
vi oracle
#!/bin/bash case "$1" in start) echo "Starting Oracle Listener and Database ... " echo "----------------------------------------------------------------------" >> /var/log/oracle date +" %T %a %D : Starting Oracle Listener and Database ... " >> /var/log/oracle echo "----------------------------------------------------------------------" >> /var/log/oracle su - oracle -c dbstartup >> /var/log/oracle echo "Done." echo "" echo "---------------------------------------------------------------------" >> /var/log/oracle date +" %T %a %D :Finished." >>/var/log/oracle echo "---------------------------------------------------------------------" >> /var/log/oracle touch /var/lock/subsys/oracle ;; stop) echo "Stop Oracle Database and Listener ... " echo "---------------------------------------------------------------------" >> /var/log/oracle date +" %T %a %D : Stop Oracle Listener and Databases ..." >> /var/log/oracle echo "---------------------------------------------------------------------" >> /var/log/oracle su - oracle -c dbstop >> /var/log/oracle rm -f /var/lock/subsys/oracle echo "Done." echo "" echo "---------------------------------------------------------------------" >> /var/log/oracle date +" %T %a %D : Finished." >> /var/log/oracle echo "---------------------------------------------------------------------" >> /var/log/oracle ;; restart) echo "Restarting Oracle Listener and Database ..." echo "---------------------------------------------------------------------" >> /var/log/oracle date +" %T %a %D : Restart ing Oracle Listener and Databases ..." >> /var/log/oracle echo "---------------------------------------------------------------------" >> /var/log/oracle su - oracle -c dbstop >> /var/log/oracle su - oracle -c dbstartup >> /var/log/oracle echo "Done." echo "" echo "---------------------------------------------------------------------" >> /var/log/oracle date +" %T %a %D : Finished." >> /var/log/oracle echo "---------------------------------------------------------------------" >> /var/log/oracle touch /var/lock/subsys/oracle ;; *) echo "Usage: oracle {start|stop|restart}" exit 1 esac
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
赋予执行权限:
chmod +x oracle
- 1
测试:
[root@jmilk init.d]# /sbin/service oracle restart
Restarting Oracle Listener and Database ...
Done
- 1
- 2
- 3
创建进程链接文件:
[root@jmilk init.d]# ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc3.d/K01oracle
[root@jmilk init.d]# ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc3.d/S99oracle
[root@jmilk init.d]# ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc5.d/K01oracle
[root@jmilk init.d]# ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc5.d/S99oracle
[root@jmilk init.d]# ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc0.d/K01oracle
[root@jmilk init.d]# ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc6.d/K01oracle
- 1
- 2
- 3
- 4
- 5
- 6
自动启动实例:
vi /etc/oratab
demo:/u01/oracle:Y #把N改为Y
- 1
文章来源: is-cloud.blog.csdn.net,作者:范桂飓,版权归原作者所有,如需转载,请联系作者。
原文链接:is-cloud.blog.csdn.net/article/details/51576362
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)