用 rman copy 的方法更改数据文件名称或者迁移到其他的磁盘中。

Posted chendian0

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用 rman copy 的方法更改数据文件名称或者迁移到其他的磁盘中。相关的知识,希望对你有一定的参考价值。

全部在rman下操作:

用 rman copy 的方法更改数据文件名称或者迁移到其他的磁盘中。


select tablespace_name,file_id,file_name from dba_data_files where tablespace_name = TBS_TRANS ;

TABLESPACE_NAME                         FILE_ID     FILE_NAME
--------------------------  ----------  -------------------------------------------------- 
TBS_TRANS                                   12         /u01/app/oracle/oradata/testdb2/df_trans.dbf

12 rows selected.



现在要将数据文件 /u01/app/oracle/oradata/testdb2/df_trans.dbf 名称改为 /u01/app/oracle/oradata/testdb2/df_trans_test20190514.dbf 



必须在归档模式下才可以,先打开归档模式:

SQL> archive log list ;
Database log mode                 Archive Mode
Automatic archival               Enabled
Archive destination               /home/oracle/arch1
Oldest online log sequence     6
Next log sequence to archive   8
Current log sequence             8



backup AS copy datafile 12 format /u01/app/oracle/oradata/testdb2/df_trans_test20190514.dbf;
SQL alter database datafile 12 offline;
switch datafile 12 TO copy;
recover datafile 12;
SQL alter database datafile 12 online;



[[email protected] ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Mon May 13 15:15:50 2019

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

connected to target database: TESTDB2 (DBID=1329834865)

RMAN> backup AS copy datafile 12 format /u01/app/oracle/oradata/testdb2/df_trans_test20190514.dbf;

Starting backup at 13-MAY-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=140 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00012 name=/u01/app/oracle/oradata/testdb2/df_trans.dbf
output file name=/u01/app/oracle/oradata/testdb2/df_trans_test20190514.dbf tag=TAG20190513T151619 RECID=5 STAMP=1008170179
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 13-MAY-19

RMAN> SQL alter database datafile 12 offline;

sql statement: alter database datafile 12 offline

RMAN> switch datafile 12 TO copy;

datafile 12 switched to datafile copy "/u01/app/oracle/oradata/testdb2/df_trans_test20190514.dbf"

RMAN> recover datafile 12;

Starting recover at 13-MAY-19
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 13-MAY-19

RMAN> SQL alter database datafile 12 online;

sql statement: alter database datafile 12 online




查看最终结果
select tablespace_name,file_id,file_name from dba_data_files where tablespace_name = TBS_TRANS ;

TABLESPACE_NAME                          FILE_ID                            FILE_NAME
--------------------------  ---------------------------------- -------------------------------------------------------------------------------------------------------------
TBS_TRANS                                   12                                 /u01/app/oracle/oradata/testdb2/df_trans_test20190514.dbf

 

以上是关于用 rman copy 的方法更改数据文件名称或者迁移到其他的磁盘中。的主要内容,如果未能解决你的问题,请参考以下文章

DBV工具的使用

[20171121]rman backup as copy 2.txt

Rman 中 Backupsets and Images copy的概念区别

利用RMAN IMAGE COPY,启动新的数据库

异机恢复 RMAN-06023: no backup or copy of datafile 17 found to restore

一则关于控制文件全部丢失后如何重新编目RMAN元数据的简单实验