linux oracle10g自动启动关闭方法

 经过度娘搜索,网络的关于这个问题解决方法太多了,总结几个自己亲测的。

自动启动:

方法:1           a.  vi /etc/oratab

                           ORCL:/u01/app/oracle/product/1002/db:Y     修改这一行为Y

                         b.修改dbstart

                            vi $ORACLE_HOME/bin/dbstart

                            将ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle这一行改为: ORACLE_HOME_LISTNER=$ORACLE_HOME

                       c.vi /etc/rc.local   加入这一行

                           su - oracle -c "dbstart"

方法:2      a.  vi orastart.sh

                    #!/bin/sh
                   echo "begin to start oracle"
                   su - oracle -c "lsnrctl start"
                   su - oracle -c "sqlplus / as sysdba"<<EOF  
                   startup open;
                   exit
                   EOF
                 # end 

                 b.chmod a+x orastart.sh

                 c.vi /etc/rc.local 加入这一行

                   /u01/script/orastart.sh

方法:3   a.  vi /etc/rc.d/init.d/orastart

                  #!/bin/sh
                  #chkconfig:2345 80 05
                  #description: Oracle 10g start
                  echo "begin to start oracle"
                  su - oracle -c "lsnrctl start"
                  su - oracle -c "sqlplus / as sysdba"<<EOF  
                  startup open;
                  exit
                 EOF
                 #end

              b. chmod a+x orastart

              c.chkconfig --add orastart

              d.chkconfig --level 2345 on

               reboot 查看

 方法4.  a.  vi dbstart

                  cat /u01/sc/dbstart.sh

             b. chmod a+x dbstart.sh

             c. 在Linux中,检查/etc/inittab默认的启动级别,一般运行级别为3,id:3:initdefault:

                   #ln -s /etc/dbstart.sh /etc/rc.d/rc3.d/S99dbstart

              K开头的代表系统关闭的时候执行,S开头的代表开机的时候执行,99代表运行顺序,注意服务器脚本编写的规范,因为有K开通的软链接并不一定会在关机的时候自动去执行,执行K脚本的时候会查询/var/lock/subsys/下是否有与K开头脚本同名的空文件名,如果没有就不去执行,所以要按照服务器脚本编写的规范,启动的时候要在/var/lock/subsys/先touch一个与K01后面同名的空文件.

              reboot

 

 

关闭方法:

          方法1.

              a.  vi orastop

                 #!/bin/sh
                 echo "begin to stop oracle"
                 su - oracle -c "lsnrctl stop"
                 su - oracle -c "sqlplus / as sysdba"<<EOF  
                 shutdown immediate;
                exit
                EOF
               #end

              b.chmod a+x orastop

              c.  #ln -s /u01/script/orastop/etc/rc.d/rc0.d/K01orastop

                   #ln -s /u01/script/orastop  /etc/rc.d/rc6.d/K01orastop

      方法2: (这个方法个人推荐 ,可以实现在开关机,启动关闭数据库,)

            a. vi /etc/init.d/oracle

               #!/bin/bash
               #chkconfig:2345 96 01
               #description: Oracle 10g Server

               case $1 in
                  start)
                  su - oracle -c "dbstart"
                  touch /var/lock/subsys/oracle
                  ;;
                 stop)
                 su - oracle -c "dbshut"
                 su - oracle -c "lsnrctl stop" 
                 ;;
            esac

      b.chmod a+x oracle

      c.chkconfig --add oracle

      d.chkconfig --level 35 oracle on

      e.
 

 

 

      reboot

你可能感兴趣的:(linux,职场,oracle10g,休闲,自动启动关闭方法)