ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Tips--DBNEWID有机会用上了。

Tips--DBNEWID有机会用上了。

原创 Linux操作系统 作者:vongates 时间:2019-07-17 20:45:02 0 删除 编辑

接着上周Disk Array的硬盘坏了一颗,最近又没有条件做做RAID,所以客户的老板要求测试的数据库也先备份一下,在注册DB到 catalog DB 时就遇到了一个可以说百年难遇的现象,尽然测试用的三个DB中有两个DB的DBID是一样的。因为想在catalog DB中只用一个帐号来管理这三个测试数据库,所以想到了改DBID。从9i R2起oracle提供了DBNEWID这个新的工具,来方便对DB的管理和维护。更详细的用法和说明请看官方文档,这个工具可以只改DBID,也可以只改DB name,当然还可以两个一起改,根据我们实际的需要,只要改DBID就可以了。下面帖一下小过程给各位参考


1。问题现场
[oracle:/opt/oracle/9.2.0/bin FXPROD]$ rman

Recovery Manager: Release 9.2.0.6.0 - 64bit Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

RMAN> connect catalog rman/rman@catdb

connected to recovery catalog database

RMAN> connect target /

connected to target database: FXPROD (DBID=1589783499)

RMAN> register database;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of register command on default channel at 04/17/2007 10:32:38
RMAN-20002: target database already registered in recovery catalog

RMAN> list incarnation;


List of Database Incarnations
DB Key Inc Key DB Name DB ID CUR Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 189 FPROD 99016148 NO 1 2004-06-05 11:47:32
1 2 FPROD 99016148 YES 8046888951288 2007-02-05 09:58:39
2761 2769 YPROD 1589783499 NO 1 2004-06-06 13:14:51
2761 2762 YPROD 1589783499 YES 8046956311527 2007-02-05 10:07:12

RMAN>

2。测试过程(记得按照nid的提示作业,要不然会有一些出错提示哟)

[oracle@szvsx019:/home/oracle]
[TEST]~$ sqlplus /nolog

SQL*Plus: Release 9.2.0.6.0 - Production on Tue Apr 17 10:22:17 2007

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

SQL> conn / as sysdba
Connected.

SQL> select dbid,name from v$database;

DBID NAME
---------- ---------
1445153162 TEST

SQL> alter user sys identified by password;

User altered.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area 455864696 bytes
Fixed Size 737656 bytes
Variable Size 234881024 bytes
Database Buffers 218103808 bytes
Redo Buffers 2142208 bytes
Database mounted.
SQL> !
$ nid target sys/password
DBNEWID: Release 9.2.0.6.0 - 64bit Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.


NID-00002: Parse error: LRM-00108: invalid positional parameter value 'target'


Change of database ID failed during validation - database is intact.
DBNEWID - Completed with validation errors.

$ nid target=sys/password
DBNEWID: Release 9.2.0.6.0 - 64bit Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

Connected to database TEST (DBID=1445153162)

Control Files in database:
/home/che/test/TESTctrl01.ctl
/home/che/test/TESTctrl02.ctl
/home/che/test/TESTctrl03.ctl

Change database ID of database TEST? (Y/[N]) => y

Proceeding with operation
Changing database ID from 1445153162 to 1918276839
Control File /home/che/test/TESTctrl01.ctl - modified
Control File /home/che/test/TESTctrl02.ctl - modified
Control File /home/che/test/TESTctrl03.ctl - modified
Datafile /home/che/test/system01.dbf - dbid changed
Datafile /home/che/test/undotbs01.dbf - dbid changed
Datafile /home/che/test/tools01.dbf - dbid changed
Datafile /home/che/test/first.dbf - dbid changed
Control File /home/che/test/TESTctrl01.ctl - dbid changed
Control File /home/che/test/TESTctrl02.ctl - dbid changed
Control File /home/che/test/TESTctrl03.ctl - dbid changed

Database ID for database TEST changed to 1918276839.
All previous backups and archived redo logs for this database are unusable.
Shut down database and open with RESETLOGS option.
Succesfully changed database ID.
DBNEWID - Completed succesfully.

$ exit

SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/home/che/test/system01.dbf'
ORA-01206: file is not part of this database - wrong database id


SQL> shutdown immediate;
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area 455864696 bytes
Fixed Size 737656 bytes
Variable Size 234881024 bytes
Database Buffers 218103808 bytes
Redo Buffers 2142208 bytes
Database mounted.
SQL> alter database open resetlogs;

Database altered.

SQL> select dbid,name from v$database;

DBID NAME
---------- ---------
1918276839 TEST

SQL>

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29987/viewspace-51995/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2018-09-11

  • 博文量
    449
  • 访问量
    292676