日期:2014-05-16 浏览次数:20738 次
参考自(亲自试验,并稍作修改):
http://www.oracle-base.com/articles/linux/automating-database-startup-and-shutdown-on-linux.php
support.filecatalyst.com/index.php?/Knowledgebase/Article/View/210/0/starting-tomcat-as-a-linux-service
tomcat加入服务并设置自启动在另一篇:http://blog.csdn.net/zxnlmj/article/details/22933477
oracle数据库安装见:http://blog.csdn.net/zxnlmj/article/details/22826149
1、编辑/etc/oradb文件,将每个数据库实例的重启标志由N都设置为Y:
su root gedit /etc/oratab
# The first and second fields are the system identifier and home # directory of the database respectively. The third filed indicates # to the dbstart utility that the database should , "Y", or should not, # "N", be brought up at system boot time. # # Multiple entries with the same $ORACLE_SID are not allowed. # # sunlight:/home/oracle/product/11.2/db_1:Y
2、新建/etc/init.d/oracle文件,并添加如下配置:
su root: gedit /etc/init.d/oracle
添加如下内容:
#!/bin/sh # chkconfig: 345 99 10 # description: Oracle auto start-stop script. # # Set ORA_OWNER to the user id of the owner of the # Oracle database software. # ORA_OWNER为在linux中安装oracle数据库时建立的属于dba组的用户名oracle,而非登陆oracle数据库时的用户名 ORA_OWNER=oracle case "$1" in 'start') # Start the Oracle databases: # The following command assumes that the oracle login # will not prompt the user for any values # Remove "&" if you don't want startup as a background process. su $ORA_OWNER -c "/home/oracle/scripts/startup.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1" & touch /var/lock/subsys/dbora ;; 'stop') # Stop the Oracle databases: # The following command assumes that the oracle login # will not prompt the user for any values su $ORA_OWNER -c "/home/oracle/scripts/shutdown.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1" rm -f /var/lock/subsys/dbora ;; esac
su root [root@JTWF Desktop]# chmod 750 /etc/init.d/oracle
[root@JTWF Desktop]# chkconfig --add oracle [root@JTWF Desktop]#
# mkdir -p /home/oracle/scripts # chown oracle.oinstall /home/oracle/scripts [root@JTWF Desktop]# chown oracle.dba /home/oracle/scripts
#!/bin/bash export TMP=/tmp export TMPDIR=$TMP export PATH=/usr/sbin:/usr/local/bin:$PATH export ORACLE_HOSTNAME=JTWF #export ORACLE_UNQNAME=db12c export ORACLE_SID=sunlight ORAENV_ASK=NO . oraenv ORAENV_ASK=YES # Start Listener lsnrctl start # Start Database sqlplus / as sysdba << EOF STARTUP; EXIT; EOF
#!/bin/bash export TMP=/tmp export TMPDIR=$TMP export PATH=/usr/sbin:/usr/local/bin:$PATH export ORACLE_HOSTNAME=