Datafile 경로 변경 절차(online, offline) File system, ASM


참조문서


(How to Rename or Move Datafiles and Logfiles (문서 ID 115424.1),


How to move a datafile from a file system to ASM (문서 ID 390274.1)


How to move ASM database files from one diskgroup to another ? (문서 ID 330103.1))


²  Datafile 경로 및 이름 변경 시에 가장 중요한 point 는 Online/Offline 여부이다.


SYSTEM 이나 SYSAUX를 변경하기 위해서는 필히 Shutdown 이 필요하고 이외의 Datafile 은 Online 과 Offline 모두 가능하다.


 


A.     OPEN 상태에서 Rename


                         i.         File system


①    현재 Datafile 위치와 상태 확인


②    tablespace 를 read only 상태로 변경(service 시간 최대화를 위해)


③    기존 경로의 datafile 을 새 경로에 copy


④    tablespace 를 offline 상태로 변경


⑤    tablespace Rename (두가지 syntax 모두 가능)


⑥    tablespace online 상태로 변경


⑦    tablespace read write 상태로 변경


⑧    새로 변경한 구조를 저장하기 위해 control file trace file 로 backup


–       alter database backup controlfile to trace;


⑨    기존 경로의 datafile 삭제







명령어


SQL> select file_name, status from dba_data_files


where tablespace_name=’EXAMPLES’;


SQL> alter tablespace EXAMPLES read only;


SQL> select tablespace_name, status from dba_tablespaces;


$ cp /u01/oradata/example.dbf /oradata/datafile/example.dbf


SQL> alter tablespace EXAMPLE offline;


SQL> alter database rename file


‘/u01/oradata/example.dbf’ to ‘/oradata/datafile/example.dbf’


또는


SQL> alter tablespace EXAMPLE rename datafile


‘/u01/oradata/example.dbf’ to ‘/oradata/datafile/example.dbf’


SQL> alter tablespace EXAMPLE online;


SQL> alter tablespace EXAMPLE read write;


SQL> alter database backup controlfile to trace


$ rm /u01/oradata/example.dbf


 


                        ii.         ASM


①    move 할 datafile 경로 확인 후


②    move 할 datafile 의 diskgroup 확인


③    Tablespace offline 상태로 변경


④    가) DBMS_FILE_TRANSFER Package 이용 해서 수행


나) RMAN 을 이용 해서 수행


⑤    Datafile Recover


⑥    Tablespace Online 상태로 변경


⑦    Rename 한 위치 확인


⑧    기존 위치의 datafile 삭제







명령어


SQL> select file_name from dba_data_files;


SQL> select group_number, name from v$asm_diskgroup; (ASM Instance)


SQL> alter database datafile


‘+ASMDISK2/tech/datafile/users.256.565313’ offline;


l  DBMS_FILE_TRANSFER Package 이용


SQL> create or replace directory tech1 as ‘+ASMDISK1/tech/datafile’;


SQL> alter disgroup ASMDISK2 add directory ‘+ASMDISK2/test’;


(ASM Instance)


SQL> create or replace directory tech2 as ‘+ASMDISK2/test’;


SQL> begin


DBMS_FILE_TRANSFER.COPY_FILE(


source_directory_object => ‘TECH1’,


source_file_name => ‘USERS. users.256.565313’,


destination_directory_object => ‘TECH2’,


destination_file_name => ‘UGERS01.DBF’);


END;


SQL> alter database rename file


‘+ASMDISK2/tech/datafile/ users.256.565313’


to ‘+ASMDISK1/tech/datafile/ users.256.565313’;


 


 


l  RMAN 을 이용


RMAN> copy datafile


‘+ASMDISK2/tech/datafile/users.256.565313’ to  ‘+ASMDISK1’;


RMAN> run { set newname for datafile


‘+ASMDISK2/tech/datafile/ users.256.565313’


to ‘+ASMDISK1/tech/datafile/ users.256.565313’;


switch datafile all; }


 


SQL> recover datafile ‘+ASMDISK1/tech/datafile/ users.256.565313’


SQL> alter database datafile 


‘+ASMDISK1/tech/datafile/ users.256.565313’ online


SQL> select file_name from dba_data_files;


SQL> alter diskgroup ASMDISK2 drop file users.256.565313;


(ASM Instance)


 


B.      Shutdown 상태에서 Rename


                         i.         File system


①    Instance Shutdown


②    기존 경로의 datafile 을 새 경로에 copy


③    Database Mount


④    Datafile Rename


⑤    Database Open


⑥    기존 경로의 datafile 삭제







명령어


SQL> shutdown immediate


$ cp /u01/oracle/oradata/system01.dbf /oradata/system01.dbf


SQL> startup mount


SQL> alter database rename file


‘/u01/oracle/oradata/system01.dbf’ to ‘/oradata/system01.dbf;


SQL> alter database open;


$ rm /u01/oracle/oradata/system01.dbf


 


                        ii.         ASM


①    새로운 경로에 Copy 본 생성


②    Instance Shutdown &  Database mount


③    Copy 해 놓은 file 로 변경


④    Database recover


 







명령어


RMAN> backup as copy tablespace system format ‘새로운 경로’;


RMAN> shutdown immediate


RMAN> startup mount


RMAN> switch tablespace system to copy;


RMAN> recover database;


 


 


 

By haisins

오라클 DBA 박용석 입니다. haisins@gmail.com 으로 문의 주세요.

답글 남기기

이메일 주소를 발행하지 않을 것입니다. 필수 항목은 *(으)로 표시합니다