您的位置:首页 > 数据库 > Oracle

Linux 下Oracle 开机自启动 与 oratab, dbstart 脚本 说明

2013-07-24 18:07 513 查看

一./etc/oratab说明

直接使用cat 查看这个文件:



这里是我测试环境上的文件,在这个注释里面,对这个文件讲的比较清楚。/etc/oratab 由root.sh 脚本创建,在用DBCA 创建实例时也会更新这个文件。
当$ORACLE_SID:$ORACLE_HOME:<N|Y> 设置为Y时,允许实例自启动,当设置为N时,则不允许自启动。 这个文件里的配置仅仅起一个开关的作用,其并不会具体的执行启动和关闭,具体的操作由$ORACLE_HOME/bin/dbstart和dbshut 脚本来实现。 这2个脚本在执行时会检查/etc/oratab 文件里的配置,为Y时才能继续执行。
所以配置数据库自启动和关闭的步骤如下:(1) 配置/etc/oratab(2) 修改$ORACLE_HOME/bin/dbstart和dbshut,并将其添加到/etc/rc(.local) 文件中。
这里是使用oracle 自带的dbstart 和dbshut脚本,如果使用自己写的脚本来启动或关闭DB 就不需要关心这个文件的设置了。

二.$ORACLE_HOME/bin/dbstart,dbshut 说明

2.1 dbstart 脚本


2.2 dbshut 脚本



通过以上信息,我们可以看出,我们只需要修改/etc/oratab脚本就可以了,dbstart 和dbshut命令可以从/etc/oratab里获取需要的参数值。

三.DB 开机自启动示例

3.1 修改/etc/oratab的值为Y

gg1:/u01/app/oracle/product/11.2.0.3/db_1/bin>ll /etc/oratab-rw-rw-r-- 1 oracle oinstall 722 Jan 3020:36 /etc/oratabgg1:/u01/app/oracle/product/11.2.0.3/db_1/bin>cat /etc/oratab#gg1:/u01/app/oracle/product/11.2.0.3/db_1:Y

3.2 修改dbstart的ORACLE_HOME_LISTNER,使其指向$ORACLE_HOME:

# First argument is used to bring up OracleNet ListenerORACLE_HOME_LISTNER=$ORACLE_HOME

3.3 用root用户在rc.local里添加如下内容:

[root@gg1 ~]# cat /etc/rc.local #!/bin/sh## This script will be executed *after* allthe other init scripts.# You can put your own initialization stuffin here if you don't# want to do the full Sys V style initstuff.
touch /var/lock/subsys/localsu - oracle -c"/u01/app/oracle/product/11.2.0.3/db_1/bin/dbstart"su - oracle -c"/u01/app/oracle/product/11.2.0.3/db_1/bin/emctl start dbconsole"
这里注意必须用oracle 用户来启动脚本。

3.4 reboot 系统,Oracle就自动启动了。

在我们的配置中,启动的包括监听,实例和OEM。
启动日志如下:gg1:/u01/app/oracle/product/11.2.0.3/db_1>cat startup.log
/u01/app/oracle/product/11.2.0.3/db_1/bin/dbstart:Starting up database "gg1"Mon Jan 30 20:48:26 CST 2012

SQL*Plus: Release 11.2.0.3.0 Production onMon Jan 30 20:48:31 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
SQL> Connected to an idle instance.SQL> ORACLE instance started.
Total System Global Area 939495424 bytesFixed Size 2233960 bytesVariable Size 675285400 bytesDatabase Buffers 255852544 bytesRedo Buffers 6123520 bytesDatabase mounted.Database opened.SQL> Disconnected from Oracle Database11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining andReal Application Testing options
/u01/app/oracle/product/11.2.0.3/db_1/bin/dbstart:Database instance "gg1" warm started.

gg1:/u01/app/oracle/product/11.2.0.3/db_1>cat listener.log/u01/app/oracle/product/11.2.0.3/db_1/bin/dbstart:Starting Oracle Net Listener
LSNRCTL for Linux: Version 11.2.0.3.0 -Production on 30-JAN-2012 21:24:37
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0.3/db_1/bin/tnslsnr:please wait...
TNSLSNR for Linux: Version 11.2.0.3.0 -ProductionSystem parameter file is/u01/app/oracle/product/11.2.0.3/db_1/network/admin/listener.oraLog messages written to/u01/app/oracle/diag/tnslsnr/gg1/listener/alert/log.xmlListening on:(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=gg1)(PORT=1521)))Listening on:(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=gg1)(PORT=1521)))STATUS of the LISTENER------------------------Alias LISTENERVersion TNSLSNR for Linux: Version11.2.0.3.0 - ProductionStart Date 30-JAN-2012 21:24:40Uptime 0 days 0 hr. 0 min. 1 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter File /u01/app/oracle/product/11.2.0.3/db_1/network/admin/listener.oraListener Log File /u01/app/oracle/diag/tnslsnr/gg1/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=gg1)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))The listener supports no servicesThe command completed successfully

-------------------------------------------------------------------------------------------------------版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!Email: tianlesoftware@gmail.comSkype: tianlesoftwareBlog: http://www.tianlesoftware.comWeibo: http://weibo.com/tianlesoftwareTwitter: http://twitter.com/tianlesoftwareFacebook:http://www.facebook.com/tianlesoftware
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: