ORACLE/Migration2015. 3. 23. 14:17
반응형
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
 

[출처] 이관 - raw device to file system(dd copy)|작성자 smileDBA

[출처]    http://power.iotn.co.kr/zboard.php?id=9_1_bbs&no=1197

 


[ Oracle 9.2.0.8 ]

[ filesystem to raw device ]
$ dbfsize /oracle/system/tools01.dbf

Database file: /data/system/tools01.dbf
Database file type: file system
Database file size: 83840 8192 byte blocks

SQL> alter database datafile '/data/system/tools01.dbf' offline;
SQL> !dd if=/data/system/tools01.dbf of=/dev/rdsk/c0t0d0s1 bs=8192 count=83840
83840+0 레코드 입력
83840+0 레코드 출력
SQL> alter database rename file '/data/system/tools01.dbf' to '/dev/rdsk/c0t0d0s1';
SQL> recover datafile '/dev/rdsk/c0t0d0s1';
SQL> alter database datafile '/dev/rdsk/c0t0d0s1' online;

[ raw device to filesystem ]

$ dbfsize /dev/rdsk/c0t0d0s1

Database file: /dev/rdsk/c0t0d0s1
Database file type: raw device
Database file size: 83840 8192 byte blocks

SQL> alter database datafile '/dev/rdsk/c0t0d0s1' offline;
SQL> !dd if=/dev/rdsk/c0t0d0s1 of=/data/system/tools01.dbf bs=8192 count=83840
83840+0 레코드 입력
83840+0 레코드 출력
SQL> alter database rename file '/dev/rdsk/c0t0d0s1' to '/data/system/tools01.dbf';
SQL> recover datafile '/data/system/tools01.dbf';
ORA-00283: recovery session canceled due to errors
ORA-01110: data file 2: '/data/system/tools01.dbf'
ORA-01122: database file 2 failed verification check
ORA-01110: data file 2: '/data/system/tools01.dbf'
ORA-01200: actual file size of 83839 is smaller than correct size of 83840 blocks
SQL> !dd if=/dev/rdsk/c0t0d0s1 of=/data/system/tools01.dbf bs=8192 count=83841
83841+0 레코드 입력
83841+0 레코드 출력
14:31:23 SQL> recover datafile '/data/system/tools01.dbf';
Media recovery complete.
14:31:38 SQL> alter database datafile '/data/system/tools01.dbf' online;
Database altered.

 
  $ rawutl -s /dev/vx/rdsk/oracle/system.dbf [ 운영중인 lv size 2G, datafile size 2G ]
2148532224 [ 2G ]
$ rawutl -s /dev/vx/rdsk/oracle/r_system.dbf [ 임시 복구 lv size 3G, datafile size 2G ]
3221225472 [ 3G ]

$ dbfsize /dev/vx/rdsk/oracle/system.dbf
Database file: /dev/vx/rdsk/oracle/system.dbf
Database file type: raw device
Database file size: 262144 8192 byte blocks

$ dbfsize /dev/vx/rdsk/oracle/r_system.dbf
Database file: /dev/vx/rdsk/oracle/r_system.dbf
Database file type: raw device
Database file size: 262144 8192 byte blocks

SQL> select file#,name,bytes from v$datafile where file#=1;
 FILE# NAME BYTES
---------- ---------------------------------------- ----------
 1 /dev/vx/rdsk/oracle/system.dbf 2147483648 / 8192 = 262144 +1 = 262145

$ dd if=/dev/vx/rdsk/oracle/r_system.dbf of=system.dbf bs=8192 count=262145
$ ls -al
-rw-r--r-- 1 oracle dba 2147491840 9월 7일 13:28 system.dbf

$ dbfsize system.dbf
Database file: system.dbf
Database file type: file system
Database file size: 262144 8192 byte blocks

$ dd if=/dev/vx/rdsk/oracle/r_system.dbf of=system.dbf count=262144
$ ls -al
-rw-r--r-- 1 oracle dba 134217728 9월 7일 13:31 system.dbf [ 134217728 / 262144 = 512 block ]

 

  for AIX

select 'dd if='||f.name||' of='||lower(t.name)||
row_number() over (partition by t.name order by f.file# )||
'.dbf bs=4k count='||to_char(((BLOCKS*BLOCK_SIZE)/4096)+4906)||
' #'||t.name||' '||f.file#
 from v$datafile f,v$tablespace t where t.ts#=f.ts#;

or

select 'dd if='||fname||' of='||lower(tname)||
decode(sign(rn -9),1,'','0')||rn||
'.dbf bs=4k count='||to_char(((BLOCKS*BLOCK_SIZE)/4096)+4906)||
' #'||tname||' '||file#
from (select f.name fname,t.name tname,f.file#,blocks,block_size,
row_number() over (partition by t.name order by f.file# ) rn
from v$datafile f,v$tablespace t where t.ts#=f.ts#);

select 'dd if='||member||' of=redo'||group#||'.log bs=4k count='||to_char(((lesiz*lebsz)/4096)+4096)
 from v$logfile f, x$kccle l where f.group#=l.lenum;

select 'dd if='||name||' of=control.ctl bs=4k count='||to_char(((file_size_blks*block_size)/4096)+4096)
 from v$controlfile where rownum=1;

wait: there are no child processes.
같은 서버에서 test 나기도하고 안나기도함.
파일크기 같고 rename 성공


  -- DSVM prime
vxprint -g data -m gj_v4_001_5g|grep devsubtype
 devsubtype=dsvmprime
dd if=/dev/vx/rdsk/data/gj_v4_001_5g of=/data/oradata/TSADMI_04.dbf bs=8192k
-- DSVM
vxprint -g data -m gj_v3_013_10g|grep devsubtype
 devsubtype=dsvm
dd if=/dev/vx/rdsk/data/gj_v3_013_10g of=/data/oradata/TSADMI_05.dbf bs=4096 skip=1 count=2560002

반응형
Posted by [PineTree]