您的位置:首页 > 数据库 > Oracle

CentOS 6下 Oracle11gR2 设置开机自启动

2016-11-09 00:00 148 查看
[1] 更改/etc/oratab

# This file is used by ORACLE utilities.  It is created by root.sh # and updated by the Database Configuration Assistant when creating # a database. # A colon, ':', is used as the field terminator. A new line terminates # the entry. Lines beginning with a pound sign, '#', are comments. # # Entries are of the form: # $ORACLE_SID:$ORACLE_HOME:<N|Y>: # # 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. # # orcl:/usr/oracle/app/product/11.2.0/dbhome_1:Y


[2] oracle用户profile文件中增加SID环境变量

[root@oracledb oracle]#  vi /usr/oracle/.bash_profile


# 在文件末尾添加

export ORACLE_SID=orcl


[3] 创建启动Oracle的Init脚本

[root@oracledb oracle]# vi /etc/rc.d/init.d/oracle

# this is an example #!/bin/bash # oracle: Start/Stop Oracle Database 11g R2 # # chkconfig: 345 90 10 # description: The Oracle Database is an Object-Relational Database Management System. # # processname: oracle . /etc/rc.d/init.d/functions LOCKFILE=/var/lock/subsys/oracle ORACLE_HOME=/usr/oracle/app/product/11.2.0/dbhome_1 ORACLE_USER=oracle case "$1" in
'start') if [ -f $LOCKFILE ]; then
echo $0 already running. exit 1
fi
echo -n $"Starting Oracle Database:"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"
touch $LOCKFILE ;; 'stop') if [ ! -f $LOCKFILE ]; then
echo $0 already stopping. exit 1
fi
echo -n $"Stopping Oracle Database:"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
rm -f $LOCKFILE ;; 'restart') $0 stop $0 start ;; 'status') if [ -f $LOCKFILE ]; then
echo $0 started. else
echo $0 stopped. fi ;; *) echo "Usage: $0 [start|stop|status]" exit 1
esac exit 0


[4] 更改启动脚本权限

[root@oracledb oracle]#  chmod 755 /etc/rc.d/init.d/oracle


[5] 启动oracle数据库

[root@oracledb oracle]# service oracle start


[6] 关闭oracle数据库

[root@oracledb oracle]# service oracle stop


[7] 设置oracle为开机自启动

[root@oracledb oracle]# chkconfig oracle on [root@oracledb oracle]# chkconfig --list oracle oracle 0:关闭    1:关闭    2:启用    3:启用    4:启用    5:启用    6:关闭 [root@oracledb oracle]#


[8]重启电脑测试

原文地址:

CentOS Oracle11gR2 设置开机自启动
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: