버전 비교

  • 이 줄이 추가되었습니다.
  • 이 줄이 삭제되었습니다.
  • 서식이 변경되었습니다.

Standby DB Instance 기동

nomount 모드로 DB 시작

코드 블럭
titleStandby 인스턴스 기동
linenumberstrue
STARTUP NOMOUNT PFILE='~oracle/[standby 글로벌 DB명].ora'
펼치기
서식 미적용
[oracle@orcl ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Feb 13 14:18:29 2024
Version 19.11.0.0.0

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

Connected to an idle instance.

SQL> startup nomount pfile='/home/oracle/orcl_stby.ora';
ORACLE instance started.

Total System Global Area  268434272 bytes
Fixed Size                  8895328 bytes
Variable Size             201326592 bytes
Database Buffers           50331648 bytes
Redo Buffers                7880704 bytes



RMAN을 이용한 DB 복제

RMAN 접속

코드 블럭
languagebash
titleRMAN 으로 Primary와 Standby 동시 접속
linenumberstrue
rman TARGET sys/<sys[sys 계정 암호>@ORCL 암호]@[primary 네트워크 서비스명] AUXILIARY sys/<sys[sys 계정 암호>@ORCL_STB 암호]@[standby 네트워크 서비스명]
펼치기
서식 미적용
[oracle@orcl ~]$ export NLS_DATE_FORMAT="yyyy/mm/dd hh24:mi:ss"

[oracle@orcl ~]$ rman TARGET sys/oracle@orcloracle@seoul_primarysyn AUXILIARY sys/oracle@orcloracle@busan_standbysyn

Recovery Manager: Release 19.0.0.0.0 - Production on Tue Feb 13 14:19:15 2024
Version 19.11.0.0.0

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

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



Duplicate 명령으로 DB 복제

코드 블럭
title운영 중인 DB를 RMAN으로 standby 서버에 복제
linenumberstrue
DUPLICATE TARGET DATABASE
   FOR STANDBY
   FROM ACTIVE DATABASE
   DORECOVER
--   PASSWORD FILE
  SPFILE SPFILE
     SET db_unique_name='[standby 글로벌 DB명]' COMMENT 'Is standby'
--     SET cluster_database='FALSE'
    SET SET FAL_SERVER='[primary 글로벌 DB명]' COMMENT 'Is primary'
   NOFILENAMECHECK;
펼치기
서식 미적용
RMAN> DUPLICATE TARGET DATABASE
2>    FOR STANDBY
3>    FROM ACTIVE DATABASE
4>    DORECOVER
5>    SPFILE
6>      SET db_unique_name='orcl_stby' COMMENT 'Is standby'
7>      SET FAL_SERVER='orcl' COMMENT 'Is primary'
8>    NOFILENAMECHECK;

Starting Duplicate Db at 2024/02/13 14:21:26
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=182 device type=DISK
current log archived

contents of Memory Script:
{
   backup as copy reuse
   passwordfile auxiliary format  '/u01/app/oracle/product/19c/db_1/dbs/orapworcl'   ;
   restore clone from service  'orclseoul_primarysyn' spfile to
 '/u01/app/oracle/product/19c/db_1/dbs/spfileorcl.ora';
   sql clone "alter system set spfile= ''/u01/app/oracle/product/19c/db_1/dbs/spfileorcl.ora''";
}
executing Memory Script

Starting backup at 2024/02/13 14:21:27
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=291 device type=DISK
Finished backup at 2024/02/13 14:21:30

Starting restore at 2024/02/13 14:21:30
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 orclseoul_primarysyn
channel ORA_AUX_DISK_1: restoring SPFILE
output file name=/u01/app/oracle/product/19c/db_1/dbs/spfileorcl.ora
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 2024/02/13 14:21:33

sql statement: alter system set spfile= ''/u01/app/oracle/product/19c/db_1/dbs/spfileorcl.ora''

contents of Memory Script:
{
   sql clone "alter system set  db_unique_name =
 ''orcl_stby'' comment=
 ''Is standby'' scope=spfile";
   sql clone "alter system set  FAL_SERVER =
 ''orcl'' comment=
 ''Is primary'' scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script

sql statement: alter system set  db_unique_name =  ''orcl_stby'' comment= ''Is standby'' scope=spfile

sql statement: alter system set  FAL_SERVER =  ''orcl'' comment= ''Is primary'' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area    1258290744 bytes

Fixed Size                     8896056 bytes
Variable Size                318767104 bytes
Database Buffers             922746880 bytes
Redo Buffers                   7880704 bytes
duplicating Online logs to Oracle Managed File (OMF) location

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

Starting restore at 2024/02/13 14:22:00
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=20 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service orclseoul_primarysyn
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/fast_recovery_area/ORCL/control02.ctl
Finished restore at 2024/02/13 14:22:04

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

sql statement: alter database mount standby database
RMAN-05538: warning: implicitly using DB_FILE_NAME_CONVERT
RMAN-05158: WARNING: auxiliary (datafile) file name /oradata/ORCL/system01.dbf conflicts with a file used by the target database
RMAN-05158: WARNING: auxiliary (datafile) file name /oradata/ORCL/sysaux01.dbf conflicts with a file used by the target database
RMAN-05158: WARNING: auxiliary (datafile) file name /oradata/ORCL/undotbs01.dbf conflicts with a file used by the target database
RMAN-05158: WARNING: auxiliary (datafile) file name /oradata/ORCL/users01.dbf conflicts with a file used by the target database
RMAN-05158: WARNING: auxiliary (tempfile) file name /oradata/ORCL/temp01.dbf conflicts with a file used by the target database

contents of Memory Script:
{
   set newname for tempfile  1 to
 "/oradata/ORCL/temp01.dbf";
   switch clone tempfile all;
   set newname for datafile  1 to
 "/oradata/ORCL/system01.dbf";
   set newname for datafile  2 to
 "/oradata/ORCL/sysaux01.dbf";
   set newname for datafile  3 to
 "/oradata/ORCL/undotbs01.dbf";
   set newname for datafile  4 to
 "/oradata/ORCL/users01.dbf";
   restore
   from  nonsparse   from service
 'orclseoul_primarysyn'   clone database
   ;
   sql 'alter system archive log current';
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /oradata/ORCL/temp01.dbf in control file

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 2024/02/13 14:22:09
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 orclseoul_primarysyn
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 orclseoul_primarysyn
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00002 to /oradata/ORCL/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 orclseoul_primarysyn
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00003 to /oradata/ORCL/undotbs01.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 orclseoul_primarysyn
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00004 to /oradata/ORCL/users01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 2024/02/13 14:22:48

sql statement: alter system archive log current
current log archived

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

Starting restore at 2024/02/13 14:22:48
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 orclseoul_primarysyn
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=14
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 orclseoul_primarysyn
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=15
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 2024/02/13 14:22:50

datafile 1 switched to datafile copy
input datafile copy RECID=1 STAMP=1160835769 file name=/oradata/ORCL/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=2 STAMP=1160835769 file name=/oradata/ORCL/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=3 STAMP=1160835769 file name=/oradata/ORCL/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=4 STAMP=1160835769 file name=/oradata/ORCL/users01.dbf

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

executing command: SET until clause

Starting recover at 2024/02/13 14:22:50
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 14 is already on disk as file /oradata/fast_recovery_area/ORCL_STBY/archivelog/2024_02_13/o1_mf_1_14_lwoz57hg_.arc
archived log for thread 1 with sequence 15 is already on disk as file /oradata/fast_recovery_area/ORCL_STBY/archivelog/2024_02_13/o1_mf_1_15_lwoz58kc_.arc
archived log file name=/oradata/fast_recovery_area/ORCL_STBY/archivelog/2024_02_13/o1_mf_1_14_lwoz57hg_.arc thread=1 sequence=14
archived log file name=/oradata/fast_recovery_area/ORCL_STBY/archivelog/2024_02_13/o1_mf_1_15_lwoz58kc_.arc thread=1 sequence=15
media recovery complete, elapsed time: 00:00:01
Finished recover at 2024/02/13 14:22:53

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=291 device type=DISK
deleted archived log
archived log file name=/oradata/fast_recovery_area/ORCL_STBY/archivelog/2024_02_13/o1_mf_1_14_lwoz57hg_.arc RECID=1 STAMP=1160835767
deleted archived log
archived log file name=/oradata/fast_recovery_area/ORCL_STBY/archivelog/2024_02_13/o1_mf_1_15_lwoz58kc_.arc RECID=2 STAMP=1160835768
Deleted 2 objects

Finished Duplicate Db at 2024/02/13 14:22:59

Standby 복제 DB 확인

서식 미적용
[oracle@orcl ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Feb 13 14:24:17 2024
Version 19.11.0.0.0

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


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

SQL> select status from v$instance;

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

SQL> show parameter db_name

NAME                                 TYPE                              VALUE
------------------------------------ --------------------------------- ------------------------------
db_name                              string                            orcl

SQL> show parameter db_unique_name

NAME                                 TYPE                              VALUE
------------------------------------ --------------------------------- ------------------------------
db_unique_name                       string                            orcl_stby

SQL> SELECT db_unique_name FROM v$database;

DB_UNIQUE_NAME
------------------------------------------------------------------------------------------
orcl_stby

아카이브 로그 삭제 방지 정책 추가

코드 블럭
titlePrimary와 Standby의 RMAN 설정 변경
linenumberstrue
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
펼치기
서식 미적용
[oracle@orcl ~]$ rman auxiliary sys/oracle@orcl_standby target=sys/oracle@orcl_primary

Recovery Manager: Release 19.0.0.0.0 - Production on Tue Feb 13 14:25:48 2024
Version 19.11.0.0.0

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

connected to target database: ORCL (DBID=1688108027)
connected to auxiliary database: ORCL (DBID=1688108027, not open)

RMAN> SHOW ARCHIVELOG DELETION POLICY;

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default

RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;

new RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
new RMAN configuration parameters are successfully stored

RMAN> SHOW ARCHIVELOG DELETION POLICY;

RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;