问题描述:dg搭建成功后,发现线程1中group 1和2的的两个redo日志成员分别为同一个文件,如下所示.
环境:主库rac(2节点) + oracle 11.2.0.4 备库:文件系统
1、异常现象
SQL> select t2.thread#,t1.group#,t1.member,t2.bytes/1024/1024 from v$logfile t1,v$log t2 where t1.group#=t2.group# order by 1,2;
THREAD# GROUP# MEMBER T2.BYTES/1024/1024
---------- ---------- ------------------------------------------------------------ ------------------
1 1 /u01/app/oracle/oradata/group_1.257.1132745547 50
1 1 /u01/app/oracle/oradata/group_1.257.1132745547 50
1 2 /u01/app/oracle/oradata/group_2.258.1132745547 50
1 2 /u01/app/oracle/oradata/group_2.258.1132745547 50
2 3 /u01/app/oracle/oradata/group_3.265.1132747513 50
2 3 /u01/app/oracle/oradata/group_3.259.1132747513 50
2 4 /u01/app/oracle/oradata/group_4.266.1132747513 50
2 4 /u01/app/oracle/oradata/group_4.260.1132747515 50
8 rows selected.
2、问题分析
--主库redo日志的情况如下.
SQL> select t2.thread#,t1.group#,t1.member,t2.bytes/1024/1024 from v$logfile t1,v$log t2 where t1.group#=t2.group# order by 1,2;
THREAD# GROUP# MEMBER T2.BYTES/1024/1024
---------- ---------- -------------------------------------------------- ------------------
1 1 +DATA/orcl/onlinelog/group_1.257.1132745547 50
1 1 +FRA/orcl/onlinelog/group_1.257.1132745547 50
1 2 +DATA/orcl/onlinelog/group_2.258.1132745547 50
1 2 +FRA/orcl/onlinelog/group_2.258.1132745547 50
2 3 +DATA/orcl/onlinelog/group_3.265.1132747513 50
2 3 +FRA/orcl/onlinelog/group_3.259.1132747513 50
2 4 +DATA/orcl/onlinelog/group_4.266.1132747513 50
2 4 +FRA/orcl/onlinelog/group_4.260.1132747515 50
8 rows selected.
SQL> show parameter log_file_name_convert
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_file_name_convert string +DATA/orcl/onlinelog/, /u01/ap
p/oracle/oradata/, +FRA/orcl/o
nlinelog/, /u01/app/oracle/ora
data/, +DATA/orcl/controlfile/
, /u01/app/oracle/oradata/, +F
RA/orcl/controlfile/, /u01/app
/oracle/oradata/
分析:主库thread 1的两个成员名称相同,只不过在不同目录,但搭建dg时,经过log_file_name_convert参数的转换,到dg端就变成同一个redo文件.
3、异常解决
--主库停止监听.
[grid@hisdb1 ~]$ srvctl stop listener
--备库执行.
SQL> alter system set standby_file_management=manual;
System altered.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 CLEARING
2 CURRENT
3 CLEARING
4 CURRENT
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY WITH APPLY
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> alter database add logfile thread 1 group 5 ('/u01/app/oracle/oradata/redo5.log','/u01/app/oracle/oradata/redo5B.log') size 50m reuse;
Database altered.
SQL> alter database add logfile thread 2 group 6 ('/u01/app/oracle/oradata/redo6.log','/u01/app/oracle/oradata/redo6B.log') size 50m reuse;
Database altered.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 CLEARING
2 CURRENT
3 CLEARING
4 CURRENT
5 UNUSED
6 UNUSED
6 rows selected.
SQL> alter database clear logfile group 1;
Database altered.
SQL> alter database clear logfile group 3;
Database altered.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 UNUSED
2 CURRENT
3 UNUSED
4 CURRENT
5 UNUSED
6 UNUSED
6 rows selected.
SQL> alter database drop logfile group 1;
Database altered.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
2 CURRENT
3 UNUSED
4 CURRENT
5 UNUSED
6 UNUSED
--主库切换日志
SQL> alter system switch logfile;
System altered.
--备库查询
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
2 CLEARING
3 UNUSED
4 CURRENT
5 UNUSED
6 UNUSED
SQL> alter database clear logfile group 2;
Database altered.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
2 UNUSED
3 UNUSED
4 CURRENT
5 UNUSED
6 UNUSED
--主库再次切换日志
SQL> alter system switch logfile;
System altered.
--备库再次查询
SQL> r
1* select group#,status from v$log
GROUP# STATUS
---------- ----------------
2 CURRENT
3 UNUSED
4 CURRENT
5 UNUSED
6 UNUSED
SQL> alter database add logfile thread 1 group 1 ('/u01/app/oracle/oradata/redo1.log','/u01/app/oracle/oradata/redo1B.log') size 50m reuse;
Database altered.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 UNUSED
2 CURRENT
3 UNUSED
4 CURRENT
5 UNUSED
6 UNUSED
6 rows selected.
--主库切换日志
SQL> alter system switch logfile;
System altered.
--备库查询
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 CURRENT
2 CLEARING
3 CURRENT
4 CLEARING
5 UNUSED
6 UNUSED
6 rows selected.
SQL> alter database clear logfile group 2;
Database altered.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 CURRENT
2 UNUSED
3 CURRENT
4 CLEARING
5 UNUSED
6 UNUSED
6 rows selected.
SQL> alter database drop logfile group 2;
Database altered.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 CURRENT
3 CURRENT
4 CLEARING
5 UNUSED
6 UNUSED
SQL> alter database add logfile thread 1 group 2 ('/u01/app/oracle/oradata/redo2.log','/u01/app/oracle/oradata/redo2B.log') size 50m reuse;
Database altered.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 CURRENT
2 UNUSED
3 CURRENT
4 CLEARING
5 UNUSED
6 UNUSED
6 rows selected.
SQL> alter database drop logfile group 5;
Database altered.
SQL> alter database drop logfile group 6;
Database altered.
说明:测试过程中备库新增的group 5&6没起到作用.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 CURRENT
2 UNUSED
3 CURRENT
4 CLEARING
SQL> alter database clear logfile group 4;
Database altered.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 CURRENT
2 UNUSED
3 CURRENT
4 UNUSED
SQL> select a.thread#,a.group#,b.member,b.type,a.bytes/1024/1024 MB from v$log a,v$logfile b where a.group#=b.group# ;
THREAD# GROUP# MEMBER TYPE MB
---------- ---------- ------------------------------------------------------------ ------- ----------
1 1 /u01/app/oracle/oradata/redo1.log ONLINE 50
1 1 /u01/app/oracle/oradata/redo1B.log ONLINE 50
1 2 /u01/app/oracle/oradata/redo2.log ONLINE 50
1 2 /u01/app/oracle/oradata/redo2B.log ONLINE 50
2 3 /u01/app/oracle/oradata/group_3.265.1132747513 ONLINE 50
2 3 /u01/app/oracle/oradata/group_3.259.1132747513 ONLINE 50
2 4 /u01/app/oracle/oradata/group_4.266.1132747513 ONLINE 50
2 4 /u01/app/oracle/oradata/group_4.260.1132747515 ONLINE 50
8 rows selected.
说明:如上所示,group 1&2日志文件恢复正常.
4、恢复后操作
SQL> alter system set standby_file_management=auto;
System altered.
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
--主库开启监听.
[oracle@hisdb1 ~]$ srvctl start listener