oracle rman copy测试



oracle rman copy测试


环境:
odb1.test.com-PROD1>lsb_release -a
LSB Version:    :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: EnterpriseEnterpriseServer
Description:    Enterprise Linux Enterprise Linux Server release 5.4 (Carthage)
Release:        5.4
Codename:       Carthage
odb1.test.com-PROD1>
odb1.test.com-PROD1>sqlplus -v
SQL*Plus: Release 11.2.0.3.0 Production

实验目的:
测试是否可以在数据库open状态下,数据文件为online状态,rman copy数据文件,然后再切换数据文件到copy。


实验记录:
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/arch/prod1
Oldest online log sequence     78
Next log sequence to archive   80
Current log sequence           80
SQL> 
SQL> select status from v$instance;

STATUS
------------
OPEN

SQL> select file#,name,status from v$datafile where file#=6;

     FILE# NAME                                                         STATUS
---------- ------------------------------------------------------------ -------
         6 /u01/app/oracle/oradata/prod1/test.dbf                       ONLINE


odb1.test.com-PROD1>rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Aug 12 23:35:48 2016

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

connected to target database: PROD1 (DBID=2100110708)

RMAN> 

RMAN> copy datafile '/u01/app/oracle/oradata/prod1/test.dbf' to '/u01/app/oracle/oradata/prod1/test01.dbf';        

Starting backup at 12-AUG-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/u01/app/oracle/oradata/prod1/test.dbf
output file name=/u01/app/oracle/oradata/prod1/test01.dbf tag=TAG20160812T235516 RECID=1 STAMP=919727720
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 12-AUG-16

Starting Control File and SPFILE Autobackup at 12-AUG-16
piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/c-2100110708-20160812-00 comment=NONE
Finished Control File and SPFILE Autobackup at 12-AUG-16

RMAN> 
RMAN> switch datafile '/u01/app/oracle/oradata/prod1/test.dbf' to copy;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of switch to copy command at 08/12/2016 23:56:20
RMAN-06572: database is open and datafile 6 is not offline

RMAN> 

RMAN> exit

Recovery Manager complete.
odb1.test.com-PROD1>

odb1.test.com-PROD1>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Sat Aug 13 00:06:39 2016

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> 
SQL> col name for a60
SQL> select file#,name,status from v$datafile where file#=6;

     FILE# NAME                                                         STATUS
---------- ------------------------------------------------------------ -------
         6 /u01/app/oracle/oradata/prod1/test.dbf                       ONLINE

SQL>            
SQL> alter database datafile 6 offline;

Database altered.

SQL> 
SQL>     
SQL> select file#,name,status from v$datafile where file#=6;

     FILE# NAME                                                         STATUS
---------- ------------------------------------------------------------ -------
         6 /u01/app/oracle/oradata/prod1/test.dbf                       RECOVER

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
odb1.test.com-PROD1>
odb1.test.com-PROD1>rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Sat Aug 13 00:09:39 2016

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

connected to target database: PROD1 (DBID=2100110708)

RMAN> 

RMAN> switch datafile '/u01/app/oracle/oradata/prod1/test.dbf' to copy;

using target database control file instead of recovery catalog
datafile 6 switched to datafile copy "/u01/app/oracle/oradata/prod1/test01.dbf"

RMAN>
RMAN> recover datafile 6;

Starting recover at 13-AUG-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=43 device type=DISK

starting media recovery

archived log for thread 1 with sequence 80 is already on disk as file /home/oracle/arch/prod1/1_80_910701443.dbf
archived log for thread 1 with sequence 81 is already on disk as file /home/oracle/arch/prod1/1_81_910701443.dbf
archived log for thread 1 with sequence 82 is already on disk as file /home/oracle/arch/prod1/1_82_910701443.dbf
archived log for thread 1 with sequence 83 is already on disk as file /home/oracle/arch/prod1/1_83_910701443.dbf
archived log file name=/home/oracle/arch/prod1/1_80_910701443.dbf thread=1 sequence=80
archived log file name=/home/oracle/arch/prod1/1_81_910701443.dbf thread=1 sequence=81
media recovery complete, elapsed time: 00:00:00
Finished recover at 13-AUG-16

RMAN> exit

Recovery Manager complete.
odb1.test.com-PROD1>
odb1.test.com-PROD1>
odb1.test.com-PROD1>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Sat Aug 13 00:13:10 2016

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> 
SQL> col name for a60
SQL> select file#,name,status from v$datafile where file#=6;

     FILE# NAME                                                         STATUS
---------- ------------------------------------------------------------ -------
         6 /u01/app/oracle/oradata/prod1/test01.dbf                     OFFLINE

SQL> 
SQL> alter database datafile 6 online;

Database altered.

SQL> select file#,name,status from v$datafile where file#=6;

     FILE# NAME                                                         STATUS
---------- ------------------------------------------------------------ -------
         6 /u01/app/oracle/oradata/prod1/test01.dbf                     ONLINE

SQL>


总结:
经过测试,在切换时数据文件要offline,切换的时候需要置为offline才能recover。




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

转载于:http://blog.itpub.net/24626891/viewspace-2127376/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值