在一个SHELL窗口打开 STANDBY 数据库:
SQL> startup nomount
ORACLE instance started.
Total System Global Area 2042241024 bytes
Fixed Size 1337548 bytes
Variable Size 503318324 bytes
Database Buffers 1526726656 bytes
Redo Buffers 10858496 bytes
SQL> alter database mount standby database;
Database altered.
SQL> alter database recover managed standby database disconnect from session;
Database altered.
SQL>
另一个窗口查看 [oracle@dg2 DB1]$ tail -f /opt/app/oracle/diag/rdbms/db2/DB1/trace/alert_DB1.log
....
alter database mount standby database
Thu Aug 01 10:36:44 2013
ARCH: STARTING ARCH PROCESSES
Thu Aug 01 10:36:44 2013
NSS2 started with pid=19, OS id=24923
Thu Aug 01 10:36:46 2013
ARC0 started with pid=21, OS id=24925
ARC0: Archival started
ARCH: STARTING ARCH PROCESSES COMPLETE
ARC0: STARTING ARCH PROCESSES
Thu Aug 01 10:36:47 2013
Successful mount of redo thread 1, with mount id 1416150390
Physical Standby Database mounted.
Lost write protection disabled
Thu Aug 01 10:36:48 2013
ARC1 started with pid=22, OS id=24931
Completed: alter database mount standby database
Errors in file /opt/app/oracle/diag/rdbms/db2/DB1/trace/DB1_lgwr_24838.trc:
ORA-00313: open failed for members of log group 4 of thread 0
ORA-00312: online log 4 thread 0: '/opt/app/oracle/oradata/DB2/standby_redo01.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Errors in file /opt/app/oracle/diag/rdbms/db2/DB1/trace/DB1_lgwr_24838.trc:
ORA-00313: open failed for members of log group 4 of thread 0
ORA-00312: online log 4 thread 0: '/opt/app/oracle/oradata/DB2/standby_redo01.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Errors in file /opt/app/oracle/diag/rdbms/db2/DB1/trace/DB1_lgwr_24838.trc:
ORA-00313: open failed for members of log group 5 of thread 0
ORA-00312: online log 5 thread 0: '/opt/app/oracle/oradata/DB2/standby_redo02.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Errors in file /opt/app/oracle/diag/rdbms/db2/DB1/trace/DB1_lgwr_24838.trc:
ORA-00313: open failed for members of log group 5 of thread 0
ORA-00312: online log 5 thread 0: '/opt/app/oracle/oradata/DB2/standby_redo02.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Errors in file /opt/app/oracle/diag/rdbms/db2/DB1/trace/DB1_lgwr_24838.trc:
ORA-00313: open failed for members of log group 6 of thread 0
ORA-00312: online log 6 thread 0: '/opt/app/oracle/oradata/DB2/standby_redo03.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Errors in file /opt/app/oracle/diag/rdbms/db2/DB1/trace/DB1_lgwr_24838.trc:
ORA-00313: open failed for members of log group 6 of thread 0
ORA-00312: online log 6 thread 0: '/opt/app/oracle/oradata/DB2/standby_redo03.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Errors in file /opt/app/oracle/diag/rdbms/db2/DB1/trace/DB1_lgwr_24838.trc:
ORA-00313: open failed for members of log group 7 of thread 0
ORA-00312: online log 7 thread 0: '/opt/app/oracle/oradata/DB2/standby_redo04.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Errors in file /opt/app/oracle/diag/rdbms/db2/DB1/trace/DB1_lgwr_24838.trc:
ORA-00313: open failed for members of log group 7 of thread 0
ORA-00312: online log 7 thread 0: '/opt/app/oracle/oradata/DB2/standby_redo04.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Thu Aug 01 10:36:50 2013
ARC2 started with pid=23, OS id=24933
ARC1: Becoming the 'no FAL' ARCH
ARC1: Archival started
ARC2: Archival started
ARC1: Becoming the 'no FAL' ARCH
ARC2: Becoming the heartbeat ARCH
Thu Aug 01 10:36:53 2013
ARC3 started with pid=25, OS id=24939
ARC3: Archival started
ARC0: STARTING ARCH PROCESSES COMPLETE
Thu Aug 01 10:37:12 2013
alter database recover managed standby database disconnect from session
Attempt to start background Managed Standby Recovery process (DB1)
Thu Aug 01 10:37:13 2013
MRP0 started with pid=24, OS id=24954
MRP0: Background Managed Standby Recovery process started (DB1)
started logmerger process
Thu Aug 01 10:37:21 2013
Managed Standby Recovery not using Real Time Apply
Thu Aug 01 10:37:21 2013
Errors in file /opt/app/oracle/diag/rdbms/db2/DB1/trace/DB1_dbw0_24836.trc:
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/opt/app/oracle/oradata/DB2/system01.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Errors in file /opt/app/oracle/diag/rdbms/db2/DB1/trace/DB1_dbw0_24836.trc:
ORA-01157: cannot identify/lock data file 2 - see DBWR trace file
ORA-01110: data file 2: '/opt/app/oracle/oradata/DB2/sysaux01.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Errors in file /opt/app/oracle/diag/rdbms/db2/DB1/trace/DB1_dbw0_24836.trc:
ORA-01157: cannot identify/lock data file 3 - see DBWR trace file
ORA-01110: data file 3: '/opt/app/oracle/oradata/DB2/undotbs01.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Errors in file /opt/app/oracle/diag/rdbms/db2/DB1/trace/DB1_dbw0_24836.trc:
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/opt/app/oracle/oradata/DB2/users01.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
MRP0: Background Media Recovery terminated with error 1110
Errors in file /opt/app/oracle/diag/rdbms/db2/DB1/trace/DB1_pr00_24962.trc:
ORA-01110: data file 1: '/opt/app/oracle/oradata/DB2/system01.dbf'
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/opt/app/oracle/oradata/DB2/system01.dbf'
Completed: alter database recover managed standby database disconnect from session
Recovery Slave PR00 previously exited with exception 1110
Errors in file /opt/app/oracle/diag/rdbms/db2/DB1/trace/DB1_mrp0_24954.trc:
ORA-01110: data file 1: '/opt/app/oracle/oradata/DB2/system01.dbf'
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/opt/app/oracle/oradata/DB2/system01.dbf'
MRP0: Background Media Recovery process shutdown (DB1)
看出错误提示“无法获取文件状态”,在STANDBY 中没看到/opt/app/oracle/oradata/DB2/standby_redo04.log
日志文件 。
我的参数中配置为:
db_file_name_convert string
DB1, DB2
可能在STANDBY 中已把 DB2 默认为文件 目录是:“/opt/app/oracle/oradata/DB2”。
在主库中查看并修改:
SQL> SHOW PARAMETER DB_FILE_NAME_CONVERT;
NAME TYPE
------------------------------------ ---------------------------------
VALUE
------------------------------
db_file_name_convert string
DB1, DB2
SQL> ALTER SYSTEM SET DB_FILE_NAME_CONVERT='/opt/app/oracle/oradata/DB1','/opt/app/oracle/oradata/DB1' SCOPE=SPFILE;
System altered.
SQL> ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='/opt/app/oracle/oradata/DB1','/opt/app/oracle/oradata/DB1' SCOPE=SPFILE;
System altered.
SQL> SHOW PARAMETER LOG_FILE_NAME_CONVERT;
NAME TYPE
------------------------------------ ---------------------------------
VALUE
------------------------------
log_file_name_convert string
SQL> ALTER SYSTEM SET DB_FILE_NAME_CONVERT='/opt/app/oracle/oradata/DB1','/opt/app/oracle/oradata/DB1' SCOPE=SPFILE;
System altered.
SQL> CREATE PFILE='/tmp/initDB1_stby.ora' from spfile;
File created.
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=DB2 lgwr sync affirm VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=DB2';
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=DB2 lgwr sync affirm VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=DB2';
并在STANDBY 库中修改pfile:
*.db_file_name_convert='DB1','DB2'
修改为:
*.db_file_name_convert='/opt/app/oracle/oradata/DB1','/opt/app/oracle/oradata/DB1'
*.log_file_name_convert='DB1','DB2'
修改为:
*.log_file_name_convert='/opt/app/oracle/oradata/DB1','/opt/app/oracle/oradata/DB1'
完成后的测试:
1.查看 redo 文件 已过来了。
2.在主库中测试插入:
SQL> insert into test values(11) ;
1 row created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
3.在STANDBY 中查看:
SQL> alter database recover managed standby database disconnect from session;
Database altered.
SQL> select * from test;
ID
----------
1
2
3
10
5
6
7
8
9
11
10 rows selected.
4.及alert_db2.log:
Thu Aug 01 11:40:49 2013
RFS[5]: Selected log 4 for thread 1 sequence 116 dbid 1415856135 branch 821992519
Thu Aug 01 11:40:49 2013
Archived Log entry 25 added for thread 1 sequence 115 ID 0x54641707 dest 1:
Thu Aug 01 11:42:03 2013
alter database recover managed standby database disconnect from session
Attempt to start background Managed Standby Recovery process (DB1)
Thu Aug 01 11:42:03 2013
MRP0 started with pid=27, OS id=26550
MRP0: Background Managed Standby Recovery process started (DB1)
started logmerger process
Thu Aug 01 11:42:08 2013
Managed Standby Recovery not using Real Time Apply
Parallel Media Recovery started with 2 slaves
Waiting for all non-current ORLs to be archived...
All non-current ORLs have been archived.
Media Recovery Log /opt/app/oracle/oradata/DB1/ARC1151821992519.arc
Media Recovery Waiting for thread 1 sequence 116 (in transit)
Completed: alter database recover managed standby database disconnect from session
5.查看动态表:
1.
select * from v$dataguard_stats;
NAME VALUE UNIT TIME_COMPUTED DATUM_TIME
1 +00 00:00:00 day(2) to second(0) interval 08/01/2013 11:47:57 08/01/2013 11:47:55
2 apply lag +00 00:15:15 day(2) to second(0) interval 08/01/2013 11:47:57 08/01/2013 11:47:55
3 apply finish time +00 00:00:07.000 day(2) to second(3) interval 08/01/2013 11:47:57
4 estimated startup time 118 second 08/01/2013 11:47:57
2.查看日志传输情况
select sequence#,first_time,next_time from v$archived_log;
......
SEQUENCE# FIRST_TIME NEXT_TIME
---------- ------------------- -------------------
114 2013-08-01 11:32:35 2013-08-01 11:32:40
112 2013-08-01 11:27:21 2013-08-01 11:32:17
115 2013-08-01 11:32:40 2013-08-01 11:40:49
116 2013-08-01 11:40:49 2013-08-01 13:24:06
26 rows selected.