以oracle 10g为例,oracle软件安装完后已经提供了数据库的启动脚本,我们只要自己写一个脚本调用它的脚本就可以了。
涉及的文件有:
/etc/oratab
$ORACLE_HOME/bin下的两个脚本,dbstart和dbshut
编辑配置文件:
vim /etc/oratab
将:
orcl:/u01/oracle/product/10.2.0/db_1:N
改为:
orcl:/u01/oracle/product/10.2.0/db_1:Y
随后最简单的方法,在/etc/rc.local中加入:
su - oracle -c "/u01/oracle/product/10.2.0/db_1/bin/dbstart"
su - oracle -c "/u01/oracle/product/10.2.0/db_1/bin/lsnrctl start"
在/var/log/boot.log里可以看到两个命令的执行结果。
在/u01/oracle/product/10.2.0/db_1/startup.log里可以看到dbstart的执行日志。
当然也可以做一个启动脚本,把脚本加到系统服务中:
http://blog.chinaunix.net/uid-25266990-id-2197669.html
http://blog.chinaunix.net/uid-20785090-id-1844422.html
参考资料:
http://dannyyuan.blog.51cto.com/212520/71733/
http://blog.csdn.net/kelly1984/article/details/8166316
—————分隔线—————
11xe版自启动方法。
oracle 11xe版没有提供启动脚本,大概是因为精简的原因,只能自己写了:
vim /home/oracle.sh
加入:
#!/bin/bash
su - oracle -c "
sqlplus / as sysdba <<EOF
startup;
exit;
EOF
"
设置权限:
chmod 755 /home/oracle.sh
设置启动:
vim /etc/rc.local
加入:
/home/oracle.sh