日期:2014-05-16  浏览次数:20429 次

小记修改DBID(原创)

我们知道在进行备份恢复时,可以通过rman的catalog命令注册备份文件信息,但是 catalog注册同一数据库的备份文件,如果需要注册不同数据库的备份文件,则需要将目标数据库的DBID修改成和源数据库一致。当然实际情况下,有很 多更“安全“的方法可以达到我们想要的目的,这里只是提供一个思路和解决方式,仅供参考

[oracle@dg2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Mar 22 16:07:39 2012
Copyright (c) 1982, 2005, Oracle.? All rights reserved.
Connected to an idle instance.

SQL> startup;
ORACLE instance started.

Total System Global Area? 222298112 bytes
Fixed Size????????????????? 1218628 bytes
Variable Size???????????? 100665276 bytes
Database Buffers????????? 117440512 bytes
Redo Buffers??????????????? 2973696 bytes
Database mounted.
Database opened.
SQL> select dbid from v$database;???????????????????

????? DBID
----------
3467808954

SQL> exec dbms_backup_restore.nidbegin('LGDG','LGDG','3467808666','3467808954',0,0,10)
PL/SQL procedure successfully completed.???????
注意:第二个TEST1必须大写,两个dbid前面的为修改后的,后面的为修改之前的。

SQL> variable a number;
SQL> variable b number;
SQL> variable c number;
SQL> exec dbms_backup_restore.nidprocessdf(0,0,:a,:b,:c);

PL/SQL procedure successfully completed.

SQL> print :a
???????? A
----------
???????? 0

SQL> print :b
???????? B
----------
???????? 1

SQL> print :c
???????? C
----------
???????? 0

SQL> exec dbms_backup_restore.nidprocesscf(:a,:b);
PL/SQL procedure successfully completed.

SQL> print :a
???????? A
----------
???????? 1

SQL> print :b
???????? B
----------
???????? 0

SQL> exec dbms_backup_restore.nidend;
PL/SQL procedure successfully completed.

SQL> select dbid from v$database;
????? DBID
----------
3467808666
需要重启数据库,使修改被确认
SQL> shutdown immediate;
ORA-03113: end-of-file on communication channel

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@dg2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Mar 22 17:20:30 2012
Copyright (c) 1982, 2005, Oracle.? All rights reserved.
Connected to an idle instance.

SQL> startup;
ORACLE instance started.
Total System Global Area? 222298112 bytes
Fixed Size????????????????? 1218628 bytes
Variable Size???????????? 100665276 bytes
Database Buffers????????? 117440512 bytes
Redo Buffers??????????????? 2973696 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

SQL> recover database using backup controlfile until cancel;
ORA-00279: change 519903 generated at 03/22/2012 17:14:26 needed for thread 1
ORA-00289: suggestion : /u01/archive/1_2_777032519.dbf
ORA-00280: change 519903 for thread 1 is in sequence #2

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
ORA-00308: cannot open archived log '/u01/archive/1_2_777032519.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3

ORA-00308: cannot open archived log '/u01/archive/1_2_777032519.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3

ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/app/oradata/standby/system01.dbf'

经检查发现,并不存在 /u01