最开始执行下面的脚本:
connect target sys/xxxxx@alidwpri
connect auxiliary sys/xxxx@alidwstb
run {
allocate channel c1 type disk;
allocate auxiliary channel s1 type disk;
duplicate target database for standby from active database dorecover
spfile
set db_unique_name='alidwstb'
set fal_client='alidwstb'
set fal_server='alidwpri'
set standby_file_management='AUTO'
set log_archive_dest_1='LOCATION=+ARCHVG valid_for=(all_logfiles,all_roles) db_unique_name=alidwstb'
set control_files='/opt/oracle/products/11.1.0/alidw/dbs/alidwstb.ctl'
set cluster_database='false'
set memory_max_target='6000m'
set memory_target='6000m'
set undo_tablespace='UNDOTBS1'
set log_archive_dest_2='service=alidwpri LGWR ASYNC valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=alidw'
set log_archive_dest_state_2='enable'
NOFILENAMECHECK;
sql channel c1 "alter system archive log current";
sql channel s1 "alter database recover managed standby database disconnect from session";
sql channel s1 "ALTER DATABASE OPEN read only";
release channel c1;
release channel s1;
}
复制数据库复制完之后,出现下面的出错:
input archived log thread=2 sequence=29419 RECID=133890 STAMP=701572319
output file name=+ARCHVG/alidwstb/archivelog/2009_10_31/thread_2_seq_29419.2303.701665909 RECID=0 STAMP=0
channel c1: archived log copy complete, elapsed time: 00:00:02
channel c1: starting archived log copy
input archived log thread=2 sequence=29421 RECID=133898 STAMP=701572355
output file name=+ARCHVG/alidwstb/archivelog/2009_10_31/thread_2_seq_29421.2306.701665911 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=2 sequence=29424 RECID=133911 STAMP=701572421
output file name=+ARCHVG/alidwstb/archivelog/2009_10_31/thread_2_seq_29424.2302.701665911 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=2 sequence=29370 RECID=133693 STAMP=701571094
output file name=+ARCHVG/alidwstb/archivelog/2009_10_31/thread_2_seq_29370.2305.701665913 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=2 sequence=29376 RECID=133717 STAMP=701571209
output file name=+ARCHVG/alidwstb/archivelog/2009_10_31/thread_2_seq_29376.2307.701665913 RECID=0 STAMP=0
channel c1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 2009-10-31 03:11:54
searching for all files in the recovery area
released channel: c1
released channel: s1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 10/31/2009 03:11:55
RMAN-03015: error occurred in stored script. Memory Script
RMAN-06136: ORACLE error from auxiliary database: ORA-19801: initialization parameter DB_RECOVERY_FILE_DEST is not set
Recovery Manager complete.
因为所有的数据文件跟archive 文件都已经复制过来,所以尝试手动recover .
执行:alter database recover managed standby database disconnect from session ,出现如下信息。
Waiting for all non-current ORLs to be archived...
SUCCESS: diskgroup TEMPVG was dismounted
Errors in file /home/oracle/products/diag/rdbms/alidwstb/alidw/trace/alidw_mrp0_30978.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '+REDOVG/alidw/redo01.log'
ORA-17503: ksfdopn:2 Failed to open file +REDOVG/alidw/redo01.log
ORA-15173: entry 'alidw' does not exist in directory '/'
Errors in file /home/oracle/products/diag/rdbms/alidwstb/alidw/trace/alidw_mrp0_30978.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '+REDOVG/alidw/redo01.log'
ORA-17503: ksfdopn:2 Failed to open file +REDOVG/alidw/redo01.log
ORA-15173: entry 'alidw' does not exist in directory '/'
Clearing online redo logfile 1 +REDOVG/alidw/redo01.log
Clearing online log 1 of thread 1 sequence number 87268
Errors in file /home/oracle/products/diag/rdbms/alidwstb/alidw/trace/alidw_mrp0_30978.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '+REDOVG/alidw/redo01.log'
ORA-17503: ksfdopn:2 Failed to open file +REDOVG/alidw/redo01.log
ORA-15173: entry 'alidw' does not exist in directory '/'
Errors in file /home/oracle/products/diag/rdbms/alidwstb/alidw/trace/alidw_mrp0_30978.trc:
ORA-19527: physical standby redo log must be renamed
ORA-00312: online log 1 thread 1: '+REDOVG/alidw/redo01.log'
Clearing online redo logfile 1 complete
Media Recovery Waiting for thread 1 sequence 87271
后查看之后, 是需要设置log_file_name_convert, 即使目录完全一下。
ALTER SYSTEM SET log_file_name_convert='+REDOVG/','+REDOVG/' SCOPE=SPFILE;
重新启动数据库。
Sat Oct 31 03:56:45 2009
ALTER SYSTEM SET log_file_name_convert='+REDOVG/','+REDOVG/' SCOPE=SPFILE;
Sat Oct 31 03:58:51 2009
Shutting down instance: further logons disabled
Stopping background process MMNL
Stopping background process MMON
Shutting down instance (immediate)
License high water mark = 9
ALTER DATABASE CLOSE NORMAL
ORA-1109 signalled during: ALTER DATABASE CLOSE NORMAL...
ALTER DATABASE DISMOUNT
Completed: ALTER DATABASE DISMOUNT
ARCH: Archival disabled due to shutdown: 1089
Shutting down archive processes
Archiving is disabled
Sat Oct 31 03:58:53 2009
ARCH shutting down
Sat Oct 31 03:58:53 2009
ARCH shutting down
Sat Oct 31 03:58:53 2009
ARCH shutting down
Sat Oct 31 03:58:53 2009
ARCH shutting down
ARC3: Archival stopped
ARC2: Archival stopped
ARC1: Archival stopped
ARC0: Archival stopped
ARCH: Archival disabled due to shutdown: 1089
Shutting down archive processes
Archiving is disabled
Archive process shutdown avoided: 0 active
Sat Oct 31 03:58:55 2009
Stopping background process VKTM:
Sat Oct 31 03:58:58 2009
Instance shutdown complete
Sat Oct 31 03:59:39 2009
Starting ORACLE instance (normal)
LICENSE_MAX_SESSION = 0
LICENSE_SESSIONS_WARNING = 0
Picked latch-free SCN scheme 3
Autotune of undo retention is turned on.
IMODE=BR
ILAT =182
LICENSE_MAX_USERS = 0
SYS auditing is disabled
Starting up ORACLE RDBMS Version: 11.1.0.7.0.
Using parameter settings in server-side spfile /opt/oracle/products/11.1.0/alidw/dbs/spfilealidw.ora
System parameters with non-default values:
processes = 1500
sessions = 1655
memory_target = 6016M
memory_max_target = 6016M
control_files = "/opt/oracle/products/11.1.0/alidw/dbs/alidwstb.ctl"
log_file_name_convert = "+REDOVG/"
log_file_name_convert = "+REDOVG/"
db_block_size = 32768
compatible = "11.1.0.0.0"
log_archive_config = "DG_CONFIG=(alidw,alidwstb)"
log_archive_dest_1 = "LOCATION=+ARCHVG/ valid_for=(all_logfiles,all_roles) db_unique_name=alidwstb"
log_archive_dest_2 = "service=alidwpri LGWR ASYNC valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=alidw"
log_archive_dest_state_2 = "enable"
standby_archive_dest = "LOCATION=+ARCHVG/stb"
log_archive_format = "%t_%s_%r.log"
fal_client = "alidwstb"
fal_server = "alidwpri"
db_files = 2048
cluster_database = FALSE
cluster_database_instances= 1
standby_file_management = "manual"
undo_tablespace = "UNDOTBS1"
remote_login_passwordfile= "EXCLUSIVE"
db_domain = ""
global_names = FALSE
remote_listener = ""
audit_file_dest = "/home/oracle/products/admin/alidw/adump"
audit_trail = "DB"
db_name = "alidw"
db_unique_name = "alidwstb"
open_cursors = 300
diagnostic_dest = "/home/oracle/products"
Deprecated system parameters with specified values:
standby_archive_dest
End of deprecated system parameter listing
Sat Oct 31 03:59:42 2009
PMON started with pid=2, OS id=7495
Sat Oct 31 03:59:42 2009
VKTM started with pid=3, OS id=7497 at elevated priority
VKTM running at (20)ms precision
Sat Oct 31 03:59:42 2009
DIAG started with pid=4, OS id=7501
Sat Oct 31 03:59:42 2009
DBRM started with pid=5, OS id=7503
Sat Oct 31 03:59:42 2009
PSP0 started with pid=6, OS id=7505
Sat Oct 31 03:59:42 2009
DIA0 started with pid=7, OS id=7507
Sat Oct 31 03:59:42 2009
MMAN started with pid=8, OS id=7509
Sat Oct 31 03:59:42 2009
DBW0 started with pid=9, OS id=7511
Sat Oct 31 03:59:42 2009
LGWR started with pid=10, OS id=7513
Sat Oct 31 03:59:42 2009
CKPT started with pid=11, OS id=7515
Sat Oct 31 03:59:42 2009
SMON started with pid=12, OS id=7517
Sat Oct 31 03:59:42 2009
RECO started with pid=13, OS id=7519
Sat Oct 31 03:59:42 2009
MMON started with pid=14, OS id=7521
Sat Oct 31 03:59:42 2009
MMNL started with pid=15, OS id=7523
ORACLE_BASE from environment = /opt/oracle
Sat Oct 31 04:00:05 2009
ALTER SYSTEM SET standby_file_management='AUTO' SCOPE=BOTH;
Sat Oct 31 04:00:40 2009
alter database mount standby database
Setting recovery target incarnation to 1
ARCH: STARTING ARCH PROCESSES
Sat Oct 31 04:00:44 2009
ARC0 started with pid=17, OS id=7745
Sat Oct 31 04:00:44 2009
ARC1 started with pid=18, OS id=7750
Sat Oct 31 04:00:44 2009
ARC2 started with pid=19, OS id=7752
ARC0: Archival started
Sat Oct 31 04:00:44 2009
ARC3 started with pid=20, OS id=7754
ARC1: Archival started
ARC2: Archival started
ARC3: Archival started
ARCH: STARTING ARCH PROCESSES COMPLETE
ARC0: Becoming the 'no FAL' ARCH
ARC0: Becoming the 'no SRL' ARCH
ARC0: Thread not mounted
ARC1: Becoming the heartbeat ARCH
ARC2: Thread not mounted
ARC3: Thread not mounted
Sat Oct 31 04:00:44 2009
Successful mount of redo thread 1, with mount id 423103528
Physical Standby Database mounted.
Lost write protection disabled
Completed: alter database mount standby database
Sat Oct 31 04:00:47 2009
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[1]: Assigned to RFS process 7762
RFS[1]: Identified database type as 'physical standby'
RFS LogMiner: Client disabled from further notification
Sat Oct 31 04:00:48 2009
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[2]: Assigned to RFS process 7767
RFS[2]: Identified database type as 'physical standby'
Sat Oct 31 04:00:48 2009
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[3]: Assigned to RFS process 7769
RFS[3]: Identified database type as 'physical standby'
Starting background process ASMB
Sat Oct 31 04:00:51 2009
ASMB started with pid=24, OS id=7782
Sat Oct 31 04:00:51 2009
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[4]: Assigned to RFS process 7780
RFS[4]: Identified database type as 'physical standby'
Primary database is in MAXIMUM PERFORMANCE mode
Starting background process RBAL
Sat Oct 31 04:00:51 2009
RBAL started with pid=26, OS id=7786
Primary database is in MAXIMUM PERFORMANCE mode
Sat Oct 31 04:00:54 2009
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[5]: Assigned to RFS process 7797
RFS[5]: Identified database type as 'physical standby'
Primary database is in MAXIMUM PERFORMANCE mode
Sat Oct 31 04:00:54 2009
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[6]: Assigned to RFS process 7799
RFS[6]: Identified database type as 'physical standby'
Primary database is in MAXIMUM PERFORMANCE mode
NOTE:Loaded library: System
SUCCESS: diskgroup ARCHVG was mounted
RFS[2]: Error in standby_archive_dest '+ARCHVG/stb'
RFS[3]: Error in standby_archive_dest '+ARCHVG/stb'
RFS[1]: Error in standby_archive_dest '+ARCHVG/stb'
RFS[5]: Error in standby_archive_dest '+ARCHVG/stb'
RFS[6]: Error in standby_archive_dest '+ARCHVG/stb'
RFS[4]: Error in standby_archive_dest '+ARCHVG/stb'
RFS 使用的目录是standby_archive_dest , 但+ARCHVG/目录下没有stb 目录,所以无法使用。为什么使用的是standby_archive_dest
而不是log_archive_dest_1 = "LOCATION=+ARCHVG/ valid_for=(all_logfiles,all_roles) db_unique_name=alidwstb"
查看一下log_archive_dest_1状态,发现状态为空。
执行命令 alter system set log_archive_dest_1=enable scope=both;
后发现是前面的脚本有遗漏的地方,没有设置:set log_archive_dest_state_1='enable' (开始在做duplicate target database for standby from active database dorecover
复制的时候,archive 文件正常进入+ARCHVG/ 目录。但重启instance之后,就不行了。)
将log_archive_dest_state_1 的目录enable 之后,standby 正常 recovery。
run {
allocate channel c1 type disk;
allocate auxiliary channel s1 type disk;
duplicate target database for standby from active database dorecover
spfile
set db_unique_name='alidwstb'
set fal_client='alidwstb'
set fal_server='alidwpri'
set standby_file_management='AUTO'
set log_archive_dest_1='LOCATION=+ARCHVG valid_for=(all_logfiles,all_roles) db_unique_name=alidwstb'
set control_files='/opt/oracle/products/11.1.0/alidw/dbs/alidwstb.ctl'
set cluster_database='false'
set memory_max_target='6000m'
set memory_target='6000m'
set undo_tablespace='UNDOTBS1'
set log_archive_dest_2='service=alidwpri LGWR ASYNC valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=alidw'
set log_archive_dest_state_2='enable'
NOFILENAMECHECK;
sql channel c1 "alter system archive log current";
sql channel s1 "alter database recover managed standby database disconnect from session";
sql channel s1 "alter database recover managed standby database cancel";
sql channel s1 "ALTER DATABASE OPEN read only";
sql channel s1 "alter database recover managed standby database disconnect from session";
release channel c1;
release channel s1;
}
当recovery 到数据文件完成复制的时间点的时候,执行:
alter database recover managed standby database cancel;
然后打开数据库。
ALTER DATABASE OPEN read only
在让数据库处于同步模式:
alter database recover managed standby database disconnect from session;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22795861/viewspace-617890/ ,如需转载,请注明出处,否则将追究法律责任。