1. 程式人生 > >遷移控制檔案,redo file,tempfile

遷移控制檔案,redo file,tempfile

$ ls (全在軟體目錄下面/u01,沒有在資料盤下面/oradata)

control01.ctl  redo01.log     redo02.log     redo03.log     temp01.dbf 

/u01空間不夠,計劃遷移 redo,control,temp檔案到/oradata下

/dev/oracle_lv     16.00      0.53   97%    39863    22% /u01

 

1.redo

思路:建立redo,drop redo

檢視看redo

SQL>  select INST_ID,group#,thread#,bytes/1024/1024 mb,members,status from  gv$log order by 3,2

  2  

SQL> /

 

   INST_ID     GROUP#    THREAD#         MB    MEMBERS STATUS

---------- ---------- ---------- ---------- ---------- ----------------

         1          1          1         50          1 INACTIVE

         1          2          1         50          1 INACTIVE

         1          3          1         50          1 CURRENT

SQL> select member from v$logfile;

 

MEMBER

------------------------

/u01/app/oracle/oradata/actdb/redo03.log

/u01/app/oracle/oradata/actdb/redo02.log

/u01/app/oracle/oradata/actdb/redo01.log

 

 

ALTER DATABASE ADD LOGFILE  GROUP 4 '/oradata/ACTDB/datafile/redo04.log'  SIZE 500M;

 alter system switch logfile; 

 /

 /

 /

 alter system checkpoint;

 

    INST_ID     GROUP#    THREAD#         MB    MEMBERS STATUS

---------- ---------- ---------- ---------- ---------- ----------------

         1          1          1         50          1 INACTIVE

         1          2          1         50          1 INACTIVE

         1          3          1         50          1 INACTIVE

         1          4          1        500          1 INACTIVE

         1          5          1        500          1 INACTIVE

         1          6          1        500          1 CURRENT

SQL>  alter database drop logfile group 1 ;

 

Database altered.

 

SQL>  alter database drop logfile group 2;

 

Database altered.

 

SQL>  alter database drop logfile group 3;

 

Database altered.

 

SQL> select INST_ID,group#,thread#,bytes/1024/1024 mb,members,status from  gv$log order by 3,2;

 

   INST_ID     GROUP#    THREAD#         MB    MEMBERS STATUS

---------- ---------- ---------- ---------- ---------- ----------------

         1          4          1        500          1 INACTIVE

         1          5          1        500          1 INACTIVE

         1          6          1        500          1 CURRENT

 redo就遷過去了        

  

  

  2.tempfile

思路:建立tempfile,drop tempfile

 SQL> select FILE_NAME,TABLESPACE_NAME from dba_temp_files;

 

FILE_NAME

-----------------

TABLESPACE_NAME

------------------------------

/u01/app/oracle/oradata/actdb/temp01.dbf

TEMP      

 

給temp臨時表空間新增tempfile

alter tablespace TEMP add tempfile '/oradata/ACTDB/datafile/temp01.dbf' size 32000m;

alter tablespace temp drop tempfile '/u01/app/oracle/oradata/actdb/temp01.dbf';  --需要導檔案目錄中rm檔案

ALTER DATABASE TEMPFILE '/u01/app/oracle/oradata/actdb/temp01.dbf' DROP INCLUDING DATAFILES;  --直接刪除臨時資料檔案

 

FILE_NAME                                             TABLESPACE_NAME

----------------------------------------------------- ------------------------------

/oradata/ACTDB/datafile/temp01.dbf                     TEMP     

   

 3.控制檔案

 思路:

1.create pfile

2.關閉資料庫

3.cp controlfile,修改pfile中的controlfile路徑,

4.拉起資料庫,再create spfile

5.以spfile啟動資料庫

 

 SQL> select name from v$controlfile;

 

NAME

---------------------

/u01/app/oracle/oradata/actdb/control01.ctl

/u01/app/oracle/fast_recovery_area/actdb/control02.ctl

 

 

  create pfile='/oradata/ACTDB/datafile/pfileactdb.ora' from spfile;

 

#*.control_files='/u01/app/oracle/oradata/actdb/control01.ctl','/u01/app/oracle/fast_recovery_area/actdb/control02.ctl'

*.control_files='/oradata/ACTDB/datafile/control01.ctl','/oradata/ACTDB/control02.ctl'

 

shutdown immediate

 

SQL> startup pfile='/oradata/ACTDB/datafile/pfileactdb.ora';

ORACLE instance started.

 

Total System Global Area 5.1310E+10 bytes

Fixed Size                  2258352 bytes

Variable Size            9261025872 bytes

Database Buffers         4.2010E+10 bytes

Redo Buffers               36077568 bytes

Database mounted.

 

SQL> create spfile from pfile='/oradata/ACTDB/datafile/pfileactdb.ora';

 

File created.

 

SQL> shutdown immediate;

SQL> startup

Database opened.

 

 

SQL> select name from v$controlfile;

 

NAME

-----------------------------

/oradata/ACTDB/datafile/control01.ctl

/oradata/ACTDB/control02.ctl