获取DBID的几种方法_MySQL, Oracle及数据库讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  MySQL, Oracle及数据库讨论区 »
总帖数
2
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 2704 | 回复: 1   主题: 获取DBID的几种方法        下一篇 
John
注册用户
等级:大元帅
经验:90444
发帖:136
精华:2
注册:2011-7-21
状态:离线
发送短消息息给John 加好友    发送短消息息给John 发消息
发表于: IP:您无权察看 2015-7-23 15:47:28 | [全部帖] [楼主帖] 楼主

在使用RMAN的时候,dbid极为重要,dbid唯一的标识了一个数据库。在12C的CDB架构中每个pdb都有自己的pdb。可以通过以下几种方法来查询数据库的pdb

1,查询v$database中的dbid或是12C的v$containers

SQL> select dbid from v$database;
DBID
----------
461042625
SQL> select name,dbid from v$pdbs;
NAME                                 DBID
------------------------------ ----------
PDB$SEED                       4062019834
PDBNEW3                        3955412277
PDB2                           3885634569
SQL> select name,dbid from v$containers;
NAME                                 DBID
------------------------------ ----------
CDB$ROOT                        461042625
PDB$SEED                       4062019834
PDBNEW3                        3955412277
PDB2                           3885634569


2,通过RMAN的输出来得到当前的dbid或nid

[oracle@o12c ~]$ $ORACLE_HOME/bin/rman target / nocatalog
Recovery Manager: Release 12.1.0.1.0 - Production on Wed Mar 12 02:16:24 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.
connected to target database: C12 (DBID=461042625)
......................................
[oracle@o12c ~]$ nid target=c12 sys/sys
DBNEWID: Release 12.1.0.1.0 - Production on Wed Mar 12 02:27:14 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.
Connected to database C12 (DBID=461042625)
NID-00121: Database should not be open
.........................................


3,通过controlfile autobackup生成的文件名.当rman配置成controlfile autobackup on且没有定义FRA时,RMAN会自动备份控制文件到$ORACLE_HOME/dbs目录下,其中的文件名就包含了dbid信息

RMAN> show controlfile autobackup;
RMAN configuration parameters for database with db_unique_name C12 are:
CONFIGURE CONTROLFILE AUTOBACKUP ON; # default
SQL> alter system set db_recovery_file_dest='';
System altered.
SQL> show parameter db_recovery_file_dest;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string
db_recovery_file_dest_size           big integer 10G
RMAN> backup tablespace users;
......................
Starting Control File and SPFILE Autobackup at 12-MAR-14
piece handle=/u01/app/oracle/product/12.1.0/db_1/dbs/c-461042625-20140312-03 comment=NONE
Finished Control File and SPFILE Autobackup at 12-MAR-14.
.........................


c-461042625-20140312-03 文件中的461042625为数据库的dbid信息.

4,前三种方法都是在正常的情况下情况得到的,对于很多时候我们可能并没有记录dbid信息,这时候
只有数据文件或是控制文件就可以了,然后通过dump文件来得到

SQL> startup nomount;
ORACLE instance started.
Total System Global Area  835104768 bytes
Fixed Size                  2293880 bytes
Variable Size             322965384 bytes
Database Buffers          503316480 bytes
Redo Buffers                6529024 bytes
SQL> alter system dump datafile '/u01/app/oracle/oradata/c12/sysaux01.dbf' block 1;
System altered.
SQL>  oradebug setmypid;
Statement processed.
SQL>  oradebug tracefile_name;
/u01/app/oracle/diag/rdbms/c12/c12/trace/c12_ora_5435.trc


数据件头信息

Start dump data block from file /u01/app/oracle/oradata/c12/sysaux01.dbf minblk 1 maxblk 1
V10 STYLE FILE HEADER:
Compatibility Vsn = 202375168=0xc100000
Db ID=461042625=0x1b7af3c1, Db Name='C12'
Activation ID=0=0x0
Control Seq=34457=0x8699, File size=192000=0x2ee00
File Number=3, Blksiz=8192, File Type=3 DATA
Dump all the blocks in range:


Db ID=461042625=0x1b7af3c1为该数据库的dbid信息

SQL> alter session set events 'immediate trace name controlf level 4';
Session altered...
....................
PLUGGABLE DATABASE RECORDS
***************************************************************************
(size = 684, compat size = 684, section max = 10, section in-use = 5,
last-recid= 16, old-recno = 0, last-recno = 0)
(extent = 1, blkno = 550, numrecs = 10)
Pluggable DataBase record=1
id=1
dbid=461042625
name=CDB$ROOT
first datafile link=1
............................
Pluggable DataBase record=3
id=3
dbid=3955412277
name=PDBNEW3
first datafile link=40
..............................


通过dump controlfile得到的信息最为详尽,其中包括了所有的pdb的dbid信息.

--转自 北京联动北方科技有限公司




赞(0)    操作        顶端 
联动大白
注册用户
等级:列兵
经验:91
发帖:0
精华:0
注册:2015-5-27
状态:离线
发送短消息息给联动大白 加好友    发送短消息息给联动大白 发消息
发表于: IP:您无权察看 2019-6-22 0:30:00 | [全部帖] [楼主帖] 2  楼

为了方便大家阅读,我对文章中错误号来解释一下吧!

Error Id: NID-00121

Title: Database should not be open

Description:

Database should not be open

Action:

Shutdown the database and mount it in exclusive mode.

Cause:

The database was open. To change the DBID, the database must be mounted exclusively.


也许你已明白,但对一个人有用也是我存在的理由!^_^ By:持之以恒的大白

-- 来自: 北京联动北方科技有限公司



赞(0)    操作        顶端 
总帖数
2
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论