修改/etc/oratab文件,将需要启动的实例名称后面的N修改为Y,如果要全部都启动,则使用
:g/N/s//Y/g将全部N修改为Y
然后编写个shell脚本
cd /etc/init.d
vi oraclestart
#!/bin/bash
# chkconfig: 35 95 1
# description: script to start/stop oracle serverd
case "$1" in
start)
date >>/var/log/oracle
echo -e "\nThe oracle will start\n">/var/log/oracle
su - oracle -c "lsnrctl start;dbstart;emctl start dbconsole;exit;">>/var/log/oracle
echo -e "The oracle started">>/var/log/oracle
;;
stop)
date >>/var/log/oracle
echo -e "\nThe oracle will stop\n">/var/log/oracle
su - oracle -c "dbshut;emctl stop dbconsole;lsnrctl stop;exit;">>/var/log/oracle
echo -e "The oracle stoped">>/var/log/oracle
;;
restart)
$0 stop
$0 start
;;
*)
echo -e "usage $0 {start|stop|restart}"
exit 1
esac
保存。
注:以上红色部分必须要加,否则不能用chkconfig
chmod a+x oraclestart
chkconfig --add oraclestart 加入系统服务
chkconfig --list 查看
这样就可以实现oracle多实例自动启动了。
删除oraclestart服务
chkconfig --del oraclestart