Use Rman IMAGE COPY to start a new database

Source: Internet
Author: User
Tags sqlplus

With image copy technology, you can get a complete copy of a database, quickly open the database, and avoid database restore and recovery for a long time. Here is the useIMAGE Copy makes a case of a full database restore. Since this test is performed on the same database host, it is important to note that the ORACLE_SID environment variable and the file under the associated path cannot be overwritten.


--1. Create a DB level 0 IMAGE COPY backup

[[email protected] ~]$ Rman target/rman> BACKUP as COPY INCREMENTAL level 0 TAG ' srcdb-image ' DATABASE FORMAT '/oradat A/srcdb_img/srcdb-lvl0-%u ';


--2. Create test Data

[[email protected] ~]$ sqlplus/as sysdbasql> CREATE TABLE Scott.test_backup 2 as 3 select RowNum rn from dual C Onnect by RowNum <= 1000000;


--3. Create a DB Level 1 IMAGE COPY backup

rman> backup incremental level 1 for recover of tag  ' Srcdb-image '  DATABASE FORMAT  '/oradata/srcdb_img/srcdb-lvl1-%u '  PLUS ARCHIVELOG; Starting backup at 2018-01-31 07:48:41current log archivedusing channel  ora_disk_1channel ora_disk_1: starting archived log backup setchannel  ora_disk_1: specifying archived log (s)  in backup setinput archived  log thread=1 sequence=2 RECID=1 STAMP=961989888input archived log  thread=1 sequence=3 recid=2 stamp=966842424input archived log thread=1  sequence=4 recid=3 stamp=966842833input archived log thread=1 sequence=5  Recid=4 stamp=966842838input archived log thread=1 sequence=6 recid=5 stamp =966842911input archived log thread=1 sequence=7 recid=6 stamp=966842915input archived log thread=1  sequence=8 recid=7 stamp=966844055input archived log thread=1 sequence=9  recid=8 stamp=966844059input archived log thread=1 sequence=10 recid=9  stamp=966844121channel ora_disk_1: starting piece 1 at 2018-01-31  07:48:42channel ora_disk_1: finished piece 1 at 2018-01-31 07:48:43piece  handle=/oracle/app/oracle/product/11.2.0.4/db_1/dbs/12sq1nmp_1_1 tag=srcdb-image comment= Nonechannel ora_disk_1: backup set complete, elapsed time: 00:00:01finished  backup at 2018-01-31 07:48:43Starting backup at 2018-01-31  07:48:43using channel ora_disk_1channel ora_disk_1: starting incremental level  1 datafile backup setchannel&Nbsp;ora_disk_1: specifying datafile (s)  in backup setinput datafile file  number=00001 name=/oracle/app/oracle/oradata/srcdb/system01.dbfinput datafile file  Number=00002 name=/oracle/app/oracle/oradata/srcdb/sysaux01.dbfinput datafile file number= 00005 name=/oracle/app/oracle/oradata/srcdb/ggtbs01.dbfinput datafile file number=00003  name=/oracle/app/oracle/oradata/srcdb/undotbs01.dbfinput datafile file number=00004  Name=/oracle/app/oracle/oradata/srcdb/users01.dbfchannel ora_disk_1: starting piece 1  at 2018-01-31 07:48:43channel ORA_DISK_1: finished piece 1 at  2018-01-31 07:48:44piece handle=/oradata/srcdb_img/srcdb-lvl1-13sq1nmr_1_1 tag=srcdb-image  comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time:  00:00:01channel ora_disk_1:  starting incremental level 1 datafile backup setchannel ora_disk_1:  specifying datafile (s)  in backup setincluding current control file  in backup setincluding current spfile in backup setchannel ora_ disk_1: starting piece 1 at 2018-01-31 07:48:45channel ora_disk_1:  finished piece 1 at 2018-01-31 07:48:46piece handle=/oradata/srcdb_img/ Srcdb-lvl1-14sq1nms_1_1 tag=srcdb-image comment=nonechannel ora_disk_1: backup set  complete, elapsed time: 00:00:01Finished backup at 2018-01-31  07:48:46starting backup at 2018-01-31 07:48:46current log archivedusing  channel ora_disk_1channel ora_disk_1: starting archived log backup  setchannel ora_disk_1: specifying  Archived log (s)  in backup setinput archived log thread=1 sequence=11  RECID=10 STAMP=966844126channel ORA_DISK_1: starting piece 1 at  2018-01-31 07:48:46channel ora_disk_1: finished piece 1 at 2018-01-31  07:48:47piece handle=/oracle/app/oracle/product/11.2.0.4/db_1/dbs/15sq1nmu_1_1 tag=srcdb-image  comment=nonechannel ora_disk_1: backup set complete, elapsed time:  00:00:01finished backup at 2018-01-31 07:48:47


--4. Restore operations to DB level 0 IMAGE COPY backup

rman> recover copy of database with tag  ' SRCDB-IMAGE '; Starting recover at 2018-01-31 07:48:57using channel ora_disk_1channel ora_ Disk_1: starting incremental datafile backup set restorechannel ora_disk_1:  specifying datafile copies to recoverrecovering datafile copy file  number=00001 name=/oradata/srcdb_img/srcdb-lvl0-data_d-srcdb_i-595837900_ts-system_fno-1_ 0nsq1nivrecovering datafile copy file number=00002 name=/oradata/srcdb_img/ srcdb-lvl0-data_d-srcdb_i-595837900_ts-sysaux_fno-2_0osq1nj2recovering datafile copy file  Number=00003 name=/oradata/srcdb_img/srcdb-lvl0-data_d-srcdb_i-595837900_ts-undotbs1_fno-3_ 0qsq1njkrecovering datafile copy file number=00004 name=/oradata/srcdb_img/ srcdb-lvl0-data_d-srcdb_i-595837900_ts-users_fno-4_0rsq1njlrecovering Datafile copy file number=00005 name=/oradata/srcdb_img/srcdb-lvl0-data_d-srcdb_ I-595837900_ts-ggtbs_fno-5_0psq1njhchannel ora_disk_1: reading from backup piece  /oradata/srcdb_img/srcdb-lvl1-0vsq1nko_1_1channel ora_disk_1: piece handle=/oradata/srcdb _img/srcdb-lvl1-0vsq1nko_1_1 tag=srcdb-imagechannel ora_disk_1: restored backup piece  1channel ORA_DISK_1: restore complete, elapsed time: 00:00:01channel  Ora_disk_1: starting incremental datafile backup set restorechannel ora_ disk_1: specifying datafile copies to recoverrecovering datafile copy  File number=00001 name=/oradata/srcdb_img/srcdb-lvl0-data_d-srcdb_i-595837900_ts-system_fno-1_ 0nsq1nivrecovering datafile copy file number=00002 name=/oradata/srcdb_img/ Srcdb-lvl0-data_d-srcdb_i-595837900_ts-sysaux_fno-2_0osq1nj2recovering datafile copy file number=00003 name=/oradata/srcdb_img/ Srcdb-lvl0-data_d-srcdb_i-595837900_ts-undotbs1_fno-3_0qsq1njkrecovering datafile copy file  number=00004 name=/oradata/srcdb_img/srcdb-lvl0-data_d-srcdb_i-595837900_ts-users_fno-4_ 0rsq1njlrecovering datafile copy file number=00005 name=/oradata/srcdb_img/ Srcdb-lvl0-data_d-srcdb_i-595837900_ts-ggtbs_fno-5_0psq1njhchannel ora_disk_1: reading from  backup piece /oradata/srcdb_img/srcdb-lvl1-13sq1nmr_1_1channel ora_disk_1: piece  handle=/oradata/srcdb_img/SRCDB-LVL1-13sq1nmr_1_1 tag=SRCDB-IMAGEchannel ORA_DISK_1:  restored backup piece 1channel ora_disk_1: restore complete, elapsed  time: 00:00:01finished recover at 2018-01-31 07:48:59


--5. The Source Library performs a backup control file operation to get the information in the log

sql> ALTER DATABASE backup Controlfile to trace;--Set #1. Noresetlogs casestartup nomountcreate controlfile reuse DATABASE "srcdb" noresetlogs force LOGGING ARCHIVELOG ...;


--6. Create a new object for audit on subsequent full recovery

Sql> CREATE TABLE scott.test22 (ID number); sql> alter system switch logfile; sql> shutdown immediate;


---7. parameter files required to create IMAGE COPY database (db_name in parameter file cannot be modified, audit_file_dest and control_files paths are adjusted)

[[Email protected] ~]$ CD $ORACLE _home/dbs[[email protected] dbs]$ CP orapwsrcdb orapwsrcdbnew[[email protected] dbs]$ str Ings Spfilesrcdb.ora > Initsrcdbnew.ora[[email protected] dbs]$ cat Initsrcdbnew.ora | grep '/oracle/' *.audit_file_dest= '/oracle/app/oracle/admin/srcdbnew/adump ' *.control_files= '/oradata/srcdb_img/ Control01.ctl ', '/oradata/srcdb_img/control02.ctl ' [[email protected] dbs]$ mkdir-p/oracle/app/oracle/admin/ Srcdbnew/adump

--8. Start the DB instance

[[email protected] dbs]$ export Oracle_sid=srcdbnew[[email protected] dbs]$ sqlplus/as sysdbasql> startup Nomount;


--9. Copy the online log file to the new directory for full recovery

[Email protected] archive]$ Cp/oracle/app/oracle/oradata/srcdb/redo01.log/oradata/srcdb_img/redo01.log[[email Protected] archive]$ Cp/oracle/app/oracle/oradata/srcdb/redo02.log/oradata/srcdb_img/redo02.log[[email protected] archive]$ Cp/oracle/app/oracle/oradata/srcdb/redo03.log/oradata/srcdb_img/redo03.log


--10. Rebuilding the control file

create controlfile reuse database  "SRCDB"  NORESETLOGS     maxlogfiles 16    maxlogmembers 3    maxdatafiles 100     MAXINSTANCES 8    MAXLOGHISTORY 292LOGFILE   group 1  '/oradata/srcdb_img/redo01.log '   SIZE 50M BLOCKSIZE 512,   GROUP 2  '/oradata/srcdb_img/redo02.log '   size 50m blocksize 512,   GROUP 3  '/oradata/srcdb_img/redo03.log '   SIZE 50M BLOCKSIZE  512datafile   '/oradata/srcdb_img/srcdb-lvl0-data_d-srcdb_i-595837900_ts-system_fno-1_0nsq1niv ',    '/oradata/srcdb_img/srcdb-lvl0-data_d-srcdb_i-595837900_ts-sysaux_fno-2_0osq1nj2 ',   '/ Oradata/srcdb_img/srcdb-lvl0-data_d-srcdb_i-595837900_ts-undotbs1_fno-3_0qsq1njk ',   '/oradata/srcdb_ Img/srcdb-lvl0-data_d-srcdb_i-595837900_ts-users_fno-4_0rsq1njl ',   '/oradata/srcdb_img/srcdb-lvl0-data_d-srcdb_i-595837900_ts-ggtbs_fno-5_ 0psq1njh ' character set we8mswin1252; sql> select name from v$datafile;


--11. Source Library Check check log files that need to be registered

[[email protected] dbs]$ export oracle_sid=srcdbsql> startup mount; rman> list backup of archivelog all;bs key  size       Device Type Elapsed Time Completion Time    --- ---- ---------- ----------- ------------ -------------------19       3.50K      DISK         00:00:00    2018-01-31 07:48:46        bp  Key: 19  Status: AVAILABLE  Compressed: NO  Tag:  srcdb-image        piece name: /oracle/app/oracle/product/ 11.2.0.4/db_1/dbs/15sq1nmu_1_1  list of archived logs in backup set  19  thrd seq    low scn    low time             Next SCN  Next Time  ---- ------- ----------  ------------------- ---------- ---------  1    11       969636    2018-01-31 07:48:41 969648     2018-01-31 07:48:46


--12. New Library Register log file for Source Library

sql> ALTER DATABASE REGISTER LOGFILE '/oracle/archive/1_11_961988430.dbf '; sql> ALTER DATABASE REGISTER LOGFILE '/oracle/archive/1_12_961988430.dbf '; sql> ALTER DATABASE REGISTER LOGFILE '/oracle/archive/1_13_961988430.dbf '; sql> ALTER DATABASE REGISTER LOGFILE '/oracle/archive/1_14_961988430.dbf '; Sql> RECOVER DATABASE; sql> ALTER DATABASE OPEN;


--13. Create a new temporary file

sql> ALTER tablespace TEMP ADD tempfile '/oradata/srcdb_img/temp01.dbf ' SIZE 100M autoextend OFF;


Use Rman IMAGE COPY to start a new database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.