ITPub博客

首页 > 数据库 > Oracle > 2014.06.13 网络公开课《让我们捧起2014备份和恢复的世界之杯-再叙Recover Catalog》

2014.06.13 网络公开课《让我们捧起2014备份和恢复的世界之杯-再叙Recover Catalog》

Oracle 作者:royevictory 时间:2014-08-06 23:00:16 0 删除 编辑








--登录源数据库并创建一个新的表

oracle@Host1.cuug.net:/home/oracle>$ sqlplus scott/scott

 

SQL*Plus: Release 11.2.0.3.0 Production on Fri Jun 13 04:08:08 2014

 

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

 

create table worldcup(nationa varchar2(20), nationb varchar2(20), score number(2));

 

--插入测试数据

insert into worldcup values('Brazil', 'Croatia', 1);

insert into worldcup values('Mexico', 'Cameroon', 0);

insert into worldcup values('Spain', 'Netherlands', -1);

commit;

 

--使数据库由noarchivelog模式进入到archivelog模式

 

--备份source database并将备份传送到destination database

oracle@Host1.cuug.net:/home/oracle>$ rman target /

 

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Jun 13 05:50:41 2014

 

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

 

connected to target database: TESTDB1 (DBID=602172250)

 

RMAN> backup database include current controlfile plus archivelog delete input;

 

 

Starting backup at 13-JUN-14

current log archived

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=44 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=6 RECID=1 STAMP=850110659

channel ORA_DISK_1: starting piece 1 at 13-JUN-14

channel ORA_DISK_1: finished piece 1 at 13-JUN-14

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB1/backupset/2014_06_13/o1_mf_annnn_TAG20140613T055100_9sold4os_.bkp tag=TAG20140613T055100 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

channel ORA_DISK_1: deleting archived log(s)

archived log file name=/u01/app/oracle/fast_recovery_area/TESTDB1/archivelog/2014_06_13/o1_mf_1_6_9sold18t_.arc RECID=1 STAMP=850110659

Finished backup at 13-JUN-14

 

Starting backup at 13-JUN-14

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/testdb1/system01.dbf

input datafile file number=00002 name=/u01/app/oracle/oradata/testdb1/sysaux01.dbf

input datafile file number=00005 name=/u01/app/oracle/oradata/testdb1/example01.dbf

input datafile file number=00003 name=/u01/app/oracle/oradata/testdb1/undotbs01.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/testdb1/users01.dbf

channel ORA_DISK_1: starting piece 1 at 13-JUN-14

channel ORA_DISK_1: finished piece 1 at 13-JUN-14

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB1/backupset/2014_06_13/o1_mf_nnndf_TAG20140613T055103_9sold83z_.bkp tag=TAG20140613T055103 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:02:25

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current control file in backup set

including current SPFILE in backup set

channel ORA_DISK_1: starting piece 1 at 13-JUN-14

channel ORA_DISK_1: finished piece 1 at 13-JUN-14

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB1/backupset/2014_06_13/o1_mf_ncsnf_TAG20140613T055103_9soljwl4_.bkp tag=TAG20140613T055103 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 13-JUN-14

 

Starting backup at 13-JUN-14

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=7 RECID=2 STAMP=850110813

channel ORA_DISK_1: starting piece 1 at 13-JUN-14

channel ORA_DISK_1: finished piece 1 at 13-JUN-14

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB1/backupset/2014_06_13/o1_mf_annnn_TAG20140613T055333_9soljxz1_.bkp tag=TAG20140613T055333 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02

channel ORA_DISK_1: deleting archived log(s)

archived log file name=/u01/app/oracle/fast_recovery_area/TESTDB1/archivelog/2014_06_13/o1_mf_1_7_9soljxtf_.arc RECID=2 STAMP=850110813

Finished backup at 13-JUN-14

 

--查看快速恢复区的位置

sys@TESTDB1>show parameter db_recovery_file_dest

 

--启动另一个虚拟机Host3(它是作为我们的Destination Host)

--将内容拷贝到destination  host

oracle@Host1.cuug.net:/u01/app/oracle/oradata>$ cd

oracle@Host1.cuug.net:/home/oracle>$ scp -r /u01/app/oracle/fast_recovery_area 192.168.6.103:/u01/app/oracle/

The authenticity of host '192.168.6.103 (192.168.6.103)' can't be established.

RSA key fingerprint is 5d:36:f9:7c:37:66:f2:d6:b7:c8:1e:a3:cb:7a:2a:08.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.6.103' (RSA) to the list of known hosts.

oracle@192.168.6.103's password:

o1_mf_annnn_TAG20140613T043338_9sofv2b4_.bkp                                                                    100%   47KB  47.0KB/s   00:00   

o1_mf_nnndf_TAG20140613T043126_9sofpyo6_.bkp                                                                    100% 1094MB   7.7MB/s   02:22   

o1_mf_ncsnf_TAG20140613T043126_9softywr_.bkp                                                                    100% 9600KB   9.4MB/s   00:01   

o1_mf_annnn_TAG20140613T043123_9sofpvb2_.bkp                                                                    100%   27MB   2.7MB/s   00:10   

o1_mf_ncsnf_TAG20140613T042856_9sofld4t_.bkp                                                                    100% 9600KB   1.6MB/s   00:06   

o1_mf_1_6_9sofpr0j_.arc                                                                                         100%   27MB   3.9MB/s   00:07   

o1_mf_1_7_9sofv24w_.arc                                                                                         100%   46KB  45.5KB/s   00:00   

control02.ctl                                                                                                   100% 9520KB   3.1MB/s   00:03

 

--生成文本初始化参数文件并传送到destination host

sys@TESTDB1>create pfile from spfile;

 

File created.

 

racle@Host1.cuug.net:/home/oracle>$ scp $ORACLE_HOME/dbs/inittestdb1.ora 192.168.6.103:$ORACLE_HOME/dbs

oracle@192.168.6.103''s password:

inittestdb1.ora                                                                                                 100%  958     0.9KB/s   00:00

 

--查看传送后的结果

oracle@Host3.cuug.net:/home/oracle>$ ls /u01/app/oracle/product/11.2.0/dbhome_1/dbs/inittestdb1.ora

/u01/app/oracle/product/11.2.0/dbhome_1/dbs/inittestdb1.ora

 

--查看并创建需要的目录

oracle@Host1.cuug.net:/u01/app/oracle>$ more /u01/app/oracle/product/11.2.0/dbhome_1/dbs/inittestdb1.ora

testdb1.__db_cache_size=297795584

testdb1.__java_pool_size=4194304

testdb1.__large_pool_size=4194304

testdb1.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment

testdb1.__pga_aggregate_target=318767104

testdb1.__sga_target=478150656

testdb1.__shared_io_pool_size=0

testdb1.__shared_pool_size=159383552

testdb1.__streams_pool_size=4194304

*.audit_file_dest='/u01/app/oracle/admin/testdb1/adump'

*.audit_trail='db'

*.compatible='11.2.0.0.0'

*.control_files='/u01/app/oracle/oradata/testdb1/control01.ctl','/u01/app/oracle/fast_recovery_area/testdb1/control02.ctl'

*.db_block_size=8192

*.db_domain='cuug.net'

*.db_name='testdb1'

*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'

*.db_recovery_file_dest_size=4322230272

*.diagnostic_dest='/u01/app/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=testdb1XDB)'

*.memory_target=794820608

*.open_cursors=300

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.undo_tablespace='UNDOTBS1'

 

 

oracle@Host3.cuug.net:/home/oracle>$ mkdir -p /u01/app/oracle/oradata/testdb1                                           

oracle@Host3.cuug.net:/home/oracle>$ mkdir -p /u01/app/oracle/admin/testdb1/adump

 

--配置auxiliary instance 参数文件(因为它与source instance不存在位置的变换,即完全一致,所以不用做任何修改)

--生成auxiliary instance的口令文件

oracle@Host3.cuug.net:/u01/app/oracle/product/11.2.0/dbhome_1/dbs>$ orapwd file=orapwtestdb1 password=sys entries=10

 

--实施数据库的复制

--本实验不需要连接到source instance和recover catalog,所以可先不配置监听程序

--启动auxiliary instance到nomount状态

oracle@Host3.cuug.net:/home/oracle>$ export ORACLE_SID=testdb1

oracle@Host3.cuug.net:/home/oracle>$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Fri Jun 13 05:22:27 2014

 

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

 

Connected to an idle instance.

 

idle>startup nomount;

ORACLE instance started.

 

Total System Global Area  795127808 bytes

Fixed Size                  1347876 bytes

Variable Size             490737372 bytes

Database Buffers          297795584 bytes

Redo Buffers                5246976 bytes

 

--连接到auxiliary instance并复制数据库

oracle@Host3.cuug.net:/home/oracle>$ export ORACLE_SID=testdb1

oracle@Host3.cuug.net:/home/oracle>$ rman auxiliary /        

 

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Jun 13 05:25:42 2014

 

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

 

connected to auxiliary database: TESTDB1 (not mounted)

 

RMAN> duplicate target database to testdb1 spfile

2> backup location '/u01/app/oracle/fast_recovery_area/TESTDB1'

3> nofilenamecheck;

 

Starting Duplicate Db at 13-JUN-14

 

contents of Memory Script:

{

   restore clone spfile to  '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfiletestdb1.ora' from

 '/u01/app/oracle/fast_recovery_area/TESTDB1/backupset/2014_06_13/o1_mf_ncsnf_TAG20140613T055103_9soljwl4_.bkp';

   sql clone "alter system set spfile= ''/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfiletestdb1.ora''";

}

executing Memory Script

 

Starting restore at 13-JUN-14

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=20 device type=DISK

 

channel ORA_AUX_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/fast_recovery_area/TESTDB1/backupset/2014_06_13/o1_mf_ncsnf_TAG20140613T055103_9soljwl4_.bkp

channel ORA_AUX_DISK_1: SPFILE restore from AUTOBACKUP complete

Finished restore at 13-JUN-14

 

sql statement: alter system set spfile= ''/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfiletestdb1.ora''

 

contents of Memory Script:

{

   sql clone "alter system set  db_name =

 ''TESTDB1'' comment=

 ''duplicate'' scope=spfile";

   shutdown clone immediate;

   startup clone nomount;

}

executing Memory Script

 

sql statement: alter system set  db_name =  ''TESTDB1'' comment= ''duplicate'' scope=spfile

 

Oracle instance shut down

 

connected to auxiliary database (not started)

Oracle instance started

 

Total System Global Area     795127808 bytes

 

Fixed Size                     1347876 bytes

Variable Size                482348764 bytes

Database Buffers             306184192 bytes

Redo Buffers                   5246976 bytes

 

contents of Memory Script:

{

   sql clone "alter system set  db_name =

 ''TESTDB1'' comment=

 ''Modified by RMAN duplicate'' scope=spfile";

   sql clone "alter system set  db_unique_name =

 ''TESTDB1'' comment=

 ''Modified by RMAN duplicate'' scope=spfile";

   shutdown clone immediate;

   startup clone force nomount

   restore clone primary controlfile from  '/u01/app/oracle/fast_recovery_area/TESTDB1/backupset/2014_06_13/o1_mf_ncsnf_TAG20140613T055103_9soljwl4_.bkp';

   alter clone database mount;

}

executing Memory Script

 

sql statement: alter system set  db_name =  ''TESTDB1'' comment= ''Modified by RMAN duplicate'' scope=spfile

 

sql statement: alter system set  db_unique_name =  ''TESTDB1'' comment= ''Modified by RMAN duplicate'' scope=spfile

 

Oracle instance shut down

 

Oracle instance started

 

Total System Global Area     795127808 bytes

 

Fixed Size                     1347876 bytes

Variable Size                482348764 bytes

Database Buffers             306184192 bytes

Redo Buffers                   5246976 bytes

 

Starting restore at 13-JUN-14

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=18 device type=DISK

 

channel ORA_AUX_DISK_1: restoring control file

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03

output file name=/u01/app/oracle/oradata/testdb1/control01.ctl

output file name=/u01/app/oracle/fast_recovery_area/testdb1/control02.ctl

Finished restore at 13-JUN-14

 

database mounted

released channel: ORA_AUX_DISK_1

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=18 device type=DISK

RMAN-05538: WARNING: implicitly using DB_FILE_NAME_CONVERT

 

contents of Memory Script:

{

   set until scn  876824;

   set newname for datafile  1 to

 "/u01/app/oracle/oradata/testdb1/system01.dbf";

   set newname for datafile  2 to

 "/u01/app/oracle/oradata/testdb1/sysaux01.dbf";

   set newname for datafile  3 to

 "/u01/app/oracle/oradata/testdb1/undotbs01.dbf";

   set newname for datafile  4 to

 "/u01/app/oracle/oradata/testdb1/users01.dbf";

   set newname for datafile  5 to

 "/u01/app/oracle/oradata/testdb1/example01.dbf";

   restore

   clone database

   ;

}

executing Memory Script

 

executing command: SET until clause

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

Starting restore at 13-JUN-14

using channel ORA_AUX_DISK_1

 

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/testdb1/system01.dbf

channel ORA_AUX_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/testdb1/sysaux01.dbf

channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/testdb1/undotbs01.dbf

channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/testdb1/users01.dbf

channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/testdb1/example01.dbf

channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/TESTDB1/backupset/2014_06_13/o1_mf_nnndf_TAG20140613T055103_9sold83z_.bkp

channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/TESTDB1/backupset/2014_06_13/o1_mf_nnndf_TAG20140613T055103_9sold83z_.bkp tag=TAG20140613T055103

channel ORA_AUX_DISK_1: restored backup piece 1

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:02:27

Finished restore at 13-JUN-14

 

contents of Memory Script:

{

   switch clone datafile all;

}

executing Memory Script

 

datafile 1 switched to datafile copy

input datafile copy RECID=1 STAMP=850111765 file name=/u01/app/oracle/oradata/testdb1/system01.dbf

datafile 2 switched to datafile copy

input datafile copy RECID=2 STAMP=850111765 file name=/u01/app/oracle/oradata/testdb1/sysaux01.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=3 STAMP=850111765 file name=/u01/app/oracle/oradata/testdb1/undotbs01.dbf

datafile 4 switched to datafile copy

input datafile copy RECID=4 STAMP=850111765 file name=/u01/app/oracle/oradata/testdb1/users01.dbf

datafile 5 switched to datafile copy

input datafile copy RECID=5 STAMP=850111765 file name=/u01/app/oracle/oradata/testdb1/example01.dbf

 

contents of Memory Script:

{

   set until scn  876824;

   recover

   clone database

    delete archivelog

   ;

}

executing Memory Script

 

executing command: SET until clause

 

Starting recover at 13-JUN-14

using channel ORA_AUX_DISK_1

 

starting media recovery

 

channel ORA_AUX_DISK_1: starting archived log restore to default destination

channel ORA_AUX_DISK_1: restoring archived log

archived log thread=1 sequence=7

channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/TESTDB1/backupset/2014_06_13/o1_mf_annnn_TAG20140613T055333_9soljxz1_.bkp

channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/TESTDB1/backupset/2014_06_13/o1_mf_annnn_TAG20140613T055333_9soljxz1_.bkp tag=TAG20140613T055333

channel ORA_AUX_DISK_1: restored backup piece 1

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01

archived log file name=/u01/app/oracle/fast_recovery_area/TESTDB1/archivelog/2014_06_13/o1_mf_1_7_9somgqk7_.arc thread=1 sequence=7

channel clone_default: deleting archived log(s)

archived log file name=/u01/app/oracle/fast_recovery_area/TESTDB1/archivelog/2014_06_13/o1_mf_1_7_9somgqk7_.arc RECID=1 STAMP=850111767

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

Finished recover at 13-JUN-14

Oracle instance started

 

Total System Global Area     795127808 bytes

 

Fixed Size                     1347876 bytes

Variable Size                482348764 bytes

Database Buffers             306184192 bytes

Redo Buffers                   5246976 bytes

 

contents of Memory Script:

{

   sql clone "alter system set  db_name =

 ''TESTDB1'' comment=

 ''Reset to original value by RMAN'' scope=spfile";

   sql clone "alter system reset  db_unique_name scope=spfile";

   shutdown clone immediate;

   startup clone nomount;

}

executing Memory Script

 

sql statement: alter system set  db_name =  ''TESTDB1'' comment= ''Reset to original value by RMAN'' scope=spfile

 

sql statement: alter system reset  db_unique_name scope=spfile

 

Oracle instance shut down

 

connected to auxiliary database (not started)

Oracle instance started

 

Total System Global Area     795127808 bytes

 

Fixed Size                     1347876 bytes

Variable Size                482348764 bytes

Database Buffers             306184192 bytes

Redo Buffers                   5246976 bytes

sql statement: CREATE CONTROLFILE REUSE SET DATABASE "TESTDB1" RESETLOGS ARCHIVELOG

  MAXLOGFILES     16

  MAXLOGMEMBERS      3

  MAXDATAFILES      100

  MAXINSTANCES     8

  MAXLOGHISTORY      292

 LOGFILE

  GROUP   1  SIZE 50 M ,

  GROUP   2  SIZE 50 M ,

  GROUP   3  SIZE 50 M

 DATAFILE

  '/u01/app/oracle/oradata/testdb1/system01.dbf'

 CHARACTER SET AL32UTF8

 

 

contents of Memory Script:

{

   set newname for tempfile  1 to

 "/u01/app/oracle/oradata/testdb1/temp01.dbf";

   switch clone tempfile all;

   catalog clone datafilecopy  "/u01/app/oracle/oradata/testdb1/sysaux01.dbf",

 "/u01/app/oracle/oradata/testdb1/undotbs01.dbf",

 "/u01/app/oracle/oradata/testdb1/users01.dbf",

 "/u01/app/oracle/oradata/testdb1/example01.dbf";

   switch clone datafile all;

}

executing Memory Script

 

executing command: SET NEWNAME

 

renamed tempfile 1 to /u01/app/oracle/oradata/testdb1/temp01.dbf in control file

 

cataloged datafile copy

datafile copy file name=/u01/app/oracle/oradata/testdb1/sysaux01.dbf RECID=1 STAMP=850111792

cataloged datafile copy

datafile copy file name=/u01/app/oracle/oradata/testdb1/undotbs01.dbf RECID=2 STAMP=850111792

cataloged datafile copy

datafile copy file name=/u01/app/oracle/oradata/testdb1/users01.dbf RECID=3 STAMP=850111792

cataloged datafile copy

datafile copy file name=/u01/app/oracle/oradata/testdb1/example01.dbf RECID=4 STAMP=850111792

 

datafile 2 switched to datafile copy

input datafile copy RECID=1 STAMP=850111792 file name=/u01/app/oracle/oradata/testdb1/sysaux01.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=2 STAMP=850111792 file name=/u01/app/oracle/oradata/testdb1/undotbs01.dbf

datafile 4 switched to datafile copy

input datafile copy RECID=3 STAMP=850111792 file name=/u01/app/oracle/oradata/testdb1/users01.dbf

datafile 5 switched to datafile copy

input datafile copy RECID=4 STAMP=850111792 file name=/u01/app/oracle/oradata/testdb1/example01.dbf

 

contents of Memory Script:

{

   Alter clone database open resetlogs;

}

executing Memory Script

 

database opened

Finished Duplicate Db at 13-JUN-14

 

--验证我们的复制成果

idle>conn scott/scott

Connected.

scott@TESTDB1>select * from worldcup;


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

请登录后发表评论 登录
全部评论

注册时间:2014-08-06

  • 博文量
    195
  • 访问量
    558536