write unix script and use "chkconfig" to add oracle as service
of the O.S.
1) make sure u have set all necessary for the owner of oracle,
and then create a script file named "oracleSrvc",and
using "chmod" to set access permission. the content of the file:
(surely there are many mistake,please correct them yourself)
-------------
#!/bin/sh
#the following line says that this service is involved in run
#level 345 and is the 90th service to start and the 1st
#service to stop
#chkconfig 345 90 1
case "$1" in
start)
su -l theoracleuser -c lsnrctl start
su -l theoracleuser -c svrmgrl <<!
connect internal
startup pfile=<the location of your pfile> open
!
touch /var/lock/subsys/oracle
;;
stop)
su -l theoracleuser -c svrmgrl <<!
connect internal
shutdown abort
!
su -l theoracleuser -c lsnrctl start
rm /var/lock/subsys/oracle
;;
restart)
$0 start
$0 stop
;;
esac
exit 0
OK,add the service to system: cp ./oracle /rc/init.d/oracle
chkconfig --add oracle
of the O.S.
1) make sure u have set all necessary for the owner of oracle,
and then create a script file named "oracleSrvc",and
using "chmod" to set access permission. the content of the file:
(surely there are many mistake,please correct them yourself)
-------------
#!/bin/sh
#the following line says that this service is involved in run
#level 345 and is the 90th service to start and the 1st
#service to stop
#chkconfig 345 90 1
case "$1" in
start)
su -l theoracleuser -c lsnrctl start
su -l theoracleuser -c svrmgrl <<!
connect internal
startup pfile=<the location of your pfile> open
!
touch /var/lock/subsys/oracle
;;
stop)
su -l theoracleuser -c svrmgrl <<!
connect internal
shutdown abort
!
su -l theoracleuser -c lsnrctl start
rm /var/lock/subsys/oracle
;;
restart)
$0 start
$0 stop
;;
esac
exit 0
OK,add the service to system: cp ./oracle /rc/init.d/oracle
chkconfig --add oracle
1、startdb正文如下
su - oracle <<EOF
svrmgrl
connect internal
startup
2、startlsn正文如下
su - oracle <<EOF
lsnrctl start
3、stopdb正文如下
su - oracle <<EOF
svrmgrl
connect internal
shutdown immediate
4、stoplsn 正文如下
su - oracle <<EOF
lsnrctl stop
5、修改文件执行属性:
chmod 711 startdb
chmod 711 startlsn
chmod 711 stopdb
chmod 711 stoplsn
6、创建链接:
ln -s /etc/init.d/startdb /etc/rc.d/rc5.d/S99dbstart
ln -s /etc/init.d/startlsn /etc/rc.d/rc5.d/S99dblsnstart
ln -s /etc/init.d/stopdb /etc/rc.d/rc0.d/K10dbstop
ln -s /etc/init.d/stoplsn /etc/rc.d/rc0.d/K10dblsnstop
重新启动。如果你是以字符方式启动的话,还要在rc3.d下创建链接。
chkconfig error:
service oracle dose not support chkconfig
你的方法可行,非常谢谢。
但我觉得 google_real的方法与系统其他服务类似,我看到的有关文章也是用这种方法,但就是启不来,不知是哪里有问题。
2) script file name is "oracle"
3) make sure user "root" and "oracle" could fully access this file
4) make sure the script file locate in the /etc/init.d
5) change working directory to /etc/init.d and execute
"chkconfig --add oracle"
利用 oracle 提供的 dbstart 和 dbstop .
脚本文件不一定要 oracle,亦可其他名字。其中 /etc/rc.d/init.d/oracle 如下:#!/bin/sh
#
# chkconfig: 345 90 10
# description: 启动及停止 Oracle 资料库和监听程式
# 上面两行一定得要,我就是第二行没写吃了大亏,搞了几天。cat /dev/null > /var/log/oraclecase "$1" in
start)
echo -n "Starting Oracle Databases: "
echo "-----------------------------" >> /var/log/oracle
date +"! %T %a %D : Starting Oracle Databases as part of system up." >> /var/log/oracle
echo "------------------------------" >> /var/log/oracle
su - oracle -c dbstart >> /var/log/oracle
echo "Done."
echo -n "Starting Oracle Listeners: "
su - oracle -c "lsnrctl start" >> /var/log/oracle
echo "Done."
echo ""
echo "-------------------------------" >> /var/log/oracle
date +"! %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------" >> /var/log/oracle
touch /var/lock/subsys/oracle
;;
stop)
echo -n "Shutting Down Oracle Listeners: "
echo "-------------------------------" >> /var/log/oracle
date +"! %T %a %D : Shutting Down Oracle Databases as part of system down." >> /var/log/oracle
echo "--------------------------------" >> /var/log/oracle
su - oracle -c "lsnrctl stop" >> /var/log/oracle
echo "Done."
rm -f /var/lock/subsys/oracle
echo -n "Shutting Down Oracle Databases: "
su - oracle -c dbshut >> /var/log/oracle
echo "Done."
echo ""
echo "--------- ----------------------" >> /var/log/oracle
date +"! %T %a %D : Finished." >> /var/log/oracle
echo "---------------------------------">> /var/log/oracle
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: oracle {start|stop|restart}"
exit 1
esac
exit 0然后:(root 用户)
chmod 755 oracle
chkconfig --level 345 oracle on
cd ../rc0.d
ln -s ../init.d/oracle K10oracle
cd ../rc6.d
ln -s ../init.d/oracle K10oracle测试:
cd /etc/rc.d/init.d
./oracle start 可看到进程已起,ipcs 也可看到 oracle 的 shared memory
./oracle stop