利用dd命令實現raw db到file系統db的轉換!

warehouse發表於2008-08-02
特別需要主要的就是要清楚的知道各類檔案(ctl,dbf,redo)檔案頭佔用了幾個block,當然還要知道各類檔案他們的block的大小和單位![@more@]

下面檔案raw_convert_fs.sql 中記錄的是一個raw db到file系統db的大致過程!

[oracle@xys orcl]$ more raw_convert_fs.sql
SQL> !

SQL> @ dbf.sql

FILE_NAME BYTES TABLESPACE BLOCKS BYTES+BYTES/BLOCKS
---------------- ---------- ---------- ---------- ------------------
/dev/raw/raw1 314572800 SYSTEM 38400 314580992
/dev/raw/raw3 157286400 UNDOTBS1 19200 157294592
/dev/raw/raw2 125829120 SYSAUX 15360 125837312
/dev/raw/raw6 5242880 USERS 640 5251072
/dev/raw/raw14 5242880 TRANS 640 5251072

SQL> ! dd if=/dev/raw/raw14 of=trans.dbf bs=8k count=641

SQL> !

SQL> spool raw_convert_fs.sql append
SQL> ! dd if=/dev/raw/raw6 of=users01.dbf bs=8k count=641

SQL> ! dd if=/dev/raw/raw2 of=sysaux01.dbf bs=8k count=15361

SQL> @ dbf.sql

FILE_NAME BYTES TABLESPACE BLOCKS BYTES+BYTES/BLOCKS
---------------- ---------- ---------- ---------- ------------------
/dev/raw/raw1 314572800 SYSTEM 38400 314580992
/dev/raw/raw3 157286400 UNDOTBS1 19200 157294592
/dev/raw/raw2 125829120 SYSAUX 15360 125837312
/dev/raw/raw6 5242880 USERS 640 5251072
/dev/raw/raw14 5242880 TRANS 640 5251072

SQL> ! dd if=/dev/raw/raw3 of=undotbs01.dbf bs=8k count=19201

SQL> ! dd if=/dev/raw/raw1 of=system01.dbf bs=8k count=38401

SQL> desc v$controlfile;
Name Null? Type
----------------------------------------- -------- ----------------------------
STATUS VARCHAR2(7)
NAME VARCHAR2(513)
IS_RECOVERY_DEST_FILE VARCHAR2(3)
BLOCK_SIZE NUMBER
FILE_SIZE_BLKS NUMBER

SQL> select name , block_size , file_size_blks from v$controlfile;

NAME
--------------------------------------------------------------------------------
BLOCK_SIZE FILE_SIZE_BLKS
---------- --------------
/dev/raw/raw7
16384 430

/dev/raw/raw8
16384 430

SQL> col name format a20
SQL> select name , block_size , file_size_blks from v$controlfile;

NAME BLOCK_SIZE FILE_SIZE_BLKS
-------------------- ---------- --------------
/dev/raw/raw7 16384 430
/dev/raw/raw8 16384 430

SQL> ! dd if=/dev/raw/raw7 of=control01.ctl bs=16k count=430

SQL> ! dd if=/dev/raw/raw8 of=control02.ctl bs=16k count=430

SQL> host pwd

SQL> host pwd ls -l

SQL> host ls -l

SQL> desc v$logfile;
Name Null? Type
----------------------------------------- -------- ----------------------------
GROUP# NUMBER
STATUS VARCHAR2(7)
TYPE VARCHAR2(7)
MEMBER VARCHAR2(513)
IS_RECOVERY_DEST_FILE VARCHAR2(3)

SQL> col member format a20
SQL> select member , bytes/512 from v$logfile;
select member , bytes/512 from v$logfile
*
ERROR at line 1:
ORA-00904: "BYTES": invalid identifier


SQL> select member from v$logfile;

MEMBER
--------------------
/dev/raw/raw9
/dev/raw/raw10
/dev/raw/raw11

SQL> select bytes/512 from v$log;

BYTES/512
----------
20480
20480
20480

SQL> select bytes/1024/512 from v$log;

BYTES/1024/512
--------------
20
20
20

SQL> select distinct block_size from v$archived_log;

BLOCK_SIZE
----------
512

SQL> ! dd if=/dev/raw/raw9 of=redo01.log bs=512k count=20

SQL> select member from v$logfile;

MEMBER
--------------------
/dev/raw/raw9
/dev/raw/raw10
/dev/raw/raw11

SQL> ! dd if=/dev/raw/raw10 of=redo02.log bs=512k count=20

SQL> ! dd if=/dev/raw/raw11 of=redo03.log bs=512k count=20

SQL> create pfile from spfile;

File created.

--=============================

raw db下各類檔案如下:

[oracle@xys orcl]$ sqlplus as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Aug 2 22:40:40 2008

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


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> col file_name fromat a50
SP2-0158: unknown COLUMN option "fromat"
SQL> col file_name format a50
SQL> select file_name from dba_data_files;

FILE_NAME
--------------------------------------------------
/opt/app/oracle/oradata/orcl/system01.dbf
/opt/app/oracle/oradata/orcl/undotbs01.dbf
/opt/app/oracle/oradata/orcl/sysaux01.dbf
/opt/app/oracle/oradata/orcl/users01.dbf
/opt/app/oracle/oradata/orcl/trans.dbf

SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
/opt/app/oracle/oradata/orcl/control01.ctl
/opt/app/oracle/oradata/orcl/control02.ctl

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/opt/app/oracle/oradata/orcl/redo01.log
/opt/app/oracle/oradata/orcl/redo02.log
/opt/app/oracle/oradata/orcl/redo03.log

SQL>

轉化之後db_name並沒有發生變化,因此要想在同一臺os上啟動轉化後的db,需要建立bdump,cdump,udmp等各類檔案以及需要編輯引數檔案建立口令檔案。

轉換為檔案系統 db各類檔案如下:

SQL> connect as sysdba
Connected.
SQL> col file_name format a50
SQL> select file_name from dba_data_files;

FILE_NAME
--------------------------------------------------
/opt/app/oracle/oradata/orcl/system01.dbf
/opt/app/oracle/oradata/orcl/undotbs01.dbf
/opt/app/oracle/oradata/orcl/sysaux01.dbf
/opt/app/oracle/oradata/orcl/users01.dbf
/opt/app/oracle/oradata/orcl/trans.dbf

SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
/opt/app/oracle/oradata/orcl/control01.ctl
/opt/app/oracle/oradata/orcl/control02.ctl

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/opt/app/oracle/oradata/orcl/redo01.log
/opt/app/oracle/oradata/orcl/redo02.log
/opt/app/oracle/oradata/orcl/redo03.log

SQL>

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/19602/viewspace-1008367/,如需轉載,請註明出處,否則將追究法律責任。

相關文章