DG:11.2.0.4 RAC線上duplicate恢復DG

我愛睡蓮發表於2021-08-24

1.環境介紹

測試環境, 在一個雙節點的RAC上使用duplicate搭建DG,使用線上的方式搭建

 

主機

IP

作業系統

例項

db_name

db_unique_name

db_version

配置

rac1

192.168.163.4

centos7.8

orcl1

orcl

orcl

 

11.2.0.4

4c4g50G

rac2

192.168.163.5

centos7.8

orcl2

orcl

orcl

 4c4g50G

rac-dg

192.168.163.27

centos7.8

orcl_stb

orcl

orcl_stb

 4c4g50G

2. 主庫檢查

2.1 檢查歸檔

SQL> archive log list;
Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           +CRSDG
Oldest online log sequence     76
Next log sequence to archive   77
Current log sequence           77

 

 

 

2.2主備引數檢查

set linesize 500 pages 0 
col value for a90 
col name for a50 
select name,value from v$parameter where name in ('db_name','db_unique_name','log_archive_config','log_archive_dest_1','log_archive_dest_2','log_archive_dest_state_1','log_archive_dest_state_2','remote_login_passwordfile','log_archive_format','log_archive_max_processes','fal_server','db_file_name_convert','log_file_name_convert','standby_file_management');

db_file_name_convert
log_file_name_convert
log_archive_dest_1                     LOCATION=+CRSDG
log_archive_dest_2                     service=orcl_stb lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl_stb
log_archive_dest_state_1               enable
log_archive_dest_state_2               ENABLE
fal_server                             orcl_stb
log_archive_config                     DG_CONFIG=(orcl,orcl_stb)
log_archive_format                     %t_%s_%r.dbf
log_archive_max_processes              4
standby_file_management                AUTO
remote_login_passwordfile              EXCLUSIVE
db_name                                orcl
db_unique_name                         orcl

14 rows selected.

2.3 檢查日誌歸檔檔案位置

--歸檔較多的話,建議輸出到文字中,一般歸檔都會儲存在相同位置下,如有需要可以進行查詢

 

方法一:

select name,sequence#,to_char(completion_time,'yyyy-mm-dd hh24:mi:ss') "completion_time" from v$archived_log order by sequence# ;

 

 

 

方法二:

rman{}
crosscheck archivelog all; 

 

--查詢redo檔案的位置,如果給備庫建立了standby log,需要為redo檔案進行轉儲

 

select group#,thread#,sequence#,bytes/1024/1024 mb,archived,status from V$STANDBY_LOG;

 

 

 

 

2.4 檢查資料檔案位置

--需要判斷臨時檔案資料檔案,是否在相同目錄,如果不通,都需要對目錄進行轉儲

 

select file_name from dba_temp_files;
select file_name from dba_data_files;

 

 

 

 

2.5檢查監聽

 

 

[oracle@rac1 ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 24-AUG-2021 11:21:59

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

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                24-AUG-2021 09:12:44
Uptime                    0 days 2 hr. 9 min. 15 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u1/db/11.2.0/grid/network/admin/listener.ora
Listener Log File         /u1/db/grid/diag/tnslsnr/rac1/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.163.4)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.163.7)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
  Instance "orcl1", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
  Instance "orcl1", status READY, has 1 handler(s) for this service...
The command completed successfully

 

2.6檢查tnsname

[oracle@rac1 ~]$ cat $ORACLE_HOME/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /u1/db/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac-scan)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
orcl1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
orcl2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac2)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

3.主庫配置

3.1修改歸檔設定

alter system set log_archive_config='DG_CONFIG=(orcl,orcl_stb)' sid='*';

SQL> show parameter log_archive_config

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
log_archive_config             string     DG_CONFIG=(orcl,orcl_stb)

3.2配置歸檔路徑

alter system set log_archive_dest_2='service=orcl_stb lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl_stb' scope=both sid='*';

alter system set log_archive_dest_state_2='enable' sid='*';

SQL> show parameter log_archive_dest_2

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2             string     service=orcl_stb lgwr async va
                         lid_for=(online_logfiles,prima
                         ry_role) db_unique_name=orcl_s
                         tb

3.3設定fal_server

alter system set fal_server='orcl_stb' scope=both sid='*';

SQL> show parameter fal_server

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
fal_server                 string     orcl_stb

3.4生成pfile檔案

create pfile='/tmp/initorcl.ora' from spfile;

傳輸pfile檔案到備庫指定目錄

scp /tmp/initorcl.ora root@192.168.163.27:$ORACLE_HOME/dbs

 

3.5 standby_file_management

注意修改standby_file_management的生成方式,如果是MANUAL,改成AUTO

 

3.6拷貝密碼檔案

rac搭建DG,需要把密碼檔案一節點->傳到二節點->二節點傳到備庫,統一密碼檔案

scp /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/orapworcl oracle@rac2:$ORACLE_HOME/dbs

 

scp /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/orapworcl oracle@192.168.163.27:$ORACLE_HOME/dbs

 

備庫

mv orapworcl orapworcl_stb

 

--如果需要重新生成密碼檔案或者修改密碼

 

alter user sys identified by oracle;
orapwd file=$ORACLE_HOME/dbs/orapworcl_stb password=oracle entries=100 ignorecase=y

 

3.7修改tnsname

雙節點修改tnsnames.ora 

 

[oracle@rac1 ~]$ cat $ORACLE_HOME/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /u1/db/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac-scan)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
orcl1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
orcl2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac2)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
orcl_stb =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.163.27)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl_stb)
    )
  )

 

4.備庫配置

192.168.163.27,提前給備庫伺服器安裝好資料庫軟體,不用新建例項,測試伺服器跟主庫伺服器配置都相同

4.1修改pfile檔案

修改ora檔名稱

mv  initorcl.ora  initorcl_stb.ora

 

編輯pfile檔案

  1. 註釋有關叢集相關引數
  2. 給控制檔案新生成一個位置
  3. 修改fal_clientfal_server的名稱
  4. 轉儲資料和日誌檔案路徑
  5. 給一個歸檔的路徑
[oracle@rac-dg dbs]$ vim initorcl_stb.ora 

orcl2.__db_cache_size=603979776
orcl1.__db_cache_size=603979776
orcl2.__java_pool_size=16777216
orcl1.__java_pool_size=16777216
orcl2.__large_pool_size=33554432
orcl1.__large_pool_size=33554432
orcl2.__oracle_base='/u1/db/oracle'#ORACLE_BASE set from environment
orcl2.__pga_aggregate_target=637534208
orcl1.__pga_aggregate_target=637534208
orcl2.__sga_target=956301312
orcl1.__sga_target=956301312
orcl2.__shared_io_pool_size=0
orcl1.__shared_io_pool_size=0
orcl2.__shared_pool_size=285212672
orcl1.__shared_pool_size=285212672
orcl2.__streams_pool_size=0
orcl1.__streams_pool_size=0
*.audit_file_dest='/u1/db/oracle/admin/orcl/adump'
*.audit_trail='none'
#*.cluster_database=TRUE
*.compatible='11.2.0.4.0'
*.control_files='/u1/db/oracle/product/11.2.0/db_1/dbs/orcl_stb.ctl'
*.db_block_size=8192
*.db_create_file_dest='/u1/db/oracle/product/11.2.0/db_1/dbs'
*.db_domain=''
*.db_name='orcl'
*.db_unique_name='orcl_stb'
*.diagnostic_dest='/u1/db/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.fal_client='orcl_stb'
*.fal_server='orcl'
#orcl1.instance_number=1
#orcl2.instance_number=2
*.log_archive_config='DG_CONFIG=(orcl,orcl_stb)'
*.log_archive_dest_1='LOCATION=/arch'
#*.log_archive_dest_2='service=orcl_stb lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl_stb'
*.db_file_name_convert='+FRADG/orcl/datafile','/u1/db/oracle/product/11.2.0/db_1/dbs','+FRADG/orcl/tempfile','/u1/db/oracle/product/11.2.0/db_1/dbs'
*.log_file_name_convert='+CRSDG/ORCL/ARCHIVELOG','/arch','+CRSDG/rac-cluster/ocrfile','/arch'
*.memory_target=1589641216
*.open_cursors=300
*.processes=150
#*.remote_listener='rac-scan:1521'
*.remote_login_passwordfile='exclusive'
*.standby_file_management='AUTO'
#orcl2.thread=2
#orcl1.thread=1
orcl2.undo_tablespace='UNDOTBS2'
orcl1.undo_tablespace='UNDOTBS1'

4.2建立目錄並授權

建立initorcl_stb.ora中需要目錄並授權

 

mkdir -p /u1/db/oracle/admin/orcl/adump
mkdir -p /arch
mkdir -p /u1/db/oracle

chown -R oracle.oinstall /arch
chown -R oracle.oinstall /u1/db/oracle/admin/orcl/adump
chown -R oracle.oinstall /u1/db/oracle

 

4.3配置監聽

配置靜態監聽,LISTENER在前,SID_LIST_LISTENER在後

 

[oracle@rac-dg admin]$ cat listener.ora 
LISTENER =
   (DESCRIPTION=
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.163.27)(PORT=1521)
    )
  )
SID_LIST_LISTENER=
  (SID_LIST =
   (SID_DESC =
     (GLOBAL_DBNAME= orcl_stb)
     (ORACLE_HOME=/u1/db/oracle/product/11.2.0/db_1)
     (SID_NAME = orcl_stb)
   )
 )
ADR_BASE_LISTENER = /u1/db/oracle

 

4.4啟動監聽

[oracle@rac-dg admin]$ lsnrctl start

 

 

4.5配置tnsname

在備庫中如果使用了主機名代替IP,就先將rac中的/etc/hosts 解析的主機名寫進到備庫的hosts檔案裡

 

[oracle@rac-dg admin]$ cat tnsnames.ora
ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.163.9)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
orcl1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.163.4)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
orcl2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac2)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
orcl_stb =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.163.27)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl_stb)
    )
  )

 

4.6 修改備庫密碼檔名稱

4.7主備互相驗證tns

主:

[oracle@rac1 ~]$ tnsping orcl_stb

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 24-AUG-2021 15:03:18

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

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.163.27)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl_stb)))
OK (0 msec)
[oracle@rac1 ~]$ tnsping orcl1

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 24-AUG-2021 15:03:31

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

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))
OK (10 msec)

 

備:

[oracle@rac-dg admin]$ tnsping orcl_stb

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 24-AUG-2021 15:03:26

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

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.163.27)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl_stb)))
OK (0 msec)
[oracle@rac-dg admin]$ tnsping orcl1

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 24-AUG-2021 15:03:39

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

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.163.4)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))
OK (0 msec)

--注意此時主備兩個庫的狀態是否正確,DBID等資訊,避免生產事故

 

[oracle@rac-dg admin]$ rman target sys/oracle@orcl1  auxiliary sys/oracle@orcl_stb

Recovery Manager: Release 11.2.0.4.0 - Production on Tue Aug 24 15:05:50 2021

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

connected to target database: ORCL (DBID=1608598914)
connected to auxiliary database: ORCL (not mounted)

 

5. 恢復DG

5.1啟動到nomount狀態

SQL> startup nomount pfile from 'initorcl_stb.ora';

 

5.2恢復資料庫

--如果資料量過大,儘量使用指令碼後臺恢復,很多生產的前臺連線會話時間都很短

 

[oracle@PEKPBSDIHDBP01 ~]$ cat duplicate.sh 
rman target sys/oracle@orcl  auxiliary sys/oracle@orcl_stb log=/tmp/dup.log <<EOF
run {
allocate channel p1 type disk; 
allocate channel p2 type disk; 
allocate auxiliary channel s1 type disk; 
allocate auxiliary channel s2 type disk;
duplicate target database for standby from active database nofilenamecheck;
}
exit;
EOF

 

chmod +x duplicate.sh

執行日誌:

[oracle@rac-dg tmp]$ cat dup.log 

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Aug 23 19:17:55 2021

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

connected to target database: ORCL (DBID=1608598914)
connected to auxiliary database: ORCL (not mounted)

RMAN> 2> 3> 4> 5> 6> 7> 
using target database control file instead of recovery catalog
allocated channel: p1
channel p1: SID=77 instance=orcl1 device type=DISK

allocated channel: p2
channel p2: SID=143 instance=orcl1 device type=DISK

allocated channel: s1
channel s1: SID=134 device type=DISK

allocated channel: s2
channel s2: SID=10 device type=DISK

Starting Duplicate Db at 23-AUG-21

contents of Memory Script:
{
   backup as copy reuse
   targetfile  '/u1/db/oracle/product/11.2.0/db_1/dbs/orapworcl1' auxiliary format 
 '/u1/db/oracle/product/11.2.0/db_1/dbs/orapworcl_stb'   ;
}
executing Memory Script

Starting backup at 23-AUG-21
Finished backup at 23-AUG-21

contents of Memory Script:
{
   backup as copy current controlfile for standby auxiliary format  '/u1/db/oracle/product/11.2.0/db_1/dbs/orcl_stb.ctl';
}
executing Memory Script

Starting backup at 23-AUG-21
channel p1: starting datafile copy
copying standby control file
output file name=/u1/db/oracle/product/11.2.0/db_1/dbs/snapcf_orcl1.f tag=TAG20210823T191758 RECID=30 STAMP=1081365479
channel p1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 23-AUG-21

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 
 "/u1/db/oracle/product/11.2.0/db_1/dbs/temp.263.1080818181";
   switch clone tempfile all;
   set newname for datafile  1 to 
 "/u1/db/oracle/product/11.2.0/db_1/dbs/system.256.1080818101";
   set newname for datafile  2 to 
 "/u1/db/oracle/product/11.2.0/db_1/dbs/sysaux.257.1080818101";
   set newname for datafile  3 to 
 "/u1/db/oracle/product/11.2.0/db_1/dbs/undotbs1.258.1080818101";
   set newname for datafile  4 to 
 "/u1/db/oracle/product/11.2.0/db_1/dbs/users.259.1080818101";
   set newname for datafile  5 to 
 "/u1/db/oracle/product/11.2.0/db_1/dbs/example.264.1080818183";
   set newname for datafile  6 to 
 "/u1/db/oracle/product/11.2.0/db_1/dbs/undotbs2.265.1080818283";
   backup as copy reuse
   datafile  1 auxiliary format 
 "/u1/db/oracle/product/11.2.0/db_1/dbs/system.256.1080818101"   datafile 
 2 auxiliary format 
 "/u1/db/oracle/product/11.2.0/db_1/dbs/sysaux.257.1080818101"   datafile 
 3 auxiliary format 
 "/u1/db/oracle/product/11.2.0/db_1/dbs/undotbs1.258.1080818101"   datafile 
 4 auxiliary format 
 "/u1/db/oracle/product/11.2.0/db_1/dbs/users.259.1080818101"   datafile 
 5 auxiliary format 
 "/u1/db/oracle/product/11.2.0/db_1/dbs/example.264.1080818183"   datafile 
 6 auxiliary format 
 "/u1/db/oracle/product/11.2.0/db_1/dbs/undotbs2.265.1080818283"   ;
   sql 'alter system archive log current';
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u1/db/oracle/product/11.2.0/db_1/dbs/temp.263.1080818181 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

Starting backup at 23-AUG-21
channel p1: starting datafile copy
input datafile file number=00001 name=+FRADG/orcl/datafile/system.256.1080818101
channel p2: starting datafile copy
input datafile file number=00002 name=+FRADG/orcl/datafile/sysaux.257.1080818101
output file name=/u1/db/oracle/product/11.2.0/db_1/dbs/system.256.1080818101 tag=TAG20210823T191805
channel p1: datafile copy complete, elapsed time: 00:00:07
channel p1: starting datafile copy
input datafile file number=00005 name=+FRADG/orcl/datafile/example.264.1080818183
output file name=/u1/db/oracle/product/11.2.0/db_1/dbs/sysaux.257.1080818101 tag=TAG20210823T191805
channel p2: datafile copy complete, elapsed time: 00:00:07
channel p2: starting datafile copy
input datafile file number=00003 name=+FRADG/orcl/datafile/undotbs1.258.1080818101
output file name=/u1/db/oracle/product/11.2.0/db_1/dbs/undotbs1.258.1080818101 tag=TAG20210823T191805
channel p2: datafile copy complete, elapsed time: 00:00:01
channel p2: starting datafile copy
input datafile file number=00006 name=+FRADG/orcl/datafile/undotbs2.265.1080818283
output file name=/u1/db/oracle/product/11.2.0/db_1/dbs/example.264.1080818183 tag=TAG20210823T191805
channel p1: datafile copy complete, elapsed time: 00:00:02
channel p1: starting datafile copy
input datafile file number=00004 name=+FRADG/orcl/datafile/users.259.1080818101
output file name=/u1/db/oracle/product/11.2.0/db_1/dbs/undotbs2.265.1080818283 tag=TAG20210823T191805
channel p2: datafile copy complete, elapsed time: 00:00:01
output file name=/u1/db/oracle/product/11.2.0/db_1/dbs/users.259.1080818101 tag=TAG20210823T191805
channel p1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 23-AUG-21

sql statement: alter system archive log current

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=30 STAMP=1081365498 file name=/u1/db/oracle/product/11.2.0/db_1/dbs/system.256.1080818101
datafile 2 switched to datafile copy
input datafile copy RECID=31 STAMP=1081365498 file name=/u1/db/oracle/product/11.2.0/db_1/dbs/sysaux.257.1080818101
datafile 3 switched to datafile copy
input datafile copy RECID=32 STAMP=1081365498 file name=/u1/db/oracle/product/11.2.0/db_1/dbs/undotbs1.258.1080818101
datafile 4 switched to datafile copy
input datafile copy RECID=33 STAMP=1081365498 file name=/u1/db/oracle/product/11.2.0/db_1/dbs/users.259.1080818101
datafile 5 switched to datafile copy
input datafile copy RECID=34 STAMP=1081365498 file name=/u1/db/oracle/product/11.2.0/db_1/dbs/example.264.1080818183
datafile 6 switched to datafile copy
input datafile copy RECID=35 STAMP=1081365498 file name=/u1/db/oracle/product/11.2.0/db_1/dbs/undotbs2.265.1080818283
Finished Duplicate Db at 23-AUG-21
released channel: p1
released channel: p2
released channel: s1
released channel: s2

RMAN> 

Recovery Manager complete.

5.3開啟實時同步

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

5.4主備狀態查詢

可以進行日誌切換進行驗證

alter system switch logfile;

 

主備角色狀態

主:

SQL> select open_mode,protection_mode,database_role,switchover_status from v$database;

OPEN_MODE         PROTECTION_MODE      DATABASE_ROLE    SWITCHOVER_STATUS
-------------------- -------------------- ---------------- --------------------
READ WRITE         MAXIMUM PERFORMANCE  PRIMARY       TO STANDBY

備:

SQL> select open_mode,protection_mode,database_role,switchover_status from v$database;

OPEN_MODE         PROTECTION_MODE      DATABASE_ROLE    SWITCHOVER_STATUS
-------------------- -------------------- ---------------- --------------------
READ ONLY WITH APPLY MAXIMUM PERFORMANCE  PHYSICAL STANDBY NOT ALLOWED

 

當前歸檔狀態

主:

SQL> archive log list;
Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           +CRSDG
Oldest online log sequence     79
Next log sequence to archive   80
Current log sequence           80

 

備:

SQL> archive log list;
Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           /arch
Oldest online log sequence     79
Next log sequence to archive   0
Current log sequence           80

 

MRP應用狀態

SQL> select process,client_process,sequence#,status,BLOCK#,BLOCKS from v$managed_standby; 

PROCESS   CLIENT_P  SEQUENCE# STATUS           BLOCK#      BLOCKS
--------- -------- ---------- ------------ ---------- ----------
ARCH      ARCH           77 CLOSING        12288         136
ARCH      ARCH            0 CONNECTED         0           0
ARCH      ARCH           78 CLOSING            1           1
ARCH      ARCH           79 CLOSING            1          98
RFS      LGWR           57 IDLE        14318           1
RFS      UNKNOWN        0 IDLE            0           0
RFS      ARCH            0 IDLE            0           0
RFS      UNKNOWN        0 IDLE            0           0
RFS      ARCH            0 IDLE            0           0
RFS      UNKNOWN        0 IDLE            0           0
RFS      LGWR           80 IDLE        10142           1

PROCESS   CLIENT_P  SEQUENCE# STATUS           BLOCK#      BLOCKS
--------- -------- ---------- ------------ ---------- ----------
MRP0      N/A           80 APPLYING_LOG    10142      102400

12 rows selected.

 

 

 

相關文章