签到成功

知道了

CNDBA社区CNDBA社区

Linux 7.7 平台 Oracle 19.3 物理Data Guard 搭建手册

2020-03-10 21:27 4358 0 原创 Oracle 19c
作者: dave

之前的博客我们了解Oracle 19.3 的安装和 RU的升级操作,如下:

Linux 7.4 平台下 Oracle 19.3 单实例安装手册
https://www.cndba.cn/dave/article/3427
Oracle 19c 单实例 RU 从19.3.0 升级到19.6.0 操作手册
https://www.cndba.cn/dave/article/4065
Oracle 12.2 家族的补丁 RU 和 RUR 说明
https://www.cndba.cn/dave/article/4063

Oracle 19c 的DG 环境搭建与18c 相同,关于18c 物理DG环境搭建参考之前的博客:

http://www.cndba.cn/cndba/dave/article/4067
http://www.cndba.cn/cndba/dave/article/4067http://www.cndba.cn/cndba/dave/article/4067

Oracle 18c Data Guard 搭建手册
https://www.cndba.cn/dave/article/2995http://www.cndba.cn/cndba/dave/article/4067

本片博客我们来学习下Oracle 19.3 物理DG的搭建。http://www.cndba.cn/cndba/dave/article/4067

1 环境说明

这里准备2台虚拟机,操作系统安装Redhat 7.7。 其他信息规划如下:

源数据库 目标数据库
IP地址 192.168.74.203 192.168.74.204
数据库SID cndba cndba
DB_UNIQUE_NAME dave_p dave_s

在2台虚拟机分别安装19.3 的数据库软件,主库创建CDB实例 cndba,PDB实例:dave_p。 备库只安装数据库软件,不创建实例。

软件安装的具体过程这里不在描述,请参考博客:

Linux 7.4 平台下 Oracle 19.3 单实例安装手册
https://www.cndba.cn/dave/article/3427

2 主库启动FORCE LOGGING

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 DAVE                           READ WRITE NO
SQL> col name for a20
SQL> select name,open_mode from v$pdbs;

NAME                 OPEN_MODE
-------------------- ------------------------------
PDB$SEED             READ ONLY
DAVE                 READ WRITE

SQL> select force_logging from v$database;

FORCE_LOGGING
--------------------------------------------------------------------------------
NO

SQL> alter database force logging;

Database altered.

SQL> select force_logging from v$database;

FORCE_LOGGING
--------------------------------------------------------------------------------
YES

SQL>

3 主库启动归档模式

SQL> archive log list;
Database log mode           No Archive Mode
Automatic archival           Disabled
Archive destination           USE_DB_RECOVERY_FILE_DEST
SQL> alter system set log_archive_dest_1='location=/u01/archivelog/' scope=spfile ;
System altered.
SQL>alter system set log_archive_format='arch_%t_%s_%r.arc' scope=spfile;
System altered.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 DAVE                           MOUNTED
SQL> alter pluggable database dave open;

Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 DAVE                           READ WRITE NO
SQL>

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/archivelog/
Oldest online log sequence     7
Next log sequence to archive   9
Current log sequence           9
SQL>

4 在主库添加 standby redo logfile

在Oracle 19c的多租户架构里,online redo log 和控制文件是保存在CDB中的,PDB中只有运行需要的数据文件,所以我们这里加standby redo log,也是在CDB中加。

SQL> select  group#, members,  bytes  from v$log;

    GROUP#    MEMBERS      BYTES
---------- ---------- ----------
         1          2  209715200
         2          2  209715200
         3          2  209715200

注意这里online redo log大小的变化,详细参考:

Oracle 12cR2 默认 online redo log 的大小从50M 增加到 200M
https://www.cndba.cn/dave/article/2054

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/CNDBA/onlinelog/o1_mf_3_h6go2p4q_.log
/u01/app/oracle/fast_recovery_area/CNDBA/onlinelog/o1_mf_3_h6go2pn6_.log
/u01/app/oracle/oradata/CNDBA/onlinelog/o1_mf_2_h6go2p47_.log
/u01/app/oracle/fast_recovery_area/CNDBA/onlinelog/o1_mf_2_h6go2ph2_.log
/u01/app/oracle/oradata/CNDBA/onlinelog/o1_mf_1_h6go2p3k_.log
/u01/app/oracle/fast_recovery_area/CNDBA/onlinelog/o1_mf_1_h6go2pgm_.log

6 rows selected.


SQL> alter  database add  standby  logfile '/u01/app/oracle/oradata/CNDBA/stdredo01.log'  size 200M;
SQL> alter  database add  standby  logfile '/u01/app/oracle/oradata/CNDBA/stdredo02.log'  size 200M;
SQL> alter  database add  standby  logfile '/u01/app/oracle/oradata/CNDBA/stdredo03.log'  size 200M;
SQL> alter  database add  standby  logfile '/u01/app/oracle/oradata/CNDBA/stdredo04.log'  size 200M;

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/CNDBA/onlinelog/o1_mf_3_h6go2p4q_.log
/u01/app/oracle/fast_recovery_area/CNDBA/onlinelog/o1_mf_3_h6go2pn6_.log
/u01/app/oracle/oradata/CNDBA/onlinelog/o1_mf_2_h6go2p47_.log
/u01/app/oracle/fast_recovery_area/CNDBA/onlinelog/o1_mf_2_h6go2ph2_.log
/u01/app/oracle/oradata/CNDBA/onlinelog/o1_mf_1_h6go2p3k_.log
/u01/app/oracle/fast_recovery_area/CNDBA/onlinelog/o1_mf_1_h6go2pgm_.log
/u01/app/oracle/oradata/CNDBA/stdredo01.log
/u01/app/oracle/oradata/CNDBA/stdredo02.log
/u01/app/oracle/oradata/CNDBA/stdredo03.log
/u01/app/oracle/oradata/CNDBA/stdredo04.log

10 rows selected.

5 在主库创建pfile 文件并修改pfile 内容

SQL>  create pfile from spfile;
File created.
在pfile中添加如下内容:
[oracle@www.cndba.cn1 ~]$ cd /u01/app/oracle/product/19.3.0/dbhome_1/dbs/
[oracle@www.cndba.cn1 dbs]$ ls
hc_cndba.dat  initcndba.ora  init.ora  lkCNDBA  orapwcndba  spfilecndba.ora
[oracle@www.cndba.cn1 dbs]$ vim initcndba.ora
[oracle@www.cndba.cn1 dbs]$ cat initcndba.ora

### add for dg
*.db_unique_name='cndba_p'
*.log_archive_config='dg_config=(cndba_p, cndba_s)'
*.log_archive_dest_1='location=/u01/archivelog/ valid_for=(all_logfiles,all_roles) db_unique_name=cndba_p'
*.log_archive_dest_2='service=cndba_s lgwr affirm sync valid_for=(online_logfiles,primary_role) db_unique_name=cndba_s'
*.log_archive_dest_state_1=enable 
*.log_archive_dest_state_2=enable 
*.standby_file_management='auto'
*.fal_server='cndba_s'
#*.log_file_name_convert='/u01/app/oracle/oradata/cndba','/u01/app/oracle/oradata/cndba' 
#*.db_file_name_convert='/u01/app/oracle/oradata/cndba','/u01/app/oracle/oradata/cndba'

用新参数重启数据库:

http://www.cndba.cn/cndba/dave/article/4067

[oracle@www.cndba.cn1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Mar 10 20:05:21 2020
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> create spfile from pfile;

File created.

SQL> startup
ORACLE instance started.

Total System Global Area 1962932472 bytes
Fixed Size                  9136376 bytes
Variable Size            1107296256 bytes
Database Buffers          838860800 bytes
Redo Buffers                7639040 bytes
Database mounted.
Database opened.
SQL>

6 分别在主备库配置监听并启动

[oracle@www.cndba.cn1 admin]$ pwd
/u01/app/oracle/product/19.3.0/dbhome_1/network/admin
[oracle@www.cndba.cn1 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = cndba)
      (ORACLE_HOME = /u01/app/oracle/product/19.3.0/dbhome_1)
      (SID_NAME = cndba)
    )
  )

LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dg1)(PORT = 1521))
  )

ADR_BASE_LISTENER = /u01/app/oracle

[oracle@www.cndba.cn1 admin]$

[oracle@www.cndba.cn1 admin]$ lsnrctl reload

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 10-MAR-2020 20:20:15

Copyright (c) 1991, 2019, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dg1)(PORT=1521)))
The command completed successfully
[oracle@www.cndba.cn1 admin]$

7 分别在主备库配置tnsnames.ora

[oracle@www.cndba.cn1 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

CNDBA_S =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.74.204)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = cndba)
    )
  )

CNDBA_P =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.74.203)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = cndba)
    )
  )

[oracle@www.cndba.cn1 admin]$

配置完成后,使用tnsping 命令校验,切记要相互ping 通方可继续后面的操作,如果不通的话检查防火墙有没有关或者1521 端口有没有关,tnsname.ora 配置是否正确,一般是这些原因,防火墙占多数原因。

[oracle@www.cndba.cn2 admin]$ tnsping cndba_p

TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 10-MAR-2020 20:23:58

Copyright (c) 1997, 2019, Oracle.  All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.74.203)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = cndba)))
OK (0 msec)
[oracle@www.cndba.cn2 admin]$ tnsping cndba_s

TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 10-MAR-2020 20:23:59

Copyright (c) 1997, 2019, Oracle.  All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.74.204)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = cndba)))
OK (0 msec)
[oracle@www.cndba.cn2 admin]$

8 将主库的口令文件copy到备库

这里主备库的CDB实例相同,如果不同,可以使用orapwd命令重建。

[oracle@www.cndba.cn1 dbs]$ scp orapwcndba dg2:`pwd`
oracle@www.cndba.cn2's password:
orapwcndba                                                                                              100% 2048     2.8MB/s   00:00
[oracle@www.cndba.cn1 dbs]$

9 将主库的参数文件copy到备库并修改

--主库操作
[oracle@www.cndba.cn1 dbs]$ scp initcndba.ora dg2:`pwd`
oracle@www.cndba.cn2's password:
initcndba.ora                                                                                           100% 1810     2.7MB/s   00:00
[oracle@www.cndba.cn1 dbs]$

--备库修改参数文件添加以下内容在重新生成spfile:
### add for dg
*.db_unique_name='cndba_s'
*.log_archive_config='dg_config=(cndba_p, cndba_s)'
*.log_archive_dest_1='location=/u01/archivelog/ valid_for=(all_logfiles,all_roles) db_unique_name=cndba_s'
*.log_archive_dest_2='service=cndba_p lgwr affirm sync valid_for=(online_logfiles,primary_role) db_unique_name=cndba_p'
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
*.standby_file_management='auto'
*.fal_server='cndba_p'

生成spfile:
[oracle@www.cndba.cn2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Mar 10 20:42:29 2020
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> create spfile from pfile;

File created.

SQL>

10 在备库创建必要的目录

根据pfile 文件,将该文件中出现的所有路径全部检查一遍,如果不存在,则创建之。 否在启动备库会报错。

[oracle@www.cndba.cn2 dbs]$ mkdir -p /u01/app/oracle/admin/cndba/adump
[oracle@www.cndba.cn2 dbs]$ mkdir -p /u01/app/oracle/oradata/CNDBA/controlfile
[oracle@www.cndba.cn2 dbs]$ mkdir -p /u01/app/oracle/fast_recovery_area/CNDBA/controlfile

11 用spfile 将备库启动到nomount 状态

[oracle@www.cndba.cn2 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Mar 10 20:45:21 2020
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount
ORACLE instance started.

Total System Global Area 1962932472 bytes
Fixed Size                  9136376 bytes
Variable Size            1107296256 bytes
Database Buffers          838860800 bytes
Redo Buffers                7639040 bytes
SQL>

12 开始进行Active duplicate

这里可能遇到以下错误,供参考:

Oracle 18c ADG RMAN duplicate ORA-01017错误解决方法
https://www.cndba.cn/dave/article/2994

[oracle@www.cndba.cn2 ~]$  rman target sys/oracle@cndba_p auxiliary sys/oracle@cndba_s;

Recovery Manager: Release 19.0.0.0.0 - Production on Tue Mar 10 20:50:35 2020
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database: CNDBA (DBID=299163283)
connected to auxiliary database: CNDBA (not mounted)

RMAN> duplicate target database for standby from active database nofilenamecheck dorecover;

Starting Duplicate Db at 2020:03:1020:50:51
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=10 device type=DISK
current log archived

contents of Memory Script:
{
   backup as copy reuse
   passwordfile auxiliary format  '/u01/app/oracle/product/19.3.0/dbhome_1/dbs/orapwcndba'   ;
}
executing Memory Script

Starting backup at 2020:03:1020:50:51
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=146 device type=DISK
Finished backup at 2020:03:1020:50:54
duplicating Online logs to Oracle Managed File (OMF) location
duplicating Datafiles to Oracle Managed File (OMF) location

contents of Memory Script:
{
   sql clone "alter system set  control_files =
  ''/u01/app/oracle/oradata/CNDBA/controlfile/o1_mf_h6go2myb_.ctl'', ''/u01/app/oracle/fast_recovery_area/CNDBA/controlfile/o1_mf_h6go2mz4_.ctl'' comment=
 ''Set by RMAN'' scope=spfile";
   restore clone from service  'cndba_p' standby controlfile;
}
executing Memory Script

sql statement: alter system set  control_files =   ''/u01/app/oracle/oradata/CNDBA/controlfile/o1_mf_h6go2myb_.ctl'', ''/u01/app/oracle/fast_recovery_area/CNDBA/controlfile/o1_mf_h6go2mz4_.ctl'' comment= ''Set by RMAN'' scope=spfile

Starting restore at 2020:03:1020:50:55
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cndba_p
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/CNDBA/controlfile/o1_mf_h6go2myb_.ctl
output file name=/u01/app/oracle/fast_recovery_area/CNDBA/controlfile/o1_mf_h6go2mz4_.ctl
Finished restore at 2020:03:1020:50:58

contents of Memory Script:
{
   sql clone 'alter database mount standby database';
}
executing Memory Script

sql statement: alter database mount standby database

contents of Memory Script:
{
   set newname for clone tempfile  1 to new;
   set newname for clone tempfile  2 to new;
   set newname for clone tempfile  3 to new;
   switch clone tempfile all;
   set newname for clone datafile  1 to new;
   set newname for clone datafile  3 to new;
   set newname for clone datafile  4 to new;
   set newname for clone datafile  5 to new;
   set newname for clone datafile  6 to new;
   set newname for clone datafile  7 to new;
   set newname for clone datafile  8 to new;
   set newname for clone datafile  9 to new;
   set newname for clone datafile  10 to new;
   set newname for clone datafile  11 to new;
   set newname for clone datafile  12 to new;
   restore
   from  nonsparse   from service
 'cndba_p'   clone database
   ;
   sql 'alter system archive log current';
}
executing Memory Script

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

renamed tempfile 1 to /u01/app/oracle/oradata/CNDBA_S/datafile/o1_mf_temp_%u_.tmp in control file
renamed tempfile 2 to /u01/app/oracle/oradata/CNDBA_S/A07D3DDE6882372BE053CB4AA8C075F7/datafile/o1_mf_temp_%u_.tmp in control file
renamed tempfile 3 to /u01/app/oracle/oradata/CNDBA_S/A07D60C80C1F3EE0E053CB4AA8C073B5/datafile/o1_mf_temp_%u_.tmp 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

Starting restore at 2020:03:1020:51:02
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cndba_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/CNDBA_S/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cndba_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/CNDBA_S/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cndba_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/CNDBA_S/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cndba_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/CNDBA_S/A07D3DDE6882372BE053CB4AA8C075F7/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cndba_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/CNDBA_S/A07D3DDE6882372BE053CB4AA8C075F7/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cndba_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/CNDBA_S/datafile/o1_mf_users_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cndba_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/CNDBA_S/A07D3DDE6882372BE053CB4AA8C075F7/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cndba_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00009 to /u01/app/oracle/oradata/CNDBA_S/A07D60C80C1F3EE0E053CB4AA8C073B5/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cndba_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00010 to /u01/app/oracle/oradata/CNDBA_S/A07D60C80C1F3EE0E053CB4AA8C073B5/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cndba_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00011 to /u01/app/oracle/oradata/CNDBA_S/A07D60C80C1F3EE0E053CB4AA8C073B5/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cndba_p
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00012 to /u01/app/oracle/oradata/CNDBA_S/A07D60C80C1F3EE0E053CB4AA8C073B5/datafile/o1_mf_users_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 2020:03:1020:51:35

sql statement: alter system archive log current
current log archived

contents of Memory Script:
{
   restore clone force from service  'cndba_p'
           archivelog from scn  2378139;
   switch clone datafile all;
}
executing Memory Script

Starting restore at 2020:03:1020:51:35
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using network backup set from service cndba_p
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=11
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using network backup set from service cndba_p
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=12
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using network backup set from service cndba_p
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=13
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 2020:03:1020:51:38

datafile 1 switched to datafile copy
input datafile copy RECID=15 STAMP=1034715098 file name=/u01/app/oracle/oradata/CNDBA_S/datafile/o1_mf_system_h6h39q6b_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=16 STAMP=1034715098 file name=/u01/app/oracle/oradata/CNDBA_S/datafile/o1_mf_sysaux_h6h39y8h_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=17 STAMP=1034715098 file name=/u01/app/oracle/oradata/CNDBA_S/datafile/o1_mf_undotbs1_h6h3b5cw_.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=18 STAMP=1034715098 file name=/u01/app/oracle/oradata/CNDBA_S/A07D3DDE6882372BE053CB4AA8C075F7/datafile/o1_mf_system_h6h3b8hs_.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=19 STAMP=1034715098 file name=/u01/app/oracle/oradata/CNDBA_S/A07D3DDE6882372BE053CB4AA8C075F7/datafile/o1_mf_sysaux_h6h3bcj7_.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=20 STAMP=1034715098 file name=/u01/app/oracle/oradata/CNDBA_S/datafile/o1_mf_users_h6h3bgkx_.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=21 STAMP=1034715098 file name=/u01/app/oracle/oradata/CNDBA_S/A07D3DDE6882372BE053CB4AA8C075F7/datafile/o1_mf_undotbs1_h6h3bhq3_.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=22 STAMP=1034715098 file name=/u01/app/oracle/oradata/CNDBA_S/A07D60C80C1F3EE0E053CB4AA8C073B5/datafile/o1_mf_system_h6h3bjvm_.dbf
datafile 10 switched to datafile copy
input datafile copy RECID=23 STAMP=1034715098 file name=/u01/app/oracle/oradata/CNDBA_S/A07D60C80C1F3EE0E053CB4AA8C073B5/datafile/o1_mf_sysaux_h6h3bkx2_.dbf
datafile 11 switched to datafile copy
input datafile copy RECID=24 STAMP=1034715098 file name=/u01/app/oracle/oradata/CNDBA_S/A07D60C80C1F3EE0E053CB4AA8C073B5/datafile/o1_mf_undotbs1_h6h3bo0p_.dbf
datafile 12 switched to datafile copy
input datafile copy RECID=25 STAMP=1034715098 file name=/u01/app/oracle/oradata/CNDBA_S/A07D60C80C1F3EE0E053CB4AA8C073B5/datafile/o1_mf_users_h6h3bp1g_.dbf

contents of Memory Script:
{
   set until scn  2378573;
   recover
   standby
   clone database
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 2020:03:1020:51:38
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 11 is already on disk as file /u01/archivelog/arch_1_11_1034700502.arc
archived log for thread 1 with sequence 12 is already on disk as file /u01/archivelog/arch_1_12_1034700502.arc
archived log for thread 1 with sequence 13 is already on disk as file /u01/archivelog/arch_1_13_1034700502.arc
archived log file name=/u01/archivelog/arch_1_11_1034700502.arc thread=1 sequence=11
archived log file name=/u01/archivelog/arch_1_12_1034700502.arc thread=1 sequence=12
archived log file name=/u01/archivelog/arch_1_13_1034700502.arc thread=1 sequence=13
media recovery complete, elapsed time: 00:00:01
Finished recover at 2020:03:1020:51:40

contents of Memory Script:
{
   delete clone force archivelog all;
}
executing Memory Script

released channel: ORA_DISK_1
released channel: ORA_AUX_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=146 device type=DISK
deleted archived log
archived log file name=/u01/archivelog/arch_1_11_1034700502.arc RECID=1 STAMP=1034715095
deleted archived log
archived log file name=/u01/archivelog/arch_1_12_1034700502.arc RECID=2 STAMP=1034715096
deleted archived log
archived log file name=/u01/archivelog/arch_1_13_1034700502.arc RECID=3 STAMP=1034715097
Deleted 3 objects

Finished Duplicate Db at 2020:03:1020:51:45

RMAN>

13 打开备库并并启动apply

duplicate 完成之后,备库是mount的。

SQL>  select open_mode from v$database;

OPEN_MODE
------------------------------------------------------------
MOUNTED

SQL> alter database open;

Database altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 DAVE                           READ ONLY  NO
SQL>



--查看主库
SQL> set lines 150
SQL> col log_mode for a15
SQL> col open_mode for a15
SQL> col database_role for a20
SQL> select log_mode,open_mode ,database_role from v$database;

LOG_MODE        OPEN_MODE       DATABASE_ROLE
--------------- --------------- ---------------
ARCHIVELOG      READ WRITE      PRIMARY

SQL>


--查看备库
SQL> select log_mode,open_mode ,database_role from v$database;

LOG_MODE        OPEN_MODE       DATABASE_ROLE
--------------- --------------- --------------------
ARCHIVELOG      READ ONLY       PHYSICAL STANDBY

SQL>



--启动日志应用
SQL> alter database recover managed standby database disconnect;
Database altered.

SQL> select open_mode from v$database;
OPEN_MODE
------------------------------
READ ONLY WITH APPLY

SQL>

14 验证DG

主库:http://www.cndba.cn/cndba/dave/article/4067

SQL> col status for a15
SQL> col error for a20
SQL> select status,error from v$archive_dest where dest_id=2;

STATUS          ERROR
--------------- --------------------
VALID

这里可能会遇到如下错误:http://www.cndba.cn/cndba/dave/article/4067

Oracle 19c Data Guard ORA-12154 错误解决方法
https://www.cndba.cn/dave/article/4066http://www.cndba.cn/cndba/dave/article/4067http://www.cndba.cn/cndba/dave/article/4067

SQL>  alter system switch logfile;

System altered.

SQL>  select sequence#,applied from v$archived_log order by 1;

 SEQUENCE# APPLIED
---------- ---------------------------
         9 NO
        10 NO
        11 NO
        12 NO
        13 NO
        14 NO
        14 YES
        15 YES
        15 NO
        16 YES
        16 NO

 SEQUENCE# APPLIED
---------- ---------------------------
        17 NO
        17 NO

13 rows selected.

备库:

SQL> select sequence#,applied from v$archived_log;

 SEQUENCE# APPLIED
---------- ---------------------------
        11 YES
        12 YES
        13 YES
        15 YES
        14 YES
        16 YES
        17 IN-MEMORY

7 rows selected.

SQL>

同步正常。

15 DG 模式切换

DG的模式切换之前参考18c,这里不再单独描述。

Oracle 18c Data Guard 切换保护模式 和 主备库角色操作手册
https://www.cndba.cn/dave/article/2996

版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
dave

dave

关注

人的一生应该是这样度过的:当他回首往事的时候,他不会因为虚度年华而悔恨,也不会因为碌碌无为而羞耻;这样,在临死的时候,他就能够说:“我的整个生命和全部精力,都已经献给世界上最壮丽的事业....."

  • 2296
    原创
  • 3
    翻译
  • 582
    转载
  • 198
    评论
  • 访问:8504341次
  • 积分:4477
  • 等级:核心会员
  • 排名:第1名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ