使用备份集创建数据库

环境:
hostname1 :PROD1  db_name :PROD1
hostname 2:PROD2  db_name: PROD1(被还原的数据库
过程:备份hostname1的数据库PROD1,将数据库PROD1的备份集传输到hostname2,使用备份集在hostname2上还原数据库PROD1.
[oracle@PROD1 oracle]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sun Jan 3 02:15:47 2016

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS@PROD1>select DBID,NAME,LOG_MODE from v$database;


      DBID NAME      LOG_MODE
---------- --------- ------------
2121466348 PROD1     ARCHIVELOG

SYS@PROD1>show parameter db_recover

NAME     TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest     string /u01/app/oracle/fast_recovery_
area
db_recovery_file_dest_size     big integer 4182M

SYS@PROD1>ho rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Sun Jan 3 02:18:20 2016

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

Connected to target database: PROD1 (DBID=2121466348)

RMAN> show all;

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name PROD1 are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_PROD1.f'; # default


RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;


new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

RMAN> backup database plus archivelog;


Starting backup at 03-JAN-16
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=36 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=2 RECID=1 STAMP=900123534
channel ORA_DISK_1: starting piece 1 at 03-JAN-16
channel ORA_DISK_1: finished piece 1 at 03-JAN-16
piece handle=/u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_01_03/o1_mf_annnn_TAG20160103T021855_c8j54h9s_.bkp tag=TAG20160103T021855 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 03-JAN-16


Starting backup at 03-JAN-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/PROD1/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/PROD1/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/PROD1/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/PROD1/users01.dbf
channel ORA_DISK_1: starting piece 1 at 03-JAN-16
channel ORA_DISK_1: finished piece 1 at 03-JAN-16
piece handle=/u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_01_03/o1_mf_nnndf_TAG20160103T021856_c8j54k5b_.bkp tag=TAG20160103T021856 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
Finished backup at 03-JAN-16


Starting backup at 03-JAN-16
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=3 RECID=2 STAMP=900123581
channel ORA_DISK_1: starting piece 1 at 03-JAN-16
channel ORA_DISK_1: finished piece 1 at 03-JAN-16
piece handle=/u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_01_03/o1_mf_annnn_TAG20160103T021941_c8j55xsr_.bkp tag=TAG20160103T021941 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 03-JAN-16


Starting Control File and SPFILE Autobackup at 03-JAN-16
piece handle=/u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_01_03/o1_mf_s_900123582_c8j55zd7_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 03-JAN-16

RMAN> exit

Recovery Manager complete.

SYS@PROD1>exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@PROD1 oracle]$ ls
admin  cfgtoollogs  checkpoints  diag  fast_recovery_area  oradata  product
[oracle@PROD1 oracle]$ scp -r fast_recovery_area/  oracle@PROD2:/u01/app/oracle
oracle@prod2's password: 
o1_mf_s_900123582_c8j55zd7_.bkp                                                                                                      100% 9600KB   9.4MB/s   00:00    
o1_mf_1_3_c8j55xo0_.arc                                                                                                              100% 2048     2.0KB/s   00:00    
o1_mf_1_2_c8j54g2x_.arc                                                                                                              100%   28MB  28.1MB/s   00:01    
o1_mf_annnn_TAG20160103T021941_c8j55xsr_.bkp                                                                                         100% 3584     3.5KB/s   00:00    
o1_mf_annnn_TAG20160103T021855_c8j54h9s_.bkp                                                                                         100%   28MB  28.1MB/s   00:00    
o1_mf_nnndf_TAG20160103T021856_c8j54k5b_.bkp                                                                                         100% 1014MB  26.0MB/s   00:39    

在hostname2主机上还原数据库PROD1
还原参数文件
[oracle@PROD2 oracle]$ ls
admin  cfgtoollogs  checkpoints  diag  fast_recovery_area  oradata  product

[oracle@PROD2 oracle]$ cd fast_recovery_area/
[oracle@PROD2 fast_recovery_area]$ ls
PROD1
[oracle@PROD2 fast_recovery_area]$ cd PROD1/

[oracle@PROD2 PROD1]$ ls
archivelog  autobackup  backupset  onlinelog
[oracle@PROD2 PROD1]$ cd autobackup/
[oracle@PROD2 autobackup]$ ls
2016_01_03
[oracle@PROD2 autobackup]$ cd 2016_01_03/
[oracle@PROD2 2016_01_03]$ ls
o1_mf_s_900123582_c8j55zd7_.bkp
[oracle@PROD2 2016_01_03]$ pwd
/u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_01_03
[oracle@PROD2 2016_01_03]$ export ORACLE_SID=PROD1
[oracle@PROD2 2016_01_03]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sun Jan 3 02:27:35 2016

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


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


SYS@PROD1>startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initPROD1.ora'
SYS@PROD1>ho rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Sun Jan 3 01:59:56 2016

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

connected to target database (not started)

RMAN> startup nomount;

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initPROD1.ora'

starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started

Total System Global Area    1068937216 bytes


Fixed Size                     2260088 bytes
Variable Size                281019272 bytes
Database Buffers             780140544 bytes
Redo Buffers                   5517312 bytes
RMAN> set dbid=2121466348

executing command: SET DBID

RMAN> restore spfile from '/u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_01_03/o1_mf_s_900123582_c8j55zd7_.bkp';

Starting restore at 03-JAN-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK


channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_01_03/o1_mf_s_900123582_c8j55zd7_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 03-JAN-16

RMAN> exit

Recovery Manager complete.
SYS@PROD1>exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@PROD2 2016_01_03]$ export ORACLE_SID=PROD1
[oracle@PROD2 2016_01_03]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sun Jan 3 02:45:55 2016

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

Connected to an idle instance.

SYS@PROD1>create pfile from spfile; 

File created.

SYS@PROD1>exit
Disconnected
[oracle@PROD2 2016_01_03]$ cd $ORACLE_HOME/dbs
[oracle@PROD2 dbs]$ ls
hc_PROD1.dat  hc_PROD2.dat  init.ora  initPROD1.ora  lkPROD2  orapwPROD2  spfilePROD1.ora  spfilePROD2.ora
[oracle@PROD2 dbs]$ cat initPROD1.ora 
PROD1.__db_cache_size=352321536
PROD1.__java_pool_size=4194304
PROD1.__large_pool_size=8388608
PROD1.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
PROD1.__pga_aggregate_target=335544320
PROD1.__sga_target=503316480
PROD1.__shared_io_pool_size=0
PROD1.__shared_pool_size=130023424
PROD1.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/PROD1/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oracle/oradata/PROD1/control01.ctl','/u01/app/oracle/oradata/PROD1/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='PROD1'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=PROD1XDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=838860800
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
[oracle@PROD2 dbs]$ mkdir -p /u01/app/oracle/admin/PROD1/adump
[oracle@PROD2 dbs]$ mkdir -p /u01/app/oracle/oradata/PROD1/
[oracle@PROD2 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sun Jan 3 02:48:15 2016

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

Connected to an idle instance.

SYS@PROD2>exit
Disconnected
[oracle@PROD2 dbs]$ export ORACLE_SID=PROD1
[oracle@PROD2 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sun Jan 3 02:48:30 2016

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


Connected to an idle instance.

SYS@PROD1>create spfile from pfile;

File created.

SYS@PROD1>startup nomount;
ORACLE instance started.

Total System Global Area  835104768 bytes
Fixed Size    2257840 bytes
Variable Size  541068368 bytes
Database Buffers  289406976 bytes
Redo Buffers    2371584 bytes
还原控制文件
SYS@PROD1>ho rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Jan 3 02:52:46 2016

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

connected to target database: PROD1 (not mounted)

RMAN> restore controlfile from '/u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_01_03/o1_mf_s_900123582_c8j55zd7_.bkp';

Starting restore at 03-JAN-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK


channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/PROD1/control01.ctl
output file name=/u01/app/oracle/oradata/PROD1/control02.ctl
Finished restore at 03-JAN-16

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

还原数据文件
RMAN> restore database;     


Starting restore at 03-JAN-16
Starting implicit crosscheck backup at 03-JAN-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
Crosschecked 3 objects
Finished implicit crosscheck backup at 03-JAN-16


Starting implicit crosscheck copy at 03-JAN-16
using channel ORA_DISK_1
Finished implicit crosscheck copy at 03-JAN-16


searching for all files in the recovery area
cataloging files...
cataloging done


List of Cataloged Files
=======================
File Name: /u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_01_03/o1_mf_s_900123582_c8j55zd7_.bkp


using channel ORA_DISK_1


channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/PROD1/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/PROD1/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/PROD1/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/PROD1/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_01_03/o1_mf_nnndf_TAG20160103T021856_c8j54k5b_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_01_03/o1_mf_nnndf_TAG20160103T021856_c8j54k5b_.bkp tag=TAG20160103T021856
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 03-JAN-16


RMAN> recover database;


Starting recover at 03-JAN-16
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 3 is already on disk as file /u01/app/oracle/fast_recovery_area/PROD1/archivelog/2016_01_03/o1_mf_1_3_c8j55xo0_.arc
archived log file name=/u01/app/oracle/fast_recovery_area/PROD1/archivelog/2016_01_03/o1_mf_1_3_c8j55xo0_.arc thread=1 sequence=3
unable to find archived log
archived log thread=1 sequence=4
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/03/2016 02:55:36
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 4 and starting SCN of 930689

RMAN>  alter database open resetlogs;

database opened

RMAN> exit


Recovery Manager complete.


SYS@PROD1>select DBID,NAME,LOG_MODE from v$database;


      DBID NAME      LOG_MODE
---------- --------- ------------
2121466348 PROD1     ARCHIVELOG


--END--






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

转载于:http://blog.itpub.net/30606744/viewspace-1970131/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值