方法一:使用Oracle自带的启动和关闭脚本<?XML:NAMESPACE PREFIX = O />1. oracle用户修改/etc/oratab 文件:$ vi /etc/orataborcl:/oracle/app/product/<?XML:NAMESPACE PREFIX = ST1 />10.2.0/db_1:N改为:orcl:/oracle/app/product/10.2.0/db_1:Y也就是将最后的N改为Y,允许在系统启动时运行dbstart启动数据库。2. oracle用户修改$ORACLE_HOME/bin/dbstart文件:# su - oracle$ cd $ORACLE_HOME/bin$ vi dbstart找到 ORACLE_HOME_LISTNER=.....这行, 修改成ORACLE_HOME_LISTNER=/u01/app/oracle/product/10.1.0/db_1或者直接修改成:ORACLE_HOME_LISTNER=$ORACLE_HOME3. 测试运行 dbshut, dbstart 看能否启动oracle 服务及listener服务:3.1. 执行相应的脚本进行测试#su - oracle$cd $ORACLE_HOME/bin$./dbstart (启动数据库和监听)$ ps -efw | grep ora_ (查看数据库进程是否启动)$ lsnrctl status (查看监听状态) $ ps -efw | grep LISTEN | grep -v grep (查看监听进程,去除grep查询本身)$./dbshut (关闭数据库,监听不会关闭,需要手动停止) 3.2. 修改dbstart和dbshut的日志文件的权限:$su - root#cd $ORACLE_HOME#chown oracle:oinstall startup.log#chown oracle:oinstall shutdown.log注:startup.log 和shutdown.log 可能没有,当你运行 ./dbstart 和 ./dbshut 之后才自动创建。 4. 创建服务$su - root# cd /etc/rc.d/init.d/# vi oracle (oracle为将安装到系统的服务名,可任取)有两种脚本可选,启动内容不同。根据自己的环境修改环境变量配置部分(蓝色字体位置)脚本1(启动数据库、监听、dbconsole、sqlplus)以下红色字体的3行是必需的345:定义运行级别 80:开机时服务启动优先级(数字越小启动越早) 10:关机时服务停止优先级(数字越小关闭越早)#!/bin/bash# chkconfig: 345 80 10# description: Startup Script for oracle Databases# /etc/rc.d/init.d/oracleexport ORACLE_BASE=/u01/oracleexport ORACLE_HOME=/u01/oracle/productexport ORACLE_SID=paexport PATH=$PATH:$ORACLE_HOME/binORA_OWNR="oracle"# if the executables do not exist -- display errorif [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]thenecho "oracle startup: cannot start"exit 1fi# depending on parameter -- startup, shutdown, restart# of the instance and listener or usage displaycase "$1" instart)# oracle listener and instance startupecho -n "Starting oracle: "su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart"touch /var/lock/oraclesu - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctl start"echo "OK";;stop)# oracle listener and instance shutdownecho -n "Shutdown oracle: "su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctl stop"su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut"su - $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"rm -f /var/lock/oracleecho "OK";;reload|restart)$0 stop$0 start;;*)echo "Usage: `basename $0` start|stop|restart|reload"exit 1esacexit 0 脚本2(只启动数据库和监听)以下红色字体的3行是必需的345:定义运行级别 80:开机时服务启动优先级(数字越小启动越早) 10:关机时服务停止优先级(数字越小关闭越早)#!/bin/bash# chkconfig: 345 80 10# description: Startup Script for oracle Databases# /etc/rc.d/init.d/oracleexport ORACLE_BASE=/u01/oracleexport ORACLE_HOME=/u01/oracle/productexport ORACLE_SID=paexport PATH=$PATH:$ORACLE_HOME/bincase "$1" instart)su oracle -c $ORACLE_HOME/bin/dbstarttouch /var/lock/oracleecho "OK";;stop)echo -n "Shutdown oracle: "su oracle -c $ORACLE_HOME/bin/dbshutrm -f /var/lock/oracleecho "OK";;*)echo "Usage: "basename $0" start|stop"exit 1esacexit 0保存退出。打开终端执行:$su - root#chown oracle.oinstall /etc/rc.d/init.d/oracle#chmod 775 /etc/rc.d/init.d/oracle然后执行:#chkconfig --add oracle或者运行如下命令#chkconfig --level 345 oracle on#chkconfig --list oracle正常输出:oracle 0:off 1:off 2:off 3:on 4:on 5:on 6:offUbuntu 10.10 源码安装MySQL 5.1.34Oracle分区表新增主分区及子分区语句相关资讯 oracle
- [INS-32052] Oracle基目录和Oracle (07/22/2014 07:41:41)
- Oracle 4个大对象(lobs)数据类型 (02/03/2013 12:33:05)
- Oracle按时间段分组统计 (07/26/2012 10:36:48)
| - [Oracle] dbms_metadata.get_ddl的 (07/12/2013 07:37:30)
- Liferay Portal 配置使用Oracle和 (07/31/2012 20:07:18)
- Concurrent Request:Inactive (07/20/2012 07:44:05)
|
本文评论 查看全部评论 (0)