기존에 생성해서 사용하고 있는 DB와 같은 엔진을 사용하는 CloneDB를 생성하는 테스트방법에 대해서 설명하겠습니다.
DB : Oracle 11gR2
AS-IS : ysbae
To-Be : ysbae2
1. RMAN으로 백업
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/home/oracle/nid_test/ctl_%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/home/oracle/nid_test/ctl_%F';
RMAN> backup database plus archivelog format '/home/oracle/nid_test/database_%T_%U';
Starting backup at 19-DEC-19
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=37 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=29 RECID=1 STAMP=1027421238
input archived log thread=1 sequence=30 RECID=2 STAMP=1027421446
input archived log thread=1 sequence=31 RECID=3 STAMP=1027421465
input archived log thread=1 sequence=32 RECID=4 STAMP=1027421474
input archived log thread=1 sequence=33 RECID=5 STAMP=1027421504
channel ORA_DISK_1: starting piece 1 at 19-DEC-19
channel ORA_DISK_1: finished piece 1 at 19-DEC-19
piece handle=/home/oracle/nid_test/database_20191219_07ujqda1_1_1 tag=TAG20191219T105144 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 19-DEC-19
Starting backup at 19-DEC-19
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/app/oracle/oradata/ysbae2/maxrepo01.dbf
input datafile file number=00007 name=/app/oracle/oradata/ysbae2/test01.dbf
input datafile file number=00001 name=/app/oracle/oradata/ysbae2/system01.dbf
input datafile file number=00002 name=/app/oracle/oradata/ysbae2/sysaux01.dbf
input datafile file number=00005 name=/app/oracle/oradata/ysbae2/example01.dbf
input datafile file number=00003 name=/app/oracle/oradata/ysbae2/undotbs01.dbf
input datafile file number=00004 name=/app/oracle/oradata/ysbae2/users01.dbf
channel ORA_DISK_1: starting piece 1 at 19-DEC-19
channel ORA_DISK_1: finished piece 1 at 19-DEC-19
piece handle=/app/oracle/flash_recovery_area/ysbae2/backupset/2019_12_19/o1_mf_nnndf_TAG20191219T105146_gzooxl8d_.bkp tag=TAG20191219T105146 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 19-DEC-19
Starting backup at 19-DEC-19
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=34 RECID=6 STAMP=1027421513
channel ORA_DISK_1: starting piece 1 at 19-DEC-19
channel ORA_DISK_1: finished piece 1 at 19-DEC-19
piece handle=/home/oracle/nid_test/database_20191219_09ujqda9_1_1 tag=TAG20191219T105153 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 19-DEC-19
Starting Control File and SPFILE Autobackup at 19-DEC-19
piece handle=/home/oracle/nid_test/ctl_c-1681187063-20191219-00 comment=NONE
Finished Control File and SPFILE Autobackup at 19-DEC-19
2. CloneDB이 사용할 디렉토리 생성
$ mkdir /home/oracle/cloneDB
3.리스너,TNS 파일 수정
- RMAN접속시 TNS통신을 통하여 접속하기 때문에 리스너와 TNSNAMES.ORA를 수정합니다.
$vi listener.ora
수정전
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ysbae)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /app/oracle
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ysbae
(ORACLE_HOME = /app/oracle/product/11.2.0.4/db_1)
(SID_NAME = ysbae)
)
)
수정후
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ysbae)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /app/oracle
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ysbae
(ORACLE_HOME = /app/oracle/product/11.2.0.4/db_1)
(SID_NAME = ysbae)
(SID_DESC =
(GLOBAL_DBNAME = ysbae2
(ORACLE_HOME = /app/oracle/product/11.2.0.4/db_1) <-- ysbae2 정보 추가
(SID_NAME = ysbae2)
)
)
$vi tnsnames.ora
YSBAE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ysbae)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ysbae)
)
)
YSBAE2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ysbae)(PORT = 1521)) <--ysbae2정보 추가
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ysbae2)
)
)
4.파라미터파일 수정
$ cp initysbae.ora initysbae2.ora
vi initysbae2.ora
ysbae2.__db_cache_size=603979776
ysbae2.__java_pool_size=33554432
ysbae2.__large_pool_size=16777216
ysbae2.__oracle_base='/app/oracle'#ORACLE_BASE set from environment
ysbae2.__pga_aggregate_target=671088640
ysbae2.__sga_target=989855744
ysbae2.__shared_io_pool_size=0
ysbae2.__shared_pool_size=318767104
ysbae2.__streams_pool_size=0
*.audit_file_dest='/app/oracle/admin/ysbae2/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/home/oracle/cloneDB/control01.ctl','/home/oracle/cloneDB/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='ysbae2'
*.db_recovery_file_dest='/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4070572032
*.diagnostic_dest='/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ysbaeXDB)'
*.memory_target=1655701504
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
db_file_name_convert=('/app/oracle/oradata/ysbae','/home/oracle/cloneDB')
log_file_name_convert=('/app/oracle/oradata/ysbae','/home/oracle/cloneDB')
db_file_name_convert와 log_file_name_convert는 복구를 위한 cloneDB생성하는데 사용하면 유용한 명령어입니다.
5.passwd파일 생성
$ orapwd file=orapwysbae2 password=oracle entries=5
$ls -al |grep orapw
-rw-r-----. 1 oracle oinstall 1536 Sep 18 14:05 orapwysbae
-rw-r-----. 1 oracle oinstall 2048 Dec 20 10:49 orapwysbae2
6.TO-BE DB nomount
$vi .bash_profile_ysbae2
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
JAVA_HOME=/home/maxrepo/jdk1.8.0_201
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$JAVA_HOME/bin
export PATH
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_HOSTNAME=ysbae2; export ORACLE_HOSTNAME
ORACLE_UNQNAME=ysbae2; export ORACLE_UNQNAME
ORACLE_BASE=/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/db_1; export ORACLE_HOME
ORACLE_SID=ysbae2; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
export NLS_LANG=AMERICAN_AMERICA.KO16MSWIN949
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$JAVA_HOME/lib; export CLASSPATH
$. .bash_profile_ysbae2
$echo $ORACLE_SID
ysbae2
$sqlplus / as sysdba
SYS@ysbae2> startup nomount;
ORACLE instance started.
Total System Global Area 655556608 bytes
Fixed Size 2216224 bytes
Variable Size 390074080 bytes
Database Buffers 260046848 bytes
Redo Buffers 3219456 bytes
Trouble Shooting
startup nomount시 아래와 같은 에러가 나올때
ORA-00845: MEMORY_TARGET not supported on this system
원인 : OS상의 TO-BE DB에 할당할 메모리가 부족해서 나타남
해결 : initysbae2.ora에서 *.memory_target=1655701504 의 값을 줄이고 다시 시도
ORA-09925: Unable to create audit trail file
Linux-x86_64 Error: 2: No such file or directory
원인 : 파라미터파일내의 audit 디렉토리가 존재하지 않아서 나타남
해결 : initysbae2.ora에 설정한 audit_file_dest에 디렉토리를 생성하거나, 이 파라미터를 삭제하고 다시 시도
7.RMAN 실행
$ rman nocatalog
Recovery Manager: Release 11.2.0.1.0 - Production on Fri Dec 20 10:59:11 2019
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
RMAN> connect target sys/oracle@YSBAE
connected to target database: YSBAE (DBID=1681187063)
using target database control file instead of recovery catalog
RMAN> connect auxiliary /
connected to auxiliary database: YSBAE2 (not mounted)
8.DUPLICATE 명령어를 사용해서 복사
RMAN> run {
allocate auxiliary channel c1 device type disk;
duplicate target database to ysbae2;
}
allocated channel: c1
channel c1: SID=19 device type=DISK
Starting Duplicate Db at 20-DEC-19
contents of Memory Script:
{
sql clone "create spfile from memory";
}
executing Memory Script
sql statement: create spfile from memory
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 655556608 bytes
Fixed Size 2216224 bytes
Variable Size 394268384 bytes
Database Buffers 255852544 bytes
Redo Buffers 3219456 bytes
allocated channel: c1
channel c1: SID=19 device type=DISK
contents of Memory Script:
{
sql clone "alter system set db_name =
''YSBAE'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''YSBAE2'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone primary controlfile;
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''YSBAE'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''YSBAE2'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 655556608 bytes
Fixed Size 2216224 bytes
Variable Size 394268384 bytes
Database Buffers 255852544 bytes
Redo Buffers 3219456 bytes
allocated channel: c1
channel c1: SID=19 device type=DISK
Starting restore at 20-DEC-19
channel c1: starting datafile backup set restore
channel c1: restoring control file
channel c1: reading from backup piece /home/oracle/nid_test/ctl_c-1681187063-20191219-01
channel c1: piece handle=/home/oracle/nid_test/ctl_c-1681187063-20191219-01 tag=TAG20191219T113214
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:00:01
output file name=/home/oracle/cloneDB/control01.ctl
output file name=/home/oracle/cloneDB/control02.ctl
Finished restore at 20-DEC-19
database mounted
contents of Memory Script:
{
set until scn 1579822;
set newname for datafile 1 to
"/home/oracle/cloneDB/system01.dbf";
set newname for datafile 2 to
"/home/oracle/cloneDB/sysaux01.dbf";
set newname for datafile 3 to
"/home/oracle/cloneDB/undotbs01.dbf";
set newname for datafile 4 to
"/home/oracle/cloneDB/users01.dbf";
set newname for datafile 5 to
"/home/oracle/cloneDB/example01.dbf";
set newname for datafile 6 to
"/home/oracle/cloneDB/maxrepo01.dbf";
set newname for datafile 7 to
"/home/oracle/cloneDB/test01.dbf";
restore
clone database
;
}
executing Memory Script
executing command: SET until clause
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 20-DEC-19
channel c1: starting datafile backup set restore
channel c1: specifying datafile(s) to restore from backup set
channel c1: restoring datafile 00001 to /home/oracle/cloneDB/system01.dbf
channel c1: restoring datafile 00002 to /home/oracle/cloneDB/sysaux01.dbf
channel c1: restoring datafile 00003 to /home/oracle/cloneDB/undotbs01.dbf
channel c1: restoring datafile 00004 to /home/oracle/cloneDB/users01.dbf
channel c1: restoring datafile 00005 to /home/oracle/cloneDB/example01.dbf
channel c1: restoring datafile 00006 to /home/oracle/cloneDB/maxrepo01.dbf
channel c1: restoring datafile 00007 to /home/oracle/cloneDB/test01.dbf
channel c1: reading from backup piece /app/oracle/flash_recovery_area/YSBAE/backupset/2019_12_19/o1_mf_nnndf_TAG20191219T105146_gzooxl8d_.bkp
channel c1: piece handle=/app/oracle/flash_recovery_area/YSBAE/backupset/2019_12_19/o1_mf_nnndf_TAG20191219T105146_gzooxl8d_.bkp tag=TAG20191219T105146
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:00:15
Finished restore at 20-DEC-19
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=9 STAMP=1027508767 file name=/home/oracle/cloneDB/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=10 STAMP=1027508767 file name=/home/oracle/cloneDB/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=11 STAMP=1027508767 file name=/home/oracle/cloneDB/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=12 STAMP=1027508767 file name=/home/oracle/cloneDB/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=13 STAMP=1027508767 file name=/home/oracle/cloneDB/example01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=14 STAMP=1027508767 file name=/home/oracle/cloneDB/maxrepo01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=15 STAMP=1027508767 file name=/home/oracle/cloneDB/test01.dbf
contents of Memory Script:
{
set until scn 1579822;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 20-DEC-19
starting media recovery
archived log for thread 1 with sequence 34 is already on disk as file /app/oracle/flash_recovery_area/YSBAE/archivelog/2019_12_19/o1_mf_1_34_gzooxsbp_.arc
archived log for thread 1 with sequence 35 is already on disk as file /app/oracle/flash_recovery_area/YSBAE/archivelog/2019_12_19/o1_mf_1_35_gzoq2180_.arc
archived log for thread 1 with sequence 36 is already on disk as file /app/oracle/flash_recovery_area/YSBAE/archivelog/2019_12_19/o1_mf_1_36_gzor9cby_.arc
archived log for thread 1 with sequence 1 is already on disk as file /app/oracle/flash_recovery_area/YSBAE/archivelog/2019_12_19/o1_mf_1_1_gzpx3sl5_.arc
archived log file name=/app/oracle/flash_recovery_area/YSBAE/archivelog/2019_12_19/o1_mf_1_34_gzooxsbp_.arc thread=1 sequence=34
archived log file name=/app/oracle/flash_recovery_area/YSBAE/archivelog/2019_12_19/o1_mf_1_35_gzoq2180_.arc thread=1 sequence=35
archived log file name=/app/oracle/flash_recovery_area/YSBAE/archivelog/2019_12_19/o1_mf_1_36_gzor9cby_.arc thread=1 sequence=36
archived log file name=/app/oracle/flash_recovery_area/YSBAE/archivelog/2019_12_19/o1_mf_1_1_gzpx3sl5_.arc thread=1 sequence=1
media recovery complete, elapsed time: 00:00:05
Finished recover at 20-DEC-19
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set db_name =
''YSBAE2'' comment=
''Reset to original value by RMAN'' scope=spfile";
sql clone "alter system reset db_unique_name scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 655556608 bytes
Fixed Size 2216224 bytes
Variable Size 394268384 bytes
Database Buffers 255852544 bytes
Redo Buffers 3219456 bytes
allocated channel: c1
channel c1: SID=18 device type=DISK
sql statement: alter system set db_name = ''YSBAE2'' comment= ''Reset to original value by RMAN'' scope=spfile
sql statement: alter system reset db_unique_name scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 655556608 bytes
Fixed Size 2216224 bytes
Variable Size 394268384 bytes
Database Buffers 255852544 bytes
Redo Buffers 3219456 bytes
allocated channel: c1
channel c1: SID=18 device type=DISK
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "YSBAE2" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/home/oracle/cloneDB/redo01.log', '/home/oracle/cloneDB/redo01_02.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/home/oracle/cloneDB/redo02.log', '/home/oracle/cloneDB/redo02_02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/home/oracle/cloneDB/redo03_02.log', '/home/oracle/cloneDB/redo03.log' ) SIZE 50 M REUSE,
GROUP 4 ( '/home/oracle/cloneDB/redo04_02.log', '/home/oracle/cloneDB/redo04.log' ) SIZE 10 M REUSE
DATAFILE
'/home/oracle/cloneDB/system01.dbf'
CHARACTER SET KO16MSWIN949
contents of Memory Script:
{
set newname for tempfile 1 to
"/home/oracle/cloneDB/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/home/oracle/cloneDB/sysaux01.dbf",
"/home/oracle/cloneDB/undotbs01.dbf",
"/home/oracle/cloneDB/users01.dbf",
"/home/oracle/cloneDB/example01.dbf",
"/home/oracle/cloneDB/maxrepo01.dbf",
"/home/oracle/cloneDB/test01.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /home/oracle/cloneDB/temp01.dbf in control file
cataloged datafile copy
datafile copy file name=/home/oracle/cloneDB/sysaux01.dbf RECID=1 STAMP=1027508787
cataloged datafile copy
datafile copy file name=/home/oracle/cloneDB/undotbs01.dbf RECID=2 STAMP=1027508787
cataloged datafile copy
datafile copy file name=/home/oracle/cloneDB/users01.dbf RECID=3 STAMP=1027508787
cataloged datafile copy
datafile copy file name=/home/oracle/cloneDB/example01.dbf RECID=4 STAMP=1027508787
cataloged datafile copy
datafile copy file name=/home/oracle/cloneDB/maxrepo01.dbf RECID=5 STAMP=1027508788
cataloged datafile copy
datafile copy file name=/home/oracle/cloneDB/test01.dbf RECID=6 STAMP=1027508788
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=1027508787 file name=/home/oracle/cloneDB/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=1027508787 file name=/home/oracle/cloneDB/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=1027508787 file name=/home/oracle/cloneDB/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=1027508787 file name=/home/oracle/cloneDB/example01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=1027508788 file name=/home/oracle/cloneDB/maxrepo01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=6 STAMP=1027508788 file name=/home/oracle/cloneDB/test01.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 20-DEC-19
released channel: c1
9.확인
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Fri Dec 20 11:07:13 2019
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS@ysbae2> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
ysbae2 OPEN
1 row selected.
'Oracle > RMAN' 카테고리의 다른 글
[Recover Table] 여러 테이블 recover 및 remap 옵션 (0) | 2023.06.14 |
---|---|
[RMAN] recover table 테스트 시나리오 (0) | 2022.07.01 |
[RMAN]Recover Table (2) | 2019.12.22 |
[RMAN]Database 사전 예방 점검 기능 (0) | 2019.12.21 |
[RMAN] Data Recovery Adivisor (0) | 2019.12.20 |
댓글