mysql如何查看dbid_获取DBID的几种方法

获取DBID的几种方法

在使用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
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值