Create a local Duplicate Database

Source: Internet
Author: User
Create a local Duplicate database. The path of the newly created file is different from that of the target database, and the initialization parameter DB_NAME of the auxiliary instance cannot be the same as that of the target database. 1. Create a key file for the secondary instance [oracle @ linux5dbs] $ pwdu01apporacle10.2.0db _ 1dbs [oracle @ linux5dbs] $ orapwdfileu01appor

Create a local Duplicate database. The path of the newly created file is different from that of the target database, and the initialization parameter DB_NAME of the auxiliary instance cannot be the same as that of the target database. 1. create a key file for the secondary instance [oracle @ linux5 dbs] $ pwd/u01/app/oracle/10.2.0/db_1/dbs [oracle @ linux5 dbs] $ orapwd file =/u01/app /or

Create a local Duplicate database. The path of the newly created file is different from that of the target database, and the initialization parameter DB_NAME of the auxiliary instance cannot be the same as that of the target database.
1. Create a key file for the secondary instance
[Oracle @ linux5 dbs] $ pwd
/U01/app/oracle/10.2.0/db_1/dbs
[Oracle @ linux5 dbs] $ orapwd file =/u01/app/oracle/10.2.0/db_1/dbs/orapworcldup password = safe entries = 30
2. manual database creation
[Oracle @ linux5 admin] $ pwd
/U01/app/oracle/admin
[Oracle @ linux5 admin] $ mkdir orcldup
[Oracle @ linux5 admin] $ cd orcldup/
[Oracle @ linux5 orcldup] $ mkdir {a, B, c, u} dump
[Oracle @ linux5 orcldup] $ ls
Adump bdump cdump udump
[Oracle @ linux5 orcldup] $
3. Configure the initialization parameter file
[Oracle @ linux5 orcldup] $ export ORACLE_SID = orcl
[Oracle @ linux5 orcldup] $ sqlplus/as sysdba

SQL * Plus: Release 10.2.0.1.0-Production on Thu Apr 17 05:32:56 2014

Copyright (c) 1982,200 5, Oracle. All rights reserved.

Connected to an idle instance.

SQL> create pfile = '/u01/dup_test/pfile' from spfile;

File created.


[Oracle @ linux5 orcldup] $ export ORACLE_SID = orcldup specifies the sid of the secondary instance before creating the spfile of the secondary instance. Otherwise, the target database will be overwritten.
[Oracle @ linux5 orcldup] $ sqlplus/as sysdba

SQL * Plus: Release 10.2.0.1.0-Production on Thu Apr 17 05:31:41 2014

Copyright (c) 1982,200 5, Oracle. All rights reserved.

Connected to an idle instance.

[Oracle @ linux5 ~] $ Cd/u01/
[Oracle @ linux5 u01] $ ls
App arch bak dup_test
[Oracle @ linux5 u01] $ cd dup_test/
[Oracle @ linux5 dup_test] $ ls
Pfile
[Oracle @ linux5 dup_test] $ pwd
/U01/dup_test
[Oracle @ linux5 dup_test] $ mkdir orcldup
[Oracle @ linux5 dup_test] $ ls
Orcldup pfile
PFILE:
*. Control_files = '/u01/dup_test/orcldup/control01.ctl', '/u01/dup_test/orcldup/control02.ctl', '/u01/dup_test/orcldup/control03.ctl'
*. Db_block_size = 8192
*. Db_name = 'orcldup'
*. Shared_pool_size = 200000000
*. Db_block_size = 8192
*. Db_file_name_convert = '/u01/app/oracle/oradata/orcl', '/u01/dup_test/orcldup'

# *. Log_file_name_convert = '/u01/app/oracle/oradata/orcl', '/u01/dup_test/orcldup' can generate logfile without specifying the statement in duplicate
*. Log_file_name_convert = '/u01/arch', '/u01/dup_test/orcldup'
*. Audit_file_dest = '/u01/app/oracle/admin/orcldup/adump'
*. Background_dump_dest = '/u01/app/oracle/admin/orcldup/bdump'
*. Compatible = '10. 2.0.1.0'
*. Core_dump_dest = '/u01/app/oracle/admin/orcldup/cdump'
*. User_dump_dest = '/u01/app/oracle/admin/orcldup/udump'

SQL> create spfile from pfile = '/u01/dup_test/pfile ';

File created.

4. Start the secondary instance
SQL> startup nomount // The duplicate command can be executed only after the nomount state is started.
ORACLE instance started.

Total System Global Area 281018368 bytes
Fixed Size 1218968 bytes
Variable Size 226494056 bytes
Database Buffers 50331648 bytes
Redo Buffers 2973696 bytes
5. Configure the network
/Etc/sysconfig/network-scripts
Eth0:
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE = eth0
BOOTPROTO = static
DHCPCLASS =
HWADDR = 00: 0C: 29: 53: DB: E3
ONBOOT = yes
IPADDR = 10.20.17.222
NETMASK = 255.255.0.0
GATEWAY = 10.20.0.1
~
~
Eth1:
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE = eth1
BOOTPROTO = static
ONBOOT = yes
HWADDR = 00: 0c: 29: 53: db: ed
IPADDR = 192.168.1.222
NETMASK = 255.255.255.0
~
~
~
[Root @ linux5 network-scripts] # service network stop
Shutting down interface eth0: [OK]
Shutting down interface eth1: [OK]
Shutting down loopback interface: [OK]
[Root @ linux5 network-scripts] # service network start
Bringing up loopback interface: [OK]
Bringing up interface eth0: [OK]
Bringing up interface eth1: [OK]
Configure the listener and Network Service name
LISTENER. ORA
# Listener. ora Network Configuration File:/u01/app/oracle/10.2.0/db_1/network/admin/listener. ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = orcl)
(ORACLE_HOME =/u01/app/oracle/10.2.0/db_1)
(Global_name = orcl)
)
(SID_DESC =
(SID_NAME = orcldup)
(ORACLE_HOME =/u01/app/oracle/10.2.0/db_1)
(Global_name = orcldup)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC1 ))
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.222) (PORT = 1521 ))
)
)

TNSNAMES. ORA
# Tnsnames. ora Network Configuration File:/u01/app/oracle/10.2.0/db_1/network/admin/tnsnames. ora
# Generated by Oracle configuration tools.

Orcl_local =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.222) (PORT = 1521 ))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)

Orcl_dup =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.222) (PORT = 1521 ))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcldup)
)
)

EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC1 ))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
Restart the listener to make it take effect
[Oracle @ linux5 admin] $ lsnrctl stop

LSNRCTL for Linux: Version 10.2.0.1.0-Production on 17-APR-2014 04:56:44

Copyright (c) 1991,200 5, Oracle. All rights reserved.

Connecting to (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC1 )))
The command completed successfully
[Oracle @ linux5 admin] $ lsnrctl start

LSNRCTL for Linux: Version 10.2.0.1.0-Production on 17-APR-2014 04:59:12

Copyright (c) 1991,200 5, Oracle. All rights reserved.

Starting/u01/app/oracle/10.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.1.0-Production
System parameter file is/u01/app/oracle/10.2.0/db_1/network/admin/listener. ora
Log messages written to/u01/app/oracle/10.2.0/db_1/network/log/listener. log
Listening on: (DESCRIPTION = (ADDRESS = (PROTOCOL = ipc) (KEY = EXTPROC1 )))
Listening on: (DESCRIPTION = (ADDRESS = (PROTOCOL = tcp) (HOST = 192.168.1.222) (PORT = 1521 )))

Connecting to (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC1 )))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0-Production
Start Date 17-APR-2014 04:59:12
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File/u01/app/oracle/10.2.0/db_1/network/admin/listener. ora
Listener Log File/u01/app/oracle/10.2.0/db_1/network/log/listener. log
Listening Endpoints Summary...
(DESCRIPTION = (ADDRESS = (PROTOCOL = ipc) (KEY = EXTPROC1 )))
(DESCRIPTION = (ADDRESS = (PROTOCOL = tcp) (HOST = 192.168.1.222) (PORT = 1521 )))
Services Summary...
Service "orcl" has 1 instance (s ).
Instance "orcl", status UNKNOWN, has 1 handler (s) for this service...
Service "orcldup" has 1 instance (s ).
Instance "orcldup", status UNKNOWN, has 1 handler (s) for this service...
The command completed successfully
6. Start the target database to the MOUNT or OPEN state.
[Oracle @ linux5 orcldup] $ export ORACLE_SID = orcl // ORACLE_SID should be capitalized
[Oracle @ linux5 orcldup] $ sqlplus/as sysdba

SQL * Plus: Release 10.2.0.1.0-Production on Thu Apr 17 05:08:29 2014

Copyright (c) 1982,200 5, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 167772160 bytes
Fixed Size 1218316 bytes
Variable Size 75499764 bytes
Database Buffers 88080384 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.

7. Verify the backup
RMAN> list backup of database
2>;

Using target database control file instead of recovery catalog

List of Backup Sets
==============================

BS Key Type LV Size Device Type Elapsed Time Completion Time
-------------------------------------------------------------
5 Full 573.44 m disk 00:00:53 26-FEB-14
BP Key: 5 Status: AVAILABLE Compressed: NO Tag: TAG20140226T035256
Piece Name:/u01/app/oracle/flash_recovery_area/ORCL/backupset/2014_02_26/o1_mf_nnndf_TAG20140226T035256_9jvodwgh _. bkp
List of Datafiles in backup set 5
File LV Type Ckp SCN Ckp Time Name
---------------------------------
1 Full 500685 26-FEB-14/u01/app/oracle/oradata/orcl/system01.dbf
2 Full 500685 26-FEB-14/u01/app/oracle/oradata/orcl/undotbs01.dbf
3 Full 500685 26-FEB-14/u01/app/oracle/oradata/orcl/sysaux01.dbf
4 Full 500685 26-FEB-14/u01/app/oracle/oradata/orcl/users01.dbf
5 Full 500685 26-FEB-14/u01/app/oracle/oradata/orcl/example01.dbf
8. RMAN connects to the target database and auxiliary instance, and the formal Environment allocates the channel according to the actual situation.
[Oracle @ linux5 admin] $ rman target sys/oracle @ orcl_local auxiliary sys/safe @ orcl_dup

Recovery Manager: Release 10.2.0.1.0-Production on Thu Apr 17 05:54:44 2014

Copyright (c) 1982,200 5, Oracle. All rights reserved.

Connected to target database: ORCL (DBID = 1368292794)
Connected to auxiliary database: ORCLDUP (not mounted)

RMAN> duplicate target database to orcldup
2>;

Starting Duplicate Db at 17-APR-14
Using target database control file instead of recovery catalog
Allocated channel: ORA_AUX_DISK_1
Channel ORA_AUX_DISK_1: sid = 35 devtype = DISK
RMAN-00571: ========================================================== ==============================
RMAN-00569: ==================== error message stack follows ==========================
RMAN-00571: ========================================================== ==============================
RMAN-03002: failure of Duplicate Db command at 04/17/2014 05:57:23
RMAN-05501: aborting duplication of target database
RMAN-05001: auxiliary filename/u01/app/oracle/oradata/orcl/redo03.log conflicts with a file used by the target database
RMAN-05001: auxiliary filename/u01/app/oracle/oradata/orcl/redo02.log conflicts with a file used by the target database
RMAN-05001: auxiliary filename/u01/app/oracle/oradata/orcl/redo01.log conflicts with a file used by the target database

RMAN> duplicate target database to orcldup // create/u01/app/oracle/oradata/orcldup first
2> logfile
3> '/u01/app/oracle/oradata/orcldup/redo01.log' size 20 m,
4> '/u01/app/oracle/oradata/orcldup/redo02.log' size 20 m,
5> '/u01/app/oracle/oradata/orcldup/redo03.log' size 20 m
6>;

Starting Duplicate Db at 17-APR-14
Using channel ORA_AUX_DISK_1

Contents of Memory Script:
{
Set until scn 500750;
Set newname for datafile 1
"/U01/dup_test/orcldup/system01.dbf ";
Set newname for datafile 2
"/U01/dup_test/orcldup/undotbs01.dbf ";
Set newname for datafile 3
"/U01/dup_test/orcldup/sysaux01.dbf ";
Set newname for datafile 4
"/U01/dup_test/orcldup/users01.dbf ";
Set newname for datafile 5
"/U01/dup_test/orcldup/example01.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

Starting restore at 17-APR-14
Using channel ORA_AUX_DISK_1

Channel ORA_AUX_DISK_1: starting datafile backupset restore
Channel ORA_AUX_DISK_1: specifying datafile (s) to restore from backup set
Restoring datafile 00001 to/u01/dup_test/orcldup/system01.dbf
Restoring datafile 00002 to/u01/dup_test/orcldup/undotbs01.dbf
Restoring datafile 00003 to/u01/dup_test/orcldup/sysaux01.dbf
Restoring datafile 00004 to/u01/dup_test/orcldup/users01.dbf
Restoring datafile 00005 to/u01/dup_test/orcldup/example01.dbf
Channel ORA_AUX_DISK_1: reading from backup piece/u01/app/oracle/flash_recovery_area/ORCL/backupset/2014_02_26/o1_mf_nnndf_TAG20140226T035256_9jvodwgh _.
Channel ORA_AUX_DISK_1: restored backup piece 1
Piece handle =/u01/app/oracle/flash_recovery_area/ORCL/backupset/2014_02_26/blank _. bkp tag = TAG20140226T035256
Channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:02:12
Finished restore at 17-APR-14
SQL statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCLDUP" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
# MAXLOGHISTORY 292
LOGFILE
GROUP 1'/u01/app/oracle/oradata/orcldup/redo01.log 'SIZE 20 M,
GROUP 2'/u01/app/oracle/oradata/orcldup/redo02.log 'SIZE 20 M,
GROUP 3 '/u01/app/oracle/oradata/orcldup/redo03.log' SIZE 20 M
DATAFILE
'/U01/dup_test/orcldup/system01.dbf'
Character set WE8ISO8859P1


Contents of Memory Script:
{
Switch clone datafile all;
}
Executing Memory Script

Released channel: ORA_AUX_DISK_1
Datafile 2 switched to datafile copy
Input datafile copy recid = 1 stamp = 845100699 filename =/u01/dup_test/orcldup/undotbs01.dbf
Datafile 3 switched to datafile copy
Input datafile copy recid = 2 stamp = 845100699 filename =/u01/dup_test/orcldup/sysaux01.dbf
Datafile 4 switched to datafile copy
Input datafile copy recid = 3 stamp = 845100699 filename =/u01/dup_test/orcldup/users01.dbf
Datafile 5 switched to datafile copy
Input datafile copy recid = 4 stamp = 845100700 filename =/u01/dup_test/orcldup/example01.dbf

Contents of Memory Script:
{
Set until scn 500750;
Recover
Clone database
Delete archivelog
;
}
Executing Memory Script

Executing command: SET until clause

Starting recover at 17-APR-14
Allocated channel: ORA_AUX_DISK_1
Channel ORA_AUX_DISK_1: sid = 35 devtype = DISK

Starting media recovery

Channel ORA_AUX_DISK_1: starting archive log restore to default destination
Channel ORA_AUX_DISK_1: restoring archive log
Archive log thread = 1 sequence = 7
Channel ORA_AUX_DISK_1: reading from backup piece/u01/bak/rman_bak_02-26_840513235.bak
Channel ORA_AUX_DISK_1: restored backup piece 1
Piece handle =/u01/bak/rman_bak_02-26_840513235.bak tag = TAG20140226T035355
Channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
Archive log filename =/u01/app/oracle/10.2.0/db_1/dbs/arch1_7_840512061.dbf thread = 1 sequence = 7
Channel clone_default: deleting archive log (s)
Archive log filename =/u01/app/oracle/10.2.0/db_1/dbs/arch1_7_840512061.dbf recid = 1 stamp = 845100711
Media recovery complete, elapsed time: 00:00:11
Finished recover at 17-APR-14

Contents of Memory Script:
{
Shutdown clone;
Startup clone nomount;
}
Executing Memory Script //// long time there is a link stuck here, it is best to open only one window

Database dismounted
Oracle instance shut down

Connected to auxiliary database (not started)
Oracle instance started

Total System Global Area 281018368 bytes

Fixed Size 1218968 bytes
Variable Size 226494056 bytes
Database Buffers 50331648 bytes
Redo Buffers 2973696 bytes
SQL statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCLDUP" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
# MAXLOGHISTORY 292
LOGFILE
GROUP 1'/u01/app/oracle/oradata/orcldup/redo01.log 'SIZE 20 M,
GROUP 2'/u01/app/oracle/oradata/orcldup/redo02.log 'SIZE 20 M,
GROUP 3 '/u01/app/oracle/oradata/orcldup/redo03.log' SIZE 20 M
DATAFILE
'/U01/dup_test/orcldup/system01.dbf'
Character set WE8ISO8859P1


Contents of Memory Script:
{
Set newname for tempfile 1
"/U01/dup_test/orcldup/temp01.dbf ";
Switch clone tempfile all;
Catalog clone datafilecopy "/u01/dup_test/orcldup/undotbs01.dbf ";
Catalog clone datafilecopy "/u01/dup_test/orcldup/sysaux01.dbf ";
Catalog clone datafilecopy "/u01/dup_test/orcldup/users01.dbf ";
Catalog clone datafilecopy "/u01/dup_test/orcldup/example01.dbf ";
Switch clone datafile all;
}
Executing Memory Script

Executing command: SET NEWNAME

Renamed temporary file 1 to/u01/dup_test/orcldup/temp01.dbf in control file

Cataloged datafile copy
Datafile copy filename =/u01/dup_test/orcldup/undotbs01.dbf recid = 1 stamp = 845228858

Cataloged datafile copy
Datafile copy filename =/u01/dup_test/orcldup/sysaux01.dbf recid = 2 stamp = 845228860

Cataloged datafile copy
Datafile copy filename =/u01/dup_test/orcldup/users01.dbf recid = 3 stamp = 845228862

Cataloged datafile copy
Datafile copy filename =/u01/dup_test/orcldup/example01.dbf recid = 4 stamp = 845228865

Datafile 2 switched to datafile copy
Input datafile copy recid = 1 stamp = 845228858 filename =/u01/dup_test/orcldup/undotbs01.dbf
Datafile 3 switched to datafile copy
Input datafile copy recid = 2 stamp = 845228860 filename =/u01/dup_test/orcldup/sysaux01.dbf
Datafile 4 switched to datafile copy
Input datafile copy recid = 3 stamp = 845228862 filename =/u01/dup_test/orcldup/users01.dbf
Datafile 5 switched to datafile copy
Input datafile copy recid = 4 stamp = 845228865 filename =/u01/dup_test/orcldup/example01.dbf

Contents of Memory Script:
{
Alter clone database open resetlogs;
}
Executing Memory Script

Database opened
Finished Duplicate Db at 18-APR-14

RMAN>
Verification:
SQL> conn sys/safe @ orcl_dup as sysdba
Connected.
SQL> select name from v $ tablespace;

NAME
------------------------------
SYSTEM
TEMP
UNDOTBS1
SYSAUX
USERS
EXAMPLE

6 rows selected.

SQL> select name from v $ datafile;

NAME
--------------------------------------------------------------------------------
/U01/dup_test/orcldup/system01.dbf
/U01/dup_test/orcldup/undotbs01.dbf
/U01/dup_test/orcldup/sysaux01.dbf
/U01/dup_test/orcldup/users01.dbf
/U01/dup_test/orcldup/example01.dbf

SQL> select name from v $ tempfile;

NAME
--------------------------------------------------------------------------------
/U01/dup_test/orcldup/temp01.dbf
Note that the path has been converted.

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.