четверг, 8 сентября 2011 г.

RMAN Duplicate without Target using Veritas Netbackup

1. Исходная промышленная СУБД (SPOD)

$ export ORACLE_SID=spod
$ sqlplus "/as sysdba"
SQL*Plus: Release 11.2.0.2.0 Production on Thu Sep 1 11:34:02 2011

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u03/app/oradb/oradata/spod/system/system01.dbf
/u03/app/oradb/oradata/spod/sysaux/sysaux01.dbf
/u03/app/oradb/oradata/spod/undotbs/undotbs01.dbf
/u03/app/oradb/oradata/spod/users/users01.dbf

SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
/u03/app/oradb/oradata/spod/temp/temp01.dbf

SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u02/app/oradb/oradata/spod/redoa/redo01.log
/u02/app/oradb/oradata/spod/redoa/redo02.log
/u02/app/oradb/oradata/spod/redoa/redo03.log

SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/u03/app/oradb/oradata/spod/control1/control01.ctl
/u03/app/oradb/oradata/spod/control2/control02.ctl

SQL> exit

$ strings spfilespod.ora
spod.__db_cache_size=1409286144
spod.__java_pool_size=16777216
spod.__large_pool_size=16777216
spod.__oracle_base='/u01/app'#ORACLE_BASE set from environment
spod.__pga_aggregate_target=1342177280
spod.__sga_target=2013265920
spod.__shared_io_pool_size=0
spod.__shared_pool_size=520093696
spod.__streams_pool_size=16777216
*.audit_file_dest='/u01/app/admin/spod/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u03/app/oradb/oradata/spod/control1/control01.ctl','/u03/app/oradb/oradata/spod/control2/control02.ctl'
*.db_block_size=8192
*.db_domain='oracle.sun.com'
*.db_name='spod'
*.db_recovery_file_dest='/u01/app/fast_recovery_area'
*.db_recovery_file_dest_size=5218762752
*.diagnostic_dest='/u01/app'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=spodXDB)'
*.log_archive_dest_1='LOCATION=/u01/app/oradb/archlogs/arch01/spod/'
*.log_archive_dest_2='LOCATION=/u01/app/oradb/archlogs/arch02/spod OPTIONAL'
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
$

2. Создаем структуру каталогов для тестовой базы данных (SPODT2)

mkdir -p /u03/app/oradb/oradata/spodt2/system
mkdir -p /u03/app/oradb/oradata/spodt2/sysaux
mkdir -p /u03/app/oradb/oradata/spodt2/undotbs
mkdir -p /u03/app/oradb/oradata/spodt2/users
mkdir -p /u03/app/oradb/oradata/spodt2/temp
mkdir -p /u02/app/oradb/oradata/spodt2/redoa
mkdir -p /u03/app/oradb/oradata/spodt2/control1
mkdir -p /u03/app/oradb/oradata/spodt2/control2

mkdir -p /u01/app/oradb/archlogs/arch01/spodt2
mkdir -p /u01/app/oradb/archlogs/arch02/spodt2


3. Внесем изменения в фалйы: listener.ora и tnsnames.ora

$ more /u01/app/11.2.0.2/grid/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/app/11.2.0.2/grid/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = spodt1.oracle.sun.com)
(ORACLE_HOME = /u01/app/oradb/product/11.2.0.2/dbhome_1)
(SID_NAME = spodt1)
)
(SID_DESC =
(GLOBAL_DBNAME = spodt2.oracle.sun.com)
(ORACLE_HOME = /u01/app/oradb/product/11.2.0.2/dbhome_1)
(SID_NAME = spodt2)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = kr400.oracle.sun.com)(PORT = 1521))
)
)

ADR_BASE_LISTENER = /u01/app/oragrid

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
$


$ more /u01/app/oradb/product/11.2.0.2/dbhome_1/network/admin/tnsnames.ora

# tnsnames.ora Network Configuration File: /u01/app/oradb/product/11.2.0.2/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

SPOD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = kr400.oracle.sun.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = spod.oracle.sun.com)
)
)

SPODT1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = kr400.oracle.sun.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = spodt1.oracle.sun.com)
)
)

SPODT2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = kr400.oracle.sun.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = spodt2.oracle.sun.com)
)
)

4. Подготовим скрипт backupSPOD_tape.sh для создания резервной копии промышленной СУБД (SPOD)

$ more backupSPOD_tape.sh

ORACLE_HOME=/u01/app/oradb/product/11.2.0.2/dbhome_1
export ORACLE_HOME
ORACLE_SID=spod
export ORACLE_SID
rman target / catalog 'rman/passwd@catdb' << EOF

########################################## Clear configuration ###########################################
CONFIGURE RETENTION POLICY CLEAR;
CONFIGURE BACKUP OPTIMIZATION CLEAR;
CONFIGURE DEFAULT DEVICE TYPE CLEAR;
CONFIGURE CONTROLFILE AUTOBACKUP CLEAR;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK CLEAR;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT CLEAR;
CONFIGURE DEVICE TYPE DISK CLEAR;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK CLEAR;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE SBT CLEAR;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK CLEAR;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE SBT CLEAR;
CONFIGURE CHANNEL DEVICE TYPE DISK CLEAR;
CONFIGURE CHANNEL DEVICE TYPE SBT CLEAR;
CONFIGURE MAXSETSIZE CLEAR;
CONFIGURE SNAPSHOT CONTROLFILE NAME CLEAR;
########################################### Configure #####################################################

CONFIGURE DEFAULT DEVICE TYPE TO sbt;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT_TAPE TO '%F';
CONFIGURE DEVICE TYPE 'SBT_TAPE' PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE 'SBT_TAPE' TO 1;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE 'SBT_TAPE' TO 1;
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/snapcf_orcl.f';
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;

########################################### BACKUP SCRIPT #################################################

DELETE NOPROMPT obsolete redundancy 2;
CROSSCHECK BACKUP;
CROSSCHECK archivelog all;
CROSSCHECK COPY;
CROSSCHECK backup of database;
CROSSCHECK backup of controlfile;

RUN {
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
SEND 'NB_ORA_SERV=nbsrv-1,NB_ORA_CLIENT=kr400-1,NB_ORA_POLICY=KR400_Oracle';

sql 'alter system switch logfile';
sql 'alter system archive log current';
backup database plus archivelog delete input;
sql 'alter system switch logfile';
sql 'alter system archive log current';

delete noprompt obsolete;
RELEASE CHANNEL ch00;
}
EOF
exit 0

$

5. Выполним резервное копирование промышленной СУБД (SPOD):

$ ./backupSPOD_tape.sh
Recovery Manager: Release 11.2.0.2.0 - Production on Thu Sep 8 16:04:28 2011

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

connected to target database: SPOD (DBID=1675227431)
connected to recovery catalog database

RMAN>
RMAN> 2>
starting full resync of recovery catalog
full resync complete
old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 3 DAYS;
RMAN configuration parameters are successfully reset to default value
starting full resync of recovery catalog
full resync complete

RMAN>
old RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION OFF;
RMAN configuration parameters are successfully reset to default value
starting full resync of recovery catalog
full resync complete

RMAN>
old RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
RMAN configuration parameters are successfully reset to default value
starting full resync of recovery catalog
full resync complete

RMAN>
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
RMAN configuration parameters are successfully reset to default value
starting full resync of recovery catalog
full resync complete

RMAN>
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u03/app/oradb/backups/rman/spod/cf_%F';
RMAN configuration parameters are successfully reset to default value
starting full resync of recovery catalog
full resync complete

RMAN>
RMAN configuration parameters are successfully reset to default value

RMAN>
old RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
RMAN configuration parameters are successfully reset to default value
starting full resync of recovery catalog
full resync complete

RMAN>
old RMAN configuration parameters:
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
RMAN configuration parameters are successfully reset to default value
starting full resync of recovery catalog
full resync complete

RMAN>
RMAN configuration parameters are successfully reset to default value

RMAN>
old RMAN configuration parameters:
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
RMAN configuration parameters are successfully reset to default value
starting full resync of recovery catalog
full resync complete

RMAN>
RMAN configuration parameters are successfully reset to default value

RMAN>
old RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u03/app/oradb/backups/rman/spod/%U';
old RMAN configuration parameters are successfully deleted
starting full resync of recovery catalog
full resync complete

RMAN>
old RMAN configuration parameters are successfully deleted

RMAN>
old RMAN configuration parameters:
CONFIGURE MAXSETSIZE TO UNLIMITED;
RMAN configuration parameters are successfully reset to default value
starting full resync of recovery catalog
full resync complete

RMAN>
old RMAN configuration parameters:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u03/app/oradb/backups/rman/spod/snapcf_syslog.f';
RMAN configuration parameters are successfully reset to default value
starting full resync of recovery catalog
full resync complete

RMAN> 2> 3>
new RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN>
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN>
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE 'SBT_TAPE' TO '%F';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN>
old RMAN configuration parameters:
CONFIGURE DEVICE TYPE 'SBT_TAPE' PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE 'SBT_TAPE' PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN>
new RMAN configuration parameters:
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE 'SBT_TAPE' TO 1;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN>
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE 'SBT_TAPE' TO 1;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN>
new RMAN configuration parameters:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/snapcf_orcl.f';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN>
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN>
RMAN> 2> 3>
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=100 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: Veritas NetBackup for Oracle - Release 6.5 (2010042404)
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=131 device type=DISK
Deleting the following obsolete backups and copies:
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 240920 08-SEP-11
Backup Piece 240932 08-SEP-11 8jmm1de7_1_1
Backup Set 240944 08-SEP-11
Backup Piece 240949 08-SEP-11 8kmm1dgv_1_1
Backup Set 240958 08-SEP-11
Backup Piece 240960 08-SEP-11 c-1675227431-20110908-06
Backup Set 241065 08-SEP-11
Backup Piece 241070 08-SEP-11 8mmm1mrk_1_1
Backup Set 241066 08-SEP-11
Backup Piece 241071 08-SEP-11 8omm1mv8_1_1
Backup Set 241067 08-SEP-11
Backup Piece 241072 08-SEP-11 8nmm1mrk_1_1
deleted backup piece
backup piece handle=8jmm1de7_1_1 RECID=207 STAMP=761312711
deleted backup piece
backup piece handle=8kmm1dgv_1_1 RECID=208 STAMP=761312799
deleted backup piece
backup piece handle=c-1675227431-20110908-06 RECID=209 STAMP=761312856
deleted backup piece
backup piece handle=8mmm1mrk_1_1 RECID=210 STAMP=761322356
deleted backup piece
backup piece handle=8omm1mv8_1_1 RECID=211 STAMP=761322472
deleted backup piece
backup piece handle=8nmm1mrk_1_1 RECID=212 STAMP=761322356
Deleted 6 objects


RMAN>
using channel ORA_SBT_TAPE_1
using channel ORA_DISK_1
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=8qmm1n29_1_1 RECID=213 STAMP=761322570
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=8pmm1n29_1_1 RECID=214 STAMP=761322570
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=8rmm1n4o_1_1 RECID=215 STAMP=761322648
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=c-1675227431-20110908-07 RECID=216 STAMP=761322705
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/app/oradb/backups/rman/spod/8tmm1s7i_1_1 RECID=217 STAMP=761327858
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/app/oradb/backups/rman/spod/8umm1s7j_1_1 RECID=218 STAMP=761327860
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/app/oradb/backups/rman/spod/8vmm1s8n_1_1 RECID=219 STAMP=761327895
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/app/oradb/backups/rman/spod/cf_c-1675227431-20110908-08 RECID=220 STAMP=761327897
Crosschecked 8 objects


RMAN>
released channel: ORA_SBT_TAPE_1
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=100 device type=DISK
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_409_760029095.dbf RECID=639 STAMP=761322763
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_410_760029095.dbf RECID=641 STAMP=761322765
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_411_760029095.dbf RECID=643 STAMP=761327856
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_412_760029095.dbf RECID=646 STAMP=761327856
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_413_760029095.dbf RECID=648 STAMP=761327857
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_414_760029095.dbf RECID=650 STAMP=761327895
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_415_760029095.dbf RECID=651 STAMP=761327900
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_415_760029095.dbf RECID=652 STAMP=761327900
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_416_760029095.dbf RECID=653 STAMP=761327902
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_416_760029095.dbf RECID=654 STAMP=761327902
Crosschecked 10 objects


RMAN>
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=100 device type=DISK
specification does not match any datafile copy in the repository
specification does not match any control file copy in the repository
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_409_760029095.dbf RECID=639 STAMP=761322763
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_410_760029095.dbf RECID=641 STAMP=761322765
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_411_760029095.dbf RECID=643 STAMP=761327856
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_412_760029095.dbf RECID=646 STAMP=761327856
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_413_760029095.dbf RECID=648 STAMP=761327857
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_414_760029095.dbf RECID=650 STAMP=761327895
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_415_760029095.dbf RECID=651 STAMP=761327900
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_415_760029095.dbf RECID=652 STAMP=761327900
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_416_760029095.dbf RECID=653 STAMP=761327902
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_416_760029095.dbf RECID=654 STAMP=761327902
Crosschecked 10 objects


RMAN>
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=131 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: Veritas NetBackup for Oracle - Release 6.5 (2010042404)
using channel ORA_DISK_1
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/app/oradb/backups/rman/spod/8umm1s7j_1_1 RECID=218 STAMP=761327860
Crosschecked 1 objects

crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=8qmm1n29_1_1 RECID=213 STAMP=761322570
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=8pmm1n29_1_1 RECID=214 STAMP=761322570
Crosschecked 2 objects


RMAN>
using channel ORA_SBT_TAPE_1
using channel ORA_DISK_1
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/app/oradb/backups/rman/spod/cf_c-1675227431-20110908-08 RECID=220 STAMP=761327897
Crosschecked 1 objects

crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=c-1675227431-20110908-07 RECID=216 STAMP=761322705
Crosschecked 1 objects


RMAN>
RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13>
released channel: ORA_SBT_TAPE_1
released channel: ORA_DISK_1
allocated channel: ch00
channel ch00: SID=100 device type=SBT_TAPE
channel ch00: Veritas NetBackup for Oracle - Release 6.5 (2010042404)

sent command to channel: ch00

sql statement: alter system switch logfile

sql statement: alter system archive log current


Starting backup at 08-SEP-11
current log archived
channel ch00: starting archived log backup set
channel ch00: specifying archived log(s) in backup set
input archived log thread=1 sequence=409 RECID=639 STAMP=761322763
input archived log thread=1 sequence=410 RECID=641 STAMP=761322765
input archived log thread=1 sequence=411 RECID=643 STAMP=761327856
input archived log thread=1 sequence=412 RECID=646 STAMP=761327856
input archived log thread=1 sequence=413 RECID=648 STAMP=761327857
input archived log thread=1 sequence=414 RECID=650 STAMP=761327895
input archived log thread=1 sequence=415 RECID=651 STAMP=761327900
input archived log thread=1 sequence=416 RECID=653 STAMP=761327902
input archived log thread=1 sequence=417 RECID=655 STAMP=761328334
input archived log thread=1 sequence=418 RECID=657 STAMP=761328335
input archived log thread=1 sequence=419 RECID=660 STAMP=761328339
channel ch00: starting piece 1 at 08-SEP-11
channel ch00: finished piece 1 at 08-SEP-11
piece handle=91mm1sml_1_1 tag=TAG20110908T160540 comment=API Version 2.0,MMS Version 5.0.0.0
channel ch00: backup set complete, elapsed time: 00:02:55
channel ch00: deleting archived log(s)
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_409_760029095.dbf RECID=639 STAMP=761322763
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_410_760029095.dbf RECID=641 STAMP=761322765
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_411_760029095.dbf RECID=643 STAMP=761327856
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_412_760029095.dbf RECID=646 STAMP=761327856
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_413_760029095.dbf RECID=648 STAMP=761327857
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_414_760029095.dbf RECID=650 STAMP=761327895
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_415_760029095.dbf RECID=651 STAMP=761327900
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_416_760029095.dbf RECID=653 STAMP=761327902
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_417_760029095.dbf RECID=655 STAMP=761328334
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_418_760029095.dbf RECID=657 STAMP=761328335
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_419_760029095.dbf RECID=660 STAMP=761328339
Finished backup at 08-SEP-11

Starting backup at 08-SEP-11
channel ch00: starting full datafile backup set
channel ch00: specifying datafile(s) in backup set
input datafile file number=00001 name=/u03/app/oradb/oradata/spod/system/system01.dbf
input datafile file number=00003 name=/u03/app/oradb/oradata/spod/undotbs/undotbs01.dbf
input datafile file number=00002 name=/u03/app/oradb/oradata/spod/sysaux/sysaux01.dbf
input datafile file number=00004 name=/u03/app/oradb/oradata/spod/users/users01.dbf
channel ch00: starting piece 1 at 08-SEP-11
channel ch00: finished piece 1 at 08-SEP-11
piece handle=92mm1ss6_1_1 tag=TAG20110908T160837 comment=API Version 2.0,MMS Version 5.0.0.0
channel ch00: backup set complete, elapsed time: 00:01:25
Finished backup at 08-SEP-11

Starting backup at 08-SEP-11
current log archived
channel ch00: starting archived log backup set
channel ch00: specifying archived log(s) in backup set
input archived log thread=1 sequence=420 RECID=662 STAMP=761328604
channel ch00: starting piece 1 at 08-SEP-11
channel ch00: finished piece 1 at 08-SEP-11
piece handle=93mm1suv_1_1 tag=TAG20110908T161005 comment=API Version 2.0,MMS Version 5.0.0.0
channel ch00: backup set complete, elapsed time: 00:00:55
channel ch00: deleting archived log(s)
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_420_760029095.dbf RECID=662 STAMP=761328604
Finished backup at 08-SEP-11

Starting Control File and SPFILE Autobackup at 08-SEP-11
piece handle=c-1675227431-20110908-09 comment=API Version 2.0,MMS Version 5.0.0.0
Finished Control File and SPFILE Autobackup at 08-SEP-11

sql statement: alter system switch logfile

sql statement: alter system archive log current

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
Deleting the following obsolete backups and copies:
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 241093 08-SEP-11
Backup Piece 241098 08-SEP-11 8qmm1n29_1_1
Backup Set 241094 08-SEP-11
Backup Piece 241099 08-SEP-11 8pmm1n29_1_1
Backup Set 241111 08-SEP-11
Backup Piece 241114 08-SEP-11 8rmm1n4o_1_1
Backup Set 241123 08-SEP-11
Backup Piece 241125 08-SEP-11 c-1675227431-20110908-07
Backup Set 241191 08-SEP-11
Backup Piece 241197 08-SEP-11 /u03/app/oradb/backups/rman/spod/8tmm1s7i_1_1
deleted backup piece
backup piece handle=/u03/app/oradb/backups/rman/spod/8tmm1s7i_1_1 RECID=217 STAMP=761327858
Deleted 1 objects

deleted backup piece
backup piece handle=8qmm1n29_1_1 RECID=213 STAMP=761322570
deleted backup piece
backup piece handle=8pmm1n29_1_1 RECID=214 STAMP=761322570
deleted backup piece
backup piece handle=8rmm1n4o_1_1 RECID=215 STAMP=761322648
deleted backup piece
backup piece handle=c-1675227431-20110908-07 RECID=216 STAMP=761322705
Deleted 4 objects


released channel: ch00

RMAN>

Recovery Manager complete.
$

6. Подготовим скрипт makeSPODT2.sh для создания тестовой СУБД (SPODT2)

$ more makeSPODT2_tape.sh

#!/bin/bash

# Create temporary password file, must have same password as primary
rm /u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/orapwspodt2
orapwd file=/u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/orapwspodt2 password=oracle

# Create temporary parameter file
echo "db_name=spodt2" > /u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/initspodt2.ora

export ORACLE_SID=spodt2
export ORACLE_HOME=/u01/app/oradb/product/11.2.0.2/dbhome_1

# Start up the auxiliary instance nomount
sqlplus '/ as sysdba' << EOF
shutdown immediate;
STARTUP PFILE='/u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/initspodt2.ora' NOMOUNT;
EOF

rman << EOF
connect catalog rman/passwd@catdb;
connect auxiliary sys/oracle@spodt2;
run {
ALLOCATE AUXILIARY CHANNEL c1 DEVICE TYPE 'SBT_TAPE';
SEND 'NB_ORA_SERV=nbsrv-1,NB_ORA_CLIENT=kr400-1,NB_ORA_POLICY=KR400_Oracle';
duplicate database 'spod' to 'spodt2'
spfile
SET CONTROL_FILES '/u03/app/oradb/oradata/spodt2/control1/control01.ctl','/u03/app/oradb/oradata/spodt2/control2/control02.ctl'
SET LOG_FILE_NAME_CONVERT '/u02/app/oradb/oradata/spod/','/u02/app/oradb/oradata/spodt2/'
SET DB_FILE_NAME_CONVERT '/u03/app/oradb/oradata/spod/','/u03/app/oradb/oradata/spodt2/'
;
}

EOF
exit 0

$

7. Выполним этот скрипт :

$ ./makeSPODT2_tape.sh
SQL*Plus: Release 11.2.0.2.0 Production on Thu Sep 8 16:23:58 2011

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> ORACLE instance started.

Total System Global Area 217157632 bytes
Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Recovery Manager: Release 11.2.0.2.0 - Production on Thu Sep 8 16:24:22 2011

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

RMAN>
connected to recovery catalog database

RMAN>
connected to auxiliary database: SPODT2 (not mounted)

RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10>
allocated channel: c1
channel c1: SID=67 device type=SBT_TAPE
channel c1: Veritas NetBackup for Oracle - Release 6.5 (2010042404)

sent command to channel: c1

Starting Duplicate Db at 08-SEP-11

contents of Memory Script:
{
set until scn 2836104;
restore clone spfile to '/u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/spfilespodt2.ora';
sql clone "alter system set spfile= ''/u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/spfilespodt2.ora''";
}
executing Memory Script

executing command: SET until clause

Starting restore at 08-SEP-11

WARNING: A restore time was estimated based on the supplied UNTIL SCN
channel c1: starting datafile backup set restore
channel c1: restoring SPFILE
output file name=/u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/spfilespodt2.ora
channel c1: reading from backup piece c-1675227431-20110908-09
channel c1: piece handle=c-1675227431-20110908-09 tag=TAG20110908T161103
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:02:35
Finished restore at 08-SEP-11

sql statement: alter system set spfile= ''/u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/spfilespodt2.ora''

contents of Memory Script:
{
sql clone "alter system set db_name =
''SPODT2'' comment=
''duplicate'' scope=spfile";
sql clone "alter system set CONTROL_FILES =
''/u03/app/oradb/oradata/spodt2/control1/control01.ctl'', ''/u03/app/oradb/oradata/spodt2/control2/control02.ctl'' comment=
'''' scope=spfile";
sql clone "alter system set LOG_FILE_NAME_CONVERT =
''/u02/app/oradb/oradata/spod/'', ''/u02/app/oradb/oradata/spodt2/'' comment=
'''' scope=spfile";
sql clone "alter system set db_file_name_convert =
''/u03/app/oradb/oradata/spod/'', ''/u03/app/oradb/oradata/spodt2/'' comment=
'''' scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script

sql statement: alter system set db_name = ''SPODT2'' comment= ''duplicate'' scope=spfile

sql statement: alter system set CONTROL_FILES = ''/u03/app/oradb/oradata/spodt2/control1/control01.ctl'', ''/u03/app/oradb/oradata/s podt2/control2/control02.ctl'' comment= '''' scope=spfile

sql statement: alter system set LOG_FILE_NAME_CONVERT = ''/u02/app/oradb/oradata/spod/'', ''/u02/app/oradb/oradata/spodt2/'' comment = '''' scope=spfile

sql statement: alter system set db_file_name_convert = ''/u03/app/oradb/oradata/spod/'', ''/u03/app/oradb/oradata/spodt2/'' comment= '''' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area 217157632 bytes

Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes
allocated channel: c1
channel c1: SID=156 device type=SBT_TAPE
channel c1: Veritas NetBackup for Oracle - Release 6.5 (2010042404)

contents of Memory Script:
{
sql clone "alter system set db_name =
''SPOD'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''SPODT2'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone primary controlfile;
alter clone database mount;
}
executing Memory Script

sql statement: alter system set db_name = ''SPOD'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system set db_unique_name = ''SPODT2'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area 217157632 bytes

Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes
allocated channel: c1
channel c1: SID=156 device type=SBT_TAPE
channel c1: Veritas NetBackup for Oracle - Release 6.5 (2010042404)

Starting restore at 08-SEP-11

channel c1: starting datafile backup set restore
channel c1: restoring control file
channel c1: reading from backup piece c-1675227431-20110908-09
channel c1: piece handle=c-1675227431-20110908-09 tag=TAG20110908T161103
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:00:45
output file name=/u03/app/oradb/oradata/spodt2/control1/control01.ctl
output file name=/u03/app/oradb/oradata/spodt2/control2/control02.ctl
Finished restore at 08-SEP-11

database mounted

contents of Memory Script:
{
set until scn 2836104;
set newname for datafile 1 to
"/u03/app/oradb/oradata/spodt2/system/system01.dbf";
set newname for datafile 2 to
"/u03/app/oradb/oradata/spodt2/sysaux/sysaux01.dbf";
set newname for datafile 3 to
"/u03/app/oradb/oradata/spodt2/undotbs/undotbs01.dbf";
set newname for datafile 4 to
"/u03/app/oradb/oradata/spodt2/users/users01.dbf";
restore
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

Starting restore at 08-SEP-11

channel c1: starting datafile backup set restore
channel c1: specifying datafile(s) to restore from backup set
channel c1: restoring datafile 00001 to /u03/app/oradb/oradata/spodt2/system/system01.dbf
channel c1: restoring datafile 00002 to /u03/app/oradb/oradata/spodt2/sysaux/sysaux01.dbf
channel c1: restoring datafile 00003 to /u03/app/oradb/oradata/spodt2/undotbs/undotbs01.dbf
channel c1: restoring datafile 00004 to /u03/app/oradb/oradata/spodt2/users/users01.dbf
channel c1: reading from backup piece 92mm1ss6_1_1
channel c1: piece handle=92mm1ss6_1_1 tag=TAG20110908T160837
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:01:35
Finished restore at 08-SEP-11

contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=62 STAMP=761329812 file name=/u03/app/oradb/oradata/spodt2/system/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=63 STAMP=761329812 file name=/u03/app/oradb/oradata/spodt2/sysaux/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=64 STAMP=761329812 file name=/u03/app/oradb/oradata/spodt2/undotbs/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=65 STAMP=761329812 file name=/u03/app/oradb/oradata/spodt2/users/users01.dbf

contents of Memory Script:
{
set until scn 2836104;
recover
clone database
delete archivelog
;
}
executing Memory Script

executing command: SET until clause

Starting recover at 08-SEP-11

starting media recovery

archived log for thread 1 with sequence 420 is already on disk as file /u01/app/oradb/archlogs/arch01/spod/1_420_760029095.dbf
archived log for thread 1 with sequence 421 is already on disk as file /u01/app/oradb/archlogs/arch01/spod/1_421_760029095.dbf
archived log for thread 1 with sequence 422 is already on disk as file /u01/app/oradb/archlogs/arch01/spod/1_422_760029095.dbf
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_420_760029095.dbf thread=1 sequence=420
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_421_760029095.dbf thread=1 sequence=421
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_422_760029095.dbf thread=1 sequence=422
media recovery complete, elapsed time: 00:00:00
Finished recover at 08-SEP-11
Oracle instance started

Total System Global Area 217157632 bytes

Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes

contents of Memory Script:
{
sql clone "alter system set db_name =
''SPODT2'' 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 = ''SPODT2'' 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 217157632 bytes

Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes
allocated channel: c1
channel c1: SID=156 device type=SBT_TAPE
channel c1: Veritas NetBackup for Oracle - Release 6.5 (2010042404)
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "SPODT2" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u02/app/oradb/oradata/spodt2/redoa/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/u02/app/oradb/oradata/spodt2/redoa/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/u02/app/oradb/oradata/spodt2/redoa/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/u03/app/oradb/oradata/spodt2/system/system01.dbf'
CHARACTER SET CL8MSWIN1251


contents of Memory Script:
{
set newname for tempfile 1 to
"/u03/app/oradb/oradata/spodt2/temp/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u03/app/oradb/oradata/spodt2/sysaux/sysaux01.dbf",
"/u03/app/oradb/oradata/spodt2/undotbs/undotbs01.dbf",
"/u03/app/oradb/oradata/spodt2/users/users01.dbf";
switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u03/app/oradb/oradata/spodt2/temp/temp01.dbf in control file

cataloged datafile copy
datafile copy file name=/u03/app/oradb/oradata/spodt2/sysaux/sysaux01.dbf RECID=1 STAMP=761329853
cataloged datafile copy
datafile copy file name=/u03/app/oradb/oradata/spodt2/undotbs/undotbs01.dbf RECID=2 STAMP=761329853
cataloged datafile copy
datafile copy file name=/u03/app/oradb/oradata/spodt2/users/users01.dbf RECID=3 STAMP=761329853

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=761329853 file name=/u03/app/oradb/oradata/spodt2/sysaux/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=761329853 file name=/u03/app/oradb/oradata/spodt2/undotbs/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=761329853 file name=/u03/app/oradb/oradata/spodt2/users/users01.dbf

contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script

database opened
Finished Duplicate Db at 08-SEP-11
released channel: c1

RMAN>
RMAN>

Recovery Manager complete.
$

8. Проверяем созданную базу данных (SPODT2)

$ ps -ef|grep pmon
oradb 8900 1 0 12:43 ? 00:00:01 ora_pmon_spod
oragrid 9167 1 0 12:43 ? 00:00:01 asm_pmon_+ASM
oradb 20306 1 0 14:25 ? 00:00:00 ora_pmon_spodt2
oradb 27736 1 0 Sep01 ? 00:00:14 ora_pmon_spodt1

$ export ORACLE_SID=spodt2
$ sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.2.0 Production on Thu Sep 1 12:32:10 2011

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u03/app/oradb/oradata/spodt2/system/system01.dbf
/u03/app/oradb/oradata/spodt2/sysaux/sysaux01.dbf
/u03/app/oradb/oradata/spodt2/undotbs/undotbs01.dbf
/u03/app/oradb/oradata/spodt2/users/users01.dbf

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
/u03/app/oradb/oradata/spodt2/temp/temp01.dbf

SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u02/app/oradb/oradata/spodt2/redoa/redo03.log
/u02/app/oradb/oradata/spodt2/redoa/redo02.log
/u02/app/oradb/oradata/spodt2/redoa/redo01.log


SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/u03/app/oradb/oradata/spodt2/control1/control01.ctl
/u03/app/oradb/oradata/spodt2/control2/control02.ctl

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
$




пятница, 2 сентября 2011 г.

RMAN Duplicate without Target

1. Исходная промышленная СУБД (SPOD)

$ export ORACLE_SID=spod
$ sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.2.0 Production on Thu Sep 1 11:34:02 2011

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u03/app/oradb/oradata/spod/system/system01.dbf
/u03/app/oradb/oradata/spod/sysaux/sysaux01.dbf
/u03/app/oradb/oradata/spod/undotbs/undotbs01.dbf
/u03/app/oradb/oradata/spod/users/users01.dbf

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
/u03/app/oradb/oradata/spod/temp/temp01.dbf

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u02/app/oradb/oradata/spod/redoa/redo01.log
/u02/app/oradb/oradata/spod/redoa/redo02.log
/u02/app/oradb/oradata/spod/redoa/redo03.log

SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
/u03/app/oradb/oradata/spod/control1/control01.ctl
/u03/app/oradb/oradata/spod/control2/control02.ctl

SQL> exit

$ strings spfilespod.ora
spod.__db_cache_size=1409286144
spod.__java_pool_size=16777216
spod.__large_pool_size=16777216
spod.__oracle_base='/u01/app'#ORACLE_BASE set from environment
spod.__pga_aggregate_target=1342177280
spod.__sga_target=2013265920
spod.__shared_io_pool_size=0
spod.__shared_pool_size=520093696
spod.__streams_pool_size=16777216
*.audit_file_dest='/u01/app/admin/spod/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u03/app/oradb/oradata/spod/control1/control01.ctl','/u03/app/oradb/oradata/spod/control2/control02.ctl'
*.db_block_size=8192
*.db_domain='oracle.sun.com'
*.db_name='spod'
*.db_recovery_file_dest='/u01/app/fast_recovery_area'
*.db_recovery_file_dest_size=5218762752
*.diagnostic_dest='/u01/app'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=spodXDB)'
*.log_archive_dest_1='LOCATION=/u01/app/oradb/archlogs/arch01/spod/'
*.log_archive_dest_2='LOCATION=/u01/app/oradb/archlogs/arch02/spod OPTIONAL'
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
$

2. Создаем структуру каталогов для тестовой базы данных (SPODT2)

mkdir -p /u03/app/oradb/oradata/spodt2/system
mkdir -p /u03/app/oradb/oradata/spodt2/sysaux
mkdir -p /u03/app/oradb/oradata/spodt2/undotbs
mkdir -p /u03/app/oradb/oradata/spodt2/users
mkdir -p /u03/app/oradb/oradata/spodt2/temp
mkdir -p /u02/app/oradb/oradata/spodt2/redoa
mkdir -p /u03/app/oradb/oradata/spodt2/control1
mkdir -p /u03/app/oradb/oradata/spodt2/control2

mkdir -p /u01/app/oradb/archlogs/arch01/spodt2
mkdir -p /u01/app/oradb/archlogs/arch02/spodt2


3. Внесем изменения в фалйы: listener.ora и tnsnames.ora

$ more /u01/app/11.2.0.2/grid/network/admin/listener.ora

# listener.ora Network Configuration File: /u01/app/11.2.0.2/grid/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = spodt1.oracle.sun.com)
(ORACLE_HOME = /u01/app/oradb/product/11.2.0.2/dbhome_1)
(SID_NAME = spodt1)
)
(SID_DESC =
(GLOBAL_DBNAME = spodt2.oracle.sun.com)
(ORACLE_HOME = /u01/app/oradb/product/11.2.0.2/dbhome_1)
(SID_NAME = spodt2)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = kr400.oracle.sun.com)(PORT = 1521))
)
)

ADR_BASE_LISTENER = /u01/app/oragrid

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
$


$ more /u01/app/oradb/product/11.2.0.2/dbhome_1/network/admin/tnsnames.ora

# tnsnames.ora Network Configuration File: /u01/app/oradb/product/11.2.0.2/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

SPOD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = kr400.oracle.sun.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = spod.oracle.sun.com)
)
)

SPODT1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = kr400.oracle.sun.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = spodt1.oracle.sun.com)
)
)

SPODT2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = kr400.oracle.sun.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = spodt2.oracle.sun.com)
)
)

4. Подготовим скрипт backupSPOD.sh для создания резервной копии промышленной СУБД (SPOD)

#!/bin/bash

export ORACLE_SID=spod

rman target / nocatalog << EOF

######### Clear ##################################################
CONFIGURE RETENTION POLICY CLEAR;
CONFIGURE BACKUP OPTIMIZATION CLEAR;
CONFIGURE DEFAULT DEVICE TYPE CLEAR;
CONFIGURE CONTROLFILE AUTOBACKUP CLEAR;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK CLEAR;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT CLEAR;
CONFIGURE DEVICE TYPE DISK CLEAR;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK CLEAR;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE SBT CLEAR;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK CLEAR;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE SBT CLEAR;
CONFIGURE CHANNEL DEVICE TYPE DISK CLEAR;
CONFIGURE CHANNEL DEVICE TYPE SBT CLEAR;
CONFIGURE MAXSETSIZE CLEAR;
CONFIGURE SNAPSHOT CONTROLFILE NAME CLEAR;
##################################################################

CROSSCHECK BACKUP;
CROSSCHECK archivelog all;
CROSSCHECK COPY;
CROSSCHECK backup of database;
CROSSCHECK backup of controlfile;

########## RETENTION POLICY ###########################################

CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
DELETE NOPROMPT obsolete redundancy 2;

#CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 1 DAYS;
#DELETE NOPROMPT OBSOLETE RECOVERY WINDOW OF 1 DAYS;

#######################################################################
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u03/app/oradb/backups/rman/spod/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 '/u03/app/oradb/backups/rman/spod/%U';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u03/app/oradb/backups/rman/spod/snapcf_syslog.f'; # default

sql 'alter system switch logfile';
sql 'alter system archive log current';
backup database plus archivelog delete input;
sql 'alter system switch logfile';
sql 'alter system archive log current';

delete noprompt obsolete;
EOF
exit 0

$

5. Выполним резервное копирование промышленной СУБД (SPOD):

$ ./backupSPOD.sh

Recovery Manager: Release 11.2.0.2.0 - Production on Fri Sep 2 14:10:49 2011

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

connected to target database: SPOD (DBID=1675227431)
using target database control file instead of recovery catalog

RMAN>
RMAN> 2>
old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
RMAN configuration parameters are successfully reset to default value

RMAN>
old RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION OFF;
RMAN configuration parameters are successfully reset to default value

RMAN>
old RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
RMAN configuration parameters are successfully reset to default value

RMAN>
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
RMAN configuration parameters are successfully reset to default value

RMAN>
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u03/app/oradb/backups/rman/spod/cf_%F';
RMAN configuration parameters are successfully reset to default value

RMAN>
RMAN configuration parameters are successfully reset to default value

RMAN>
old RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
RMAN configuration parameters are successfully reset to default value

RMAN>
old RMAN configuration parameters:
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
RMAN configuration parameters are successfully reset to default value

RMAN>
RMAN configuration parameters are successfully reset to default value

RMAN>
old RMAN configuration parameters:
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
RMAN configuration parameters are successfully reset to default value

RMAN>
RMAN configuration parameters are successfully reset to default value

RMAN>
old RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u03/app/oradb/backups/rman/spod/%U';
old RMAN configuration parameters are successfully deleted

RMAN>
old RMAN configuration parameters are successfully deleted

RMAN>
old RMAN configuration parameters:
CONFIGURE MAXSETSIZE TO UNLIMITED;
RMAN configuration parameters are successfully reset to default value

RMAN>
old RMAN configuration parameters:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u03/app/oradb/backups/rman/spod/snapcf_syslog.f';
RMAN configuration parameters are successfully reset to default value

RMAN> 2> 3>
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=66 device type=DISK
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/app/oradb/backups/rman/spod/4cmlhkq1_1_1 RECID=75 STAMP=760795969
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/app/oradb/backups/rman/spod/4dmlhkr5_1_1 RECID=76 STAMP=760796005
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/app/oradb/backups/rman/spod/cf_c-1675227431-20110902-0d RECID=77 STAMP=760796006
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/app/oradb/backups/rman/spod/4fmlhkt5_1_1 RECID=78 STAMP=760796069
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/app/oradb/backups/rman/spod/4gmlhkt7_1_1 RECID=79 STAMP=760796071
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/app/oradb/backups/rman/spod/4hmlhkub_1_1 RECID=80 STAMP=760796107
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/app/oradb/backups/rman/spod/cf_c-1675227431-20110902-0e RECID=81 STAMP=760796108
Crosschecked 7 objects


RMAN>
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=66 device type=DISK
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_250_760029095.dbf RECID=321 STAMP=760796064
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_251_760029095.dbf RECID=323 STAMP=760796066
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_252_760029095.dbf RECID=326 STAMP=760796069
validation failed for archived log
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_253_760029095.dbf RECID=328 STAMP=760796106
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_254_760029095.dbf RECID=329 STAMP=760797826
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_254_760029095.dbf RECID=330 STAMP=760797826
Crosschecked 6 objects


RMAN>
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=66 device type=DISK
specification does not match any datafile copy in the repository
specification does not match any control file copy in the repository
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_250_760029095.dbf RECID=321 STAMP=760796064
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_251_760029095.dbf RECID=323 STAMP=760796066
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_252_760029095.dbf RECID=326 STAMP=760796069
validation failed for archived log
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_253_760029095.dbf RECID=328 STAMP=760796106
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_254_760029095.dbf RECID=329 STAMP=760797826
validation succeeded for archived log
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_254_760029095.dbf RECID=330 STAMP=760797826
Crosschecked 6 objects


RMAN>
using channel ORA_DISK_1
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/app/oradb/backups/rman/spod/4cmlhkq1_1_1 RECID=75 STAMP=760795969
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/app/oradb/backups/rman/spod/4gmlhkt7_1_1 RECID=79 STAMP=760796071
Crosschecked 2 objects


RMAN>
using channel ORA_DISK_1
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/app/oradb/backups/rman/spod/cf_c-1675227431-20110902-0d RECID=77 STAMP=760796006
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/app/oradb/backups/rman/spod/cf_c-1675227431-20110902-0e RECID=81 STAMP=760796108
Crosschecked 2 objects


RMAN>
RMAN> 2> 3>
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
new RMAN configuration parameters are successfully stored

RMAN>
using channel ORA_DISK_1
no obsolete backups found

RMAN>
RMAN> 2> 3> 4> 5>
new RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION OFF;
new RMAN configuration parameters are successfully stored

RMAN>
new RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
new RMAN configuration parameters are successfully stored
released channel: ORA_DISK_1

RMAN>
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

RMAN>
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u03/app/oradb/backups/rman/spod/cf_%F';
new RMAN configuration parameters are successfully stored

RMAN>
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
new RMAN configuration parameters are successfully stored

RMAN>
new RMAN configuration parameters:
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
new RMAN configuration parameters are successfully stored

RMAN>
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
new RMAN configuration parameters are successfully stored

RMAN>
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u03/app/oradb/backups/rman/spod/%U';
new RMAN configuration parameters are successfully stored

RMAN>
new RMAN configuration parameters:
CONFIGURE MAXSETSIZE TO UNLIMITED;
new RMAN configuration parameters are successfully stored

RMAN>
old RMAN configuration parameters:
CONFIGURE ENCRYPTION FOR DATABASE OFF;
new RMAN configuration parameters:
CONFIGURE ENCRYPTION FOR DATABASE OFF;
new RMAN configuration parameters are successfully stored

RMAN>
old RMAN configuration parameters:
CONFIGURE ENCRYPTION ALGORITHM 'AES128';
new RMAN configuration parameters:
CONFIGURE ENCRYPTION ALGORITHM 'AES128';
new RMAN configuration parameters are successfully stored

RMAN>
old RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
new RMAN configuration parameters are successfully stored

RMAN>
new RMAN configuration parameters:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u03/app/oradb/backups/rman/spod/snapcf_syslog.f';
new RMAN configuration parameters are successfully stored

RMAN>
RMAN>
sql statement: alter system switch logfile

RMAN>
sql statement: alter system archive log current

RMAN>
RMAN>

Starting backup at 02-SEP-11
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=66 device type=DISK
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=250 RECID=321 STAMP=760796064
input archived log thread=1 sequence=251 RECID=323 STAMP=760796066
input archived log thread=1 sequence=252 RECID=326 STAMP=760796069
input archived log thread=1 sequence=254 RECID=329 STAMP=760797826
input archived log thread=1 sequence=255 RECID=332 STAMP=760803059
input archived log thread=1 sequence=256 RECID=334 STAMP=760803059
input archived log thread=1 sequence=257 RECID=335 STAMP=760803061
channel ORA_DISK_1: starting piece 1 at 02-SEP-11
channel ORA_DISK_1: finished piece 1 at 02-SEP-11
piece handle=/u03/app/oradb/backups/rman/spod/4jmlhrnm_1_1 tag=TAG20110902T141101 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/oradb/archlogs/arch01/spod/1_250_760029095.dbf RECID=321 STAMP=760796064
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_251_760029095.dbf RECID=323 STAMP=760796066
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_252_760029095.dbf RECID=326 STAMP=760796069
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_254_760029095.dbf RECID=329 STAMP=760797826
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_255_760029095.dbf RECID=332 STAMP=760803059
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_256_760029095.dbf RECID=334 STAMP=760803059
archived log file name=/u01/app/oradb/archlogs/arch01/spod/1_257_760029095.dbf RECID=335 STAMP=760803061
Finished backup at 02-SEP-11

Starting backup at 02-SEP-11
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=/u03/app/oradb/oradata/spod/system/system01.dbf
input datafile file number=00003 name=/u03/app/oradb/oradata/spod/undotbs/undotbs01.dbf
input datafile file number=00002 name=/u03/app/oradb/oradata/spod/sysaux/sysaux01.dbf
input datafile file number=00004 name=/u03/app/oradb/oradata/spod/users/users01.dbf
channel ORA_DISK_1: starting piece 1 at 02-SEP-11
channel ORA_DISK_1: finished piece 1 at 02-SEP-11
piece handle=/u03/app/oradb/backups/rman/spod/4kmlhrnn_1_1 tag=TAG20110902T141103 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
Finished backup at 02-SEP-11

Starting backup at 02-SEP-11
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=258 RECID=337 STAMP=760803099
channel ORA_DISK_1: starting piece 1 at 02-SEP-11
channel ORA_DISK_1: finished piece 1 at 02-SEP-11
piece handle=/u03/app/oradb/backups/rman/spod/4lmlhror_1_1 tag=TAG20110902T141139 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/oradb/archlogs/arch01/spod/1_258_760029095.dbf RECID=337 STAMP=760803099
Finished backup at 02-SEP-11

Starting Control File and SPFILE Autobackup at 02-SEP-11
piece handle=/u03/app/oradb/backups/rman/spod/cf_c-1675227431-20110902-0f comment=NONE
Finished Control File and SPFILE Autobackup at 02-SEP-11

RMAN>
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 75 02-SEP-11
Backup Piece 75 02-SEP-11 /u03/app/oradb/backups/rman/spod/4cmlhkq1_1_1
Backup Set 76 02-SEP-11
Backup Piece 76 02-SEP-11 /u03/app/oradb/backups/rman/spod/4dmlhkr5_1_1
Backup Set 77 02-SEP-11
Backup Piece 77 02-SEP-11 /u03/app/oradb/backups/rman/spod/cf_c-1675227431-20110902-0d
Backup Set 78 02-SEP-11
Backup Piece 78 02-SEP-11 /u03/app/oradb/backups/rman/spod/4fmlhkt5_1_1
deleted backup piece
backup piece handle=/u03/app/oradb/backups/rman/spod/4cmlhkq1_1_1 RECID=75 STAMP=760795969
deleted backup piece
backup piece handle=/u03/app/oradb/backups/rman/spod/4dmlhkr5_1_1 RECID=76 STAMP=760796005
deleted backup piece
backup piece handle=/u03/app/oradb/backups/rman/spod/cf_c-1675227431-20110902-0d RECID=77 STAMP=760796006
deleted backup piece
backup piece handle=/u03/app/oradb/backups/rman/spod/4fmlhkt5_1_1 RECID=78 STAMP=760796069
Deleted 4 objects


RMAN>

Recovery Manager complete.
$

6. Подготовим скрипт makeSPODT2.sh для создания тестовой СУБД (SPODT2)

#!/bin/bash

# Create temporary password file, must have same password as primary
rm /u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/orapwspodt2
orapwd file=/u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/orapwspodt2 password=oracle

# Create temporary parameter file
echo "db_name=spodt2" > /u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/initspodt2.ora

export ORACLE_SID=spodt2
export ORACLE_HOME=/u01/app/oradb/product/11.2.0.2/dbhome_1

# Start up the auxiliary instance nomount
sqlplus '/ as sysdba' << EOF
shutdown immediate;
STARTUP PFILE='/u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/initspodt2.ora' NOMOUNT;
EOF

export ORACLE_SID=spod

rman << EOF
connect auxiliary sys/oracle@spodt2;
run {
duplicate target database to 'spodt2'
SPFILE
SET CONTROL_FILES '/u03/app/oradb/oradata/spodt2/control1/control01.ctl','/u03/app/oradb/oradata/spodt2/control2/control02.ctl'
SET CLUSTER_DATABASE 'false'
SET LOG_FILE_NAME_CONVERT '/u02/app/oradb/oradata/spod/','/u02/app/oradb/oradata/spodt2/'
SET DB_FILE_NAME_CONVERT '/u03/app/oradb/oradata/spod/','/u03/app/oradb/oradata/spodt2/'
BACKUP LOCATION '/u03/app/oradb/backups/rman/spod/'
;
}

EOF
exit 0

$

7. Выполним этот скрипт :

$ ./makeSPODT2.sh

SQL*Plus: Release 11.2.0.2.0 Production on Fri Sep 2 14:21:52 2011

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> ORACLE instance started.

Total System Global Area 217157632 bytes
Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Recovery Manager: Release 11.2.0.2.0 - Production on Fri Sep 2 14:22:15 2011

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

RMAN>
connected to auxiliary database: SPODT2 (not mounted)

RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10>
Starting Duplicate Db at 02-SEP-11

contents of Memory Script:
{
restore clone spfile to '/u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/spfilespodt2.ora' from
'/u03/app/oradb/backups/rman/spod/cf_c-1675227431-20110902-0f';
sql clone "alter system set spfile= ''/u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/spfilespodt2.ora''";
}
executing Memory Script

Starting restore at 02-SEP-11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=67 device type=DISK

channel ORA_AUX_DISK_1: restoring spfile from AUTOBACKUP /u03/app/oradb/backups/rman/spod/cf_c-1675227431-20110902-0f
channel ORA_AUX_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 02-SEP-11

sql statement: alter system set spfile= ''/u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/spfilespodt2.ora''

contents of Memory Script:
{
sql clone "alter system set db_name =
''SPODT2'' comment=
''duplicate'' scope=spfile";
sql clone "alter system set CONTROL_FILES =
''/u03/app/oradb/oradata/spodt2/control1/control01.ctl'', ''/u03/app/oradb/oradata/spodt2/control2/control02.ctl'' comment=
'''' scope=spfile";
sql clone "alter system set CLUSTER_DATABASE =
false comment=
'''' scope=spfile";
sql clone "alter system set LOG_FILE_NAME_CONVERT =
''/u02/app/oradb/oradata/spod/'', ''/u02/app/oradb/oradata/spodt2/'' comment=
'''' scope=spfile";
sql clone "alter system set db_file_name_convert =
''/u03/app/oradb/oradata/spod/'', ''/u03/app/oradb/oradata/spodt2/'' comment=
'''' scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script

sql statement: alter system set db_name = ''SPODT2'' comment= ''duplicate'' scope=spfile

sql statement: alter system set CONTROL_FILES = ''/u03/app/oradb/oradata/spodt2/control1/control01.ctl'', ''/u03/app/oradb/oradata/spodt2/control2/control02.ctl'' comment= '''' scope=spfile

sql statement: alter system set CLUSTER_DATABASE = false comment= '''' scope=spfile

sql statement: alter system set LOG_FILE_NAME_CONVERT = ''/u02/app/oradb/oradata/spod/'', ''/u02/app/oradb/oradata/spodt2/'' comment= '''' scope=spfile

sql statement: alter system set db_file_name_convert = ''/u03/app/oradb/oradata/spod/'', ''/u03/app/oradb/oradata/spodt2/'' comment= '''' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area 217157632 bytes

Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes

contents of Memory Script:
{
sql clone "alter system set db_name =
''SPOD'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''SPODT2'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone primary controlfile from '/u03/app/oradb/backups/rman/spod/cf_c-1675227431-20110902-0f';
alter clone database mount;
}
executing Memory Script

sql statement: alter system set db_name = ''SPOD'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system set db_unique_name = ''SPODT2'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area 217157632 bytes

Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes

Starting restore at 02-SEP-11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=156 device type=DISK

channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u03/app/oradb/oradata/spodt2/control1/control01.ctl
output file name=/u03/app/oradb/oradata/spodt2/control2/control02.ctl
Finished restore at 02-SEP-11

database mounted
released channel: ORA_AUX_DISK_1
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=156 device type=DISK

contents of Memory Script:
{
set until scn 2037511;
set newname for datafile 1 to
"/u03/app/oradb/oradata/spodt2/system/system01.dbf";
set newname for datafile 2 to
"/u03/app/oradb/oradata/spodt2/sysaux/sysaux01.dbf";
set newname for datafile 3 to
"/u03/app/oradb/oradata/spodt2/undotbs/undotbs01.dbf";
set newname for datafile 4 to
"/u03/app/oradb/oradata/spodt2/users/users01.dbf";
restore
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

Starting restore at 02-SEP-11
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u03/app/oradb/oradata/spodt2/system/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /u03/app/oradb/oradata/spodt2/sysaux/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u03/app/oradb/oradata/spodt2/undotbs/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u03/app/oradb/oradata/spodt2/users/users01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u03/app/oradb/backups/rman/spod/4kmlhrnn_1_1
channel ORA_AUX_DISK_1: piece handle=/u03/app/oradb/backups/rman/spod/4kmlhrnn_1_1 tag=TAG20110902T141103
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:15
Finished restore at 02-SEP-11

contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=6 STAMP=760803863 file name=/u03/app/oradb/oradata/spodt2/system/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=7 STAMP=760803864 file name=/u03/app/oradb/oradata/spodt2/sysaux/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=8 STAMP=760803864 file name=/u03/app/oradb/oradata/spodt2/undotbs/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=9 STAMP=760803864 file name=/u03/app/oradb/oradata/spodt2/users/users01.dbf

contents of Memory Script:
{
set until scn 2037511;
recover
clone database
delete archivelog
;
}
executing Memory Script

executing command: SET until clause

Starting recover at 02-SEP-11
using channel ORA_AUX_DISK_1

starting media recovery

channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=258
channel ORA_AUX_DISK_1: reading from backup piece /u03/app/oradb/backups/rman/spod/4lmlhror_1_1
channel ORA_AUX_DISK_1: piece handle=/u03/app/oradb/backups/rman/spod/4lmlhror_1_1 tag=TAG20110902T141139
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_258_760029095.dbf thread=1 sequence=258
channel clone_default: deleting archived log(s)
archived log file name=/u01/app/oradb/archlogs/arch02/spod/1_258_760029095.dbf RECID=1 STAMP=760803865
media recovery complete, elapsed time: 00:00:00
Finished recover at 02-SEP-11
Oracle instance started

Total System Global Area 217157632 bytes

Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes

contents of Memory Script:
{
sql clone "alter system set db_name =
''SPODT2'' 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 = ''SPODT2'' 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 217157632 bytes

Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "SPODT2" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u02/app/oradb/oradata/spodt2/redoa/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/u02/app/oradb/oradata/spodt2/redoa/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/u02/app/oradb/oradata/spodt2/redoa/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/u03/app/oradb/oradata/spodt2/system/system01.dbf'
CHARACTER SET CL8MSWIN1251


contents of Memory Script:
{
set newname for tempfile 1 to
"/u03/app/oradb/oradata/spodt2/temp/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u03/app/oradb/oradata/spodt2/sysaux/sysaux01.dbf",
"/u03/app/oradb/oradata/spodt2/undotbs/undotbs01.dbf",
"/u03/app/oradb/oradata/spodt2/users/users01.dbf";
switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u03/app/oradb/oradata/spodt2/temp/temp01.dbf in control file

cataloged datafile copy
datafile copy file name=/u03/app/oradb/oradata/spodt2/sysaux/sysaux01.dbf RECID=1 STAMP=760803905
cataloged datafile copy
datafile copy file name=/u03/app/oradb/oradata/spodt2/undotbs/undotbs01.dbf RECID=2 STAMP=760803905
cataloged datafile copy
datafile copy file name=/u03/app/oradb/oradata/spodt2/users/users01.dbf RECID=3 STAMP=760803905

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=760803905 file name=/u03/app/oradb/oradata/spodt2/sysaux/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=760803905 file name=/u03/app/oradb/oradata/spodt2/undotbs/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=760803905 file name=/u03/app/oradb/oradata/spodt2/users/users01.dbf

contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script

database opened
Finished Duplicate Db at 02-SEP-11

RMAN>
RMAN>

Recovery Manager complete.
$

8. Проверяем созданную базу данных (SPODT2)

$ ps -ef|grep pmon
oradb 8900 1 0 12:43 ? 00:00:01 ora_pmon_spod
oragrid 9167 1 0 12:43 ? 00:00:01 asm_pmon_+ASM
oradb 20306 1 0 14:25 ? 00:00:00 ora_pmon_spodt2
oradb 27736 1 0 Sep01 ? 00:00:14 ora_pmon_spodt1

$ export ORACLE_SID=spodt2
$ sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.2.0 Production on Thu Sep 1 12:32:10 2011

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u03/app/oradb/oradata/spodt2/system/system01.dbf
/u03/app/oradb/oradata/spodt2/sysaux/sysaux01.dbf
/u03/app/oradb/oradata/spodt2/undotbs/undotbs01.dbf
/u03/app/oradb/oradata/spodt2/users/users01.dbf

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
/u03/app/oradb/oradata/spodt2/temp/temp01.dbf

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u02/app/oradb/oradata/spodt2/redoa/redo03.log
/u02/app/oradb/oradata/spodt2/redoa/redo02.log
/u02/app/oradb/oradata/spodt2/redoa/redo01.log


SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
/u03/app/oradb/oradata/spodt2/control1/control01.ctl
/u03/app/oradb/oradata/spodt2/control2/control02.ctl

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
$

четверг, 1 сентября 2011 г.

Duplicate target database from active database

1. Исходная промышленная СУБД (SPOD)

$ export ORACLE_SID=spod
$ sqlplus "/as sysdba"


SQL*Plus: Release 11.2.0.2.0 Production on Thu Sep 1 11:34:02 2011

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u03/app/oradb/oradata/spod/system/system01.dbf
/u03/app/oradb/oradata/spod/sysaux/sysaux01.dbf
/u03/app/oradb/oradata/spod/undotbs/undotbs01.dbf
/u03/app/oradb/oradata/spod/users/users01.dbf

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
/u03/app/oradb/oradata/spod/temp/temp01.dbf

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u02/app/oradb/oradata/spod/redoa/redo01.log
/u02/app/oradb/oradata/spod/redoa/redo02.log
/u02/app/oradb/oradata/spod/redoa/redo03.log

SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
/u03/app/oradb/oradata/spod/control1/control01.ctl
/u03/app/oradb/oradata/spod/control2/control02.ctl

SQL> exit

$ strings spfilespod.ora
spod.__db_cache_size=1409286144
spod.__java_pool_size=16777216
spod.__large_pool_size=16777216
spod.__oracle_base='/u01/app'#ORACLE_BASE set from environment
spod.__pga_aggregate_target=1342177280
spod.__sga_target=2013265920
spod.__shared_io_pool_size=0
spod.__shared_pool_size=520093696
spod.__streams_pool_size=16777216
*.audit_file_dest='/u01/app/admin/spod/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u03/app/oradb/oradata/spod/control1/control01.ctl','/u03/app/oradb/oradata/spod/control2/control02.ctl'
*.db_block_size=8192
*.db_domain='oracle.sun.com'
*.db_name='spod'
*.db_recovery_file_dest='/u01/app/fast_recovery_area'
*.db_recovery_file_dest_size=5218762752
*.diagnostic_dest='/u01/app'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=spodXDB)'
*.log_archive_dest_1='LOCATION=/u01/app/oradb/archlogs/arch01/spod/'
*.log_archive_dest_2='LOCATION=/u01/app/oradb/archlogs/arch02/spod OPTIONAL'
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
$

2. Создаем структуру каталогов для тестовой базы данных (SPODT1)

mkdir -p /u03/app/oradb/oradata/spodt1/system
mkdir -p /u03/app/oradb/oradata/spodt1/sysaux
mkdir -p /u03/app/oradb/oradata/spodt1/undotbs
mkdir -p /u03/app/oradb/oradata/spodt1/users
mkdir -p /u03/app/oradb/oradata/spodt1/temp
mkdir -p /u02/app/oradb/oradata/spodt1/redoa
mkdir -p /u03/app/oradb/oradata/spodt1/control1
mkdir -p /u03/app/oradb/oradata/spodt1/control2

mkdir -p /u01/app/oradb/archlogs/arch01/spodt1
mkdir -p /u01/app/oradb/archlogs/arch02/spodt1


3. Внесем изменения в фалйы: listener.ora и tnsnames.ora

$ more /u01/app/11.2.0.2/grid/network/admin/listener.ora

# listener.ora Network Configuration File: /u01/app/11.2.0.2/grid/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = spodt1.oracle.sun.com)
(ORACLE_HOME = /u01/app/oradb/product/11.2.0.2/dbhome_1)
(SID_NAME = spodt1)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = kr400.oracle.sun.com)(PORT = 1521))
)
)

ADR_BASE_LISTENER = /u01/app/oragrid

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
$


$ more /u01/app/oradb/product/11.2.0.2/dbhome_1/network/admin/tnsnames.ora

# tnsnames.ora Network Configuration File: /u01/app/oradb/product/11.2.0.2/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

SPOD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = kr400.oracle.sun.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = spod.oracle.sun.com)
)
)

SPODT1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = kr400.oracle.sun.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = spodt1.oracle.sun.com)
)
)

$


4. Подготовим скрипт makeSPODT1.sh для создания тестовой СУБД (SPODT1)

#!/bin/bash

# Create temporary password file, must have same password as primary
rm /u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/orapwspodt1
orapwd file=/u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/orapwspodt1 password=oracle

# Create temporary parameter file
echo "db_name=spodt1" > /u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/initspodt1.ora

export ORACLE_SID=spodt1
export ORACLE_HOME=/u01/app/oradb/product/11.2.0.2/dbhome_1

# Start up the auxiliary instance nomount
sqlplus '/ as sysdba' << EOF
shutdown immediate;
STARTUP PFILE='/u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/initspodt1.ora' NOMOUNT;
EOF

export ORACLE_SID=spod

rman << EOF
connect target sys/oracle@spod; # Production
connect auxiliary sys/oracle@spodt1; # Пароль должен совпадать с Production

run {
allocate channel C1 type disk;
allocate auxiliary channel DUP type disk;
duplicate target database to SPODT1 from active database
spfile
set db_unique_name='SPODT1'
set db_file_name_convert='/u03/app/oradb/oradata/spod','/u03/app/oradb/oradata/spodt1'
set log_file_name_convert='/u02/app/oradb/oradata/spod','/u02/app/oradb/oradata/spodt1'
set control_files='/u03/app/oradb/oradata/spodt1/control1/control01.ctl','/u03/app/oradb/oradata/spodt1/control2/control02.ctl'
set log_archive_max_processes='5'
set log_archive_dest_1='LOCATION=/u01/app/oradb/archlogs/arch01/spodt1'
set log_archive_dest_2='LOCATION=/u01/app/oradb/archlogs/arch02/spodt1 OPTIONAL'
;
}
EOF
exit 0

5. Выполним этот скрипт :

$ ./makeSPODT1.sh

SQL*Plus: Release 11.2.0.2.0 Production on Thu Sep 1 12:16:08 2011

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> ORACLE instance started.

Total System Global Area 217157632 bytes
Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Recovery Manager: Release 11.2.0.2.0 - Production on Thu Sep 1 12:16:32 2011

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

RMAN>
connected to target database: SPOD (DBID=1675227431)

RMAN>
connected to auxiliary database: SPODT1 (not mounted)

RMAN>
RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14>
using target database control file instead of recovery catalog
allocated channel: C1
channel C1: SID=34 device type=DISK

allocated channel: DUP
channel DUP: SID=67 device type=DISK

Starting Duplicate Db at 01-SEP-11

contents of Memory Script:
{
backup as copy reuse
targetfile '/u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/spfilespod.ora' auxiliary format
'/u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/spfilespodt1.ora' ;
sql clone "alter system set spfile= ''/u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/spfilespodt1.ora''";
}
executing Memory Script

Starting backup at 01-SEP-11
Finished backup at 01-SEP-11

sql statement: alter system set spfile= ''/u01/app/oradb/product/11.2.0.2/dbhome_1/dbs/spfilespodt1.ora''

contents of Memory Script:
{
sql clone "alter system set db_name =
''SPODT1'' comment=
''duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''SPODT1'' comment=
'''' scope=spfile";
sql clone "alter system set db_file_name_convert =
''/u03/app/oradb/oradata/spod'', ''/u03/app/oradb/oradata/spodt1'' comment=
'''' scope=spfile";
sql clone "alter system set log_file_name_convert =
''/u02/app/oradb/oradata/spod'', ''/u02/app/oradb/oradata/spodt1'' comment=
'''' scope=spfile";
sql clone "alter system set control_files =
''/u03/app/oradb/oradata/spodt1/control1/control01.ctl'', ''/u03/app/oradb/oradata/spodt1/control2/control02.ctl'' comment=
'''' scope=spfile";
sql clone "alter system set log_archive_max_processes =
5 comment=
'''' scope=spfile";
sql clone "alter system set log_archive_dest_1 =
''LOCATION=/u01/app/oradb/archlogs/arch01/spodt1'' comment=
'''' scope=spfile";
sql clone "alter system set log_archive_dest_2 =
''LOCATION=/u01/app/oradb/archlogs/arch02/spodt1 OPTIONAL'' comment=
'''' scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script

sql statement: alter system set db_name = ''SPODT1'' comment= ''duplicate'' scope=spfile

sql statement: alter system set db_unique_name = ''SPODT1'' comment= '''' scope=spfile

sql statement: alter system set db_file_name_convert = ''/u03/app/oradb/oradata/spod'', ''/u03/app/oradb/oradata/spodt1'' comment= '''' scope=spfile

sql statement: alter system set log_file_name_convert = ''/u02/app/oradb/oradata/spod'', ''/u02/app/oradb/oradata/spodt1'' comment= '''' scope=spfile

sql statement: alter system set control_files = ''/u03/app/oradb/oradata/spodt1/control1/control01.ctl'', ''/u03/app/oradb/oradata/spodt1/control2/control02.ctl'' comment= '''' scope=spfile

sql statement: alter system set log_archive_max_processes = 5 comment= '''' scope=spfile

sql statement: alter system set log_archive_dest_1 = ''LOCATION=/u01/app/oradb/archlogs/arch01/spodt1'' comment= '''' scope=spfile

sql statement: alter system set log_archive_dest_2 = ''LOCATION=/u01/app/oradb/archlogs/arch02/spodt1 OPTIONAL'' comment= '''' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area 217157632 bytes

Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes
allocated channel: DUP
channel DUP: SID=156 device type=DISK

contents of Memory Script:
{
sql clone "alter system set db_name =
''SPOD'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''SPODT1'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
backup as copy current controlfile auxiliary format '/u03/app/oradb/oradata/spodt1/control1/control01.ctl';
restore clone controlfile to '/u03/app/oradb/oradata/spodt1/control2/control02.ctl' from
'/u03/app/oradb/oradata/spodt1/control1/control01.ctl';
alter clone database mount;
}
executing Memory Script

sql statement: alter system set db_name = ''SPOD'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system set db_unique_name = ''SPODT1'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area 217157632 bytes

Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes
allocated channel: DUP
channel DUP: SID=156 device type=DISK

Starting backup at 01-SEP-11
channel C1: starting datafile copy
copying current control file
output file name=/u03/app/oradb/backups/rman/spod/snapcf_syslog.f tag=TAG20110901T121720 RECID=35 STAMP=760709841
channel C1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 01-SEP-11

Starting restore at 01-SEP-11

channel DUP: copied control file copy
Finished restore at 01-SEP-11

database mounted

contents of Memory Script:
{
set newname for datafile 1 to
"/u03/app/oradb/oradata/spodt1/system/system01.dbf";
set newname for datafile 2 to
"/u03/app/oradb/oradata/spodt1/sysaux/sysaux01.dbf";
set newname for datafile 3 to
"/u03/app/oradb/oradata/spodt1/undotbs/undotbs01.dbf";
set newname for datafile 4 to
"/u03/app/oradb/oradata/spodt1/users/users01.dbf";
backup as copy reuse
datafile 1 auxiliary format
"/u03/app/oradb/oradata/spodt1/system/system01.dbf" datafile
2 auxiliary format
"/u03/app/oradb/oradata/spodt1/sysaux/sysaux01.dbf" datafile
3 auxiliary format
"/u03/app/oradb/oradata/spodt1/undotbs/undotbs01.dbf" datafile
4 auxiliary format
"/u03/app/oradb/oradata/spodt1/users/users01.dbf" ;
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

Starting backup at 01-SEP-11
channel C1: starting datafile copy
input datafile file number=00001 name=/u03/app/oradb/oradata/spod/system/system01.dbf
output file name=/u03/app/oradb/oradata/spodt1/system/system01.dbf tag=TAG20110901T121727
channel C1: datafile copy complete, elapsed time: 00:00:25
channel C1: starting datafile copy
input datafile file number=00003 name=/u03/app/oradb/oradata/spod/undotbs/undotbs01.dbf
output file name=/u03/app/oradb/oradata/spodt1/undotbs/undotbs01.dbf tag=TAG20110901T121727
channel C1: datafile copy complete, elapsed time: 00:00:25
channel C1: starting datafile copy
input datafile file number=00002 name=/u03/app/oradb/oradata/spod/sysaux/sysaux01.dbf
output file name=/u03/app/oradb/oradata/spodt1/sysaux/sysaux01.dbf tag=TAG20110901T121727
channel C1: datafile copy complete, elapsed time: 00:00:25
channel C1: starting datafile copy
input datafile file number=00004 name=/u03/app/oradb/oradata/spod/users/users01.dbf
output file name=/u03/app/oradb/oradata/spodt1/users/users01.dbf tag=TAG20110901T121727
channel C1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 01-SEP-11

sql statement: alter system archive log current

contents of Memory Script:
{
backup as copy reuse
archivelog like "/u01/app/oradb/archlogs/arch01/spod/1_183_760029095.dbf" auxiliary format
"/u01/app/oradb/archlogs/arch02/spodt1/1_183_760029095.dbf" archivelog like
"/u01/app/oradb/archlogs/arch02/spod/1_183_760029095.dbf" auxiliary format
"/u01/app/oradb/archlogs/arch02/spodt1/1_183_760029095.dbf" ;
catalog clone archivelog "/u01/app/oradb/archlogs/arch02/spodt1/1_183_760029095.dbf";
catalog clone archivelog "/u01/app/oradb/archlogs/arch02/spodt1/1_183_760029095.dbf";
switch clone datafile all;
}
executing Memory Script

Starting backup at 01-SEP-11
channel C1: starting archived log copy
input archived log thread=1 sequence=183 RECID=187 STAMP=760709925
output file name=/u01/app/oradb/archlogs/arch02/spodt1/1_183_760029095.dbf RECID=0 STAMP=0
channel C1: archived log copy complete, elapsed time: 00:00:01
channel C1: starting archived log copy
input archived log thread=1 sequence=183 RECID=188 STAMP=760709925
output file name=/u01/app/oradb/archlogs/arch02/spodt1/1_183_760029095.dbf RECID=0 STAMP=0
channel C1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 01-SEP-11

cataloged archived log
archived log file name=/u01/app/oradb/archlogs/arch02/spodt1/1_183_760029095.dbf RECID=187 STAMP=760709927

cataloged archived log
archived log file name=/u01/app/oradb/archlogs/arch02/spodt1/1_183_760029095.dbf RECID=188 STAMP=760709928

datafile 1 switched to datafile copy
input datafile copy RECID=35 STAMP=760709928 file name=/u03/app/oradb/oradata/spodt1/system/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=36 STAMP=760709928 file name=/u03/app/oradb/oradata/spodt1/sysaux/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=37 STAMP=760709928 file name=/u03/app/oradb/oradata/spodt1/undotbs/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=38 STAMP=760709928 file name=/u03/app/oradb/oradata/spodt1/users/users01.dbf

contents of Memory Script:
{
set until scn 1868129;
recover
clone database
delete archivelog
;
}
executing Memory Script

executing command: SET until clause

Starting recover at 01-SEP-11

starting media recovery

archived log for thread 1 with sequence 183 is already on disk as file /u01/app/oradb/archlogs/arch02/spodt1/1_183_760029095.dbf
archived log file name=/u01/app/oradb/archlogs/arch02/spodt1/1_183_760029095.dbf thread=1 sequence=183
media recovery complete, elapsed time: 00:00:01
Finished recover at 01-SEP-11
Oracle instance started

Total System Global Area 217157632 bytes

Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes

contents of Memory Script:
{
sql clone "alter system set db_name =
''SPODT1'' 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 = ''SPODT1'' 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 217157632 bytes

Fixed Size 2225064 bytes
Variable Size 159386712 bytes
Database Buffers 50331648 bytes
Redo Buffers 5214208 bytes
allocated channel: DUP
channel DUP: SID=156 device type=DISK
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "SPODT1" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u02/app/oradb/oradata/spodt1/redoa/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/u02/app/oradb/oradata/spodt1/redoa/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/u02/app/oradb/oradata/spodt1/redoa/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/u03/app/oradb/oradata/spodt1/system/system01.dbf'
CHARACTER SET CL8MSWIN1251


contents of Memory Script:
{
set newname for tempfile 1 to
"/u03/app/oradb/oradata/spodt1/temp/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u03/app/oradb/oradata/spodt1/sysaux/sysaux01.dbf",
"/u03/app/oradb/oradata/spodt1/undotbs/undotbs01.dbf",
"/u03/app/oradb/oradata/spodt1/users/users01.dbf";
switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u03/app/oradb/oradata/spodt1/temp/temp01.dbf in control file

cataloged datafile copy
datafile copy file name=/u03/app/oradb/oradata/spodt1/sysaux/sysaux01.dbf RECID=1 STAMP=760709969
cataloged datafile copy
datafile copy file name=/u03/app/oradb/oradata/spodt1/undotbs/undotbs01.dbf RECID=2 STAMP=760709969
cataloged datafile copy
datafile copy file name=/u03/app/oradb/oradata/spodt1/users/users01.dbf RECID=3 STAMP=760709969

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=760709969 file name=/u03/app/oradb/oradata/spodt1/sysaux/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=760709969 file name=/u03/app/oradb/oradata/spodt1/undotbs/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=760709969 file name=/u03/app/oradb/oradata/spodt1/users/users01.dbf

contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script

database opened
Finished Duplicate Db at 01-SEP-11
released channel: C1
released channel: DUP

RMAN>

Recovery Manager complete.
$

6. Проверяем созданную базу данных (SPODT1)

$ ps -ef|grep pmon
oradb 4747 1 0 12:19 ? 00:00:00 ora_pmon_spodt1
oradb 5705 26526 0 12:29 pts/2 00:00:00 grep pmon
oragrid 14172 1 0 Aug31 ? 00:00:11 asm_pmon_+ASM
oradb 15172 1 0 Aug31 ? 00:00:12 ora_pmon_spod
$

$ export ORACLE_SID=spodt1
$ sqlplus "/as sysdba"


SQL*Plus: Release 11.2.0.2.0 Production on Thu Sep 1 12:32:10 2011

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u03/app/oradb/oradata/spodt1/system/system01.dbf
/u03/app/oradb/oradata/spodt1/sysaux/sysaux01.dbf
/u03/app/oradb/oradata/spodt1/undotbs/undotbs01.dbf
/u03/app/oradb/oradata/spodt1/users/users01.dbf

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
/u03/app/oradb/oradata/spodt1/temp/temp01.dbf

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u02/app/oradb/oradata/spodt1/redoa/redo03.log
/u02/app/oradb/oradata/spodt1/redoa/redo02.log
/u02/app/oradb/oradata/spodt1/redoa/redo01.log


SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
/u03/app/oradb/oradata/spodt1/control1/control01.ctl
/u03/app/oradb/oradata/spodt1/control2/control02.ctl

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
$