DG GAP 顾名思义就是:DG不同步,当备库不能接受到一个或多个主库的归档日志文件时候,就发生了 GAP。
那么,如果遇到GAP如何修复呢?且听我细细道来~
DG GAP 主要分为以下两类情况:
1、主库归档日志存在,可以通过配置 Fetch Archive Log(FAL) 参数,自动解决归档 GAP。 2、主库归档日志丢失,需要
人工干预
来修复。
不同 Oracle 版本的 GAP 修复方式也不尽相同,下面分别介绍不同版本的方式!
11G 的处理步骤:
a.在主库上创建一个备库的控制文件 b.以备库的当前SCN号为起点,在主库上做一个增量备份 c.将增量备份拷贝到备库上 d.使用新的控制文件将备库启动到mount状态 e.将增量备份注册到RMAN的catalog,取消备库的恢复应用,恢复增量备份 f.开启备库的恢复进程
12C 的新特性(RECOVER … FROM SERVICE)
18C 的新特性(RECOVER STANDBY DATABASE FROM SERVICE)
Oracle随着版本的升级,逐渐将步骤缩减,进行封装,18C之后可谓是达到了所谓的一键刷新,恢复DG同步。
下面我们通过实验来进行演示如何修复:
安装测试环境可以使用博主编写的 Oracle 一键安装脚本,同时支持单机和 RAC 集群模式!
更多更详细的脚本使用方式可以订阅专栏:Oracle一键安装脚本。
首先,模拟备库断电,主库切几个最新的归档,然后手工删掉,重新开启DG同步。
备库停止DG同步进程:
sqlplus / as sysdba
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
shutdown immediate
主库切换多次归档:
sqlplus / as sysdba
alter system switch logfile;
主库删除最近几个归档日志:
rm 1_34_1070147137.arc
rm 1_33_1070147137.arc
备库开启同步进程:
startup
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
查看GAP:
sqlplus / as sysdba
SELECT * FROM V$ARCHIVE_GAP;
THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#
---------- ------------- --------------
1 32 34
SELECT max(sequence#) from v$archived_log where applied='YES';
MAX(SEQUENCE#)
--------------
31
📢 注意: 当前DG数据库已存在GAP,GAP日志为:32—34。
alter database create standby controlfile as '/tmp/standby.ctl';
备库查询当前 scn 号:
sqlplus / as sysdba
select to_char(current_scn) from v$database;
TO_CHAR(CURRENT_SCN)
----------------------------------------
1086639
确认主备GAP期间是否新增数据文件:
sqlplus / as sysdba
select file# from v$datafile where creation_change# > =1086639;
主库根据备库scn号进行增量备份:
rman target /
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
backup INCREMENTAL from scn 1086639 database format '/tmp/incre_%U';
release channel c1;
release channel c2;
}
📢 注意: 如果存在新增数据文件,备库恢复时需要先restore新添加的数据文件。
主库拷贝增量备份和控制文件你至备库:
scp incre_0* oracle@orcl_stby:/home/oracle
scp standby.ctl oracle@orcl_stby:/home/oracle
📢 注意: 确认备库的磁盘空间是否足够存放。
备库关闭数据库实例,开启至nomount状态:
sqlplus / as sysdba
shutdown immediate
startup nomount
备库恢复新的控制文件:
rman target /
restore controlfile from '/home/oracle/standby.ctl';
备库开启到mount状态:
alter database mount;
确认备库已关闭DG同步进程:
sqlplus / as sysdba
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
备库rman注册增量备份文件:
rman target /
catalog start with '/home/oracle/';
YES
备库开启恢复增量备份:
recover database noredo;
备库开启日志同步进程:
sqlplus / as sysdba
alter database open read only;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
主库重新激活同步:
sqlplus / as sysdba
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=defer;
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=enable;
查询是否存在GAP,确认主备是否同步:
sqlplus / as sysdba
SELECT * FROM V$ARCHIVE_GAP;
SELECT max(sequence#) from v$archived_log where applied='YES';
SELECT PROCESS, STATUS, THREAD#, SEQUENCE#, BLOCK#, BLOCKS FROM V$MANAGED_STANDBY;
至此,DG GAP已被修复,以上方式为常规修复方式,各个版本都通用。
首先,模拟备库断电,主库切几个最新的归档,然后手工删掉,重新开启DG同步。
模拟GAP期间,有数据文件添加的情况:
##主库添加数据文件
alter tablespace TEST add datafile '/oradata/ORCL/test02.dbf' size 100M autoextend off;
📢 注意: 当前DG数据库已存在GAP,GAP日志为:30—31 。
备库记录当前 scn 号:
sqlplus / as sysdba
SELECT CURRENT_SCN FROM V$DATABASE;
CURRENT_SCN
-----------
2600487
采用rman的新功能,recover standby using service
,通过RMAN连接到target备库,然后用主库的service执行恢复备库命令。
语法:
RECOVER DATABASE FROM SERVICE < PRIMARY DB SERVICE NAME > NOREDO USING COMPRESSED BACKUPSET;
📢 注意: 确认主库的TNS已配置,这里的< PRIMARY DB SERVICE NAME >即 TNSNAME。
备库启动到nomount状态:
sqlplus / as sysdba
shutdown immediate
startup nomount
备库通过from service恢复控制文件:
rman target /
restore standby controlfile from service orcl;
备库开启到mount状态:
sqlplus / as sysdba
alter database mount;
检查主备GAP期间是否添加数据文件:
sqlplus / as sysdba
select file# from v$datafile where creation_change# > =2600487;
FILE#
----------
13
restore 新添加的数据文件:
rman target /
run
{
SET NEWNAME FOR DATABASE TO '/oradata/ORCL_STBY/%f_%U';
RESTORE DATAFILE 13 FROM SERVICE orcl;
}
由于主备的数据文件目录不一致,需要修改controlfile中数据文件位置:
rman target /
catalog start with '/oradata/ORCL_STBY';
YES
SWITCH DATABASE TO COPY;
将备库文件管理方式改为手动:
sqlplus / as sysdba
alter system set standby_file_management=MANUAL;
重命名 tempfile && logfile:
sqlplus / as sysdba
##logfile
alter database clear logfile group 1;
alter database clear logfile group 2;
alter database clear logfile group 3;
alter database clear logfile group 4;
alter database clear logfile group 5;
alter database clear logfile group 6;
alter database clear logfile group 7;
alter database rename file '/oradata/ORCL/redo03.log' to '/oradata/ORCL_STBY/redo03.log';
alter database rename file '/oradata/ORCL/redo02.log' to '/oradata/ORCL_STBY/redo02.log';
alter database rename file '/oradata/ORCL/redo01.log' to '/oradata/ORCL_STBY/redo01.log';
alter database rename file '/oradata/ORCL/standby_redo04.log' to '/oradata/ORCL_STBY/standby_redo04.log';
alter database rename file '/oradata/ORCL/standby_redo05.log' to '/oradata/ORCL_STBY/standby_redo05.log';
alter database rename file '/oradata/ORCL/standby_redo06.log' to '/oradata/ORCL_STBY/standby_redo06.log';
alter database rename file '/oradata/ORCL/standby_redo07.log' to '/oradata/ORCL_STBY/standby_redo07.log';
##tempfile
alter database rename file '/oradata/ORCL/temp01.dbf' to '/oradata/ORCL_STBY/temp01.dbf';
alter database rename file '/oradata/ORCL/pdbseed/temp012021-04-11_06-13-50-844-AM.dbf' to '/oradata/ORCL_STBY/pdbseed/temp012021-04-11_06-13-50-844-AM.dbf';
alter database rename file '/oradata/ORCL/BFA6BEE45A1E3605E053AC01A8C0DD20/datafile/o1_mf_temp_j749f5fy_.dbf' to '/oradata/ORCL_STBY/BFA6BEE45A1E3605E053AC01A8C0DD20/datafile/o1_mf_temp_j749f5fy_.dbf';
备库重命名完后再改为自动:
sqlplus / as sysdba
alter system set standby_file_management=AUTO;
恢复主备GAP:
recover database from service orcl noredo using compressed backupset;
📢 注意: 如果主备库文件目录不一致,则需要catalog切换控制文件中路径,否则报错:
sqlplus / as sysdba
col HXFNM for a100
set line222
select HXFIL File_num,substr(HXFNM,1,40) HXFNM,fhscn from x$kcvfh;
sqlplus / as sysdba
ALTER SYSTEM ARCHIVE LOG CURRENT;
ALTER SYSTEM SWITCH LOGFILE;
sqlplus / as sysdba
alter database open;
alter pluggable database all open;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
sqlplus / as sysdba
set line222
col member for a60
select t1.group#,t1.thread#,t1.bytes/1024/1024,t1.status,t2.member from gv$standby_log t1,gv$logfile t2 where t1.group#=t2.group#;
sqlplus test/test@pdb01
insert into test values (999);
commit;
alter session set container=pdb01;
select * from test.test;
ID
----------
1
2
999
至此,GAP已修复完成,可以发现,12C这个新特性,将一些步骤进行了省略和封装,进一步减少了我们的操作步骤,但是内部的原理仍然是一致的。
18C 新特性是在 12C 的基础上,将 RECOVER STANDBY DATABASE 命令与 FROM SERVICE 子句一起使用,以通过对主数据库进行的更改来刷新物理备用数据库。备库可以直接在开启状态进行刷新。
语法:
RECOVER STANDBY DATABASE FROM SERVICE primary_db;
首先,模拟备库断电,主库切几个最新的归档,然后手工删掉,重新开启DG同步。
模拟GAP期间,有数据文件添加的情况:
##主库添加数据文件
alter tablespace TEST add datafile '/oradata/ORCL/test02.dbf' size 100M autoextend off;
📢 注意: 当前 DG 数据库已存在 GAP,GAP 日志为:69—70。
下面演示一下,如何使用一行命令在线修复DG GAP:
备库取消日志应用:
sqlplus / as sysdba
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
备库执行修复命令,开始在线刷新备库:
rman target /
RMAN> RECOVER STANDBY DATABASE FROM SERVICE orcl;
Starting recover at 19-APR-21
using target database control file instead of recovery catalog
Oracle instance started
Total System Global Area3355441944 bytes
Fixed Size 9141016 bytes
Variable Size671088640 bytes
Database Buffers2667577344 bytes
Redo Buffers 7634944 bytes
contents of Memory Script:
{
restore standby controlfile from service 'orcl';
alter database mount standby database;
}
executing Memory Script
Starting restore at 19-APR-21
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=502 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: using network backup set from service orcl
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
output file name=/oradata/ORCL_STBY/control01.ctl
output file name=/oradata/ORCL_STBY/control02.ctl
Finished restore at 19-APR-21
released channel: ORA_DISK_1
Statement processed
Executing: alter system set standby_file_management=manual
contents of Memory Script:
{
set newname for tempfile 1 to
"/oradata/ORCL_STBY/temp01.dbf";
set newname for tempfile 2 to
"/oradata/ORCL_STBY/pdbseed/temp012021-04-11_06-13-50-844-AM.dbf";
set newname for tempfile 3 to
"/oradata/ORCL_STBY/BFA6BEE45A1E3605E053AC01A8C0DD20/datafile/o1_mf_temp_j749f5fy_.dbf";
switch tempfile all;
set newname for datafile 1 to
"/oradata/ORCL_STBY/system01.dbf";
set newname for datafile 3 to
"/oradata/ORCL_STBY/sysaux01.dbf";
set newname for datafile 4 to
"/oradata/ORCL_STBY/undotbs01.dbf";
set newname for datafile 5 to
"/oradata/ORCL_STBY/pdbseed/system01.dbf";
set newname for datafile 6 to
"/oradata/ORCL_STBY/pdbseed/sysaux01.dbf";
set newname for datafile 7 to
"/oradata/ORCL_STBY/users01.dbf";
set newname for datafile 8 to
"/oradata/ORCL_STBY/pdbseed/undotbs01.dbf";
set newname for datafile 9 to
"/oradata/ORCL_STBY/PDB01/o1_mf_system_j749f5d5_.dbf";
set newname for datafile 10 to
"/oradata/ORCL_STBY/PDB01/o1_mf_sysaux_j749f5fw_.dbf";
set newname for datafile 11 to
"/oradata/ORCL_STBY/PDB01/o1_mf_undotbs1_j749f5fx_.dbf";
set newname for datafile 12 to
"/oradata/ORCL_STBY/test01.dbf";
set newname for datafile 14 to
"/oradata/ORCL/test02.dbf";
restore from service 'orcl' datafile
14;
catalog datafilecopy "/oradata/ORCL_STBY/system01.dbf",
"/oradata/ORCL_STBY/sysaux01.dbf",
"/oradata/ORCL_STBY/undotbs01.dbf",
"/oradata/ORCL_STBY/pdbseed/system01.dbf",
"/oradata/ORCL_STBY/pdbseed/sysaux01.dbf",
"/oradata/ORCL_STBY/users01.dbf",
"/oradata/ORCL_STBY/pdbseed/undotbs01.dbf",
"/oradata/ORCL_STBY/PDB01/o1_mf_system_j749f5d5_.dbf",
"/oradata/ORCL_STBY/PDB01/o1_mf_sysaux_j749f5fw_.dbf",
"/oradata/ORCL_STBY/PDB01/o1_mf_undotbs1_j749f5fx_.dbf",
"/oradata/ORCL_STBY/test01.dbf",
"/oradata/ORCL/test02.dbf";
switch datafile all;
}
executing Memory Script
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed tempfile 1 to /oradata/ORCL_STBY/temp01.dbf in control file
renamed tempfile 2 to /oradata/ORCL_STBY/pdbseed/temp012021-04-11_06-13-50-844-AM.dbf in control file
renamed tempfile 3 to /oradata/ORCL_STBY/BFA6BEE45A1E3605E053AC01A8C0DD20/datafile/o1_mf_temp_j749f5fy_.dbf in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 19-APR-21
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=504 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: using network backup set from service orcl
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00014 to /oradata/ORCL/test02.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 19-APR-21
cataloged datafile copy
datafile copy file name=/oradata/ORCL_STBY/system01.dbf RECID=4 STAMP=1070263316
cataloged datafile copy
datafile copy file name=/oradata/ORCL_STBY/sysaux01.dbf RECID=5 STAMP=1070263317
cataloged datafile copy
datafile copy file name=/oradata/ORCL_STBY/undotbs01.dbf RECID=6 STAMP=1070263317
cataloged datafile copy
datafile copy file name=/oradata/ORCL_STBY/pdbseed/system01.dbf RECID=7 STAMP=1070263317
cataloged datafile copy
datafile copy file name=/oradata/ORCL_STBY/pdbseed/sysaux01.dbf RECID=8 STAMP=1070263318
cataloged datafile copy
datafile copy file name=/oradata/ORCL_STBY/users01.dbf RECID=9 STAMP=1070263318
cataloged datafile copy
datafile copy file name=/oradata/ORCL_STBY/pdbseed/undotbs01.dbf RECID=10 STAMP=1070263318
cataloged datafile copy
datafile copy file name=/oradata/ORCL_STBY/PDB01/o1_mf_system_j749f5d5_.dbf RECID=11 STAMP=1070263318
cataloged datafile copy
datafile copy file name=/oradata/ORCL_STBY/PDB01/o1_mf_sysaux_j749f5fw_.dbf RECID=12 STAMP=1070263318
cataloged datafile copy
datafile copy file name=/oradata/ORCL_STBY/PDB01/o1_mf_undotbs1_j749f5fx_.dbf RECID=13 STAMP=1070263318
cataloged datafile copy
datafile copy file name=/oradata/ORCL_STBY/test01.dbf RECID=14 STAMP=1070263318
cataloged datafile copy
datafile copy file name=/oradata/ORCL/test02.dbf RECID=15 STAMP=1070263318
datafile 14 switched to datafile copy
input datafile copy RECID=15 STAMP=1070263318 file name=/oradata/ORCL/test02.dbf
datafile 1 switched to datafile copy
input datafile copy RECID=4 STAMP=1070263316 file name=/oradata/ORCL_STBY/system01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=5 STAMP=1070263317 file name=/oradata/ORCL_STBY/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=6 STAMP=1070263317 file name=/oradata/ORCL_STBY/undotbs01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=7 STAMP=1070263317 file name=/oradata/ORCL_STBY/pdbseed/system01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=8 STAMP=1070263318 file name=/oradata/ORCL_STBY/pdbseed/sysaux01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=9 STAMP=1070263318 file name=/oradata/ORCL_STBY/users01.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=10 STAMP=1070263318 file name=/oradata/ORCL_STBY/pdbseed/undotbs01.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=11 STAMP=1070263318 file name=/oradata/ORCL_STBY/PDB01/o1_mf_system_j749f5d5_.dbf
datafile 10 switched to datafile copy
input datafile copy RECID=12 STAMP=1070263318 file name=/oradata/ORCL_STBY/PDB01/o1_mf_sysaux_j749f5fw_.dbf
datafile 11 switched to datafile copy
input datafile copy RECID=13 STAMP=1070263318 file name=/oradata/ORCL_STBY/PDB01/o1_mf_undotbs1_j749f5fx_.dbf
datafile 12 switched to datafile copy
input datafile copy RECID=14 STAMP=1070263318 file name=/oradata/ORCL_STBY/test01.dbf
Executing: alter database rename file '/oradata/ORCL/redo01.log' to '/oradata/ORCL_STBY/redo01.log'
Executing: alter database rename file '/oradata/ORCL/redo02.log' to '/oradata/ORCL_STBY/redo02.log'
Executing: alter database rename file '/oradata/ORCL/redo03.log' to '/oradata/ORCL_STBY/redo03.log'
contents of Memory Script:
{
recover database from service 'orcl';
}
executing Memory Script
Starting recover at 19-APR-21
using channel ORA_DISK_1
skipping datafile 5; already restored to SCN 2155383
skipping datafile 6; already restored to SCN 2155383
skipping datafile 8; already restored to SCN 2155383
skipping datafile 14; already restored to SCN 2658548
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using network backup set from service orcl
destination for restore of datafile 00001: /oradata/ORCL_STBY/system01.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using network backup set from service orcl
destination for restore of datafile 00003: /oradata/ORCL_STBY/sysaux01.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using network backup set from service orcl
destination for restore of datafile 00004: /oradata/ORCL_STBY/undotbs01.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using network backup set from service orcl
destination for restore of datafile 00007: /oradata/ORCL_STBY/users01.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using network backup set from service orcl
destination for restore of datafile 00009: /oradata/ORCL_STBY/PDB01/o1_mf_system_j749f5d5_.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using network backup set from service orcl
destination for restore of datafile 00010: /oradata/ORCL_STBY/PDB01/o1_mf_sysaux_j749f5fw_.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using network backup set from service orcl
destination for restore of datafile 00011: /oradata/ORCL_STBY/PDB01/o1_mf_undotbs1_j749f5fx_.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using network backup set from service orcl
destination for restore of datafile 00012: /oradata/ORCL_STBY/test01.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 19-APR-21
Executing: alter system set standby_file_management=auto
Finished recover at 19-APR-21
方便大家查看,于是记录恢复全过程,通过以上执行过程,可以看到:
发现刷新过后,备库redo log路径已修改,standby log路径未修改,因此手动修改。
查询备库的日志文件路径:
sqlplus / as sysdba
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/oradata/ORCL_STBY/redo03.log
/oradata/ORCL_STBY/redo02.log
/oradata/ORCL_STBY/redo01.log
/oradata/ORCL/standby_redo04.log
/oradata/ORCL/standby_redo05.log
/oradata/ORCL/standby_redo06.log
/oradata/ORCL/standby_redo07.log
关闭备库文件自动管理:
sqlplus / as sysdba
alter system set standby_file_management=MANUAL;
清理standby log:
sqlplus / as sysdba
alter database clear logfile group 4;
alter database clear logfile group 5;
alter database clear logfile group 6;
alter database clear logfile group 7;
修改standby log路径:
sqlplus / as sysdba
alter database rename file '/oradata/ORCL/standby_redo04.log' to '/oradata/ORCL_STBY/standby_redo04.log';
alter database rename file '/oradata/ORCL/standby_redo05.log' to '/oradata/ORCL_STBY/standby_redo05.log';
alter database rename file '/oradata/ORCL/standby_redo06.log' to '/oradata/ORCL_STBY/standby_redo06.log';
alter database rename file '/oradata/ORCL/standby_redo07.log' to '/oradata/ORCL_STBY/standby_redo07.log';
修改完后打开备库文件自动管理:
sqlplus / as sysdba
alter system set standby_file_management=AUTO;
检查主备scn是否一致:
sqlplus / as sysdba
col HXFNM for a100
set line222
select HXFIL File_num,substr(HXFNM,1,40) HXFNM,fhscn from x$kcvfh;
主库切几次归档:
sqlplus / as sysdba
ALTER SYSTEM ARCHIVE LOG CURRENT;
ALTER SYSTEM SWITCH LOGFILE;
开启备库应用日志:
sqlplus / as sysdba
alter database open;
alter pluggable database all open;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
查看备库同步是否正常:
sqlplus / as sysdba
set line222
col member for a60
select t1.group#,t1.thread#,t1.bytes/1024/1024,t1.status,t2.member from gv$standby_log t1,gv$logfile t2 where t1.group#=t2.group#;
主库插入数据:
sqlplus test/test@pdb01
insert into test values (999);
commit;
备库查询是否实时同步:
sqlplus / as sysdba
alter session set container=pdb01;
select * from test.test;
ID
----------
1
2
999
至此,18C的GAP也已修复,可以看到Oracle随着版本升级,越来越自动化的操作,意味着运维自动化的未来。
参考文档: