[edgen@rhel54 ~]$ su - root
口令:
[root@rhel54 ~]# vi /etc/oratab
[root@rhel54 ~]# cat /etc/oratab | grep :Y
DB_INSTANCE_1:/app/oracle/product/10.2.0/db_1:Y
DB_INSTANCE_2:/app/oracle/product/10.2.0/db_1:Y
[root@rhel54 ~]# su - oracle
[oracle@rhel54 ~]$ vi $ORACLE_HOME/bin/dbstart
[oracle@rhel54 ~]$ cat $ORACLE_HOME/bin/dbstart | grep ORACLE_HOME_LISTNER=
ORACLE_HOME_LISTNER=$ORACLE_HOME
[oracle@rhel54 ~]$ cat $ORACLE_HOME/bin/dbshut | grep ORACLE_HOME_LISTNER
[oracle@rhel54 ~]$ exit
logout
[root@rhel54 ~]# vi /etc/rc.d/init.d/oradb
[root@rhel54 ~]# cat /etc/rc.d/init.d/oradb
#!/bin/bash
# chkconfig: 345 88 11
# description: Oracle 10g Startup Script
# /etc/rc.d/init.d/oradb
export ORACLE_BASE=/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export PATH=$PATH:$ORACLE_HOME/bin
ORACLE_OWNER="oracle"
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start, the executable dbstart file does not exist"
exit 1
fi
case "$1" in
start)
echo -n "Starting Oracle: "
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbstart"
touch /var/lock/subsys/oradb
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl start dbconsole"
echo "OK"
;;
stop)
echo -n "Shutdown Oracle: "
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbshut"
rm -f /var/lock/subsys/oradb
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: 'basename $0' start|stop|restart|reload"
exit 1
esac
exit 0
[root@rhel54 ~]# chown oracle:oinstall /etc/rc.d/init.d/oradb
[root@rhel54 ~]# chmod 775 /etc/rc.d/init.d/oradb
[root@rhel54 ~]# ll /etc/rc.d/init.d/oradb
-rwxrwxr-x 1 oracle oinstall 836 01-05 16:44 /etc/rc.d/init.d/oradb
[root@rhel54 ~]# chkconfig --add oradb
[root@rhel54 ~]# chkconfig --list | grep oradb
oradb 0:关闭 1:关闭 2:关闭 3:启用 4:启用 5:启用 6:关闭
[root@rhel54 ~]# ln -s /etc/rc.d/init.d/oradb /etc/rc3.d/K11oradb
[root@rhel54 ~]# ln -s /etc/rc.d/init.d/oradb /etc/rc4.d/K11oradb
[root@rhel54 ~]# ln -s /etc/rc.d/init.d/oradb /etc/rc5.d/K11oradb
[root@rhel54 ~]# /sbin/service oradb start
[root@rhel54 ~]# /sbin/service oradb stop