DG环境已经搭建完成 DG1(主) DG2(备)
DG1:
SQL> create table t1 (id number(5));
Table created.
SQL> insert into t1 values(1);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t1;
ID
----------
1
SQL> alter system switch logfile;
System altered.
SQL> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
--------------
31
DG2:
SQL> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
--------------
31
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Database altered.
SQL> ALTER DATABASE OPEN READ ONLY;
Database altered.
SQL> select * from t1;
ID
----------
1
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Database altered.
insert之后不commit
DG1:
SQL> insert into t1 values(2);
1 row created.
没有commit,直接做了日志轮转
SQL> alter system switch logfile;
System altered.
SQL> select * from t1;
ID
----------
1
2
SQL> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
--------------
32
DG2:
SQL> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
--------------
32
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Database altered.
SQL> ALTER DATABASE OPEN READ ONLY;
Database altered.
SQL> select * from t1;
ID
----------
1
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Database altered.
问题:
alter system switch logfile不是可以触发隐试提交吗,但是为什么DG2的数据没有同步?
以至于之后做主备切换的时候,备机切换主机
SQL> alter database commit to switchover to primary;
alter database commit to switchover to primary
*
ERROR at line 1:
ORA-16139: media recovery required
需要alter database recover managed standby database finish
SQL> alter database commit to switchover to primary;
Database altered.