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
$
Подписаться на:
Комментарии к сообщению (Atom)
Комментариев нет:
Отправить комментарий