linux手动或者自动启动oracle11g的服务 Oracle 自动启动脚本
2016-04-28 14:03
621 查看
手动启动:
[oracle@localhost ~]$ sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 26 23:39:52 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Enter user-name: sys as sysdba
Enter password:
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 496881664 bytes
Fixed Size 2214696 bytes
Variable Size 377488600 bytes
Database Buffers 113246208 bytes
Redo Buffers 3932160 bytes
Database mounted.
Database opened.
SQL>
Oracle 自动启动脚本
1. 修改Oracle系统配置文件:/etc/oratab,只有这样,Oracle 自带的dbstart和dbshut才能够发挥作用。N修改为Y
vi /etc/oratab
orcl:/ /home/oracle/app/oracle/product/11.2.0/dbhome_1:Y
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
修改vi /etc/init.d/oracle
如已存在需要检查
ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1
对不对。
不存在的话把以下内容加入:
#!/bin/sh
#chkconfig: 2345 20 80
#description: Oracle dbstart / dbshut
#以上两行为chkconfig所需
ORA_HOME=/home/ oracle /app/oracle/product/11.2.0/dbhome_1
ORA_OWNER= oracle
LOGFILE=/var/log/oracle.log
echo "#################################" >> ${LOGFILE}
date +"### %T %a %D: Run Oracle" >> ${LOGFILE}
if [ ! -f ${ORA_HOME}/bin/dbstart ] || [ ! -f ${ORA_HOME}/bin/dbshut ]; then
echo "Error: Missing the script file ${ORA_HOME}/bin/dbstart or ${ORA_HOME}/bin/dbshut!" >> ${LOGFILE}
echo "#################################" >> ${LOGFILE}
exit
fi
start(){
echo "###Startup Database..."
su - ${ORA_OWNER} -c "${ORA_HOME}/bin/dbstart ${ORA_HOME}"
echo "###Done."
echo "###Run database control..."
su - ${ORA_OWNER} -c "${ORA_HOME}/bin/emctl start dbconsole"
echo "###Done."
}
stop(){
echo "###Stop database control..."
su - ${ORA_OWNER} -c "${ORA_HOME}/bin/emctl stop dbconsole"
echo "###Done."
echo "###Shutdown Database..."
su - ${ORA_OWNER} -c "${ORA_HOME}/bin/dbshut ${ORA_HOME}"
echo "###Done."
}
case "$1" in
'start')
start >> ${LOGFILE}
;;
'stop')
stop >> ${LOGFILE}
;;
'restart')
stop >> ${LOGFILE}
start >> ${LOGFILE}
;;
esac
date +"### %T %a %D: Finished." >> ${LOGFILE}
echo "#################################" >> ${LOGFILE}
echo ""
3. 改变文件权限
chmod 755 /etc/init.d/oracle
4. 添加服务
chkconfig --level 35 oracle on
5. 测试
重启系统sqlplus查看
6. 使用方法
# service oracle start //启动oracle
# service oracle stop //关闭oracle
# service oracle restart //重启oracle
[oracle@localhost ~]$ sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 26 23:39:52 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Enter user-name: sys as sysdba
Enter password:
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 496881664 bytes
Fixed Size 2214696 bytes
Variable Size 377488600 bytes
Database Buffers 113246208 bytes
Redo Buffers 3932160 bytes
Database mounted.
Database opened.
SQL>
Oracle 自动启动脚本
1. 修改Oracle系统配置文件:/etc/oratab,只有这样,Oracle 自带的dbstart和dbshut才能够发挥作用。N修改为Y
vi /etc/oratab
orcl:/ /home/oracle/app/oracle/product/11.2.0/dbhome_1:Y
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
修改vi /etc/init.d/oracle
如已存在需要检查
ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1
对不对。
不存在的话把以下内容加入:
#!/bin/sh
#chkconfig: 2345 20 80
#description: Oracle dbstart / dbshut
#以上两行为chkconfig所需
ORA_HOME=/home/ oracle /app/oracle/product/11.2.0/dbhome_1
ORA_OWNER= oracle
LOGFILE=/var/log/oracle.log
echo "#################################" >> ${LOGFILE}
date +"### %T %a %D: Run Oracle" >> ${LOGFILE}
if [ ! -f ${ORA_HOME}/bin/dbstart ] || [ ! -f ${ORA_HOME}/bin/dbshut ]; then
echo "Error: Missing the script file ${ORA_HOME}/bin/dbstart or ${ORA_HOME}/bin/dbshut!" >> ${LOGFILE}
echo "#################################" >> ${LOGFILE}
exit
fi
start(){
echo "###Startup Database..."
su - ${ORA_OWNER} -c "${ORA_HOME}/bin/dbstart ${ORA_HOME}"
echo "###Done."
echo "###Run database control..."
su - ${ORA_OWNER} -c "${ORA_HOME}/bin/emctl start dbconsole"
echo "###Done."
}
stop(){
echo "###Stop database control..."
su - ${ORA_OWNER} -c "${ORA_HOME}/bin/emctl stop dbconsole"
echo "###Done."
echo "###Shutdown Database..."
su - ${ORA_OWNER} -c "${ORA_HOME}/bin/dbshut ${ORA_HOME}"
echo "###Done."
}
case "$1" in
'start')
start >> ${LOGFILE}
;;
'stop')
stop >> ${LOGFILE}
;;
'restart')
stop >> ${LOGFILE}
start >> ${LOGFILE}
;;
esac
date +"### %T %a %D: Finished." >> ${LOGFILE}
echo "#################################" >> ${LOGFILE}
echo ""
3. 改变文件权限
chmod 755 /etc/init.d/oracle
4. 添加服务
chkconfig --level 35 oracle on
5. 测试
重启系统sqlplus查看
6. 使用方法
# service oracle start //启动oracle
# service oracle stop //关闭oracle
# service oracle restart //重启oracle
相关文章推荐
- linux redhat6.4安装oracle11g
- oracle创建表空间
- 利用DB Link实现Oracle两个数据库间的表同步
- CentOS7中oracle11g备份脚本
- Oracle查看连接数、表空间大小及使用率
- Oracle 配置transparent gateway(透明网关)连接sqlserver数据库(gateway安装在sqlserver服务器)
- CentOS6.5x64采用静默模式安装64位oracle11g
- Oracle使用Mybatis实现List批量插入数据
- Python访问Oracle
- oracle导入dmp文件命令、sql文件命令, Oracle用户的新增、修改、删除及授权
- java web项目与oracle rac连接JNDI
- oracle使用exp导出时不导出空表解决方法
- oracle.jbo.JboException: JBO-29000: JBO-29000: Bad version number in .class file
- ORACLE 11G R2 DGBROKER 之总结
- oracle+mybatis 使用动态Sql当插入字段不确定的情况下实现批量insert
- oracle字符集设置
- Oracle sql日期比较和常用日期函数整理(全)
- 使用MySQL Migration Toolkit快速将Oracle数据导入MySQL
- Building Your First Process with Oracle BPM 11g
- Oracle update 两表及以上关联更新,出现多值情况,不是一对一更新