Oracle 12c DG配置(两节点)

一、系统版本

1.操作系统

[oracle@DB1 ~]$ cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)

2.数据库

Oracle 12c DG配置(两节点)_第1张图片

3.节点情况

DB1:


DB2:

序号 主库(10.1.1.100) 备库(10.1.1.130)
1 sid:orcl sid:orcl
2 db_unique_name='orcl_pd' db_unique_name='orcl_st'

 

注:12c的物理DG是基于cdb级别的;

二、安装数据库(安装主库软件和建库,备库只需安装数据库软件)

见安装数据库章节;(此处略)

三、配置主库

1.归档

关机 shutdown immediate;

启动数据库到mount状态 startup mount;

启动归档:alter database archivelog;

启动数据库:alter database open;

设置归档目录:

SQL>alter system set log_archive_dest_1='location=/archivelog1/' scope=spfile ;
SQL>alter system set log_archive_format='arch_%t_%s_%r.arc' scope=spfile;

2.强制日志

SQL> alter database force logging;

3.创建standby redo log日志组

SQL> alter  database add  standby  logfile '/oradata/orcl/stdredo01.log'  size 200M;
SQL> alter  database add  standby  logfile '/oradata/orcl/stdredo01.log'  size 200M;
SQL> alter  database add  standby  logfile '/oradata/orcl/stdredo01.log'  size 200M;
SQL> alter  database add  standby  logfile '/oradata/orcl/stdredo01.log'  size 200M;

Oracle 12c DG配置(两节点)_第2张图片

4.修改参数文件

创建参数文件:create pfile='/home/oracle/pfile.ora' from spfile;

[oracle@DB1 ~]$ vi pfile.ora
[oracle@DB1 ~]$ cat pfile.ora
orcl.__data_transfer_cache_size=0
orcl.__db_cache_size=587202560
orcl.__inmemory_ext_roarea=0
orcl.__inmemory_ext_rwarea=0
orcl.__java_pool_size=16777216
orcl.__large_pool_size=33554432
orcl.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=553648128
orcl.__sga_target=1040187392
orcl.__shared_io_pool_size=50331648
orcl.__shared_pool_size=335544320
orcl.__streams_pool_size=0
*._catalog_foreign_restore=FALSE
*._restore_create_directory=FALSE
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.audit_trail='db'
*.compatible='12.2.0'
*.control_file_record_keep_time=30
*.control_files='/oradata/orcl/control01.ctl','/oradata/orcl/control02.ctl'
*.db_block_size=8192
*.db_file_name_convert='/oradata/orcl','/oradata/orcl'
*.db_name='orcl'
*.db_recovery_file_dest='/archivelog'
*.db_recovery_file_dest_size=10737418240
*.db_unique_name='orcl_pd'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.enable_ddl_logging=TRUE
*.enable_pluggable_database=true
*.fal_server='orcl_st'
*.local_listener='LISTENER_ORCL'
*.log_archive_config='dg_config=(orcl_pd,orcl_st,orcl_bt)'
*.log_archive_dest_1='location=/archivelog1/'
*.log_archive_dest_2='service=orcl_st lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl_st'
*.log_archive_dest_state_1='enable'
*.log_archive_dest_state_2='enable'

*.log_archive_format='arch_%t_%s_%r.arc'

*.log_file_name_convert='/oradata/orcl','/oradata/orcl' 
*.db_file_name_convert='/oradata/orcl','/oradata/orcl'

*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='auto'

*.memory_target=1507m
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.optimizer_capture_sql_plan_baselines=TRUE
*.processes=500
*.undo_tablespace='UNDOTBS1'

5.修改listener.ora和tnsname.ora文件并测试

[oracle@DB1 admin]$ cat listener.ora 
# listener.ora Network Configuration File: /u01/app/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
ADR_BASE_LISTENER = /u01/app/oracle

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.100)(PORT = 1521))
    )
  )


SID_LIST_LISTENER =  
  (SID_LIST =  
    (SID_DESC =  
      (GLOBAL_DBNAME = orcl)  
      (ORACLE_HOME = /u01/app/oracle/product/12.2.0.1/dbhome_1)  
      (SID_NAME = orcl)  
    ) 
       (SID_DESC =
       (GLOBAL_DBNAME = pdb01)  #pdb01
       (SID_NAME = orcl)
    )
        (SID_DESC =
       (GLOBAL_DBNAME = pdb02)  #pdb02
       (SID_NAME = orcl)
    )
        (SID_DESC =
       (GLOBAL_DBNAME = pdb03)  #pdb03
       (SID_NAME = orcl)
    ) 
  )

[oracle@DB1 admin]$ cat tnsnames.ora 
ORCL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.100)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )

pdb01 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.100)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = pdb01)  #pdbs
    )
  )

pdb02 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.100)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = pdb02)  #pdbs
    )
  )

pdb03 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.100)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = pdb03)  #pdbs
    )
  )


ORCL_ST =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.130)(PORT = 1521))
    )
    (CONNECT_DATA =
       (SERVER = DEDICATED)
       (SERVICE_NAME = orcl)
    )
  )

ORCL_PD =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.100)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

ORCL_BT =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.140)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

[oracle@DB1 admin]$ cat sqlnet.ora 
#NAMES.DIRECTORY_PATH=(tnsnames,ezconnect)
SQLNET.AUTHENTICATION_SERVICES=(NONE)
SQLNET.ALLOWED_LOGON_VERSION=8
SQLNET.ALLOWED_LOGON_VERSION_CLIENT=8
SQLNET.ALLOWED_LOGON_VERSION_SERVE=10
 

lsnrctl  stop

lsnrctl start

Oracle 12c DG配置(两节点)_第3张图片

5.拷贝参数文件,密码文件到备机

Oracle 12c DG配置(两节点)_第4张图片

四、备库

1.修改参数文件

[oracle@DB2 ~]$ cat pfile.ora 
orcl.__data_transfer_cache_size=0
orcl.__db_cache_size=603979776
orcl.__inmemory_ext_roarea=0
orcl.__inmemory_ext_rwarea=0
orcl.__java_pool_size=16777216
orcl.__large_pool_size=33554432
orcl.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=553648128
orcl.__sga_target=1040187392
orcl.__shared_io_pool_size=50331648
orcl.__shared_pool_size=318767104
orcl.__streams_pool_size=0
*._catalog_foreign_restore=FALSE
*._restore_create_directory=FALSE
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.audit_trail='db'
*.compatible='12.2.0'
*.control_file_record_keep_time=30
*.control_files='/oradata/orcl/control01.ctl','/oradata/orcl/control02.ctl'
*.db_block_size=8192
*.db_name='orcl'
*.db_recovery_file_dest_size=25g
*.db_recovery_file_dest='/archivelog'
### add for dg
*.db_name='orcl'
*.db_unique_name='orcl_st'
*.log_archive_config='dg_config=(orcl_pd,orcl_st)'
*.log_archive_dest_1='location=/archivelog1 valid_for=(all_logfiles,all_roles) db_unique_name=orcl_st'
*.log_archive_dest_2='service=orcl_pd lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl_pd'
*.log_archive_dest_state_1=enable 
*.log_archive_dest_state_2=enable 
*.standby_file_management='auto'
*.fal_server='orcl_pd'
*.log_file_name_convert='/oradata/orcl','/oradata/orcl' 
*.db_file_name_convert='/oradata/orcl','/oradata/orcl'

*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.enable_ddl_logging=TRUE
*.enable_pluggable_database=true
*.local_listener='LISTENER_ORCL'
*.log_archive_dest_1='location=/archivelog1/'
*.log_archive_format='arch_%t_%s_%r.arc'
*.memory_target=1507m
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.optimizer_capture_sql_plan_baselines=TRUE
*.processes=500
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'

2.修改listener.ora和tnsname.ora文件并测试

[oracle@DB2 admin]$ cat listener.ora 
# listener.ora Network Configuration File: /u01/app/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
ADR_BASE_LISTENER = /u01/app/oracle

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.130)(PORT = 1521))
    )
  )


SID_LIST_LISTENER =  
  (SID_LIST =  
    (SID_DESC =  
      (GLOBAL_DBNAME = orcl)  
      (ORACLE_HOME = /u01/app/oracle/product/12.2.0.1/dbhome_1)  
      (SID_NAME = orcl)  
    )  
       (SID_DESC =
       (GLOBAL_DBNAME = pdb01)  #pdb01
       (SID_NAME = orcl)
    )
        (SID_DESC =
       (GLOBAL_DBNAME = pdb02)  #pdb02
       (SID_NAME = orcl)
    )
        (SID_DESC =
       (GLOBAL_DBNAME = pdb03)  #pdb03
       (SID_NAME = orcl)
    )

 )

[oracle@DB2 admin]$ cat tnsnames.ora 
ORCL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.130)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )

pdb01 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.130)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = pdb01)  #pdbs
    )
  )

pdb02 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.130)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = pdb02)  #pdbs
    )
  )

pdb03 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.130)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = pdb03)  #pdbs
    )
  )


ORCL_ST =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.130)(PORT = 1521))
    )
    (CONNECT_DATA =
       (SERVER = DEDICATED)
       (SERVICE_NAME = orcl)
    )
  )

ORCL_PD =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.100)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

[oracle@DB2 admin]$ cat sqlnet.ora
#NAMES.DIRECTORY_PATH=(tnsnames,ezconnect)
SQLNET.AUTHENTICATION_SERVICES=(NONE)
SQLNET.ALLOWED_LOGON_VERSION=8
SQLNET.ALLOWED_LOGON_VERSION_CLIENT=8
SQLNET.ALLOWED_LOGON_VERSION_SERVE=10

lsnrctl stop

lsnrctl start

Oracle 12c DG配置(两节点)_第5张图片

3.使用在线复制主库数据到备库

Oracle 12c DG配置(两节点)_第6张图片

[oracle@DB2 ~]$ rman target sys/oracle@orcl_pd auxiliary sys/oracle@orcl_st

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

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

Starting Duplicate Db at 15-MAY-20
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=202 device type=DISK
current log archived

contents of Memory Script:
{
   backup as copy reuse
   targetfile  '/u01/app/oracle/product/12.2.0.1/dbhome_1/dbs/orapworcl' auxiliary format 
 '/u01/app/oracle/product/12.2.0.1/dbhome_1/dbs/orapworcl'   ;
}
executing Memory Script

Starting backup at 15-MAY-20
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=16 device type=DISK
Finished backup at 15-MAY-20

contents of Memory Script:
{
   restore clone from service  'orcl_pd' standby controlfile;
}
executing Memory Script

Starting restore at 15-MAY-20
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 orcl_pd
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/oradata/orcl/control01.ctl
output file name=/oradata/orcl/control02.ctl
Finished restore at 15-MAY-20

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 tempfile  1 to 
 "/oradata/orcl/temp01.dbf";
   set newname for tempfile  2 to 
 "/oradata/orcl/pdbseed/temp012020-02-14_23-20-05-073-PM.dbf";
   set newname for tempfile  3 to 
 "/oradata/pdb02/temp012020-02-14_23-20-05-073-PM.dbf";
   set newname for tempfile  4 to 
 "/oradata/pdb03/temp012020-02-14_23-20-05-073-PM.dbf";
   set newname for tempfile  5 to 
 "/oradata/pdb01/temp012020-02-14_23-20-05-073-PM.dbf";
   switch clone tempfile all;
   set newname for datafile  1 to 
 "/oradata/orcl/system01.dbf";
   set newname for datafile  3 to 
 "/oradata/orcl/sysaux01.dbf";
   set newname for datafile  4 to 
 "/oradata/orcl/undotbs01.dbf";
   set newname for datafile  5 to 
 "/oradata/orcl/pdbseed/system01.dbf";
   set newname for datafile  6 to 
 "/oradata/orcl/pdbseed/sysaux01.dbf";
   set newname for datafile  7 to 
 "/oradata/orcl/users01.dbf";
   set newname for datafile  8 to 
 "/oradata/orcl/pdbseed/undotbs01.dbf";
   set newname for datafile  93 to 
 "/oradata/pdb01/system01.dbf";
   set newname for datafile  94 to 
 "/oradata/pdb01/sysaux01.dbf";
   set newname for datafile  101 to 
 "/oradata/pdb01/tbs01.dbf";
   set newname for datafile  103 to 
 "/oradata/pdb01/system01_i1_undo.dbf";
   set newname for datafile  111 to 
 "/oradata/pdb01/tbs.dbf";
   set newname for datafile  123 to 
 "/oradata/pdb02/system01.dbf";
   set newname for datafile  124 to 
 "/oradata/pdb02/sysaux01.dbf";
   set newname for datafile  125 to 
 "/oradata/pdb02/tbs01.dbf";
   set newname for datafile  126 to 
 "/oradata/pdb02/system01_i1_undo.dbf";
   set newname for datafile  127 to 
 "/oradata/pdb02/tbs.dbf";
   set newname for datafile  128 to 
 "/oradata/pdb03/system01.dbf";
   set newname for datafile  129 to 
 "/oradata/pdb03/sysaux01.dbf";
   set newname for datafile  130 to 
 "/oradata/pdb03/tbs01.dbf";
   set newname for datafile  131 to 
 "/oradata/pdb03/system01_i1_undo.dbf";
   set newname for datafile  132 to 
 "/oradata/pdb03/tbs.dbf";
   set newname for datafile  133 to 
 "/home/oracle/id.dbf";
   restore
   from  nonsparse   from service 
 'orcl_pd'   clone database
   ;
   sql 'alter system archive log current';
}
executing Memory Script

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

renamed tempfile 1 to /oradata/orcl/temp01.dbf in control file
renamed tempfile 2 to /oradata/orcl/pdbseed/temp012020-02-14_23-20-05-073-PM.dbf in control file
renamed tempfile 3 to /oradata/pdb02/temp012020-02-14_23-20-05-073-PM.dbf in control file
renamed tempfile 4 to /oradata/pdb03/temp012020-02-14_23-20-05-073-PM.dbf in control file
renamed tempfile 5 to /oradata/pdb01/temp012020-02-14_23-20-05-073-PM.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

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 15-MAY-20
using channel ORA_AUX_DISK_1

skipping datafile 5; already restored to SCN 7366440
skipping datafile 6; already restored to SCN 7366440
skipping datafile 8; already restored to SCN 7366440
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /oradata/orcl/system01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00003 to /oradata/orcl/sysaux01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:08
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00004 to /oradata/orcl/undotbs01.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 orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00007 to /oradata/orcl/users01.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 orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00093 to /oradata/pdb01/system01.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 orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00094 to /oradata/pdb01/sysaux01.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 orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00101 to /oradata/pdb01/tbs01.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 orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00103 to /oradata/pdb01/system01_i1_undo.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 orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00111 to /oradata/pdb01/tbs.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 orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00123 to /oradata/pdb02/system01.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 orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00124 to /oradata/pdb02/sysaux01.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 orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00125 to /oradata/pdb02/tbs01.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 orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00126 to /oradata/pdb02/system01_i1_undo.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 orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00127 to /oradata/pdb02/tbs.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 orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00128 to /oradata/pdb03/system01.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 orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00129 to /oradata/pdb03/sysaux01.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 orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00130 to /oradata/pdb03/tbs01.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 orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00131 to /oradata/pdb03/system01_i1_undo.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 orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00132 to /oradata/pdb03/tbs.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 orcl_pd
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00133 to /home/oracle/id.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 15-MAY-20

sql statement: alter system archive log current
current log archived

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

Starting restore at 15-MAY-20
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 orcl_pd
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=65
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 orcl_pd
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=66
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 orcl_pd
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=67
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 15-MAY-20

datafile 1 switched to datafile copy
input datafile copy RECID=8 STAMP=1040510943 file name=/oradata/orcl/system01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=9 STAMP=1040510943 file name=/oradata/orcl/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=10 STAMP=1040510943 file name=/oradata/orcl/undotbs01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=11 STAMP=1040510943 file name=/oradata/orcl/pdbseed/system01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=12 STAMP=1040510943 file name=/oradata/orcl/pdbseed/sysaux01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=13 STAMP=1040510943 file name=/oradata/orcl/users01.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=14 STAMP=1040510943 file name=/oradata/orcl/pdbseed/undotbs01.dbf
datafile 93 switched to datafile copy
input datafile copy RECID=15 STAMP=1040510943 file name=/oradata/pdb01/system01.dbf
datafile 94 switched to datafile copy
input datafile copy RECID=16 STAMP=1040510943 file name=/oradata/pdb01/sysaux01.dbf
datafile 101 switched to datafile copy
input datafile copy RECID=17 STAMP=1040510943 file name=/oradata/pdb01/tbs01.dbf
datafile 103 switched to datafile copy
input datafile copy RECID=18 STAMP=1040510943 file name=/oradata/pdb01/system01_i1_undo.dbf
datafile 111 switched to datafile copy
input datafile copy RECID=19 STAMP=1040510943 file name=/oradata/pdb01/tbs.dbf
datafile 123 switched to datafile copy
input datafile copy RECID=20 STAMP=1040510943 file name=/oradata/pdb02/system01.dbf
datafile 124 switched to datafile copy
input datafile copy RECID=21 STAMP=1040510943 file name=/oradata/pdb02/sysaux01.dbf
datafile 125 switched to datafile copy
input datafile copy RECID=22 STAMP=1040510943 file name=/oradata/pdb02/tbs01.dbf
datafile 126 switched to datafile copy
input datafile copy RECID=23 STAMP=1040510943 file name=/oradata/pdb02/system01_i1_undo.dbf
datafile 127 switched to datafile copy
input datafile copy RECID=24 STAMP=1040510943 file name=/oradata/pdb02/tbs.dbf
datafile 128 switched to datafile copy
input datafile copy RECID=25 STAMP=1040510943 file name=/oradata/pdb03/system01.dbf
datafile 129 switched to datafile copy
input datafile copy RECID=26 STAMP=1040510943 file name=/oradata/pdb03/sysaux01.dbf
datafile 130 switched to datafile copy
input datafile copy RECID=27 STAMP=1040510943 file name=/oradata/pdb03/tbs01.dbf
datafile 131 switched to datafile copy
input datafile copy RECID=28 STAMP=1040510943 file name=/oradata/pdb03/system01_i1_undo.dbf
datafile 132 switched to datafile copy
input datafile copy RECID=29 STAMP=1040510943 file name=/oradata/pdb03/tbs.dbf
datafile 133 switched to datafile copy
input datafile copy RECID=30 STAMP=1040510943 file name=/home/oracle/id.dbf

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

executing command: SET until clause

Starting recover at 15-MAY-20
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 65 is already on disk as file /archivelog1/arch_1_65_1040077130.arc
archived log for thread 1 with sequence 66 is already on disk as file /archivelog1/arch_1_66_1040077130.arc
archived log for thread 1 with sequence 67 is already on disk as file /archivelog1/arch_1_67_1040077130.arc
archived log file name=/archivelog1/arch_1_65_1040077130.arc thread=1 sequence=65
archived log file name=/archivelog1/arch_1_66_1040077130.arc thread=1 sequence=66
archived log file name=/archivelog1/arch_1_67_1040077130.arc thread=1 sequence=67
media recovery complete, elapsed time: 00:00:01
Finished recover at 15-MAY-20
Finished Duplicate Db at 15-MAY-20

Oracle 12c DG配置(两节点)_第7张图片

4.启用备库到read only状态

Oracle 12c DG配置(两节点)_第8张图片

五、测试

1.测试数据同步状态

查看主库状态:

Oracle 12c DG配置(两节点)_第9张图片

查看备库状态:

Oracle 12c DG配置(两节点)_第10张图片

Oracle 12c DG配置(两节点)_第11张图片

 

3.数据同步

主库添加数据条目:

SQL> show pdbs;

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB02                          READ WRITE NO
         4 PDB03                          READ WRITE NO
         5 PDB01                          READ WRITE NO
SQL> alter session set container=pdb01;

Session altered.

SQL> insert into id values(6666);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from id;

        ID
----------
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11

        ID
----------
       100
       101
       102
       103
       104
       105
       105
      1000
     10000
     20000
     50000

        ID
----------
     50001
     50002
     60000
     70000
     80000
     90000
     90001
     90002
     90003
     90004
     90005

        ID
----------
     90006
      9007
     90007
     90008
     90009
     90010
     91000
     92000
     93000
     94000
     95000

        ID
----------
     96000
     88888
     99999
     66666
     77777
    111111
    222222
    333333
      6666

53 rows selected.

查询备库数据条目:

SQL> show pdbs;

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB02                          READ ONLY  NO
         4 PDB03                          READ ONLY  NO
         5 PDB01                          READ ONLY  NO
SQL> alter session set container=pdb01;

Session altered.

SQL> select * from id;

        ID
----------
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11

        ID
----------
       100
       101
       102
       103
       104
       105
       105
      1000
     10000
     20000
     50000

        ID
----------
     50001
     50002
     60000
     70000
     80000
     90000
     90001
     90002
     90003
     90004
     90005

        ID
----------
     90006
      9007
     90007
     90008
     90009
     90010
     91000
     92000
     93000
     94000
     95000

        ID
----------
     96000
     88888
     99999
     66666
     77777
    111111
    222222
    333333

52 rows selected.

###结论:备库没有和主库进行同步###############

备库开启日志应用:

Oracle 12c DG配置(两节点)_第12张图片

Oracle 12c DG配置(两节点)_第13张图片

查询数据:

SQL> alter session set container=pdb01
  2  ;

Session altered.

SQL> select * from id;

        ID
----------
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11

        ID
----------
       100
       101
       102
       103
       104
       105
       105
      1000
     10000
     20000
     50000

        ID
----------
     50001
     50002
     60000
     70000
     80000
     90000
     90001
     90002
     90003
     90004
     90005

        ID
----------
     90006
      9007
     90007
     90008
     90009
     90010
     91000
     92000
     93000
     94000
     95000

        ID
----------
     96000
     88888
     99999
     66666
     77777
    111111
    222222
    333333
      6666

53 rows selected.

#####至此,主备库数据已经同步####################################################################

 

 

你可能感兴趣的:(oracle,数据库)