当前位置:   article > 正文

Oracle12c_为RAC配置DATAGUARD_12c rac+dg 2+2

12c rac+dg 2+2
1、主库环境

以一个节点为例:

OS环境:

[root@rac1 ~]# cat /etc/oracle-release
Oracle Linux Server release 6.5
[root@rac1 ~]# uname -r
3.8.13-16.2.1.el6uek.x86_64

网络配置:

[root@rac1 ~]# cat /etc/hosts
127.0.0.1   localhost
#public host names
172.26.181.98   rac1
172.26.181.99   rac2
#private host names
192.168.1.1     rac1-priv
192.168.1.2     rac2-priv
#virtual host names
172.26.181.8    rac1-vip
172.26.181.9    rac2-vip
172.26.181.10   cluster-scan

数据库:

SQL> select * from v$version;

BANNER                                                                          CON_ID
---------------------------------------------------------------------------------------
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production    0
PL/SQL Release 12.1.0.1.0 - Production                                          0
CORE    12.1.0.1.0      Production                                              0
TNS for Linux: Version 12.1.0.1.0 - Production                                  0
NLSRTL Version 12.1.0.1.0 - Production                                          0

SQL> show pdbs;

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 TESTPDB                        READ WRITE NO
        

2、主库启动force logging

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SQL> alter database force logging;

Database altered.

SQL> select force_logging from v$database;

FORCE_LOGGING
---------------------------------------
YES
        
3、主库开启归档模式
这里已经处于归档模式:

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     32
Next log sequence to archive   33
Current log sequence           33

4、在主库添加standby redo logfile

查看主库logfile信息:

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

    GROUP#    THREAD#    MEMBERS      BYTES
---------- ---------- ---------- ----------
         1          1          2   52428800
         2          1          2   52428800
         3          2          2   52428800
         4          2          2   52428800
        
SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
+DATA/ORARAC/ONLINELOG/group_2.263.874160233
+FRA/ORARAC/ONLINELOG/group_2.258.874160233
+DATA/ORARAC/ONLINELOG/group_1.262.874160231
+FRA/ORARAC/ONLINELOG/group_1.257.874160231
+DATA/ORARAC/ONLINELOG/group_3.269.874160887
+FRA/ORARAC/ONLINELOG/group_3.259.874160887
+DATA/ORARAC/ONLINELOG/group_4.270.874160889
+FRA/ORARAC/ONLINELOG/group_4.260.874160889

每个实例的group#都加1,因此我们需要创建6个SRL,这里对SRL不做多路复用:

SQL>  alter database add standby logfile thread 1 group 5 '+DATA/ORARAC/ONLINELOG/group_5.log' size 50m;

Database altered.

SQL>  alter database add standby logfile thread 1 group 6 '+DATA/ORARAC/ONLINELOG/group_6.log' size 50m;

Database altered.

SQL>  alter database add standby logfile thread 1 group 7 '+DATA/ORARAC/ONLINELOG/group_7.log' size 50m;

Database altered.

SQL>  alter database add standby logfile thread 2 group 8 '+DATA/ORARAC/ONLINELOG/group_8.log' size 50m;

Database altered.

SQL>  alter database add standby logfile thread 2 group 9 '+DATA/ORARAC/ONLINELOG/group_9.log' size 50m;

Database altered.

SQL>  alter database add standby logfile thread 2 group 10 '+DATA/ORARAC/ONLINELOG/group_10.log' size 50m;

Database altered.


SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
+DATA/ORARAC/ONLINELOG/group_2.263.874160233
+FRA/ORARAC/ONLINELOG/group_2.258.874160233
+DATA/ORARAC/ONLINELOG/group_1.262.874160231
+FRA/ORARAC/ONLINELOG/group_1.257.874160231
+DATA/ORARAC/ONLINELOG/group_3.269.874160887
+FRA/ORARAC/ONLINELOG/group_3.259.874160887
+DATA/ORARAC/ONLINELOG/group_4.270.874160889
+FRA/ORARAC/ONLINELOG/group_4.260.874160889
+DATA/ORARAC/ONLINELOG/group_5.log
+DATA/ORARAC/ONLINELOG/group_6.log
+DATA/ORARAC/ONLINELOG/group_7.log

MEMBER
--------------------------------------------------------------------------------
+DATA/ORARAC/ONLINELOG/group_8.log
+DATA/ORARAC/ONLINELOG/group_9.log
+DATA/ORARAC/ONLINELOG/group_10.log

14 rows selected.

SQL> select group#,thread# from v$standby_log;

    GROUP#    THREAD#
---------- ----------
         5          1
         6          1
         7          1
         8          2
         9          2
        10          2

6 rows selected.


5、为备库配置静态监听

备库上使用netmgr配置静态监听(必须为静态监听):

[oracle@oracletest admin]$ more listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/12.1.0/dbhome
_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = ORARACDG)
      (ORACLE_HOME = /u01/app/oracle/product/12.1.0/dbhome_1)
      (SID_NAME = orarac)
    )
  )

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

ADR_BASE_LISTENER = /u01/app/oracle

启动监听器:

[oracle@oracletest admin]$ lsnrctl start

注意,通过tnsname连接静态注册的nomount状态的实例时,只能通过sys用户来连。

6、配置主库及备库的tnsnames

RAC的两个节点和备库上的文件都一样。

tnsnames.ora文件内容如下:

                       
[oracle@oracletest admin]$ more tnsnames.ora

ORARAC =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.26.181.10)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orarac)
    )
  )

ORARAC1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.26.181.8)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orarac1)
    )
  )

ORARAC2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.26.181.9)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orarac2)
    )
  )

ORARACDG =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.26.181.101)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = oraracdg)
    )
  )
 
7、创建相关目录

[oracle@oracletest ~]$ mkdir -p /u01/app/oracle/oradata/oraracdg

[oracle@oracletest ~]$ mkdir -p /u01/app/oracle/admin/oraracdg/adump

[oracle@oracletest oraracdg]$ mkdir -p /u01/app/oracle/oradata/oraracdg/fra

[oracle@oracletest oraracdg]$ mkdir -p /u01/app/oracle/oradata/oraracdg/datafile2

[oracle@oracletest oraracdg]$ mkdir -p /u01/app/oracle/oradata/oraracdg/datafile3

因为oracle12c的数据文件(CDB,PDB与seed)分别放在不同的目录(CDB,PDB与seed),所以这里创建多个目录放置数据文件。


8、修改主库参数文件内容

创建PFILE:

SQL> create pfile='/home/oracle/pfileorarac.ora' from spfile;

File created.

修改pfile内容:

加上下面的行:

*.db_name='orarac'
*.db_unique_name='orarac'
*.log_archive_config='dg_config=(orarac,oraracdg)'
*.log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles,all_roles) db_unique_name=orarac'
*.log_archive_dest_2='service=oraracdg valid_for=(online_logfiles,primary_role) async db_unique_name=oraracdg'
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
*.standby_file_management='auto'

#用于角色转换
*.FAL_SERVER=ORARACDG
*.FAL_CLIENT=ORARAC
*.DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/oraracdg','+DATA/ORARAC/DATAFILE','/u01/app/oracle/oradata/oraracdg/datafile2','+DATA/ORARAC/DD7C48AA5A4404A2E04325AAE80A403C/DATAFILE','/u01/app/oracle/oradata/oraracdg/datafile3','+DATA/ORARAC/111287D3DD272EB4E05362B51AAC7F13/DATAFILE'
*.LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/oraracdg','+DATA/ORARAC/ONLINELOG','/u01/app/oracle/oradata/oraracdg/fra','+FRA/ORARAC/ONLINELOG'

重建spfile:

SQL> create spfile from pfile='/home/oracle/pfileorarac.ora';

File created.

重新以新的spfile启动rac实例:

[grid@rac1 ~]$ srvctl stop instance -d orarac -i orarac1,orarac2
[grid@rac1 ~]$ srvctl start instance -d orarac -i orarac1,orarac2

这样主库的参数文件修改完成。

9、在备库创建口令文件

拷贝主库口令文件到备库(注意12cRAC的口令文件在ASM上)。

10、为备库设置参数文件

同样在主库生成pfile,然后拷贝到从库,再在从库上修改后的内容:

#orarac1.__data_transfer_cache_size=0
#orarac2.__data_transfer_cache_size=0
#orarac2.__db_cache_size=8321499136
#orarac1.__db_cache_size=8321499136
#orarac1.__java_pool_size=67108864
#orarac2.__java_pool_size=67108864
#orarac2.__large_pool_size=100663296
#orarac1.__large_pool_size=100663296
#orarac1.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
#orarac2.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
#orarac1.__pga_aggregate_target=3388997632
#orarac2.__pga_aggregate_target=3388997632
#orarac1.__sga_target=10099884032
#orarac2.__sga_target=10099884032
#orarac1.__shared_io_pool_size=0
#orarac2.__shared_io_pool_size=0
#orarac1.__shared_pool_size=1543503872
#orarac2.__shared_pool_size=1543503872
#orarac1.__streams_pool_size=0
#orarac2.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/oraracdg/adump'
*.audit_trail='db'
#*.cluster_database=true
*.compatible='12.1.0.0.0'
*.control_files='/u01/app/oracle/oradata/oraracdg/control01.ctl'
*.db_block_size=8192
#*.db_create_file_dest='+DATA'
*.db_domain=''
#注意这里在参数文件中设置了FILE_NAME_CONVERT那么在duplicate语句中就应该写NOFILENAMECHECK子句。
*.DB_FILE_NAME_CONVERT='+DATA/ORARAC/DATAFILE','/u01/app/oracle/oradata/oraracdg','+DATA/ORARAC/DD7C48AA5A4404A2E04325AAE80A403C/DATAFILE','/u01/app/oracle/oradata/oraracdg/datafile2','+DATA/ORARAC/111287D3DD272EB4E05362B51AAC7F13/DATAFILE','/u01/app/oracle/oradata/oraracdg/datafile3'
*.db_name='orarac'
#注意这里还指定了闪回恢复区
*.db_recovery_file_dest='/u01/app/oracle/oradata/oraracdg/fra'
*.db_recovery_file_dest_size=5737418240
*.db_unique_name='oraracdg'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=oraracXDB)'
*.enable_pluggable_database=true
*.FAL_CLIENT='ORARACDG'
*.FAL_SERVER='ORARAC'
#orarac1.instance_number=1
#orarac2.instance_number=2
*.log_archive_config='dg_config=(orarac,oraracdg)'
*.log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles,all_roles) db_unique_name=oraracdg'
*.log_archive_dest_2='service=oraracdg valid_for=(online_logfiles,primary_role) async db_unique_name=orarac'
*.log_archive_dest_state_1='enable'
*.log_archive_dest_state_2='enable'
*.log_archive_format='%t_%s_%r.dbf'
*.LOG_FILE_NAME_CONVERT='+DATA/ORARAC/ONLINELOG','/u01/app/oracle/oradata/oraracdg','+FRA/ORARAC/ONLINELOG','/u01/app/oracle/oradata/oraracdg/fra'
*.open_cursors=300
*.pga_aggregate_target=3210m
*.processes=300
*.remote_login_passwordfile='exclusive'
*.sga_target=9630m
*.standby_file_management='auto'
#orarac2.thread=2
#orarac1.thread=1
#orarac1.undo_tablespace='UNDOTBS1'
#orarac2.undo_tablespace='UNDOTBS2'
*.undo_tablespace='UNDOTBS1'

确认pfile已经拷贝到下列目录:
[oracle@oracletest dbs]$ pwd
/u01/app/oracle/product/12.1.0/dbhome_1/dbs
[oracle@oracletest dbs]$ ll
total 12
-rw-r--r-- 1 oracle oinstall 2539 Mar 25 16:13 initorarac.ora
-rw-r----- 1 oracle oinstall 7680 Mar 25 15:46 orapworarac

以pfile启动备库并生成spfile:

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 1.0055E+10 bytes
Fixed Size                  2691952 bytes
Variable Size            1778388112 bytes
Database Buffers         8254390272 bytes
Redo Buffers               19312640 bytes

再次使用spfile重新启动备库:

SQL> shutdown immediate;
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.

Total System Global Area 1.0055E+10 bytes
Fixed Size                  2691952 bytes
Variable Size            1778388112 bytes
Database Buffers         8254390272 bytes
Redo Buffers               19312640 bytes

11、开始duplicate

注意:下面的rman连接句指定了sys用户和相同的密码。

[oracle@rac1 admin]$ rman target sys/oracle@orarac auxiliary sys/oracle@oraracdg
 
Recovery Manager: Release 12.1.0.1.0 - Production on Thu Mar 26 14:13:15 2015

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

connected to target database: ORARAC (DBID=377624869)
connected to auxiliary database: ORARAC (not mounted)

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

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

contents of Memory Script:
{
   backup as copy reuse
   targetfile  '+DATA/orarac/orapworarac' auxiliary format
 '/u01/app/oracle/product/12.1.0/dbhome_1/dbs/orapworarac'   ;
}
executing Memory Script

Starting backup at 26-MAR-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=247 instance=orarac1 device type=DISK
Finished backup at 26-MAR-15

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

Starting restore at 26-MAR-15
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 orarac
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/oraracdg/control01.ctl
Finished restore at 26-MAR-15

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

sql statement: alter database mount standby database
RMAN-05529: WARNING: DB_FILE_NAME_CONVERT resulted in invalid ASM names; names changed to disk group only.

contents of Memory Script:
{
   set newname for tempfile  1 to
 "+DATA";
   set newname for tempfile  2 to
 "/u01/app/oracle/oradata/oraracdg/datafile2/pdbseed_temp01.dbf";
   set newname for tempfile  3 to
 "+DATA";
   switch clone tempfile all;
   set newname for datafile  1 to
 "/u01/app/oracle/oradata/oraracdg/system.258.874160123";
   set newname for datafile  3 to
 "/u01/app/oracle/oradata/oraracdg/sysaux.257.874160067";
   set newname for datafile  4 to
 "/u01/app/oracle/oradata/oraracdg/undotbs1.260.874160189";
   set newname for datafile  5 to
 "/u01/app/oracle/oradata/oraracdg/datafile2/system.266.874160245";
   set newname for datafile  6 to
 "/u01/app/oracle/oradata/oraracdg/users.259.874160187";
   set newname for datafile  7 to
 "/u01/app/oracle/oradata/oraracdg/datafile2/sysaux.265.874160245";
   set newname for datafile  8 to
 "/u01/app/oracle/oradata/oraracdg/undotbs2.268.874160743";
   set newname for datafile  9 to
 "/u01/app/oracle/oradata/oraracdg/datafile3/system.272.874161075";
   set newname for datafile  10 to
 "/u01/app/oracle/oradata/oraracdg/datafile3/sysaux.273.874161075";
   set newname for datafile  11 to
 "/u01/app/oracle/oradata/oraracdg/datafile3/users.275.874161105";
   restore
   from service  'orarac'   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 +DATA in control file
renamed tempfile 2 to /u01/app/oracle/oradata/oraracdg/datafile2/pdbseed_temp01.dbf in control file
renamed tempfile 3 to +DATA 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

Starting restore at 26-MAR-15
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 orarac
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/oraracdg/system.258.874160123
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 orarac
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/oraracdg/sysaux.257.874160067
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 orarac
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/oraracdg/undotbs1.260.874160189
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 orarac
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/oraracdg/datafile2/system.266.874160245
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 orarac
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/oraracdg/users.259.874160187
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 orarac
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/oraracdg/datafile2/sysaux.265.874160245
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 orarac
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/oraracdg/undotbs2.268.874160743
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 orarac
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/oraracdg/datafile3/system.272.874161075
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 orarac
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/oraracdg/datafile3/sysaux.273.874161075
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 orarac
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/oraracdg/datafile3/users.275.874161105
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 26-MAR-15

sql statement: alter system archive log current
current log archived

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

Starting restore at 26-MAR-15
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 orarac
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=103
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 orarac
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=104
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 orarac
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=105
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 orarac
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=2 sequence=71
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 orarac
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=2 sequence=72
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 orarac
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=2 sequence=73
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 orarac
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=2 sequence=74
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 26-MAR-15

datafile 1 switched to datafile copy
input datafile copy RECID=3 STAMP=875370208 file name=/u01/app/oracle/oradata/oraracdg/system.258.874160123
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=875370208 file name=/u01/app/oracle/oradata/oraracdg/sysaux.257.874160067
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=875370208 file name=/u01/app/oracle/oradata/oraracdg/undotbs1.260.874160189
datafile 5 switched to datafile copy
input datafile copy RECID=6 STAMP=875370208 file name=/u01/app/oracle/oradata/oraracdg/datafile2/system.266.874160245
datafile 6 switched to datafile copy
input datafile copy RECID=7 STAMP=875370208 file name=/u01/app/oracle/oradata/oraracdg/users.259.874160187
datafile 7 switched to datafile copy
input datafile copy RECID=8 STAMP=875370208 file name=/u01/app/oracle/oradata/oraracdg/datafile2/sysaux.265.874160245
datafile 8 switched to datafile copy
input datafile copy RECID=9 STAMP=875370208 file name=/u01/app/oracle/oradata/oraracdg/undotbs2.268.874160743
datafile 9 switched to datafile copy
input datafile copy RECID=10 STAMP=875370208 file name=/u01/app/oracle/oradata/oraracdg/datafile3/system.272.874161075
datafile 10 switched to datafile copy
input datafile copy RECID=11 STAMP=875370208 file name=/u01/app/oracle/oradata/oraracdg/datafile3/sysaux.273.874161075
datafile 11 switched to datafile copy
input datafile copy RECID=12 STAMP=875370208 file name=/u01/app/oracle/oradata/oraracdg/datafile3/users.275.874161105

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

executing command: SET until clause

Starting recover at 26-MAR-15
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 103 is already on disk as file /u01/app/oracle/oradata/oraracdg/fra/ORARACDG/archivelog/2015_03_26/o1_mf_1_103_bk79gson_.arc
archived log for thread 1 with sequence 104 is already on disk as file /u01/app/oracle/oradata/oraracdg/fra/ORARACDG/archivelog/2015_03_26/o1_mf_1_104_bk79gtqk_.arc
archived log for thread 1 with sequence 105 is already on disk as file /u01/app/oracle/oradata/oraracdg/fra/ORARACDG/archivelog/2015_03_26/o1_mf_1_105_bk79gvso_.arc
archived log for thread 2 with sequence 72 is already on disk as file /u01/app/oracle/oradata/oraracdg/fra/ORARACDG/archivelog/2015_03_26/o1_mf_2_72_bk79gxxh_.arc
archived log for thread 2 with sequence 73 is already on disk as file /u01/app/oracle/oradata/oraracdg/fra/ORARACDG/archivelog/2015_03_26/o1_mf_2_73_bk79gz01_.arc
archived log for thread 2 with sequence 74 is already on disk as file /u01/app/oracle/oradata/oraracdg/fra/ORARACDG/archivelog/2015_03_26/o1_mf_2_74_bk79h024_.arc
archived log file name=/u01/app/oracle/oradata/oraracdg/fra/ORARACDG/archivelog/2015_03_26/o1_mf_1_103_bk79gson_.arc thread=1 sequence=103
archived log file name=/u01/app/oracle/oradata/oraracdg/fra/ORARACDG/archivelog/2015_03_26/o1_mf_2_72_bk79gxxh_.arc thread=2 sequence=72
archived log file name=/u01/app/oracle/oradata/oraracdg/fra/ORARACDG/archivelog/2015_03_26/o1_mf_2_73_bk79gz01_.arc thread=2 sequence=73
archived log file name=/u01/app/oracle/oradata/oraracdg/fra/ORARACDG/archivelog/2015_03_26/o1_mf_1_104_bk79gtqk_.arc thread=1 sequence=104
archived log file name=/u01/app/oracle/oradata/oraracdg/fra/ORARACDG/archivelog/2015_03_26/o1_mf_1_105_bk79gvso_.arc thread=1 sequence=105
archived log file name=/u01/app/oracle/oradata/oraracdg/fra/ORARACDG/archivelog/2015_03_26/o1_mf_2_74_bk79h024_.arc thread=2 sequence=74
media recovery complete, elapsed time: 00:00:00
Finished recover at 26-MAR-15
Finished Duplicate Db at 26-MAR-15

12、打开备库并启动apply

查看备库:

[oracle@oracletest admin]$ sqlplus "/as sysdba"

SQL*Plus: Release 12.1.0.1.0 Production on Thu Mar 26 14:25:11 2015

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> select status from v$instance;

STATUS
------------
MOUNTED

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       MOUNTED
         3 TESTPDB                        MOUNTED
SQL> alter database open;

Database altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 TESTPDB                        MOUNTED

SQL> alter pluggable database testpdb open;

Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 TESTPDB                        READ ONLY  NO
        
SQL> select log_mode,open_mode,database_role from v$database;

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

查看主库:

SQL> select log_mode,open_mode,database_role from v$database;

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

在备库启动apply:

SQL> alter database recover managed standby database using current logfile disconnect from session;

Database altered.

SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ ONLY WITH APPLY

13、验证

在主库插入数据:

SQL> select name,open_mode from v$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
TESTPDB                        MOUNTED

SQL> alter pluggable database testpdb open;

Pluggable database altered.

SQL> alter session set container=testpdb;

Session altered.

SQL> select * from test.t1;

        C1
----------
         1

SQL> insert into test.t1 values(2);

1 row created.

SQL> commit;

Commit complete.

在备库查询:

SQL> select name,open_mode from v$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
TESTPDB                        READ ONLY

SQL> alter session set container=testpdb;

Session altered.

SQL> select * from test.t1;

        C1
----------
         2
         1

OK,在备库上PDB中的内容也已经插入成功了。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/秋刀鱼在做梦/article/detail/976425
推荐阅读
相关标签
  

闽ICP备14008679号