Replicating a database using Rman
Last Update:2017-02-28
Source: Internet
Author: User
Data | database
--------------------------------------------
Experimental environment: WINDOWS + Oracle 10.1.0.2.0
Original database: ning[archive mode] Copy database: Test
Author:ningoo 2005-3-27
-------------------------------------------
Use the duplicate database of Rman on the same server to create the replicated databases.
1. Create a new instance
Prepare the appropriate directory structure
E:\oracle\product\10.1.0\admin\test\bdump
E:\oracle\product\10.1.0\admin\test\cdump
E:\oracle\product\10.1.0\admin\test\create
E:\oracle\product\10.1.0\admin\test\pfile
E:\oracle\product\10.1.0\admin\test cripts
E:\oracle\product\10.1.0\admin\test\udmp
Create the parameter file Inittest.ini (which can be modified using the pfile of the original library), the main parameters are as follows:
Db_name=test
Background_dump_dest=e:\oracle\product\10.1.0\admin\test\bdump
Core_dump_dest=e:\oracle\product\10.1.0\admin\test\cdump
User_dump_dest=e:\oracle\product\10.1.0\admin\test\udump
Control_files= ' E:\oracle\oradata\test\control01.ctl ', ' E:\oracle\oradata\test \control02.ctl ', ' E:\oracle\oradata \test \control03.ctl '
db_file_name_convert= (' E:\oracle\oradata\ning ', ' E:\oracle\oradata\test ')
log_file_name_convert= (' E:\oracle\oradata\ning ', ' E:\oracle\oradata\test ')
Placed E:\oracle\product\10.1.0\admin\test\pfile or E:\oracle\product\10.1.0\db_1\database.
Create a new instance using Oradim
C:\>oradim-new-sid Test
Routine has been created.
Creating Password files using Orapwd
C:\>orapwd File=e:\oracle\product\10.1.0\db_1\database\pwdtest.ora password=test entries=10
Configure listening and tnsnames, and then use Sqlplus to test the connection
C:\>sqlplus/nolog
Sql*plus:release 10.1.0.2.0-production on Sunday March 27 21:01:13 2005
Copyright (c) 1982, Oracle. All rights reserved.
Sql> Conn Sys@test as Sysdba
Please enter password:
You are connected to an idle routine.
2. Use Rman to back up the original library
Rman> Connect Target sys/ning@ning
Connect to target database: NING (dbid=1141544503)
Replacing recovery directory with target database control files
rman> backup full database tag ' FULLBK ' format ' e:\oracle\oraback\full%u_%s_%p ';
Start Backup in 2 July-March-05
Using channel Ora_disk_1
Channel Ora_disk_1: Start all data file backup sets
Channel Ora_disk_1: Specifying Data files in Backup set
Enter the data file fno=00001 name=e:\oracle\oradata\ning YSTEM01. Dbf
Enter the data file fno=00002 name=e:\oracle\oradata\ning\undotbs01. Dbf
Enter the data file fno=00004 name=e:\oracle\oradata\ning\users01. Dbf
Enter the data file fno=00003 name=e:\oracle\oradata\ning YSAUX01. Dbf
Enter the data file fno=00005 name=e:\oracle\oradata\ning\test01. Dbf
Channel Ora_disk_1: Starting segment 1 in 2 July-March-05
Channel Ora_disk_1: Completed segment 1 in 2 July-March-05
Duan Handle=e:\oracle\oraback\full03ggcqa4_3_1 Comment=none
Channel Ora_disk_1: Backup set completed, after time: 00:00:45
Channel Ora_disk_1: Start all data file backup sets
Channel Ora_disk_1: Specifying Data files in Backup set
The backup set includes the current control file
Include the current SPFILE in the backup set
Channel Ora_disk_1: Starting segment 1 in 2 July-March-05
Channel Ora_disk_1: Completed segment 1 in 2 July-March-05
Duan Handle=e:\oracle\oraback\full04ggcqbh_4_1 Comment=none
Channel Ora_disk_1: Backup set completed, after time: 00:00:09
Completed backup in 2 July-March-05
3. Replicating databases using Rman
C:\>rman Target sys/ning@ning Auxiliary sys/test@test
Recovery Manager: Version 10.1.0.2.0-production
Opyright (c) 1995, Oracle. All rights reserved.
Connect to target database: NING (dbid=1141544503)
Connected to standby database: Test (not mounted)
Rman> DUPLICATE TARGET DATABASE to ' test ';
Start Duplicate Db in 2 July-March-05
Using channel Ora_aux_disk_1
Contents of Memory Script:
{
Set until SCN 169960;
Set newname for DataFile 1 to
"E:\ORACLE\ORADATA\TEST YSTEM01. DBF ";
Set newname for DataFile 2 to
"E:\ORACLE\ORADATA\TEST\UNDOTBS01. DBF ";
Set newname for DataFile 3 to
"E:\ORACLE\ORADATA\TEST YSAUX01. DBF ";
Set newname for DataFile 4 to
"E:\ORACLE\ORADATA\TEST\USERS01. DBF ";
Set newname for DataFile 5 to
"E:\ORACLE\ORADATA\TEST\TEST01. DBF ";
Restore
Check ReadOnly
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
Start Restore in 2 July-March-05
Using channel Ora_aux_disk_1
Channel Ora_aux_disk_1: Starting recovery of data file backup set
Channel Ora_aux_disk_1: Specifying a data file to recover from a backup set
Restoring data file 00001 to E:\ORACLE\ORADATA\TEST YSTEM01. Dbf
Restoring data file 00002 to E:\ORACLE\ORADATA\TEST\UNDOTBS01. Dbf
Restoring data file 00003 to E:\ORACLE\ORADATA\TEST YSAUX01. Dbf
Restoring data file 00004 to E:\ORACLE\ORADATA\TEST\USERS01. Dbf
Restoring data file 00005 to E:\ORACLE\ORADATA\TEST\TEST01. Dbf
Channel Ora_aux_disk_1: restored backup Segment 1
Segment handle = E:\ORACLE\ORABACK\FULL03GGCQA4_3_1 Mark = FULLBK
Channel Ora_aux_disk_1: Recovery complete
Completed restore in 2 July-March-05
SQL statement: CREATE controlfile reuse SET DATABASE "test" Resetlogs Archivelog
Maxlogfiles 16
Maxlogmembers 3
Maxdatafiles 100
Maxinstances 8
Maxloghistory 454
LOGFILE
GROUP 1 ' E:\oracle\oradata\test\redo01.log ' SIZE M,
GROUP 2 ' E:\oracle\oradata\test\redo02.log ' SIZE M,
GROUP 3 ' E:\oracle\oradata\test\redo03.log ' SIZE M
DataFile
' E:\ORACLE\ORADATA\TEST YSTEM01. DBF '
CHARACTER SET ZHS16GBK
Contents of Memory Script:
{
Switch clone datafile all;
}
Executing memory script
Data file 2 has been converted to a copy of the data file
Enter a copy of the data file recid=1 stamp=554071105 filename =e:\oracle\oradata\test\undotbs01
. Dbf
Data file 3 has been converted to a copy of the data file
Enter a copy of the data file recid=2 stamp=554071105 filename =e:\oracle\oradata\test YSAUX01.
Dbf
Data file 4 has been converted to a copy of the data file
Enter the data file copy recid=3 stamp=554071105 filename =e:\oracle\oradata\test\users01. D
BF
Data file 5 has been converted to a copy of the data file
Enter the data file copy recid=4 stamp=554071105 filename =e:\oracle\oradata\test\test01. Db
F
Contents of Memory Script:
{
Set until SCN 169960;
Recover
Clone database
Delete Archivelog
;
}
Executing memory script
Executing command: SET until clause
Started recover in 2 July-March-05
Using channel Ora_aux_disk_1
Beginning recovery of media
Archive log thread 1 sequence 16 already exists as a file E:\ORACLE\ARCH\ARC00016_0553949015.001 in
On disk
Archive log file name =e:\oracle\arch\arc00016_0553949015.001 thread =1 sequence =16
Completion of media recovery
Completed recover in 2 July-March-05
Contents of Memory Script:
{
Shutdown clone;
Startup clone Nomount;
}
Executing memory script
The database has been uninstalled
Oracle routines are closed
Connected to an alternate database (not started)
Oracle routines Started
System global Zone total 142606336 bytes
Fixed Size 787848 bytes
Variable Size 116390520 bytes
Database buffers 25165824 bytes
Redo buffers 262144 bytes
SQL statement: CREATE controlfile reuse SET DATABASE "test" Resetlogs Archivelog
Maxlogfiles 16
Maxlogmembers 3
Maxdatafiles 100
Maxinstances 8
Maxloghistory 454
LOGFILE
GROUP 1 ' E:\oracle\oradata\test\redo01.log ' SIZE M,
GROUP 2 ' E:\oracle\oradata\test\redo02.log ' SIZE M,
GROUP 3 ' E:\oracle\oradata\test\redo03.log ' SIZE M
DataFile
' E:\ORACLE\ORADATA\TEST YSTEM01. DBF '
CHARACTER SET ZHS16GBK
Contents of Memory Script:
{
Catalog Clone Datafilecopy "E:\ORACLE\ORADATA\TEST\UNDOTBS01. DBF ";
Catalog Clone datafilecopy "E:\ORACLE\ORADATA\TEST YSAUX01. DBF ";
Catalog Clone Datafilecopy "E:\ORACLE\ORADATA\TEST\USERS01. DBF ";
Catalog Clone Datafilecopy "E:\ORACLE\ORADATA\TEST\TEST01. DBF ";
Switch clone datafile all;
}
Executing memory script
A copy of the data file has been included in the directory
Data file copy filename=e:\oracle\oradata\test\undotbs01. DBF recid=1 stamp=5540716
73
A copy of the data file has been included in the directory
Data file copy filename=e:\oracle\oradata\test YSAUX01. DBF recid=2 stamp=55407167
3
A copy of the data file has been included in the directory
Data file copy filename=e:\oracle\oradata\test\users01. DBF recid=3 stamp=554071673
A copy of the data file has been included in the directory
Data file copy filename=e:\oracle\oradata\test\test01. DBF recid=4 stamp=554071673
Data file 2 has been converted to a copy of the data file
Enter a copy of the data file recid=1 stamp=554071673 filename =e:\oracle\oradata\test\undotbs01
. Dbf
Data file 3 has been converted to a copy of the data file
Enter a copy of the data file recid=2 stamp=554071673 filename =e:\oracle\oradata\test YSAUX01.
Dbf
Data file 4 has been converted to a copy of the data file
Enter the data file copy recid=3 stamp=554071673 filename =e:\oracle\oradata\test\users01. D
BF
Data file 5 has been converted to a copy of the data file
Enter the data file copy recid=4 stamp=554071673 filename =e:\oracle\oradata\test\test01. Db
F
Contents of Memory Script:
{
Alter Clone database open resetlogs;
}
Executing memory script
Database is open
Completed Duplicate Db in 2 July-March-05
4. Check the status of the replication library
C:\>sqlplus/nolog
Sql*plus:release 10.1.0.2.0-production on Sunday March 27 21:05:52 2005
Copyright (c) 1982, Oracle. All rights reserved.
Sql> Conn Sys@test as Sysdba
Please enter password:
is connected.
Sql> select Instance_name,status from V$instance;
instance_name STATUS
---------------- ------------
Test OPEN
Then remove the Inittest.ora db_file_name_convert and Log_file_name_convert parameters, and then use the file to generate SPFile
Sql> create SPFile from pfile= ' E:\oracle\product\10.1.0\db_1\database\inittest.ora ';
The file has been created.
===============================================================
Reference articles:
Oracle®database Backup and Recovery Advanced User ' s Guide 10g Release 1 (10.1) Part number b10734-01