Wednesday, October 8, 2014

Oracle Database Clone From One Server To Another Server Using RMAN

Before clone database you can configure RMAN 

[oracle@p11gr2 ora11gp]$ set ORACLE_SID=ora11gs
[oracle@s11gr2 rman_backup]$ rman target/

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Oct 9 01:33:34 2014

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

connected to target database: ORA11GS (DBID=3519562480)

RMAN> show all;

RMAN configuration parameters for database with db_unique_name ORA11GS are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 2 DAYS;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/rman_backup/bkp_cf_%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u01/rman_backup/ora11gs_bkp_%u';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/rman_backup/snapcf_ora11gs.f';

RMAN> BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;

Starting backup at 09-OCT-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=243 RECID=352 STAMP=860458582
input archived log thread=1 sequence=244 RECID=353 STAMP=860459023
channel ORA_DISK_1: starting piece 1 at 09-OCT-14
channel ORA_DISK_1: finished piece 1 at 09-OCT-14
piece handle=/u01/rman_backup/ora11gs_bkp_1gpkj40g tag=TAG20141009T002344 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/u01/app/oracle/oradata/archive/1_243_850299214.arc RECID=352 STAMP=860458582
archived log file name=/u01/app/oracle/oradata/archive/1_244_850299214.arc RECID=353 STAMP=860459023
Finished backup at 09-OCT-14

Starting backup at 09-OCT-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/ora11gp/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/ora11gp/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/ora11gp/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/ora11gp/users01.dbf
channel ORA_DISK_1: starting piece 1 at 09-OCT-14
channel ORA_DISK_1: finished piece 1 at 09-OCT-14
piece handle=/u01/rman_backup/ora11gs_bkp_1hpkj40h tag=TAG20141009T002345 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:25
Finished backup at 09-OCT-14

Starting backup at 09-OCT-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=245 RECID=354 STAMP=860459111
channel ORA_DISK_1: starting piece 1 at 09-OCT-14
channel ORA_DISK_1: finished piece 1 at 09-OCT-14
piece handle=/u01/rman_backup/ora11gs_bkp_1ipkj437 tag=TAG20141009T002511 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/u01/app/oracle/oradata/archive/1_245_850299214.arc RECID=354 STAMP=860459111
Finished backup at 09-OCT-14

Starting Control File and SPFILE Autobackup at 09-OCT-14
piece handle=/u01/rman_backup/bkp_cf_c-3519562480-20141009-01 comment=NONE
Finished Control File and SPFILE Autobackup at 09-OCT-14

RMAN> exit

Recovery Manager complete.
[oracle@s11gr2 rman_backup]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Thu Oct 9 01:36:41 2014

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

SQL> conn /as sysdba
Connected.
SQL> create pfile='/u01/rman_backup/ora11gs_pfile.ora' from spfile;

File created.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@s11gr2 rman_backup]$ cd /u01/rman_backup/
[oracle@s11gr2 rman_backup]$ scp * oracle@192.168.2.150:/u01/rman_backup
oracle@192.168.2.150's password:
bkp_cf_c-3519562480-20141009-01               100% 9728KB   9.5MB/s   00:01  
ora11gs_bkp_1gpkj40g                          100%   62KB  62.0KB/s   00:00  
ora11gs_bkp_1hpkj40h                          100% 1197MB  15.3MB/s   01:18  
ora11gs_bkp_1ipkj437                          100% 3072     3.0KB/s   00:00  
snapcf_ora11gs.f                              100% 9648KB   9.4MB/s   00:00
ora11gs_pfile.ora                             100% 1246     1.2KB/s   00:00  

====== Backup Completed Now Connect New Server 192.168.2.150(p11gr2) =======

[oracle@p11gr2 rman_backup]$ cd /u01/rman_backup/
[oracle@p11gr2 rman_backup]$ cat ora11gs_pfile.ora
ora11gs.__db_cache_size=239075328
ora11gs.__java_pool_size=4194304
ora11gs.__large_pool_size=4194304
ora11gs.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
ora11gs.__pga_aggregate_target=209715200
ora11gs.__sga_target=633339904
ora11gs.__shared_io_pool_size=0
ora11gs.__shared_pool_size=377487360
ora11gs.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/ora11gp/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/oradata/ora11gp/control01.ctl','/u01/app/oracle/flash_recovery_area/ora11gp/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='ORA11GS'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4070572032
*.db_unique_name='ora11gs'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ora11gsxDB)'
*.local_listener='(ADDRESS = (PROTOCOL = TCP)(HOST = s11gr2)(PORT = 1521))'
*.log_archive_dest_1='LOCATION=/u01/app/oracle/oradata/archive'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_format='%t_%s_%r.arc'
*.log_archive_max_processes=30
*.open_cursors=300
*.pga_aggregate_target=209715200
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=631242752
*.undo_tablespace='UNDOTBS1'
[oracle@p11gr2 rman_backup]$ mkdir /u01/app/oracle/admin/ora11gp/adump
[oracle@p11gr2 rman_backup]$ mkdir /u01/app/oracle/flash_recovery_area/ora11gp
[oracle@p11gr2 rman_backup]$ mkdir /u01/app/oracle/flash_recovery_area
[oracle@p11gr2 rman_backup]$ mkdir /u01/app/oracle/oradata/archive
[oracle@p11gr2 ora11gp]$ set ORACLE_SID=ora11gs
bash: RMAN: command not found
[oracle@p11gr2 ora11gp]$ rman target/

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Oct 9 00:52:00 2014

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

connected to target database (not started)

RMAN> startup nomount pfile='/u01/rman_backup/ora11gs_pfile.ora';

Oracle instance started

Total System Global Area     630501376 bytes

Fixed Size                     2215984 bytes
Variable Size                297799632 bytes
Database Buffers             327155712 bytes
Redo Buffers                   3330048 bytes
RMAN> restore controlfile from '/u01/rman_backup/bkp_cf_c-3519562480-20141009-01';

Starting restore at 09-OCT-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/ora11gs/control01.ctl
output file name=/u01/app/oracle/flash_recovery_area/ora11gs/control02.ctl
Finished restore at 09-OCT-14
RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> restore database;

Starting restore at 09-OCT-14
Starting implicit crosscheck backup at 09-OCT-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
Crosschecked 44 objects
Finished implicit crosscheck backup at 09-OCT-14

Starting implicit crosscheck copy at 09-OCT-14
using channel ORA_DISK_1
Finished implicit crosscheck copy at 09-OCT-14

searching for all files in the recovery area
cataloging files...
no files cataloged

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/ora11gp/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/ora11gp/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/ora11gp/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/ora11gp/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman_backup/ora11gs_bkp_1hpkj40h
channel ORA_DISK_1: piece handle=/u01/rman_backup/ora11gs_bkp_1hpkj40h tag=TAG20141009T002345
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
Finished restore at 09-OCT-14

RMAN> recover database;

Starting recover at 09-OCT-14
using channel ORA_DISK_1

starting media recovery

channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=245
channel ORA_DISK_1: reading from backup piece /u01/rman_backup/ora11gs_bkp_1ipkj437
channel ORA_DISK_1: piece handle=/u01/rman_backup/ora11gs_bkp_1ipkj437 tag=TAG20141009T002511
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/oracle/oradata/archive_ora11gs/1_245_850299214.arc thread=1 sequence=245
unable to find archived log
archived log thread=1 sequence=246
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 10/09/2014 00:56:21
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 246 and starting SCN of 4510762

RMAN> sql "alter database open resetlogs";

sql statement: alter database open resetlogs

RMAN>

No comments:

Post a Comment