使用RMAN-duplicate创建standby
1. 试验环境
[oracle@test orcl]$ sqlplus "/as sysdba"
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for Linux: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
主库主机:test
主库实例:ttt
该主库已经配置了一个物理备用库:sss
本次新搭建物理备库:
备库主机:oms
备库实例:s2
2.确认主库处于归档模式
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/archive/ttt/
Oldest online log sequence 80
Next log sequence to archive 82
Current log sequence 82
SQL> select force_logging from v$database;
FOR
---
YES
3:创建备库instance
unix/linux平台设置新的ORACLE_SID即可,
4:准备好备库的参数文件
主库几个主要参数如下:
*.compatible='10.2.0'
*.control_files='/u01/app/oracle/oradata/ttt/control.001.dbf','/u01/app/oracle/oradata/ttt/control.002.dbf','/u01/app/oracle/oradata/ttt/control.003.dbf'
*.db_block_size=8192
*.db_domain='oracle.com'
*.db_name='ttt'
*.db_recovery_file_dest_size=21474836480
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.fal_client='TTT'
*.fal_server='SSS'
*.log_archive_config='DG_CONFIG=(ttt,sss,s2)'
*.log_archive_dest_1='LOCATION=/u01/app/oracle/archive/ttt
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=ttt'
*.log_archive_dest_2='service=sss lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=sss'
*.log_archive_dest_state_2='ENABLE'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=1024
*.pga_aggregate_target=250M
*.processes=100
*.sessions=120
*.sga_target=300M
*.shared_servers=3
*.standby_file_management='AUTO'
*.undo_management='AUTO'
*.undo_tablespace='undo_tbs'
*.utl_file_dir='/tmp/dict'
备库主要的几个参数如下:
*.compatible='10.2.0'
*.control_files='/u01/app/oracle/oradata/s2/control.001.dbf','/u01/app/oracle/oradata/s2/control.002.dbf','/u01/app/oracle/oradata/s2/control.003.dbf'
*.db_block_size=8192
*.db_domain='oracle.com'
*.db_name='ttt'
*.db_unique_name='s2'
*.db_recovery_file_dest_size=21474836480
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.fal_client='S2'
*.fal_server='TTT'
*.log_archive_config='DG_CONFIG=(ttt,sss,s2)'
*.log_archive_dest_1='LOCATION=/u01/app/oracle/archive/s2
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=s2'
*.log_archive_dest_2='service=ttt lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=ttt'
*.log_archive_dest_state_2='ENABLE'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=1024
*.pga_aggregate_target=250M
*.processes=100
*.sessions=120
*.sga_target=300M
*.shared_servers=3
*.standby_file_management='AUTO'
*.undo_management='AUTO'
*.undo_tablespace='undo_tbs'
*.utl_file_dir='/tmp/dict'
*.db_file_name_convert='ttt','s2'
*.log_file_name_convert='ttt','s2'
需要修改的参数为:
control_files
db_unique_name--->在主库通过create pfile from spfile中不包含该参数。
fal_client
fal_server
log_archive_dest_1
log_archive_dest_2
db_file_name_convert
log_file_name_convert
5.在备库生成password file
[oracle@mh]$orapwd file=orapws2 password=oracle entries=10
或者可以直接复制主库密码文件到备库相应的位置也可。
6.配置网络
配置主备库的listener.ora,tnsnames.ora。修改完lisner.ora后注意重启监听。
主库Listener.ora
TTT=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=test.localdomain)(PORT=1521))
))
SID_LIST_TTT=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=ttt.oracle.com)
(ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
(SID_NAME=ttt))
)
lsnrctl start ttt
备库Listener.ora
S2=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=oms.localdomain)(PORT=1521))
))
SID_LIST_SSS=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=s2.oracle.com)
(ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
(SID_NAME=s2))
)
lsnrctl start s2
tnsnames.ora(主备库配置一样)
TTT =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = tcp)(HOST = test.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ttt.oracle.com)
)
)
S2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = tcp)(HOST = oms.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = s2.oracle.com)
)
)
7.利用rman备份主库
注意同时备库控制文件
[oracle@test admin]$ rman target /
Recovery Manager: Release 10.2.0.3.0 - Production on Wed May 29 18:50:09 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: TTT (DBID=1768998978)
RMAN> backup full format='/tmp/back4s2/%U' database
include current controlfile for standby
plus archivelog format='/tmp/back4s2/arch%U';
Starting backup at 29-MAY-13
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=102 devtype=DISK
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=6 recid=1 stamp=815521987
input archive log thread=1 sequence=7 recid=2 stamp=815521988
...
input archive log thread=1 sequence=53 recid=91 stamp=816122817
channel ORA_DISK_1: starting piece 1 at 29-MAY-13
channel ORA_DISK_1: finished piece 1 at 29-MAY-13
piece handle=/tmp/back4s2/arch0loasbmo_1_1 tag=TAG20130529T190703 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:08
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=1 recid=93 stamp=816122898
...
input archive log thread=1 sequence=12 recid=106 stamp=816721622
channel ORA_DISK_1: starting piece 1 at 29-MAY-13
channel ORA_DISK_1: finished piece 1 at 29-MAY-13
piece handle=/tmp/back4s2/arch0moasbn0_1_1 tag=TAG20130529T190703 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 29-MAY-13
Starting backup at 29-MAY-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/ttt/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/ttt/sysaux01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/ttt/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/ttt/a_tbs01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/ttt/b_tbs01.dbf
channel ORA_DISK_1: starting piece 1 at 29-MAY-13
channel ORA_DISK_1: finished piece 1 at 29-MAY-13
piece handle=/tmp/back4s2/0noasbn2_1_1 tag=TAG20130529T190714 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including standby control file in backupset
channel ORA_DISK_1: starting piece 1 at 29-MAY-13
channel ORA_DISK_1: finished piece 1 at 29-MAY-13
piece handle=/tmp/back4s2/0ooasbo6_1_1 tag=TAG20130529T190714 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 29-MAY-13
Starting backup at 29-MAY-13
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=13 recid=107 stamp=816721672
channel ORA_DISK_1: starting piece 1 at 29-MAY-13
channel ORA_DISK_1: finished piece 1 at 29-MAY-13
piece handle=/tmp/back4s2/arch0poasbo8_1_1 tag=TAG20130529T190752 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 29-MAY-13
Starting Control File and SPFILE Autobackup at 29-MAY-13
piece handle=/u01/app/oracle/flash_recovery_area/TTT/autobackup/2013_05_29/o1_mf_s_816721674_8tcrdd0q_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 29-MAY-13
RMAN>
8:复制 rman全备份到备库
利用操作系统命令scp把备份文件也放到备库同样的位置:
scp * oms:/tmp/back4s2
9.启动备库到nomount
SQL> startup nomount
ORACLE instance started.
Total System Global Area 135338868 bytes
Fixed Size 453492 bytes
Variable Size 109051904 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
10.在目标主机上利用rman恢复备库
[oracle@oms archive]$ rman target sys/oracle@ttt auxiliary /
Recovery Manager: Release 10.2.0.3.0 - Production on Wed May 29 19:16:24 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: TTT (DBID=1768998978)
connected to auxiliary database: TTT (not mounted)
RMAN> duplicate target database for standby dorecover;
Starting Duplicate Db at 29-MAY-13
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=106 devtype=DISK
contents of Memory Script.:
{
set until scn 240313;
restore clone standby controlfile;
sql clone 'alter database mount standby database';
}
executing Memory Script
executing command: SET until clause
Starting restore at 29-MAY-13
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /tmp/back4s2/0ooasbo6_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/tmp/back4s2/0ooasbo6_1_1 tag=TAG20130529T190714
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
output filename=/u01/app/oracle/oradata/s2/control.001.dbf
output filename=/u01/app/oracle/oradata/s2/control.002.dbf
output filename=/u01/app/oracle/oradata/s2/control.003.dbf
Finished restore at 29-MAY-13
sql statement: alter database mount standby database
released channel: ORA_AUX_DISK_1
contents of Memory Script.:
{
set until scn 240313;
set newname for tempfile 1 to
"/u01/app/oracle/oradata/s2/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/u01/app/oracle/oradata/s2/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/s2/undotbs01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/s2/sysaux01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/s2/a_tbs01.dbf";
set newname for datafile 5 to
"/u01/app/oracle/oradata/s2/b_tbs01.dbf";
restore
check readonly
clone database
;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
renamed temporary file 1 to /u01/app/oracle/oradata/s2/temp01.dbf in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 29-MAY-13
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=106 devtype=DISK
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/s2/system01.dbf
restoring datafile 00002 to /u01/app/oracle/oradata/s2/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/s2/sysaux01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/s2/a_tbs01.dbf
restoring datafile 00005 to /u01/app/oracle/oradata/s2/b_tbs01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /tmp/back4s2/0noasbn2_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/tmp/back4s2/0noasbn2_1_1 tag=TAG20130529T190714
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:02:07
Finished restore at 29-MAY-13
contents of Memory Script.:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy recid=9 stamp=816722424 filename=/u01/app/oracle/oradata/s2/system01.dbf
datafile 2 switched to datafile copy
input datafile copy recid=10 stamp=816722424 filename=/u01/app/oracle/oradata/s2/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=11 stamp=816722424 filename=/u01/app/oracle/oradata/s2/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=12 stamp=816722424 filename=/u01/app/oracle/oradata/s2/a_tbs01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=13 stamp=816722424 filename=/u01/app/oracle/oradata/s2/b_tbs01.dbf
contents of Memory Script.:
{
set until scn 240313;
recover
standby
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 29-MAY-13
using channel ORA_AUX_DISK_1
starting media recovery
channel ORA_AUX_DISK_1: starting archive log restore to default destination
channel ORA_AUX_DISK_1: restoring archive log
archive log thread=1 sequence=13
channel ORA_AUX_DISK_1: reading from backup piece /tmp/back4s2/arch0poasbo8_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/tmp/back4s2/arch0poasbo8_1_1 tag=TAG20130529T190752
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archive log filename=/u01/app/oracle/archive/s2/1_13_816121808.dbf thread=1 sequence=13
channel clone_default: deleting archive log(s)
archive log filename=/u01/app/oracle/archive/s2/1_13_816121808.dbf recid=1 stamp=816722426
media recovery complete, elapsed time: 00:00:02
Finished recover at 29-MAY-13
Finished Duplicate Db at 29-MAY-13
RMAN> exit
Recovery Manager complete.
11.将备库置于自动恢复状态
SQL> select status from v$instance
STATUS
------------
MOUNTED
SQL> select sequence#,applied from v$archived_log
SEQUENCE# APP
---------- ---
13 NO
1 NO
2 NO
3 NO
4 NO
5 NO
6 NO
7 NO
8 NO
9 NO
10 NO
SEQUENCE# APP
---------- ---
11 NO
12 NO
13 NO
14 NO
15 NO
16 rows selected.
SQL> recover managed standby database disconnect;
Media recovery complete.
12.在主库上执行检查
SQL> conn /as sysdba
Connected.
SQL> alter system archive log current;
System altered.
SQL> create table mh.t4s2 as select * from dba_users;
Table created.
SQL> select dest_id,status,error from v$archive_dest_status
DEST_ID STATUS ERROR
---------- --------- ------------------------------
1 VALID
2 ERROR ORA-01034: ORACLE not available --以前配置的物理standby
3 VALID --本次配置的standby
SQL> select * from v$archive_gap;
no rows selected
SQL> select process,status from v$managed_standby;
PROCESS STATUS
--------- ------------
ARCH CLOSING
ARCH CLOSING
LNS WRITING
13.在备库上执行检查
SQL> conn / as sysdba
Connected.
SQL> select * from v$archive_gap;
no rows selected
SQL> recover managed standby database disconnect;
Media recovery complete.
SQL> select sequence#,applied from v$archived_log
2 ;
SEQUENCE# APP
---------- ---
13 NO
1 NO
2 NO
3 NO
4 NO
5 NO
6 NO
7 NO
8 NO
9 NO
10 NO
11 NO
12 NO
13 YES
14 YES
15 YES
16 YES
17 rows selected.
SQL> select process,status from v$managed_standby;
PROCESS STATUS
------------------ ------------------------
ARCH CONNECTED
ARCH CONNECTED
RFS IDLE
MRP0 WAIT_FOR_LOG
SQL> recover managed standby database cancel;
Media recovery complete.
SQL> alter database open read only;
Database altered.
SQL> select count(*) from mh.t4s2;
COUNT(*)
----------
7
SQL> select process,status from v$managed_standby;
PROCESS STATUS
--------- ------------
ARCH CONNECTED
ARCH CONNECTED
RFS IDLE
RFS IDLE
SQL> recover managed standby database disconnect;
Media recovery complete.
SQL> select process,status from v$managed_standby;
PROCESS STATUS
--------- ------------
ARCH CONNECTED
ARCH CONNECTED
RFS IDLE
MRP0 WAIT_FOR_LOG
RFS IDLE
1. 试验环境
[oracle@test orcl]$ sqlplus "/as sysdba"
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for Linux: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
主库主机:test
主库实例:ttt
该主库已经配置了一个物理备用库:sss
本次新搭建物理备库:
备库主机:oms
备库实例:s2
2.确认主库处于归档模式
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/archive/ttt/
Oldest online log sequence 80
Next log sequence to archive 82
Current log sequence 82
SQL> select force_logging from v$database;
FOR
---
YES
3:创建备库instance
unix/linux平台设置新的ORACLE_SID即可,
4:准备好备库的参数文件
主库几个主要参数如下:
*.compatible='10.2.0'
*.control_files='/u01/app/oracle/oradata/ttt/control.001.dbf','/u01/app/oracle/oradata/ttt/control.002.dbf','/u01/app/oracle/oradata/ttt/control.003.dbf'
*.db_block_size=8192
*.db_domain='oracle.com'
*.db_name='ttt'
*.db_recovery_file_dest_size=21474836480
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.fal_client='TTT'
*.fal_server='SSS'
*.log_archive_config='DG_CONFIG=(ttt,sss,s2)'
*.log_archive_dest_1='LOCATION=/u01/app/oracle/archive/ttt
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=ttt'
*.log_archive_dest_2='service=sss lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=sss'
*.log_archive_dest_state_2='ENABLE'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=1024
*.pga_aggregate_target=250M
*.processes=100
*.sessions=120
*.sga_target=300M
*.shared_servers=3
*.standby_file_management='AUTO'
*.undo_management='AUTO'
*.undo_tablespace='undo_tbs'
*.utl_file_dir='/tmp/dict'
备库主要的几个参数如下:
*.compatible='10.2.0'
*.control_files='/u01/app/oracle/oradata/s2/control.001.dbf','/u01/app/oracle/oradata/s2/control.002.dbf','/u01/app/oracle/oradata/s2/control.003.dbf'
*.db_block_size=8192
*.db_domain='oracle.com'
*.db_name='ttt'
*.db_unique_name='s2'
*.db_recovery_file_dest_size=21474836480
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.fal_client='S2'
*.fal_server='TTT'
*.log_archive_config='DG_CONFIG=(ttt,sss,s2)'
*.log_archive_dest_1='LOCATION=/u01/app/oracle/archive/s2
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=s2'
*.log_archive_dest_2='service=ttt lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=ttt'
*.log_archive_dest_state_2='ENABLE'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=1024
*.pga_aggregate_target=250M
*.processes=100
*.sessions=120
*.sga_target=300M
*.shared_servers=3
*.standby_file_management='AUTO'
*.undo_management='AUTO'
*.undo_tablespace='undo_tbs'
*.utl_file_dir='/tmp/dict'
*.db_file_name_convert='ttt','s2'
*.log_file_name_convert='ttt','s2'
需要修改的参数为:
control_files
db_unique_name--->在主库通过create pfile from spfile中不包含该参数。
fal_client
fal_server
log_archive_dest_1
log_archive_dest_2
db_file_name_convert
log_file_name_convert
5.在备库生成password file
[oracle@mh]$orapwd file=orapws2 password=oracle entries=10
或者可以直接复制主库密码文件到备库相应的位置也可。
6.配置网络
配置主备库的listener.ora,tnsnames.ora。修改完lisner.ora后注意重启监听。
主库Listener.ora
TTT=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=test.localdomain)(PORT=1521))
))
SID_LIST_TTT=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=ttt.oracle.com)
(ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
(SID_NAME=ttt))
)
lsnrctl start ttt
备库Listener.ora
S2=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=oms.localdomain)(PORT=1521))
))
SID_LIST_SSS=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=s2.oracle.com)
(ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
(SID_NAME=s2))
)
lsnrctl start s2
tnsnames.ora(主备库配置一样)
TTT =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = tcp)(HOST = test.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ttt.oracle.com)
)
)
S2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = tcp)(HOST = oms.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = s2.oracle.com)
)
)
7.利用rman备份主库
注意同时备库控制文件
[oracle@test admin]$ rman target /
Recovery Manager: Release 10.2.0.3.0 - Production on Wed May 29 18:50:09 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: TTT (DBID=1768998978)
RMAN> backup full format='/tmp/back4s2/%U' database
include current controlfile for standby
plus archivelog format='/tmp/back4s2/arch%U';
Starting backup at 29-MAY-13
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=102 devtype=DISK
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=6 recid=1 stamp=815521987
input archive log thread=1 sequence=7 recid=2 stamp=815521988
...
input archive log thread=1 sequence=53 recid=91 stamp=816122817
channel ORA_DISK_1: starting piece 1 at 29-MAY-13
channel ORA_DISK_1: finished piece 1 at 29-MAY-13
piece handle=/tmp/back4s2/arch0loasbmo_1_1 tag=TAG20130529T190703 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:08
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=1 recid=93 stamp=816122898
...
input archive log thread=1 sequence=12 recid=106 stamp=816721622
channel ORA_DISK_1: starting piece 1 at 29-MAY-13
channel ORA_DISK_1: finished piece 1 at 29-MAY-13
piece handle=/tmp/back4s2/arch0moasbn0_1_1 tag=TAG20130529T190703 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 29-MAY-13
Starting backup at 29-MAY-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/ttt/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/ttt/sysaux01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/ttt/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/ttt/a_tbs01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/ttt/b_tbs01.dbf
channel ORA_DISK_1: starting piece 1 at 29-MAY-13
channel ORA_DISK_1: finished piece 1 at 29-MAY-13
piece handle=/tmp/back4s2/0noasbn2_1_1 tag=TAG20130529T190714 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including standby control file in backupset
channel ORA_DISK_1: starting piece 1 at 29-MAY-13
channel ORA_DISK_1: finished piece 1 at 29-MAY-13
piece handle=/tmp/back4s2/0ooasbo6_1_1 tag=TAG20130529T190714 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 29-MAY-13
Starting backup at 29-MAY-13
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=13 recid=107 stamp=816721672
channel ORA_DISK_1: starting piece 1 at 29-MAY-13
channel ORA_DISK_1: finished piece 1 at 29-MAY-13
piece handle=/tmp/back4s2/arch0poasbo8_1_1 tag=TAG20130529T190752 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 29-MAY-13
Starting Control File and SPFILE Autobackup at 29-MAY-13
piece handle=/u01/app/oracle/flash_recovery_area/TTT/autobackup/2013_05_29/o1_mf_s_816721674_8tcrdd0q_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 29-MAY-13
RMAN>
8:复制 rman全备份到备库
利用操作系统命令scp把备份文件也放到备库同样的位置:
scp * oms:/tmp/back4s2
9.启动备库到nomount
SQL> startup nomount
ORACLE instance started.
Total System Global Area 135338868 bytes
Fixed Size 453492 bytes
Variable Size 109051904 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
10.在目标主机上利用rman恢复备库
[oracle@oms archive]$ rman target sys/oracle@ttt auxiliary /
Recovery Manager: Release 10.2.0.3.0 - Production on Wed May 29 19:16:24 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: TTT (DBID=1768998978)
connected to auxiliary database: TTT (not mounted)
RMAN> duplicate target database for standby dorecover;
Starting Duplicate Db at 29-MAY-13
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=106 devtype=DISK
contents of Memory Script.:
{
set until scn 240313;
restore clone standby controlfile;
sql clone 'alter database mount standby database';
}
executing Memory Script
executing command: SET until clause
Starting restore at 29-MAY-13
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /tmp/back4s2/0ooasbo6_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/tmp/back4s2/0ooasbo6_1_1 tag=TAG20130529T190714
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
output filename=/u01/app/oracle/oradata/s2/control.001.dbf
output filename=/u01/app/oracle/oradata/s2/control.002.dbf
output filename=/u01/app/oracle/oradata/s2/control.003.dbf
Finished restore at 29-MAY-13
sql statement: alter database mount standby database
released channel: ORA_AUX_DISK_1
contents of Memory Script.:
{
set until scn 240313;
set newname for tempfile 1 to
"/u01/app/oracle/oradata/s2/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/u01/app/oracle/oradata/s2/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/s2/undotbs01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/s2/sysaux01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/s2/a_tbs01.dbf";
set newname for datafile 5 to
"/u01/app/oracle/oradata/s2/b_tbs01.dbf";
restore
check readonly
clone database
;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
renamed temporary file 1 to /u01/app/oracle/oradata/s2/temp01.dbf in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 29-MAY-13
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=106 devtype=DISK
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/s2/system01.dbf
restoring datafile 00002 to /u01/app/oracle/oradata/s2/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/s2/sysaux01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/s2/a_tbs01.dbf
restoring datafile 00005 to /u01/app/oracle/oradata/s2/b_tbs01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /tmp/back4s2/0noasbn2_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/tmp/back4s2/0noasbn2_1_1 tag=TAG20130529T190714
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:02:07
Finished restore at 29-MAY-13
contents of Memory Script.:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy recid=9 stamp=816722424 filename=/u01/app/oracle/oradata/s2/system01.dbf
datafile 2 switched to datafile copy
input datafile copy recid=10 stamp=816722424 filename=/u01/app/oracle/oradata/s2/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=11 stamp=816722424 filename=/u01/app/oracle/oradata/s2/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=12 stamp=816722424 filename=/u01/app/oracle/oradata/s2/a_tbs01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=13 stamp=816722424 filename=/u01/app/oracle/oradata/s2/b_tbs01.dbf
contents of Memory Script.:
{
set until scn 240313;
recover
standby
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 29-MAY-13
using channel ORA_AUX_DISK_1
starting media recovery
channel ORA_AUX_DISK_1: starting archive log restore to default destination
channel ORA_AUX_DISK_1: restoring archive log
archive log thread=1 sequence=13
channel ORA_AUX_DISK_1: reading from backup piece /tmp/back4s2/arch0poasbo8_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/tmp/back4s2/arch0poasbo8_1_1 tag=TAG20130529T190752
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archive log filename=/u01/app/oracle/archive/s2/1_13_816121808.dbf thread=1 sequence=13
channel clone_default: deleting archive log(s)
archive log filename=/u01/app/oracle/archive/s2/1_13_816121808.dbf recid=1 stamp=816722426
media recovery complete, elapsed time: 00:00:02
Finished recover at 29-MAY-13
Finished Duplicate Db at 29-MAY-13
RMAN> exit
Recovery Manager complete.
11.将备库置于自动恢复状态
SQL> select status from v$instance
STATUS
------------
MOUNTED
SQL> select sequence#,applied from v$archived_log
SEQUENCE# APP
---------- ---
13 NO
1 NO
2 NO
3 NO
4 NO
5 NO
6 NO
7 NO
8 NO
9 NO
10 NO
SEQUENCE# APP
---------- ---
11 NO
12 NO
13 NO
14 NO
15 NO
16 rows selected.
SQL> recover managed standby database disconnect;
Media recovery complete.
12.在主库上执行检查
SQL> conn /as sysdba
Connected.
SQL> alter system archive log current;
System altered.
SQL> create table mh.t4s2 as select * from dba_users;
Table created.
SQL> select dest_id,status,error from v$archive_dest_status
DEST_ID STATUS ERROR
---------- --------- ------------------------------
1 VALID
2 ERROR ORA-01034: ORACLE not available --以前配置的物理standby
3 VALID --本次配置的standby
SQL> select * from v$archive_gap;
no rows selected
SQL> select process,status from v$managed_standby;
PROCESS STATUS
--------- ------------
ARCH CLOSING
ARCH CLOSING
LNS WRITING
13.在备库上执行检查
SQL> conn / as sysdba
Connected.
SQL> select * from v$archive_gap;
no rows selected
SQL> recover managed standby database disconnect;
Media recovery complete.
SQL> select sequence#,applied from v$archived_log
2 ;
SEQUENCE# APP
---------- ---
13 NO
1 NO
2 NO
3 NO
4 NO
5 NO
6 NO
7 NO
8 NO
9 NO
10 NO
11 NO
12 NO
13 YES
14 YES
15 YES
16 YES
17 rows selected.
SQL> select process,status from v$managed_standby;
PROCESS STATUS
------------------ ------------------------
ARCH CONNECTED
ARCH CONNECTED
RFS IDLE
MRP0 WAIT_FOR_LOG
SQL> recover managed standby database cancel;
Media recovery complete.
SQL> alter database open read only;
Database altered.
SQL> select count(*) from mh.t4s2;
COUNT(*)
----------
7
SQL> select process,status from v$managed_standby;
PROCESS STATUS
--------- ------------
ARCH CONNECTED
ARCH CONNECTED
RFS IDLE
RFS IDLE
SQL> recover managed standby database disconnect;
Media recovery complete.
SQL> select process,status from v$managed_standby;
PROCESS STATUS
--------- ------------
ARCH CONNECTED
ARCH CONNECTED
RFS IDLE
MRP0 WAIT_FOR_LOG
RFS IDLE
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/18922393/viewspace-762380/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/18922393/viewspace-762380/