ORACLE/Migration2015. 9. 14. 21:37
반응형

RMAN을 사용한 raw device migration


출 처: http://jhroom.co.kr/21369
예전에 테스트했던 자료인데.. ASM -> filesystem의 경우에도 가능합니다..
개요
Oracle datafile을 raw device에서 file system file로, 또는 반대로 file system에서 raw device로 변환하기 위해 일반적으로 dd 명령을 주로 사용하게 되는데, Operating System마다 각기 다른 raw device control block size를 가지고 있기 때문에 작업 수행시 추가적인 확인 작업이 필요하다. 그러나 RMAN을 사용하여 변환 작업을 수행하면 이와 같은 과정 없이 변환이 가능하다.
작업절차
본 시나리오에서는 데이터베이스 전체에 대해 raw device/file system 상호 변환하는 과정을 테스트하였다.

##        RAW DEVICE -> FILE SYSTEM

1. Database mount

SQL> startup mount

2. Control file 재생성을 위해 trace 형태로 백업 수행

SQL> alter database backup controlfile to trace;

3. Raw device로 되어 있는 spfile을 pfile로 변경

SQL> create pfile from spfile;

4. Password file 재생성

ORA10@/oracle/product/10.2.0/dbs> orapwd file=orapwORA10 password=oracle force=y

5. RMAN을 이용하여 raw device datafile을 file system으로 변환

ORA10@/oracle> rman nocatalog target /
RMAN> copy datafile '/dev/raw/raw1' to '/oracle/oradata/ORA10/system.dbf'; -- 이처럼 파일마다 개별적으로 작업이 가능하지만, DB 전체를 복사할 경우 아래와 같이 작업한다.
RMAN> backup as copy database;

6. 위 단계에서 backup된 datafile들을 실제로 사용할 file 이름으로 변경

ORA10@/oracle> mv data_D-ORA10_I-650271866_TS-SYSTEM_FNO-1_04jsnkjp /oracle/oradata/ORA10/system.dbf
ORA10@/oracle> mv data_D-ORA10_I-650271866_TS-UNDOTBS1_FNO-2_05jsnkl6 /oracle/oradata/ORA10/undotbs1.dbf
ORA10@/oracle> mv data_D-ORA10_I-650271866_TS-SYSAUX_FNO-3_06jsnkmt /oracle/oradata/ORA10/sysaux.dbf
ORA10@/oracle> mv data_D-ORA10_I-650271866_TS-USERS_FNO-4_07jsnkol /oracle/oradata/ORA10/users.dbf

7. Parameter file(init.ora)을 열어 재 생성될 control file 경로를 지정

ORA10@/oracle/product/10.2.0/dbs> vi initORA10.ora
control_files='/oracle/oradata/ORA10/control01.ctl','/oracle/oradata/ORA10/control02.ctl'

8. Database shutdown

SQL> shutdown immediate;

9. 2번 단계에서 생성된 스크립트를 수정하여 datafile들의 새로운 경로를 지정한 후, resetlogs 옵션으로 데이터베이스를 오픈한다. 그리고 오픈 후 temp file들도 생성해 준다.

SQL> STARTUP NOMOUNT
SQL> CREATE CONTROLFILE REUSE DATABASE "ORA10" RESETLOGS  NOARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/oracle/oradata/ORA10/redo01.dbf'  SIZE 45M,
  GROUP 2 '/oracle/oradata/ORA10/redo02.dbf'  SIZE 45M
DATAFILE
  '/oracle/oradata/ORA10/sysaux.dbf',  
  '/oracle/oradata/ORA10/system.dbf',  
  '/oracle/oradata/ORA10/undotbs1.dbf', 
  '/oracle/oradata/ORA10/users.dbf'
CHARACTER SET KO16MSWIN949;
 
SQL> RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL;
ORA-00279: change 179042 generated at 10/09/2008 14:50:53 needed for thread 1
ORA-00289: suggestion : /oracle/product/10.2.0/dbs/arch1_11_667665402.dbf
ORA-00280: change 179042 for thread 1 is in sequence #11
 
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
CANCEL
Media recovery cancelled.
SQL> ALTER DATABASE OPEN RESETLOGS;
SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '/oracle/oradata/ORA10/temp.dbf' SIZE 200M;


##        FILE SYSTEM -> RAW DEVICE

1. Database mount

SQL> startup mount

2. Control file 재생성을 위해 trace 형태로 백업 수행

SQL> alter database backup controlfile to trace;

3. Password file을 raw device로 변경

ORA10@/oracle/product/10.2.0/dbs> dd if=orapwORA10 of=/dev/raw/raw13
ORA10@/oracle/product/10.2.0/dbs> rm -f orapwORA10
ORA10@/oracle/product/10.2.0/dbs> ln -s /dev/raw/raw13 orapwORA10

4. RMAN을 사용하여 file system datafile을 raw device로 변환

ORA10@/oracle> rman nocatalog target /
RMAN> copy datafile '/oracle/oradata/ORA10/system.dbf' to '/dev/raw/raw1';
RMAN> copy datafile '/oracle/oradata/ORA10/sysaux.dbf' to '/dev/raw/raw2';
RMAN> copy datafile '/oracle/oradata/ORA10/users.dbf' to '/dev/raw/raw6';
RMAN> copy datafile '/oracle/oradata/ORA10/undotbs1.dbf' to '/dev/raw/raw3';

5. Parameter file(init.ora)을 수정하여 재 생성될 control file의 경로 지정

ORA10@/oracle/product/10.2.0/dbs> vi initORA10.ora
control_files='/dev/raw/raw10','/dev/raw/raw11'

6. Database shutdown

SQL> shutdown immediate;

7. 2번 단계에서 생성된 스크립트를 수정하여 datafile들의 새로운 경로를 지정한 후, resetlogs 옵션으로 데이터베이스를 오픈한다. 그리고 오픈 후 temp file들도 생성해 준다.

SQL> STARTUP NOMOUNT
SQL> CREATE CONTROLFILE REUSE DATABASE "ORA10" RESETLOGS  NOARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/dev/raw/raw8'  SIZE 45M,
  GROUP 2 '/dev/raw/raw9'  SIZE 45M
-- STANDBY LOGFILE
DATAFILE
  '/dev/raw/raw1',
  '/dev/raw/raw3',
  '/dev/raw/raw2',
  '/dev/raw/raw6'
CHARACTER SET KO16MSWIN949
;

SQL> RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL;
ORA-00279: change 179846 generated at 10/09/2008 16:45:11 needed for thread 1
ORA-00289: suggestion : /oracle/product/10.2.0/dbs/arch1_1_667672438.dbf
ORA-00280: change 179846 for thread 1 is in sequence #1
  
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
CANCEL
Media recovery cancelled.
SQL> ALTER DATABASE OPEN RESETLOGS;
SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '/dev/raw/raw5' size 190M REUSE;

8. File system으로 되어 있는 pfile을 raw device spfile로 변환

SQL> create spfile='/dev/raw/raw12' from pfile;

9. Parameter file을 수정하여 spfile을 사용하도록 지정한다.

ORA10@/oracle/product/10.2.0/dbs> vi initORA10.ora
SPFILE=/dev/raw/raw12


반응형
Posted by [PineTree]
ORACLE/Migration2015. 9. 14. 21:31
반응형
출처 : http://blog.naver.com/itisksc/30046860726
1. raw device에는 LVCB(Logical Volume Control Block)가 있지만
   file system에는 없음.

 

   - bs    : 파일 입출력의 block(버퍼) 크기

   - skip  : 입력 파일에서 처리하지 않고 통과할 블록의 개수
             (Raw Device to Filesystem 복사 시 지정해야 함)
   - seek  : 출력 파일에서 처리하지 않고 통과할 블록의 개수
             (Filesystem to Raw Device 복사 시 지정해야 함)

   - count : 복사할 회수 or 블록의 개수 (생략 시 모든 데이터 복사 )

             (Raw Device to Filesystem 복사 시 반드시 명시해야 함,
              그 이외의 경우는 생략 가능)

플랫폼
LVCB
플랫폼
LVCB
Solaris
0
True64
64KB
HP-UX
0
Linux
0
AIX
4KB
Windows
0

 

2. dbfsize로 확인

   $ORACLE_HOME/bin/dbfsize <Oracle Datafile 명>

   [file system 결과]
   /data05/TESTDB] dbfsize UNDO01_01.dbf
   Database file: UNDO01_01.dbf
   Database file type: file system             : File Type
   Database file size: 128000 8192 byte blocks :8192 byte Block이 128000 개

 

   [raw device 결과]

   Database file type: raw device             : File Type

   Database file size: 1408 8192 byte blocks  : 8192 byte Block이 1408 개

   ※ dbsize로 조회한 결과(Dictionary View에서 select로 조회한
      block 수도 마찬가지)에는 Datafile Header Block 및 LVCB가 포함되지 않음
 
      다음과 같은 경우에는 파일이 손상된 경우이므로 다시 복사
      Header block file size is bad;            trying raw file format...
      Header block magic number is bad
 
3. 참고사항
1) Raw Device 에서 Filesystem으로 변환
   dd if=/dev/rv_data001 of=/data01/TESTDB/data001.dbf bs=4096
      skip=1 count=2818
2) Filesystem 에서 Raw Device로 변환
   dd if=/data01/TESTDB/data001.dbf of=/dev/rv_data001 bs=4096 seek=1
3) Raw Device 에서 Raw Device로 복사
   dd if=/dev/re_data001 of=/dev/rv_data001_bk bs=4096 skip=1 seek=1
4) Filesystem 에서 file system으로 복사
   cp /data01/TESTDB/data001.dbf /data01/TESTDB/data001.bak


반응형
Posted by [PineTree]
ORACLE/Migration2015. 9. 6. 18:15
반응형


Problem Description: 
====================== 
How to backup the database on the raw device to the filesystem using 'dd'.




 
 
Solution Description: 
===================== 
 
The following commands will allow you to copy a raw device to the filesystem 
and restore from the filesystem to the raw device. 
 
You must use the dd command to copy from the raw device.  
 
Please Note: 
============  
	1. Caution is required because some AIX backup programs ignore large 
	files; you must	verify that any oversized AIX files are indeed  
        backed up.	  
  
	2. When doing copy/backup operations, please consider the 4KB 
	offset (taken by Oracle) for the Logical Volume Control Block(LVCB) at 
	the beginning of all IBM Virtual Shared Disks when performing 
	backup/restore operations. 
        
        3. When using zero offset raw devices (devices created using:
        # mklv -T O -y new_raw_device VolumeGroup NumberOfPartitions), ensure
        the 'skip' parameter is adjusted accordingly.  The offset can be 4096 
        bytes or 128 KB on AIX logical volumes or zero on AIX logical volumes 
        created with the mklv -T O option.
 
Copying to Filesystem  
--------------------------  
  
Use the command:  
  
% dd if=<raw device name> of=<filesystem name> bs=<BlockSize> 
skip=<SkipInputBlocks> 
  
Example:  
% dd if=/dev/rVh09.za.716c1 of=/a/spdevs04/ibmfs/osupport/dismith/test.ctl 
bs=4096 skip=1 
 
In the above example we specify the blocksize as 4096 bytes and skip 1 block 
for the offset for the Logical Volume Control Block(LVCB) 
 
bs=BlockSize - Specifies both the input and output block size, 
superceding the ibs and obs flags. The block size values specified with 
the bs flag must always be a multiple of the physical block size for the 
media being used. 
 
skip=SkipInputBlocks - Skips the specified SkipInputBlocks value of 
input blocks before starting to copy. 
 
Restoring from Filesystem  
--------------------------  
 
Use the command:  
  
% dd if=/a/spdevs04/ibmfs/osupport/dismith/test.ctl of=/dev/rVh09.za.716c1 
bs=4096 seek=1  
 
In the above example we specify the blocksize as 4096bytes and seek 1 block 
past the beginning of output file before copying, so we will not 
overwrite the Logical Volume Control Block(LVCB) 
 
seek=RecordNumber - Seeks the record specified by the RecordNumber  
variable from the beginning of output file before copying.


반응형
Posted by [PineTree]