Step by Step clone of an Oracle 10g using RMAN
Applies to:
Oracle Server – Enterprise Edition – Version: 10.2.0.1.0 – 64 bit to 10.2.0.3.0 – 64 bit.
Information in this document applies to any platform.
Information in this document applies to any platform.
Goal:
This document gives a step by step guide about how to clone an Oracle database to a different host using RMAN.
Solution:
1- Create a new Database with a new instance. X06 is the auxiliary database.
2- Create a new table space named “REPOSITORY_FOR_RMAN” on X06;
2- Create a new table space named “REPOSITORY_FOR_RMAN” on X06;
CREATE TABLESPACE “REPOSITORY_FOR_RMAN”
LOGGING
DATAFILE ‘/u01/app/oracle/oradata/X06/REPOSITORY_FOR_RMAN.dbf’ SIZE 100M EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO
;
LOGGING
DATAFILE ‘/u01/app/oracle/oradata/X06/REPOSITORY_FOR_RMAN.dbf’ SIZE 100M EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO
;
3- Create an Oracle user rman on X06 ;
create user rman identified by wissem default tablespace REPOSITORY_FOR_RMAN
temporary tablespace temp
quota unlimited on REPOSITORY_FOR_RMAN;
create user rman identified by wissem default tablespace REPOSITORY_FOR_RMAN
temporary tablespace temp
quota unlimited on REPOSITORY_FOR_RMAN;
4- Grant to rman user on X06 with all the privileges to perform backup and recovery actions;
grant connect, resource, recovery_catalog_owner to rman;
grant connect, resource, recovery_catalog_owner to rman;
5- We must be sure that the following variables are setup correctly on X06 :
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/oracle/product/10.2.0/x06/oracle
export ORACLE_SID=X06
export ORACLE_HOME=/u01/app/oracle/oracle/product/10.2.0/x06/oracle
export ORACLE_SID=X06
6- Create a recovery manager catalog on X06 :
cd $ORACLE_HOME/bin
[oracle@x06 bin]$ ./rman catalog rman/wissem
Recovery Manager: Release 10.2.0.1.0 – Production on Wed Jun 30 11:55:53 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to recovery catalog database
RMAN> create catalog tablespace REPOSITORY_FOR_RMAN;
recovery catalog created
RMAN>
7- Add the following entry in your TNSNAMES.ORA: DEVTARGET.ES.EDWN.LAN is our target database.
[oracle@x06 admin]$ pwd
/u01/app/oracle/oracle/product/10.2.0/x06/oracle/network/admin
[oracle@x06 admin]$ cat tnsnames.ora
DEVTARGET.ES.EDWN.LAN =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = Devtarget.es.edwn.lan)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = Devtarget.es.edwn.lan)
)
)
/u01/app/oracle/oracle/product/10.2.0/x06/oracle/network/admin
[oracle@x06 admin]$ cat tnsnames.ora
DEVTARGET.ES.EDWN.LAN =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = Devtarget.es.edwn.lan)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = Devtarget.es.edwn.lan)
)
)
8- Test the connection to the target database:
[oracle@x06 admin]$ sqlplus
SQL*Plus: Release 10.2.0.1.0 – Production on Wed Jun 30 11:58:07 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Enter user-name: sys@DEVTARGET.ES.EDWN.LAN as SYSDBA
Enter password:
Enter password:
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 – 64bit Production
With the Partitioning, OLAP and Data Mining options
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 – 64bit Production
With the Partitioning, OLAP and Data Mining options
9- Register the target database with the recovery manager catalog:
[oracle@x06 admin]$ $ORACLE_HOME/bin/rman target sys@DEVTARGET.ES.EDWN.LAN
Recovery Manager: Release 10.2.0.1.0 – Production on Wed Jun 30 11:59:58 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
target database Password:
connected to target database: DEVTARGET (DBID=1826617959)
connected to target database: DEVTARGET (DBID=1826617959)
RMAN>
RMAN> connect catalog rman/wissem@X06.D15.LAN
connected to recovery catalog database
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
starting full resync of recovery catalog
full resync complete
RMAN> CONNECT AUXILIARY SYS/wissem@X06.D15.LAN
connected to auxiliary database: X06 (DBID=329306800)
RMAN>
10- No mount the auxiliary database X06. Target database still in open mode.
SQL> startup force nomount;
ORACLE instance started.
Total System Global Area 1258291200 bytes
Fixed Size 2020448 bytes
Variable Size 318770080 bytes
Database Buffers 922746880 bytes
Redo Buffers 14753792 bytes
SQL>
ORACLE instance started.
Total System Global Area 1258291200 bytes
Fixed Size 2020448 bytes
Variable Size 318770080 bytes
Database Buffers 922746880 bytes
Redo Buffers 14753792 bytes
SQL>
11- Connect to the target database using Recovery manager pointed at the auxiliary database :
[oracle@x06 admin]$ $ORACLE_HOME/bin/rman target sys@DEVTARGET.ES.EDWN.LAN AUXILIARY /
Recovery Manager: Release 10.2.0.1.0 – Production on Wed Jun 30 15:36:03 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
target database Password:
connected to target database: DEVTARGET (DBID=1826617959)
connected to auxiliary database: X06 (not mounted)
connected to target database: DEVTARGET (DBID=1826617959)
connected to auxiliary database: X06 (not mounted)
12- Make a whole backup of the target database using RMAN : (Target database is open)
[oracle@x06 admin]$ $ORACLE_HOME/bin/rman target sys@DEVTARGET.ES.EDWN.LAN
Recovery Manager: Release 10.2.0.1.0 – Production on Wed Jun 30 15:43:23 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
target database Password:
connected to target database: DEVTARGET (DBID=1826617959)
connected to target database: DEVTARGET (DBID=1826617959)
RMAN> BACKUP DATABASE;
Starting backup at 30-JUN-10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
13- Make the clone :
[oracle@x06 admin]$ $ORACLE_HOME/bin/rman target sys@DEVTARGET.ES.EDWN.LAN AUXILIARY /
Recovery Manager: Release 10.2.0.1.0 – Production on Wed Jun 30 15:36:03 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
target database Password:
connected to target database: DEVTARGET (DBID=1826617959)
connected to auxiliary database: X06 (not mounted)
Recovery Manager: Release 10.2.0.1.0 – Production on Wed Jun 30 15:36:03 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
target database Password:
connected to target database: DEVTARGET (DBID=1826617959)
connected to auxiliary database: X06 (not mounted)
RMAN> run {
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/data_partner_products.dbf’ TO ‘/u01/app/oracle/oradata/X06/data_partner_products.dbf’;
set newname for datafile ‘/home/oracle/database/data01_02.dbf’ TO ‘/u01/app/oracle/oradata/X06/data01_02.dbf’ ;
set newname for datafile ‘/home/oracle/database/INDX01_01.dbf’ TO ‘/u01/app/oracle/oradata/X06/INDX01_01.dbf’ ;
set newname for datafile ‘/home/oracle/database/data01_01.dbf’ TO ‘/u01/app/oracle/oradata/X06/data01_01.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/undotbs01.dbf’ TO ‘/u01/app/oracle/oradata/X06/undotbs01.dbf’ ;
set newname for datafile ‘/home/oracle/database/user01_05.dbf’ TO ‘/u01/app/oracle/oradata/X06/user01_05.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/users01.dbf’ TO ‘/u01/app/oracle/oradata/X06/users01.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/data_adserver.dbf’ TO ‘/u01/app/oracle/oradata/X06/data_adserver.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/data_shop_client.dbf’ TO ‘/u01/app/oracle/oradata/X06/data_shop_client.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/indx_shop_client.dbf’ TO ‘/u01/app/oracle/oradata/X06/indx_shop_client.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/data_shop.dbf’ TO ‘/u01/app/oracle/oradata/X06/data_shop.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/indx_shop.dbf’ TO ‘/u01/app/oracle/oradata/X06/indx_shop.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/indx_adserver.dbf’ TO ‘/u01/app/oracle/oradata/X06/indx_adserver.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/data_shop_stats.dbf’ TO ‘/u01/app/oracle/oradata/X06/data_shop_stats.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/indx_shop_stats.dbf’ TO ‘/u01/app/oracle/oradata/X06/indx_shop_stats.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/indx_partner_products.dbf’ TO ‘/u01/app/oracle/oradata/X06/indx_partner_products.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/system01.dbf’ TO ‘/u01/app/oracle/oradata/X06/system01.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/undotbs02.dbf’ TO ‘/u01/app/oracle/oradata/X06/undotbs02.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/data21.dbf’ TO ‘/u01/app/oracle/oradata/X06/data21.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/data_distribution_products.dbf’ TO ‘/u01/app/oracle/oradata/X06/data_distribution_products.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/indx_distribution_products.dbf’ TO ‘/u01/app/oracle/oradata/X06/indx_distribution_products.dbf’ ;
set newname for datafile ‘/home/oracle/database/user01_04.dbf’ TO ‘/u01/app/oracle/oradata/X06/user01_04.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/sysaux01.dbf’ TO ‘/u01/app/oracle/oradata/X06/sysaux01.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/data_pointer_network.dbf’ TO ‘/u01/app/oracle/oradata/X06/data_pointer_network.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/indx_pointer_network.dbf’ TO ‘/u01/app/oracle/oradata/X06/indx_pointer_network.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/data_ordim.dbf’ TO ‘/u01/app/oracle/oradata/X06/data_ordim.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/data_spatial.dbf’ TO ‘/u01/app/oracle/oradata/X06/data_spatial.dbf’ ;
set newname for datafile ‘/home/oracle/database/user01_03.dbf’ TO ‘/u01/app/oracle/oradata/X06/user01_03.dbf’ ;
set newname for datafile ‘/home/oracle/database/data01_WEB_01.dbf’ TO ‘/u01/app/oracle/oradata/X06/data01_WEB_01.dbf’ ;
set newname for datafile ‘/home/oracle/database/index01_WEB_01.dbf’ TO ‘/u01/app/oracle/oradata/X06/index01_WEB_01.dbf’ ;
set newname for datafile ‘/home/oracle/database/user01_02.dbf’ TO ‘/u01/app/oracle/oradata/X06/user01_02.dbf’ ;
set newname for datafile ‘/home/oracle/database/dataconso01_01.dbf’ TO ‘/u01/app/oracle/oradata/X06/dataconso01_01.dbf’;
set newname for TEMPFILE ‘/u01/app/oracle/oradata/DEVTARGET/temp01.dbf’ TO ‘/u01/app/oracle/oradata/X06/temp01.dbf’;
duplicate target database to X06;
}
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/data_partner_products.dbf’ TO ‘/u01/app/oracle/oradata/X06/data_partner_products.dbf’;
set newname for datafile ‘/home/oracle/database/data01_02.dbf’ TO ‘/u01/app/oracle/oradata/X06/data01_02.dbf’ ;
set newname for datafile ‘/home/oracle/database/INDX01_01.dbf’ TO ‘/u01/app/oracle/oradata/X06/INDX01_01.dbf’ ;
set newname for datafile ‘/home/oracle/database/data01_01.dbf’ TO ‘/u01/app/oracle/oradata/X06/data01_01.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/undotbs01.dbf’ TO ‘/u01/app/oracle/oradata/X06/undotbs01.dbf’ ;
set newname for datafile ‘/home/oracle/database/user01_05.dbf’ TO ‘/u01/app/oracle/oradata/X06/user01_05.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/users01.dbf’ TO ‘/u01/app/oracle/oradata/X06/users01.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/data_adserver.dbf’ TO ‘/u01/app/oracle/oradata/X06/data_adserver.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/data_shop_client.dbf’ TO ‘/u01/app/oracle/oradata/X06/data_shop_client.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/indx_shop_client.dbf’ TO ‘/u01/app/oracle/oradata/X06/indx_shop_client.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/data_shop.dbf’ TO ‘/u01/app/oracle/oradata/X06/data_shop.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/indx_shop.dbf’ TO ‘/u01/app/oracle/oradata/X06/indx_shop.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/indx_adserver.dbf’ TO ‘/u01/app/oracle/oradata/X06/indx_adserver.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/data_shop_stats.dbf’ TO ‘/u01/app/oracle/oradata/X06/data_shop_stats.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/indx_shop_stats.dbf’ TO ‘/u01/app/oracle/oradata/X06/indx_shop_stats.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/indx_partner_products.dbf’ TO ‘/u01/app/oracle/oradata/X06/indx_partner_products.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/system01.dbf’ TO ‘/u01/app/oracle/oradata/X06/system01.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/undotbs02.dbf’ TO ‘/u01/app/oracle/oradata/X06/undotbs02.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/data21.dbf’ TO ‘/u01/app/oracle/oradata/X06/data21.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/data_distribution_products.dbf’ TO ‘/u01/app/oracle/oradata/X06/data_distribution_products.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/indx_distribution_products.dbf’ TO ‘/u01/app/oracle/oradata/X06/indx_distribution_products.dbf’ ;
set newname for datafile ‘/home/oracle/database/user01_04.dbf’ TO ‘/u01/app/oracle/oradata/X06/user01_04.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/sysaux01.dbf’ TO ‘/u01/app/oracle/oradata/X06/sysaux01.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/data_pointer_network.dbf’ TO ‘/u01/app/oracle/oradata/X06/data_pointer_network.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/indx_pointer_network.dbf’ TO ‘/u01/app/oracle/oradata/X06/indx_pointer_network.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/data_ordim.dbf’ TO ‘/u01/app/oracle/oradata/X06/data_ordim.dbf’ ;
set newname for datafile ‘/u01/app/oracle/oradata/DEVTARGET/data_spatial.dbf’ TO ‘/u01/app/oracle/oradata/X06/data_spatial.dbf’ ;
set newname for datafile ‘/home/oracle/database/user01_03.dbf’ TO ‘/u01/app/oracle/oradata/X06/user01_03.dbf’ ;
set newname for datafile ‘/home/oracle/database/data01_WEB_01.dbf’ TO ‘/u01/app/oracle/oradata/X06/data01_WEB_01.dbf’ ;
set newname for datafile ‘/home/oracle/database/index01_WEB_01.dbf’ TO ‘/u01/app/oracle/oradata/X06/index01_WEB_01.dbf’ ;
set newname for datafile ‘/home/oracle/database/user01_02.dbf’ TO ‘/u01/app/oracle/oradata/X06/user01_02.dbf’ ;
set newname for datafile ‘/home/oracle/database/dataconso01_01.dbf’ TO ‘/u01/app/oracle/oradata/X06/dataconso01_01.dbf’;
set newname for TEMPFILE ‘/u01/app/oracle/oradata/DEVTARGET/temp01.dbf’ TO ‘/u01/app/oracle/oradata/X06/temp01.dbf’;
duplicate target database to X06;
}
No comments:
Post a Comment