|
FROM ACTIVE DATABASE实验:
1. 准备initdbclone1.ora:
- db_name=dbclone1
- db_domain=example.com
复制代码 2.准备orapwdbclone1:
- orapwd file=orapwdbclone1 password=oracle_4U entries=4
复制代码 3.启动auxiliary实例。(目的地实例)
先写/etc/oratab:
- +ASM:/u01/app/oracle/product/11.2.0/grid:N
- winorcl:/u01/app/oracle/product/11.2.0/dbhome_1:N # line added by Agent
- dbclone1:/u01/app/oracle/product/11.2.0/dbhome_1:N
复制代码 再. oraenv
4.在auxiliary实例的监听器上进行注册:
+ASM的listener.ora:
- # listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/grid/network/admin/listener.ora
- # Generated by Oracle configuration tools.
- SID_LIST_LISTENER =
- (SID_LIST =
- (SID_DESC =
- (GLOBAL_DBNAME = dbclone1.example.com)
- (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
- (SID_NAME = dbclone1)
- )
- )
- LISTENER =
- (DESCRIPTION_LIST =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
- )
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.87)(PORT = 1521))
- )
- )
- ADR_BASE_LISTENER = /u01/app/oracle
- ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER = ON
复制代码 5. 分发tnsnames.ora(源头、目的地和第三方控制台,第三方控制台不是必需的,可以用源头和目的地之中的任何一台代替第三方控制台):
- ORCL =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.86)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SERVER = DEDICATED)
- (SERVICE_NAME = orcl.example.com)
- )
- )
- DBCLONE1 =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.87)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SERVER = DEDICATED)
- (SERVICE_NAME = dbclone1.example.com)
- )
- )
复制代码 6. 执行duplicate database脚本(代替了第7章中实验11a的操作,如果在本地恢复还是要用11a实验的做法):
在目的地操作系统上建一下adump目录:
- mkdir -p /u01/app/oracle/admin/dbclone1/adump
复制代码- run {
- duplicate target database to dbclone1
- from active database
- nofilenamecheck
- spfile
- set
- control_files='+DATA','+FRA'
- set
- db_file_name_convert='+DATA/orcl/','+DATA/dbclone1/'
- set
- log_file_name_convert='+DATA/orcl/','+DATA/dbclone1/','+FRA/orcl','+FRA/dbclone1/'
- set
- audit_file_dest='/u01/app/oracle/admin/dbclone1/adump';
- }
复制代码 7. 具体执行命令:
- [oracle@station90 ~]$ rman target sys/oracle_4U@orcl auxiliary sys/oracle_4U@dbclone1 cmdfile=dbclone1.rcv
复制代码 内存脚本的执行全过程(输出):
- Recovery Manager: Release 11.2.0.3.0 - Production on Sat Jun 16 10:52:18 2018
- Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
- PL/SQL package SYS.DBMS_BACKUP_RESTORE version 11.02.00.01 in TARGET database is not current
- PL/SQL package SYS.DBMS_RCVMAN version 11.02.00.01 in TARGET database is not current
- connected to target database: ORCL (DBID=1359978017)
- PL/SQL package SYS.DBMS_BACKUP_RESTORE version 11.02.00.01 in AUXILIARY database is not current
- PL/SQL package SYS.DBMS_RCVMAN version 11.02.00.01 in AUXILIARY database is not current
- connected to auxiliary database: DBCLONE1 (not mounted)
- RMAN> exit
- Recovery Manager complete.
- [oracle@station90 ~]$ rman target sys/oracle_4U@orcl auxiliary sys/oracle_4U@dbclone1 cmdfile=dbclone1.rcv
- Recovery Manager: Release 11.2.0.3.0 - Production on Sat Jun 16 10:52:53 2018
- Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
- PL/SQL package SYS.DBMS_BACKUP_RESTORE version 11.02.00.01 in TARGET database is not current
- PL/SQL package SYS.DBMS_RCVMAN version 11.02.00.01 in TARGET database is not current
- connected to target database: ORCL (DBID=1359978017)
- PL/SQL package SYS.DBMS_BACKUP_RESTORE version 11.02.00.01 in AUXILIARY database is not current
- PL/SQL package SYS.DBMS_RCVMAN version 11.02.00.01 in AUXILIARY database is not current
- connected to auxiliary database: DBCLONE1 (not mounted)
- RMAN> run {
- 2> duplicate target database to dbclone1
- 3> from active database
- 4> nofilenamecheck
- 5> spfile
- 6> set
- 7> control_files='+DATA','+FRA'
- 8> set
- 9> db_file_name_convert='+DATA/orcl/','+DATA/dbclone1/'
- 10> set
- 11> log_file_name_convert='+DATA/orcl/','+DATA/dbclone1/','+FRA/orcl','+FRA/dbclone1/'
- 12> set
- 13> audit_file_dest='/u01/app/oracle/admin/dbclone1/adump';
- 14> }
- 15>
- Starting Duplicate Db at 16-JUN-18
- using target database control file instead of recovery catalog
- allocated channel: ORA_AUX_DISK_1
- channel ORA_AUX_DISK_1: SID=95 device type=DISK
- allocated channel: ORA_AUX_DISK_2
- channel ORA_AUX_DISK_2: SID=10 device type=DISK
- allocated channel: ORA_AUX_DISK_3
- channel ORA_AUX_DISK_3: SID=97 device type=DISK
- allocated channel: ORA_AUX_DISK_4
- channel ORA_AUX_DISK_4: SID=11 device type=DISK
- allocated channel: ORA_AUX_DISK_5
- channel ORA_AUX_DISK_5: SID=98 device type=DISK
- allocated channel: ORA_AUX_DISK_6
- channel ORA_AUX_DISK_6: SID=12 device type=DISK
- allocated channel: ORA_AUX_DISK_7
- channel ORA_AUX_DISK_7: SID=99 device type=DISK
- allocated channel: ORA_AUX_DISK_8
- channel ORA_AUX_DISK_8: SID=13 device type=DISK
- allocated channel: ORA_AUX_SBT_TAPE_1
- channel ORA_AUX_SBT_TAPE_1: SID=100 device type=SBT_TAPE
- channel ORA_AUX_SBT_TAPE_1: Oracle Secure Backup
- allocated channel: ORA_AUX_SBT_TAPE_2
- channel ORA_AUX_SBT_TAPE_2: SID=14 device type=SBT_TAPE
- channel ORA_AUX_SBT_TAPE_2: Oracle Secure Backup
- contents of Memory Script:
- {
- backup as copy reuse
- targetfile '+DATA/orcl/spfileorcl.ora' auxiliary format
- '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfiledbclone1.ora' ;
- sql clone "alter system set spfile= ''/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfiledbclone1.ora''";
- }
- executing Memory Script
- Starting backup at 16-JUN-18
- allocated channel: ORA_DISK_1
- channel ORA_DISK_1: SID=75 device type=DISK
- allocated channel: ORA_DISK_2
- channel ORA_DISK_2: SID=138 device type=DISK
- allocated channel: ORA_DISK_3
- channel ORA_DISK_3: SID=195 device type=DISK
- allocated channel: ORA_DISK_4
- channel ORA_DISK_4: SID=11 device type=DISK
- allocated channel: ORA_DISK_5
- channel ORA_DISK_5: SID=71 device type=DISK
- allocated channel: ORA_DISK_6
- channel ORA_DISK_6: SID=140 device type=DISK
- allocated channel: ORA_DISK_7
- channel ORA_DISK_7: SID=200 device type=DISK
- allocated channel: ORA_DISK_8
- channel ORA_DISK_8: SID=12 device type=DISK
- Finished backup at 16-JUN-18
- sql statement: alter system set spfile= ''/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfiledbclone1.ora''
- contents of Memory Script:
- {
- sql clone "alter system set db_name =
- ''DBCLONE1'' comment=
- ''duplicate'' scope=spfile";
- sql clone "alter system set control_files =
- ''+DATA'', ''+FRA'' comment=
- '''' scope=spfile";
- sql clone "alter system set db_file_name_convert =
- ''+DATA/orcl/'', ''+DATA/dbclone1/'' comment=
- '''' scope=spfile";
- sql clone "alter system set log_file_name_convert =
- ''+DATA/orcl/'', ''+DATA/dbclone1/'', ''+FRA/orcl'', ''+FRA/dbclone1/'' comment=
- '''' scope=spfile";
- sql clone "alter system set audit_file_dest =
- ''/u01/app/oracle/admin/dbclone1/adump'' comment=
- '''' scope=spfile";
- shutdown clone immediate;
- startup clone nomount;
- }
- executing Memory Script
- sql statement: alter system set db_name = ''DBCLONE1'' comment= ''duplicate'' scope=spfile
- sql statement: alter system set control_files = ''+DATA'', ''+FRA'' comment= '''' scope=spfile
- sql statement: alter system set db_file_name_convert = ''+DATA/orcl/'', ''+DATA/dbclone1/'' comment= '''' scope=spfile
- sql statement: alter system set log_file_name_convert = ''+DATA/orcl/'', ''+DATA/dbclone1/'', ''+FRA/orcl'', ''+FRA/dbclone1/'' comment= '''' scope=spfile
- sql statement: alter system set audit_file_dest = ''/u01/app/oracle/admin/dbclone1/adump'' comment= '''' scope=spfile
- Oracle instance shut down
- connected to auxiliary database (not started)
- Oracle instance started
- Total System Global Area 820236288 bytes
- Fixed Size 1339628 bytes
- Variable Size 482348820 bytes
- Database Buffers 331350016 bytes
- Redo Buffers 5197824 bytes
- contents of Memory Script:
- {
- sql clone "alter system set control_files =
- ''+DATA/dbclone1/controlfile/current.266.978979989'', ''+FRA/dbclone1/controlfile/current.320.978979991'' comment=
- ''Set by RMAN'' scope=spfile";
- sql clone "alter system set db_name =
- ''ORCL'' comment=
- ''Modified by RMAN duplicate'' scope=spfile";
- sql clone "alter system set db_unique_name =
- ''DBCLONE1'' comment=
- ''Modified by RMAN duplicate'' scope=spfile";
- shutdown clone immediate;
- startup clone force nomount
- backup as copy current controlfile auxiliary format '+DATA/dbclone1/controlfile/current.264.978979991';
- restore clone controlfile to '+FRA/dbclone1/controlfile/current.258.978979991' from
- '+DATA/dbclone1/controlfile/current.264.978979991';
- sql clone "alter system set control_files =
- ''+DATA/dbclone1/controlfile/current.264.978979991'', ''+FRA/dbclone1/controlfile/current.258.978979991'' comment=
- ''Set by RMAN'' scope=spfile";
- shutdown clone immediate;
- startup clone nomount;
- alter clone database mount;
- }
- executing Memory Script
- sql statement: alter system set control_files = ''+DATA/dbclone1/controlfile/current.266.978979989'', ''+FRA/dbclone1/controlfile/current.320.978979991'' comment= ''Set by RMAN'' scope=spfile
- sql statement: alter system set db_name = ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfile
- sql statement: alter system set db_unique_name = ''DBCLONE1'' comment= ''Modified by RMAN duplicate'' scope=spfile
- Oracle instance shut down
- Oracle instance started
- Total System Global Area 820236288 bytes
- Fixed Size 1339628 bytes
- Variable Size 482348820 bytes
- Database Buffers 331350016 bytes
- Redo Buffers 5197824 bytes
- Starting backup at 16-JUN-18
- using channel ORA_DISK_1
- using channel ORA_DISK_2
- using channel ORA_DISK_3
- using channel ORA_DISK_4
- using channel ORA_DISK_5
- using channel ORA_DISK_6
- using channel ORA_DISK_7
- using channel ORA_DISK_8
- channel ORA_DISK_1: starting datafile copy
- copying current control file
- output file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_orcl.f tag=TAG20180616T105316 RECID=2 STAMP=978951197
- channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
- Finished backup at 16-JUN-18
- Starting restore at 16-JUN-18
- allocated channel: ORA_AUX_DISK_1
- channel ORA_AUX_DISK_1: SID=13 device type=DISK
- allocated channel: ORA_AUX_DISK_2
- channel ORA_AUX_DISK_2: SID=135 device type=DISK
- allocated channel: ORA_AUX_DISK_3
- channel ORA_AUX_DISK_3: SID=136 device type=DISK
- allocated channel: ORA_AUX_DISK_4
- channel ORA_AUX_DISK_4: SID=15 device type=DISK
- allocated channel: ORA_AUX_DISK_5
- channel ORA_AUX_DISK_5: SID=137 device type=DISK
- allocated channel: ORA_AUX_DISK_6
- channel ORA_AUX_DISK_6: SID=16 device type=DISK
- allocated channel: ORA_AUX_DISK_7
- channel ORA_AUX_DISK_7: SID=138 device type=DISK
- allocated channel: ORA_AUX_DISK_8
- channel ORA_AUX_DISK_8: SID=17 device type=DISK
- allocated channel: ORA_AUX_SBT_TAPE_1
- channel ORA_AUX_SBT_TAPE_1: SID=139 device type=SBT_TAPE
- channel ORA_AUX_SBT_TAPE_1: Oracle Secure Backup
- allocated channel: ORA_AUX_SBT_TAPE_2
- channel ORA_AUX_SBT_TAPE_2: SID=18 device type=SBT_TAPE
- channel ORA_AUX_SBT_TAPE_2: Oracle Secure Backup
- channel ORA_AUX_DISK_2: skipped, AUTOBACKUP already found
- channel ORA_AUX_DISK_3: skipped, AUTOBACKUP already found
- channel ORA_AUX_DISK_4: skipped, AUTOBACKUP already found
- channel ORA_AUX_DISK_5: skipped, AUTOBACKUP already found
- channel ORA_AUX_DISK_6: skipped, AUTOBACKUP already found
- channel ORA_AUX_DISK_7: skipped, AUTOBACKUP already found
- channel ORA_AUX_DISK_8: skipped, AUTOBACKUP already found
- channel ORA_AUX_SBT_TAPE_1: skipped, AUTOBACKUP already found
- channel ORA_AUX_SBT_TAPE_2: skipped, AUTOBACKUP already found
- channel ORA_AUX_DISK_1: copied control file copy
- Finished restore at 16-JUN-18
- sql statement: alter system set control_files = ''+DATA/dbclone1/controlfile/current.264.978979991'', ''+FRA/dbclone1/controlfile/current.258.978979991'' comment= ''Set by RMAN'' scope=spfile
- Oracle instance shut down
- connected to auxiliary database (not started)
- Oracle instance started
- Total System Global Area 820236288 bytes
- Fixed Size 1339628 bytes
- Variable Size 482348820 bytes
- Database Buffers 331350016 bytes
- Redo Buffers 5197824 bytes
- database mounted
- RMAN-05529: WARNING: DB_FILE_NAME_CONVERT resulted in invalid ASM names; names changed to disk group only.
- contents of Memory Script:
- {
- set newname for datafile 1 to
- "+data";
- set newname for datafile 2 to
- "+data";
- set newname for datafile 3 to
- "+data";
- set newname for datafile 4 to
- "+data";
- set newname for datafile 5 to
- "+data";
- backup as copy reuse
- datafile 1 auxiliary format
- "+data" datafile
- 2 auxiliary format
- "+data" datafile
- 3 auxiliary format
- "+data" datafile
- 4 auxiliary format
- "+data" datafile
- 5 auxiliary format
- "+data" ;
- sql 'alter system archive log current';
- }
- executing Memory Script
- executing command: SET NEWNAME
- executing command: SET NEWNAME
- executing command: SET NEWNAME
- executing command: SET NEWNAME
- executing command: SET NEWNAME
- Starting backup at 16-JUN-18
- using channel ORA_DISK_1
- using channel ORA_DISK_2
- using channel ORA_DISK_3
- using channel ORA_DISK_4
- using channel ORA_DISK_5
- using channel ORA_DISK_6
- using channel ORA_DISK_7
- using channel ORA_DISK_8
- channel ORA_DISK_1: starting datafile copy
- input datafile file number=00001 name=+DATA/orcl/datafile/system.256.978643425
- channel ORA_DISK_2: starting datafile copy
- input datafile file number=00002 name=+DATA/orcl/datafile/sysaux.258.978643425
- channel ORA_DISK_3: starting datafile copy
- input datafile file number=00003 name=+DATA/orcl/datafile/undotbs1.259.978643423
- channel ORA_DISK_4: starting datafile copy
- input datafile file number=00005 name=+DATA/orcl/datafile/example.257.978643425
- channel ORA_DISK_5: starting datafile copy
- input datafile file number=00004 name=+DATA/orcl/datafile/users.265.978645015
- output file name=+DATA/dbclone1/datafile/users.259.978980031 tag=TAG20180616T105349
- channel ORA_DISK_5: datafile copy complete, elapsed time: 00:00:15
- output file name=+DATA/dbclone1/datafile/example.265.978980031 tag=TAG20180616T105349
- channel ORA_DISK_4: datafile copy complete, elapsed time: 00:00:45
- output file name=+DATA/dbclone1/datafile/undotbs1.267.978980031 tag=TAG20180616T105349
- channel ORA_DISK_3: datafile copy complete, elapsed time: 00:01:25
- output file name=+DATA/dbclone1/datafile/system.260.978980031 tag=TAG20180616T105349
- channel ORA_DISK_1: datafile copy complete, elapsed time: 00:02:09
- output file name=+DATA/dbclone1/datafile/sysaux.268.978980031 tag=TAG20180616T105349
- channel ORA_DISK_2: datafile copy complete, elapsed time: 00:02:09
- Finished backup at 16-JUN-18
- sql statement: alter system archive log current
- contents of Memory Script:
- {
- backup as copy reuse
- archivelog like "+FRA/orcl/archivelog/2018_06_16/thread_1_seq_4.351.978951273" auxiliary format
- "+FRA" archivelog like
- "+FRA/orcl/archivelog/2018_06_16/thread_1_seq_5.352.978951293" auxiliary format
- "+FRA" archivelog like
- "+FRA/orcl/archivelog/2018_06_16/thread_1_seq_6.359.978951361" auxiliary format
- "+FRA" ;
- catalog clone start with "+FRA";
- switch clone datafile all;
- }
- executing Memory Script
- Starting backup at 16-JUN-18
- using channel ORA_DISK_1
- using channel ORA_DISK_2
- using channel ORA_DISK_3
- using channel ORA_DISK_4
- using channel ORA_DISK_5
- using channel ORA_DISK_6
- using channel ORA_DISK_7
- using channel ORA_DISK_8
- channel ORA_DISK_1: starting archived log copy
- input archived log thread=1 sequence=4 RECID=105 STAMP=978951276
- channel ORA_DISK_2: starting archived log copy
- input archived log thread=1 sequence=5 RECID=106 STAMP=978951296
- channel ORA_DISK_3: starting archived log copy
- input archived log thread=1 sequence=6 RECID=107 STAMP=978951361
- output file name=+FRA/dbclone1/archivelog/2018_06_16/thread_1_seq_4.266.978980163 RECID=0 STAMP=0
- channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:07
- output file name=+FRA/dbclone1/archivelog/2018_06_16/thread_1_seq_5.296.978980163 RECID=0 STAMP=0
- channel ORA_DISK_2: archived log copy complete, elapsed time: 00:00:07
- output file name=+FRA/dbclone1/archivelog/2018_06_16/thread_1_seq_6.293.978980163 RECID=0 STAMP=0
- channel ORA_DISK_3: archived log copy complete, elapsed time: 00:00:07
- Finished backup at 16-JUN-18
- searching for all files that match the pattern +FRA
- List of Files Unknown to the Database
- =====================================
- File Name: +fra/DBCLONE1/ARCHIVELOG/2018_06_16/thread_1_seq_4.266.978980163
- File Name: +fra/DBCLONE1/ARCHIVELOG/2018_06_16/thread_1_seq_5.296.978980163
- File Name: +fra/DBCLONE1/ARCHIVELOG/2018_06_16/thread_1_seq_6.293.978980163
- File Name: +fra/DBCLONE1/CONTROLFILE/Current.320.978979991
- cataloging files...
- cataloging done
- List of Cataloged Files
- =======================
- File Name: +fra/DBCLONE1/ARCHIVELOG/2018_06_16/thread_1_seq_4.266.978980163
- File Name: +fra/DBCLONE1/ARCHIVELOG/2018_06_16/thread_1_seq_5.296.978980163
- File Name: +fra/DBCLONE1/ARCHIVELOG/2018_06_16/thread_1_seq_6.293.978980163
- List of Files Which Where Not Cataloged
- =======================================
- File Name: +fra/DBCLONE1/CONTROLFILE/Current.320.978979991
- RMAN-07517: Reason: The file header is corrupted
- datafile 1 switched to datafile copy
- input datafile copy RECID=2 STAMP=978980170 file name=+DATA/dbclone1/datafile/system.260.978980031
- datafile 2 switched to datafile copy
- input datafile copy RECID=3 STAMP=978980170 file name=+DATA/dbclone1/datafile/sysaux.268.978980031
- datafile 3 switched to datafile copy
- input datafile copy RECID=4 STAMP=978980170 file name=+DATA/dbclone1/datafile/undotbs1.267.978980031
- datafile 4 switched to datafile copy
- input datafile copy RECID=5 STAMP=978980170 file name=+DATA/dbclone1/datafile/users.259.978980031
- datafile 5 switched to datafile copy
- input datafile copy RECID=6 STAMP=978980170 file name=+DATA/dbclone1/datafile/example.265.978980031
- contents of Memory Script:
- {
- set until scn 1161526;
- recover
- clone database
- delete archivelog
- ;
- }
- executing Memory Script
- executing command: SET until clause
- Starting recover at 16-JUN-18
- allocated channel: ORA_AUX_DISK_1
- channel ORA_AUX_DISK_1: SID=135 device type=DISK
- allocated channel: ORA_AUX_DISK_2
- channel ORA_AUX_DISK_2: SID=15 device type=DISK
- allocated channel: ORA_AUX_DISK_3
- channel ORA_AUX_DISK_3: SID=14 device type=DISK
- allocated channel: ORA_AUX_DISK_4
- channel ORA_AUX_DISK_4: SID=137 device type=DISK
- allocated channel: ORA_AUX_DISK_5
- channel ORA_AUX_DISK_5: SID=138 device type=DISK
- allocated channel: ORA_AUX_DISK_6
- channel ORA_AUX_DISK_6: SID=139 device type=DISK
- allocated channel: ORA_AUX_DISK_7
- channel ORA_AUX_DISK_7: SID=18 device type=DISK
- allocated channel: ORA_AUX_DISK_8
- channel ORA_AUX_DISK_8: SID=140 device type=DISK
- allocated channel: ORA_AUX_SBT_TAPE_1
- channel ORA_AUX_SBT_TAPE_1: SID=19 device type=SBT_TAPE
- channel ORA_AUX_SBT_TAPE_1: Oracle Secure Backup
- allocated channel: ORA_AUX_SBT_TAPE_2
- channel ORA_AUX_SBT_TAPE_2: SID=141 device type=SBT_TAPE
- channel ORA_AUX_SBT_TAPE_2: Oracle Secure Backup
- starting media recovery
- archived log for thread 1 with sequence 4 is already on disk as file +FRA/dbclone1/archivelog/2018_06_16/thread_1_seq_4.266.978980163
- archived log for thread 1 with sequence 5 is already on disk as file +FRA/dbclone1/archivelog/2018_06_16/thread_1_seq_5.296.978980163
- archived log for thread 1 with sequence 6 is already on disk as file +FRA/dbclone1/archivelog/2018_06_16/thread_1_seq_6.293.978980163
- archived log file name=+FRA/dbclone1/archivelog/2018_06_16/thread_1_seq_4.266.978980163 thread=1 sequence=4
- archived log file name=+FRA/dbclone1/archivelog/2018_06_16/thread_1_seq_5.296.978980163 thread=1 sequence=5
- archived log file name=+FRA/dbclone1/archivelog/2018_06_16/thread_1_seq_6.293.978980163 thread=1 sequence=6
- media recovery complete, elapsed time: 00:00:17
- Finished recover at 16-JUN-18
- Oracle instance started
- Total System Global Area 820236288 bytes
- Fixed Size 1339628 bytes
- Variable Size 482348820 bytes
- Database Buffers 331350016 bytes
- Redo Buffers 5197824 bytes
- contents of Memory Script:
- {
- sql clone "alter system set db_name =
- ''DBCLONE1'' 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 = ''DBCLONE1'' 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 820236288 bytes
- Fixed Size 1339628 bytes
- Variable Size 482348820 bytes
- Database Buffers 331350016 bytes
- Redo Buffers 5197824 bytes
- sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DBCLONE1" RESETLOGS ARCHIVELOG
- MAXLOGFILES 16
- MAXLOGMEMBERS 3
- MAXDATAFILES 100
- MAXINSTANCES 8
- MAXLOGHISTORY 292
- LOGFILE
- GROUP 1 ( '+data', '+fra' ) SIZE 50 M REUSE,
- GROUP 2 ( '+data', '+fra' ) SIZE 50 M REUSE,
- GROUP 3 ( '+data', '+fra' ) SIZE 50 M REUSE
- DATAFILE
- '+DATA/dbclone1/datafile/system.260.978980031'
- CHARACTER SET AL32UTF8
- contents of Memory Script:
- {
- set newname for tempfile 1 to
- "+data";
- switch clone tempfile all;
- catalog clone datafilecopy "+DATA/dbclone1/datafile/sysaux.268.978980031",
- "+DATA/dbclone1/datafile/undotbs1.267.978980031",
- "+DATA/dbclone1/datafile/users.259.978980031",
- "+DATA/dbclone1/datafile/example.265.978980031";
- switch clone datafile all;
- }
- executing Memory Script
- executing command: SET NEWNAME
- renamed tempfile 1 to +data in control file
- cataloged datafile copy
- datafile copy file name=+DATA/dbclone1/datafile/sysaux.268.978980031 RECID=1 STAMP=978980209
- cataloged datafile copy
- datafile copy file name=+DATA/dbclone1/datafile/undotbs1.267.978980031 RECID=2 STAMP=978980209
- cataloged datafile copy
- datafile copy file name=+DATA/dbclone1/datafile/users.259.978980031 RECID=3 STAMP=978980209
- cataloged datafile copy
- datafile copy file name=+DATA/dbclone1/datafile/example.265.978980031 RECID=4 STAMP=978980209
- datafile 2 switched to datafile copy
- input datafile copy RECID=1 STAMP=978980209 file name=+DATA/dbclone1/datafile/sysaux.268.978980031
- datafile 3 switched to datafile copy
- input datafile copy RECID=2 STAMP=978980209 file name=+DATA/dbclone1/datafile/undotbs1.267.978980031
- datafile 4 switched to datafile copy
- input datafile copy RECID=3 STAMP=978980209 file name=+DATA/dbclone1/datafile/users.259.978980031
- datafile 5 switched to datafile copy
- input datafile copy RECID=4 STAMP=978980209 file name=+DATA/dbclone1/datafile/example.265.978980031
- contents of Memory Script:
- {
- Alter clone database open resetlogs;
- }
- executing Memory Script
- database opened
- Finished Duplicate Db at 16-JUN-18
- Recovery Manager complete.
- [oracle@station90 ~]$
复制代码 8. 在目的地数据库这边,注册:
- [oracle@station87 ~]$ crs_stat -t
- Name Type Target State Host
- ------------------------------------------------------------
- ora.DATA.dg ora....up.type ONLINE ONLINE station87
- ora.FRA.dg ora....up.type ONLINE ONLINE station87
- ora....ER.lsnr ora....er.type ONLINE ONLINE station87
- ora.asm ora.asm.type ONLINE ONLINE station87
- ora.cssd ora.cssd.type ONLINE ONLINE station87
- ora.diskmon ora....on.type ONLINE ONLINE station87
- [oracle@station87 ~]$ srvctl add database -d dbclone1 -o /u01/app/oracle/product/11.2.0/dbhome_1
- [oracle@station87 ~]$ crs_stat -t
- Name Type Target State Host
- ------------------------------------------------------------
- ora.DATA.dg ora....up.type ONLINE ONLINE station87
- ora.FRA.dg ora....up.type ONLINE ONLINE station87
- ora....ER.lsnr ora....er.type ONLINE ONLINE station87
- ora.asm ora.asm.type ONLINE ONLINE station87
- ora.cssd ora.cssd.type ONLINE ONLINE station87
- ora....one1.db ora....se.type OFFLINE OFFLINE
- ora.diskmon ora....on.type ONLINE ONLINE station87
- [oracle@station87 ~]$ srvctl start database -d dbclone1
- [oracle@station87 ~]$ crs_stat -t
- Name Type Target State Host
- ------------------------------------------------------------
- ora.DATA.dg ora....up.type ONLINE ONLINE station87
- ora.FRA.dg ora....up.type ONLINE ONLINE station87
- ora....ER.lsnr ora....er.type ONLINE ONLINE station87
- ora.asm ora.asm.type ONLINE ONLINE station87
- ora.cssd ora.cssd.type ONLINE ONLINE station87
- ora....one1.db ora....se.type ONLINE ONLINE station87
- ora.diskmon ora....on.type ONLINE ONLINE station87
- [oracle@station87 ~]$
复制代码
FROM ACTIVE DATABASE实验(源头是ASM目的地是文件系统):
1. 准备initdbclone2.ora:
- db_name=dbclone2
- db_domain=example.com
复制代码 2.准备orapwdbclone2:
- orapwd file=orapwdbclone2 password=oracle_4U entries=4
复制代码 3.启动auxiliary实例。(目的地实例)
先写/etc/oratab:
- +ASM:/u01/app/oracle/product/11.2.0/grid:N
- winorcl:/u01/app/oracle/product/11.2.0/dbhome_1:N # line added by Agent
- dbclone1:/u01/app/oracle/product/11.2.0/dbhome_1:N
- dbclone2:/u01/app/oracle/product/11.2.0/dbhome_1:N
复制代码 再. oraenv
4.在auxiliary实例的监听器上进行注册:
+ASM的listener.ora:
- # listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/grid/network/admin/listener.ora
- # Generated by Oracle configuration tools.
- SID_LIST_LISTENER =
- (SID_LIST =
- (SID_DESC =
- (GLOBAL_DBNAME = dbclone1.example.com)
- (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
- (SID_NAME = dbclone1)
- )
- (SID_DESC =
- (GLOBAL_DBNAME = dbclone2.example.com)
- (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
- (SID_NAME = dbclone2)
- )
- )
- LISTENER =
- (DESCRIPTION_LIST =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
- )
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.87)(PORT = 1521))
- )
- )
- ADR_BASE_LISTENER = /u01/app/oracle
- ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER = ON
复制代码 5. 分发tnsnames.ora(源头、目的地和第三方控制台,第三方控制台不是必需的,可以用源头和目的地之中的任何一台代替第三方控制台):
- ORCL =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.86)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SERVER = DEDICATED)
- (SERVICE_NAME = orcl.example.com)
- )
- )
- DBCLONE1 =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.87)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SERVER = DEDICATED)
- (SERVICE_NAME = dbclone1.example.com)
- )
- )
- DBCLONE2 =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.87)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SERVER = DEDICATED)
- (SERVICE_NAME = dbclone2.example.com)
- )
- )
复制代码 6. 执行duplicate database脚本(代替了第7章中实验11a的操作,如果在本地恢复还是要用11a实验的做法):
在目的地操作系统上建一下adump目录:
- mkdir -p /u01/app/oracle/admin/dbclone2/adump
- mkdir -p /u01/app/oracle/oradata/dbclone2
- mkdir -p /u01/app/oracle/fast_recovery_area
复制代码 顺便测试一下:选一部份表空间,不选另外一部分表空间:
- SQL> conn / as sysdba
- Connected.
- SQL> select tablespacE_name from dba_tablespaces;
- TABLESPACE_NAME
- ------------------------------
- SYSTEM
- SYSAUX
- UNDOTBS1
- TEMP
- USERS
- EXAMPLE
- 6 rows selected.
- SQL> create tablespace tbs1 datafile size 5M ;
- Tablespace created.
- SQL> create tablespace tbs2 datafile size 5M ;
- Tablespace created.
- SQL> create table t1(a number) tablespace tbs1;
- Table created.
- SQL> insert into t1 values(1) ;
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> create table hr.t2(a number) tablespace tbs2;
- Table created.
- SQL> insert into hr.t2 values (1) ;
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL>
复制代码 对排除的表空间一定要做“自包含 集检查”:
- SQL> exec dbms_tts.TRANSPORT_SET_CHECK('tbs1,tbs2');
- PL/SQL procedure successfully completed.
- SQL> select * from transport_set_violations;
- VIOLATIONS
- --------------------------------------------------------------------------------
- ORA-39917: SYS owned object T1 in tablespace TBS1 not allowed in pluggable set
复制代码 处理办法都是“移走”:
- SQL> alter table T1 move tablespace system;
- Table altered.
复制代码- run{
- duplicate target database to dbclone2
- from active database
- nofilenamecheck
- skip tablespace 'TBS1','TBS2'
- spfile
- set
- control_files='/u01/app/oracle/oradata/dbclone2/control01.ctl','/u01/app/oracle/oradata/dbclone2/control02.ctl','/u01/app/oracle/oradata/dbclone2/control03.ctl'
- set
- db_file_name_convert='+DATA/orcl/datafile/example.257.978643425','/u01/app/oracle/oradata/dbclone2/example01.dbf','+DATA/orcl/datafile/users.265.978645015','/u01/app/oracle/oradata/dbclone2/users01.dbf','+DATA/orcl/datafile/undotbs1.259.978643423','/u01/app/oracle/oradata/dbclone2/undotbs01.dbf','+DATA/orcl/datafile/sysaux.258.978643425','/u01/app/oracle/oradata/dbclone2/sysaux01.dbf','+DATA/orcl/datafile/system.256.978643425','/u01/app/oracle/oradata/dbclone2/system01.dbf'
- set
- log_file_name_convert='+DATA/orcl/onlinelog/group_1.261.978643689','/u01/app/oracle/oradata/dbclone2/redo01a.log','+FRA/orcl/onlinelog/group_1.257.978643689','/u01/app/oracle/oradata/dbclone2/redo01b.log','+DATA/orcl/onlinelog/group_3.263.978643691','/u01/app/oracle/oradata/dbclone2/redo03a.log','+FRA/orcl/onlinelog/group_3.259.978643691','/u01/app/oracle/oradata/dbclone2/redo03b.log','+DATA/orcl/onlinelog/group_2.262.978643689','/u01/app/oracle/oradata/dbclone2/redo02a.log','+FRA/orcl/onlinelog/group_2.258.978643691','/u01/app/oracle/oradata/dbclone2/redo02b.log'
- set
- audit_file_dest='/u01/app/oracle/admin/dbclone2/adump'
- set
- db_create_file_dest=''
- set
- db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
- set
- memory_target='2G'
- ;
- }
复制代码- rman target sys/oracle_4U@orcl auxiliary sys/oracle_4U@dbclone2 cmdfile=dbclone2.rcv
复制代码
BACKUP LOCATION实验:
1. 准备initdbclone3.ora:
- db_name=dbclone3
- db_domain=example.com
复制代码 2.准备orapwdbclone3:
- orapwd file=orapwdbclone3 password=oracle_4U entries=4
复制代码 3.启动auxiliary实例。(目的地实例)
先写/etc/oratab:
- +ASM:/u01/app/oracle/product/11.2.0/grid:N
- winorcl:/u01/app/oracle/product/11.2.0/dbhome_1:N # line added by Agent
- dbclone1:/u01/app/oracle/product/11.2.0/dbhome_1:N
- dbclone2:/u01/app/oracle/product/11.2.0/dbhome_1:N
- dbclone3:/u01/app/oracle/product/11.2.0/dbhome_1:N
复制代码 再. oraenv
4.在auxiliary实例的监听器上进行注册:
+ASM的listener.ora:
- # listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/grid/network/admin/listener.ora
- # Generated by Oracle configuration tools.
- SID_LIST_LISTENER =
- (SID_LIST =
- (SID_DESC =
- (GLOBAL_DBNAME = dbclone1.example.com)
- (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
- (SID_NAME = dbclone1)
- )
- (SID_DESC =
- (GLOBAL_DBNAME = dbclone2.example.com)
- (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
- (SID_NAME = dbclone2)
- )
- (SID_DESC =
- (GLOBAL_DBNAME = dbclone3.example.com)
- (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
- (SID_NAME = dbclone3)
- )
- )
- LISTENER =
- (DESCRIPTION_LIST =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
- )
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.87)(PORT = 1521))
- )
- )
- ADR_BASE_LISTENER = /u01/app/oracle
- ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER = ON
复制代码 5. 分发tnsnames.ora(源头、目的地和第三方控制台,第三方控制台不是必需的,可以用源头和目的地之中的任何一台代替第三方控制台):
- ORCL =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.86)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SERVER = DEDICATED)
- (SERVICE_NAME = orcl.example.com)
- )
- )
- DBCLONE1 =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.87)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SERVER = DEDICATED)
- (SERVICE_NAME = dbclone1.example.com)
- )
- )
- DBCLONE2 =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.87)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SERVER = DEDICATED)
- (SERVICE_NAME = dbclone2.example.com)
- )
- )
- DBCLONE3 =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.87)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SERVER = DEDICATED)
- (SERVICE_NAME = dbclone3.example.com)
- )
- )
复制代码 6. 执行duplicate database脚本(代替了第7章中实验11a的操作,如果在本地恢复还是要用11a实验的做法):
在目的地操作系统上建一下adump目录:
- mkdir -p /u01/app/oracle/admin/dbclone3/adump
复制代码 7. 在源头和目的地机器上都建一个相同的目录:
- mkdir /home/oracle/backup
复制代码 8. 在源头数据库上做备份(源头备份做完后,可以关闭):run {
- allocate channel c1 device type disk format '/home/oracle/backup/%U';
- allocate channel c2 device type disk format '/home/oracle/backup/%U';
- allocate channel c3 device type disk format '/home/oracle/backup/%U';
- allocate channel c4 device type disk format '/home/oracle/backup/%U';
- allocate channel c5 device type disk format '/home/oracle/backup/%U';
- allocate channel c6 device type disk format '/home/oracle/backup/%U';
- allocate channel c7 device type disk format '/home/oracle/backup/%U';
- allocate channel c8 device type disk format '/home/oracle/backup/%U';
- backup database plus archivelog force;
- backup spfile;
- backup current controlfile;
- }
复制代码 以上脚本结束后,把源头/home/oracle/backup/*传送到目的地/home/oracle/backup/
- [oracle@station86 backup]$ scp * station87:/home/oracle/backup/
- The authenticity of host 'station87 (192.168.0.87)' can't be established.
- RSA key fingerprint is 3c:21:7a:9c:cd:d9:41:16:75:08:fe:16:4d:37:54:5b.
- Are you sure you want to continue connecting (yes/no)? yes
- Warning: Permanently added 'station87,192.168.0.87' (RSA) to the list of known hosts.
- oracle@station87's password:
- 2et5jl2p_1_1 100% 21MB 21.3MB/s 00:00
- 2ft5jl2p_1_1 100% 43MB 21.7MB/s 00:02
- 2gt5jl2q_1_1 100% 46MB 45.9MB/s 00:01
- 2ht5jl2r_1_1
复制代码 顺便试一下新语法,老的语法供参考和显式分配通道:
- run{
- duplicate target database to mydb
- backup location '/home/oracle/backup'
- nofilenamecheck
- spfile
- set
- control_files='/u01/app/oracle/oradata/mydb/control01.ctl','/u01/app/oracle/oradata/db11g/control02.ctl','/u01/app/oracle/oradata/db11g/control03.ctl'
- set
- db_file_name_convert='+DATA/orcl/datafile/example.258.880451611','/u01/app/oracle/oradata/db11g/example01.dbf','+DATA/orcl/datafile/users.259.880451615','/u01/app/oracle/oradata/db11g/users01.dbf','+DATA/orcl/datafile/undotbs1.256.880451607','/u01/app/oracle/oradata/db11g/undotbs01.dbf','+DATA/orcl/datafile/sysaux.257.880451605','/u01/app/oracle/oradata/db11g/sysaux01.dbf','+DATA/orcl/datafile/system.265.880451605','/u01/app/oracle/oradata/db11g/system01.dbf'
- set
- log_file_name_convert='+DATA/orcl/onlinelog/group_1.270.880453135','/u01/app/oracle/oradata/db11g/redo01a.log','+FRA/orcl/onlinelog/group_1.276.880453137','/u01/app/oracle/oradata/db11g/redo01b.log','+DATA/orcl/onlinelog/group_3.272.880453141','/u01/app/oracle/oradata/db11g/redo03a.log','+FRA/orcl/onlinelog/group_3.274.880453141','/u01/app/oracle/oradata/db11g/redo03b.log','+DATA/orcl/onlinelog/group_2.271.880453137','/u01/app/oracle/oradata/db11g/redo02a.log','+FRA/orcl/onlinelog/group_2.275.880453139','/u01/app/oracle/oradata/db11g/redo02b.log'
- set
- audit_file_dest='/u01/app/oracle/admin/mydb/adump'
- set
- db_create_file_dest=''
- set
- db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
- }
复制代码
新的语法:
在目的地机器上创建/u01/app/oracle/oradata/dbclone3
- run {
- allocate auxiliary channel c1 device type disk;
- allocate auxiliary channel c2 device type disk;
- allocate auxiliary channel c3 device type disk;
- allocate auxiliary channel c4 device type disk;
- allocate auxiliary channel c5 device type disk;
- allocate auxiliary channel c6 device type disk;
- allocate auxiliary channel c7 device type disk;
- allocate auxiliary channel c8 device type disk;
- duplicate database to dbclone3
- backup location '/home/oracle/backup'
- nofilenamecheck
- db_file_name_convert '+DATA/orcl/datafile/example.257.978643425','/u01/app/oracle/oradata/dbclone3/example01.dbf','+DATA/orcl/datafile/users.265.978645015','/u01/app/oracle/oradata/dbclone3/users01.dbf','+DATA/orcl/datafile/undotbs1.259.978643423','/u01/app/oracle/oradata/dbclone3/undotbs01.dbf','+DATA/orcl/datafile/sysaux.258.978643425','/u01/app/oracle/oradata/dbclone3/sysaux01.dbf','+DATA/orcl/datafile/system.256.978643425','/u01/app/oracle/oradata/dbclone3/system01.dbf'
- logfile
- group 1 ('/u01/app/oracle/oradata/dbclone3/redo01a.log','/u01/app/oracle/oradata/dbclone3/redo01b.log') size 50M,
- group 2 ('/u01/app/oracle/oradata/dbclone3/redo02a.log','/u01/app/oracle/oradata/dbclone3/redo02b.log') size 50M,
- group 3 ('/u01/app/oracle/oradata/dbclone3/redo03a.log','/u01/app/oracle/oradata/dbclone3/redo03b.log') size 50M
- spfile
- set
- control_files='/u01/app/oracle/oradata/dbclone3/control01.ctl','/u01/app/oracle/oradata/dbclone3/control02.ctl','/u01/app/oracle/oradata/dbclone3/control03.ctl'
- set
- audit_file_dest='/u01/app/oracle/admin/dbclone3/adump'
- set
- db_create_file_dest=''
- set
- db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
- ;
- }
复制代码 在1Z0-052第18章/1Z0-053第9章之前,数据库里没有物理和逻辑坏块:
physical-block11.2.0.1.sh.zip
(645 Bytes, 下载次数: 548)
|
|