logo 广告
Loading...
 导航 所在位置:论坛首页 -> ┈┋电脑网络┋┈ -> 数据库技术 -> 讲解数据库恢复过程中获取DBID的四种方法
回复
标题:讲解数据库恢复过程中获取DBID的四种方法收藏 编辑 删除 楼主 | 上一篇 下一篇
496020685
头像
等级:大侠
权限:普通用户
积分:106
金钱:5652
声望:154
经验:154
发帖数:1392
注册:2006年9月30日
资料 短消息2008-6-10 10:50:15

在进行数据库恢复的过程中,很多时候我们需要知道Oracle数据库的DBID,通常有以下几种方法可以获得数据库的DBID.

1.查询v$database获得

由于DBID在控制文件和数据文件中都存在记录,所以如果能够mount数据库就可以查询v$database视图获得.

SQL> alter database mount;Database altered.SQL> select dbid from v$database; DBID----------3152029224SQL>

2.在nomount状态时

如果数据库配置了自动控制文件备份(Oracle9i),并且名称是缺省的,那么我们可以从自动备份文件获得DBID.

[oracle@jumper dbs]$ cd $ORACLE_HOME/dbs[oracle@jumper dbs]$ ll c-*-rw-r----- 1 oracle dba 3375104 Dec 21 11:13 c-3152029224-20051221-00-rw-r----- 1 oracle dba 3358720 Jan 21 14:03 c-3152029224-20060121-00-rw-r----- 1 oracle dba 3358720 Jan 21 14:08 c-3152029224-20060121-01

这里的3152029224就是DBID.

3.从自动备份中恢复

需要或缺DBID进行恢复通常是因为丢失了所有的控制文件.在恢复时会遇到错误.

[oracle@jumper dbs]$ rman target /Recovery Manager: Release 9.2.0.4.0 - ProductionCopyright (c) 1995, 2002, Oracle Corporation. All rights reserved.connected to target database: conner (not mounted)RMAN> restore controlfile from autobackup;Starting restore at 05-FEB-06using target database controlfile instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: sid=11 devtype=DISKRMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of restore command at 02/05/2006 20:47:25RMAN-06495: must explicitly specify DBID with SET DBID command

如果存在自动备份,我们通常可以直接恢复控制文件,mount数据库之后就好办了:

RMAN> restore controlfile from '/opt/oracle/product/9.2.0/dbs/c-3152029224-20051221-00';Starting restore at 05-FEB-06using channel ORA_DISK_1channel ORA_DISK_1: restoring controlfilechannel ORA_DISK_1: restore completereplicating controlfileinput filename=/opt/oracle/oradata/conner/control01.ctloutput filename=/opt/oracle/oradata/conner/control02.ctloutput filename=/opt/oracle/oradata/conner/control03.ctlFinished restore at 05-FEB-06

4.直接从幸存的文件中读取

由于DBID存在于数据文件及控制文件中,所以我们可以通过PL/SQL程序直接从文件中读取:

SQL> select eygle.get_dbid('/opt/oracle/oradata/conner','user02.dbf') from dual;EYGLE.GET_DBID('/OPT/ORACLE/OR------------------------------3152029224SQL> select dbid from v$database;DBID----------3152029224

签名

2008-6-10 10:50:15 顶部
第1页 共页 共0个回复     <<    >>    
 快速回复
  • 支持UBB,HTML标签

  • 高级回复

  • 操作选项:评分 加精 解精 奖惩 设专题 设公告 解公告 固顶 总固顶 解固顶 结帖 解结帖 锁帖 解锁 移帖 删帖
      首页 | 购买指南 | 虚拟主机 | 特色介绍 | 下载中心 | 支付方式
    Copyright 2004-2008 BBSGood.com Powered By: BBSGood.Speed Version 5.0
      咨询电话:0575-85513832、0575-85513825(传真)、7*24小时咨询服务:13606552007 不良信息举报中心 浙ICP备05029817号
      业务QQ:38958768、客服QQ1:415896239、客服QQ2:343896043、MSN:jccsxx@hotmail.com