在 RHEL 6.5 x86_64 系统上安装 Oracle R2 11g·下篇
来源:靑龍一笑的博客 作者:靑龍一笑 发布时间:2017-03-15 15:40:14 点击量:832 评论:0
三、配置系统服务
1、修改 Oracle 的系统配置文件
[root@ricenos ~]# vi /etc/oratab
/etc/oratab 的格式为:SID:ORACLE_HOME:AUTO,把 AUTO 域的值改为 Y:
orcl:/opt/oracle/product/11.2.0/db_1:Y
2、编写服务脚本
[root@ricenos ~]# vi /etc/rc.d/init.d/oracle
内容如下:
#!/bin/sh
# chkconfig: 35 68 42
# description: Oracle
ORACLE_HOME=/opt/oracle/product/11.2.0/db_1
ORACLE_OWNER=oracle
if [ ! -f ${ORACLE_HOME}/bin/dbstart ] || [ ! -f ${ORACLE_HOME}/bin/dbshut ]; then
echo "Error: Missing the script file ${ORACLE_HOME}/bin/dbstart or ${ORACLE_HOME}/bin/dbshut."
exit 1
fi
db_start(){
echo "Starting Oracle Listener ..."
su - ${ORACLE_OWNER} -c "${ORACLE_HOME}/bin/lsnrctl start"
echo "Done."
echo "Starting Oracle Database ..."
su - ${ORACLE_OWNER} -c "${ORACLE_HOME}/bin/dbstart ${ORACLE_HOME}"
echo "Done."
echo "Starting database control ..."
su - ${ORACLE_OWNER} -c "${ORACLE_HOME}/bin/emctl start dbconsole"
echo "Done."
}
db_stop(){
echo "Stopping database control ..."
su - ${ORACLE_OWNER} -c "${ORACLE_HOME}/bin/emctl stop dbconsole"
echo "Done."
echo "Stopping Oracle Database ..."
su - ${ORACLE_OWNER} -c "${ORACLE_HOME}/bin/dbshut ${ORACLE_HOME}"
echo "Done."
echo "Stopping Oracle Listener ..."
su - ${ORACLE_OWNER} -c "${ORACLE_HOME}/bin/lsnrctl stop"
echo "Done."
}
case "$1" in
start)
db_start
;;
stop)
db_stop
;;
restart)
db_stop
sleep 2
db_start
;;
esac
exit 0
# chkconfig: 35 68 42
# description: Oracle
ORACLE_HOME=/opt/oracle/product/11.2.0/db_1
ORACLE_OWNER=oracle
if [ ! -f ${ORACLE_HOME}/bin/dbstart ] || [ ! -f ${ORACLE_HOME}/bin/dbshut ]; then
echo "Error: Missing the script file ${ORACLE_HOME}/bin/dbstart or ${ORACLE_HOME}/bin/dbshut."
exit 1
fi
db_start(){
echo "Starting Oracle Listener ..."
su - ${ORACLE_OWNER} -c "${ORACLE_HOME}/bin/lsnrctl start"
echo "Done."
echo "Starting Oracle Database ..."
su - ${ORACLE_OWNER} -c "${ORACLE_HOME}/bin/dbstart ${ORACLE_HOME}"
echo "Done."
echo "Starting database control ..."
su - ${ORACLE_OWNER} -c "${ORACLE_HOME}/bin/emctl start dbconsole"
echo "Done."
}
db_stop(){
echo "Stopping database control ..."
su - ${ORACLE_OWNER} -c "${ORACLE_HOME}/bin/emctl stop dbconsole"
echo "Done."
echo "Stopping Oracle Database ..."
su - ${ORACLE_OWNER} -c "${ORACLE_HOME}/bin/dbshut ${ORACLE_HOME}"
echo "Done."
echo "Stopping Oracle Listener ..."
su - ${ORACLE_OWNER} -c "${ORACLE_HOME}/bin/lsnrctl stop"
echo "Done."
}
case "$1" in
start)
db_start
;;
stop)
db_stop
;;
restart)
db_stop
sleep 2
db_start
;;
esac
exit 0
赋予可执行权限:
[root@ricenos ~]# chmod +x /etc/rc.d/init.d/oracle
添加到开机启动项:
[root@ricenos ~]# chkconfig --level 35 oracle on
需要在关机或重启之前停止数据库:
[root@ricenos ~]# ln -s /etc/rc.d/init.d/oracle /etc/rc0.d/K01oracle
[root@ricenos ~]# ln -s /etc/rc.d/init.d/oracle /etc/rc6.d/K01oracle
[root@ricenos ~]# ln -s /etc/rc.d/init.d/oracle /etc/rc6.d/K01oracle
版权所有 © 2005-2023 靑龍一笑的博客 Powered by C.S.Ricen
Copyright © 2005-2023 by www.ricensoftwares.com.cn All Rights Reserved.
Copyright © 2005-2023 by www.ricensoftwares.com.cn All Rights Reserved.