1修改oratab文件
vi /etc/oratab
#把后台一行的N改为Y
db01:/usr/oracle/app/product/11.2.0/dbhome_1:Y
2如果安装时/home/oracle/.bash_profile没加export ORACLE_SID=orcl,则要加上(/home/oracle/.bash_profile中的oracle为oracle的用户)
3编辑服务文件,加入开机启动
#!/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和ORACLE_USER变量为自己安装环境的实际变量
ORACLE_HOME=/data/oracle/product/12.1.0/db_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/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/dbshut $ORACLE_HOME"
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