oracle随linux OS自动启动与关闭

来源:互联网 发布:淘宝的图片怎么做 编辑:程序博客网 时间:2024/06/07 07:05

在linux 上装的oracle ,每次开机都要手动启动oracle服务,想做到自动环境:rhel 5   linux +oracle 10g

—–NOW BEGIN—————-

用root 登录

1,vi /etc/oratab;

内容如下,orcl换成本机的实例名,Y为开机启动
+ASM:/u01/app/oracle/product/10.2.0/db_1:N  -----没ASM这部省略
orcl:/u01/app/oracle/product/10.2.0/db_1:Y

2,在/etc/init.d 下新建一文件create an file ,

touch /etc/init.d/oracle10g

3,oracle10g 内容

vi /etc/init.d/oracle10g

—复制一下内复到oracle10g中如果oracle_home不同,只需要修改一下ORACLE_HOME

# description: Oracle auto start-stop script.## Set ORACLE_HOME to be equivalent to the $ORACLE_HOME# from which you wish to execute dbstart and dbshut;## Set ORA_OWNER to the user id of the owner of the# Oracle database in ORACLE_HOME.ORACLE_HOME=/oracle/product/10.2.0/db_1ORA_OWNER=oracleif [ ! -f $ORACLE_HOME/bin/dbstart ]then    echo "Oracle startup: cannot start" >>/tmp/ora_start.log    exitficase "$1"  in    start)        # Start the Oracle databases:        # The following command assumes that the oracle login        # will not prompt the user for any values        su - $ORA_OWNER -c "$ORACLE_HOME/bin/lsnrctl start"        su - $ORA_OWNER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"        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 "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"        su - $ORA_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop"        rm -f /var/lock/subsys/dbora        ;;*)echo "Usage: $0 {start|stop|restart}"exit 1esac

-----------完 ,!wq 保存吧-------
Notice:

网页可能因为编码原因,注意修改ORACLE_HOME为你自己的环境,注意全角引号和- 的手动替换一下。
4,文件权限

chgrp dba oracle10g
chmod 750 oracle10g

5,建立软链接

# ln -s /etc/init.d/oracle10g     /etc/rc.d/rc3.d/K01oracle10g

# ln -s /etc/init.d/oracle10g    /etc/rc.d/rc3.d/S99oracle10g

# ln -s /etc/init.d/oracle10g    /etc/rc.d/rc5.d/K01oracle10g

# ln -s /etc/init.d/oracle10g    /etc/rc.d/rc5.d/S99oracle10g

 

重启操作系统试试吧

原创粉丝点击