oracle 11g rman init,Oracle 11g RMAN 备份异机恢复并创建新DBID

在执行NID命令之前:一定要关闭所有的session连接。

nid命令到执行的最后会关闭数据库,如果有session连接,就会阻止这个操作,修改dbid就会被挂死。如果中断这个操作,修改就会失败,数据库就不能mount,需要恢复。

(1)只改DBID,不改db_name

$nid target=sys/Oracle

DBNEWID: Release 11.2.0.1.0 - Production on Mon Apr 11 22:27:49 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to database ORCL (DBID=1275959622)

Connected to server version 11.2.0

Control Files in database:

/u01/oradata/orcl/control01.ctl

/u01/app/oracle/flash_recovery_area/orcl/control02.ctl

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

Proceeding with operation

Changing database ID from 1275959622 to 1276002278

Control File /u01/oradata/orcl/control01.ctl - modified

Control File /u01/app/oracle/flash_recovery_area/orcl/control02.ctl - modified

Datafile /u01/oradata/orcl/system01.db - dbid changed

Datafile /u01/oradata/orcl/sysaux01.db - dbid changed

Datafile /u01/oradata/orcl/undotbs01.db - dbid changed

Datafile /u01/oradata/orcl/users01.db - dbid changed

Datafile /u01/oradata/orcl/example01.db - dbid changed

Datafile /u01/oradata/orcl/temp01.db - dbid changed

Control File /u01/oradata/orcl/control01.ctl - dbid changed

Control File /u01/app/oracle/flash_recovery_area/orcl/control02.ctl - dbid changed

Instance shut down

Database ID for database ORCL changed to 1276002278.

All previous backups and archived redo logs for this database are unusable.

Database is not aware of previous backups and archived logs in Recovery Area.

Database has been shutdown, open database with RESETLOGS option.

Succesfully changed database ID.

DBNEWID - Completed succesfully.

重启打开数据库:

$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Mon Apr 11 22:29:54 2011

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

SQL> conn /as sysdba

Connected to an idle instance.

SQL>startup

ORACLE instance started.

Total System Global Area 6847938560 bytes

Fixed Size                  2219808 bytes

Variable Size            3539992800 bytes

Database Buffers         3288334336 bytes

Redo Buffers               17391616 bytes

Database mounted.

ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

SQL>alter database open resetlogs;

Database altered.

SQL>select name,dbid from v$database;

NAME            DBID

--------- ----------

ORCL1276002278

(2)修改DBID和DB_NAME

注意一点,修改DB_NAME之前,要将spfile创建成pfile,因为修改dbname之后,原来的参数文件就没用了。所以要保证最新的参数。 还需要修改DB_NAME的值为最新值。修改完之后,然后用这个新参数启动DB.

SQL> create spfile from pfile='?/dbs/initorcl.ora';

File created.

SQL>create pfile='/u01/inittmp.ora' from spfile;

File created.

$nid target=sys/oracle dbname=mahee

DBNEWID: Release 11.2.0.1.0 - Production on Mon Apr 11 22:38:15 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to database ORCL (DBID=1276002278)

Connected to server version 11.2.0

Control Files in database:

/u01/oradata/orcl/control01.ctl

/u01/app/oracle/flash_recovery_area/orcl/control02.ctl

Change database ID and database name ORCL to MAHEE? (Y/[N]) => Y

Proceeding with operation

Changing database ID from 1276002278 to 3475057431

Changing database name from ORCL to MAHEE

Control File /u01/oradata/orcl/control01.ctl - modified

Control File /u01/app/oracle/flash_recovery_area/orcl/control02.ctl - modified

Datafile /u01/oradata/orcl/system01.db - dbid changed, wrote new name

Datafile /u01/oradata/orcl/sysaux01.db - dbid changed, wrote new name

Datafile /u01/oradata/orcl/undotbs01.db - dbid changed, wrote new name

Datafile /u01/oradata/orcl/users01.db - dbid changed, wrote new name

Datafile /u01/oradata/orcl/example01.db - dbid changed, wrote new name

Datafile /u01/oradata/orcl/temp01.db - dbid changed, wrote new name

Control File /u01/oradata/orcl/control01.ctl - dbid changed, wrote new name

Control File /u01/app/oracle/flash_recovery_area/orcl/control02.ctl - dbid changed, wrote new name

Instance shut down

Database name changed to MAHEE.

Modify parameter file and generate a new password file before restarting.

Database ID for database MAHEE changed to 3475057431.

All previous backups and archived redo logs for this database are unusable.

Database is not aware of previous backups and archived logs in Recovery Area.

Database has been shutdown, open database with RESETLOGS option.

Succesfully changed database name and ID.

DBNEWID - Completed succesfully.

验证:

首先,更改刚才创建的那个inittmp.ora文件db_name为mahee

$ export ORACLE_SID=mahee

$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Mon Apr 11 22:46:05 2011

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

SQL> conn /as sysdba

Connected to an idle instance.

SQL>startup mount pfile='/u01/inittmp.ora';

ORACLE instance started.

Total System Global Area 6847938560 bytes

Fixed Size                  2219808 bytes

Variable Size            3539992800 bytes

Database Buffers         3288334336 bytes

Redo Buffers               17391616 bytes

Database mounted.

SQL>alter database open resetlogs;

Database altered.

SQL>select name,dbid from v$database;

NAME            DBID

--------- ----------

MAHEE     3475057431

到此,实验完成。0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值