1. The arrangement allows the system automatically starts ORACLE
modifications root user / etc / oratab file
vim /etc/oratab
The original data
modified data, you can save out
2. Switch the two files oracle user settings
su - oracle
Modify the $ ORACLE_HOME / bin / dbstart file
vim $ORACLE_HOME/bin/dbstart
After opening the file find the line indicated by the arrow, will ORACLE_HOME_LISTNER =
ORACLE_HOME. Save out
Modify the $ ORACLE_HOME / bin / dbshut file
vim $ORACLE_HOME/bin/dbshut
After opening the file find the line indicated by the arrow, will ORACLE_HOME_LISTNER =
ORACLE_HOME. Save out
3. Write a script, registered as a system service, let it run at startup and shutdown time, the role is called and executed dbstart and dbshu
root user to create a script in the /etc/init.d directory. My name is created oracle_auto
vi /etc/init.d/oracle_auto
When this command is executed nothing inside, the following commands to write into it. Save out
#!/bin/bash
# chkconfig: 2345 99 01
# description:Startup Script for oracle Databases
#/etc/rc.d/init.d/oracle_auto
ORACLE_HOME=/home/u01/app/oracle/product/11.2.0/dbhome_1
###显示打印日志的时间
DATE=`date "+%Y-%m-%d %H:%M:%S"`
if [ ! -f $ORACLE_HOME/bin/dbstart ]
then
echo "-----oracle cannot start-----"
exit
fi
if [ ! -f $ORACLE_HOME/bin/lsnrctl]
then
echo "-----lsnrctl cannot start-----"
exit
fi
case "$1" in
'start')
echo "-----startup oracle-----">> /var/log/oraclelog.log
su - oracle -c "$ORACLE_HOME/bin/dbstart"
touch /var/lock/subsys/oracle_auto
echo "-----startup oracle successful-----">> /var/log/oraclelog.log
echo "${DATE}">> /var/log/oraclelog.log
echo "OK"
;;
'stop')
echo "-----shutdown oracle-----">> /var/log/oraclelog.log
su - oracle -c "$ORACLE_HOME/bin/dbshut"
rm -f /var/lock/subsys/oracle_auto
echo "-----shutdown oracle successful-----">> /var/log/oraclelog.log
echo "${DATE}">> /var/log/oraclelog.log
echo "OK"
;;
reload|restart)
$0 stop
$1 start
;;
*)
echo "usage:'basename $0' start|stop|reload|restart"
exit 1
esac
exit 0
To assign permissions script can be executed
chown oracle /etc/init.d/oracle_auto
chmod 775 /etc/init.d/oracle_auto
Verify whether the script successfully set
service oracle_auto start
View log, have confidence in the success of representation
cat /var/log/oraclelog.log
Let the system automatically starts with the script
chkconfig oracle_auto on
View Setup Results
chkconfig oracle_auto --list
This setup is complete, reboot to test it