2024年1月31日 星期三

更改 Standby DB 的 Temp File 位置

Oracle 版本: 大於 11g


問題描述:

一般來說要更改 Temp File 位置有兩個方法,如果是 small file 格式的 Temporary Tablespace ,那就可以使用 alter tablespace temp add tempfile 新增一個 temp file ,然後再 alter tablespace temp drop tempfile 把不要的 temp file 刪除;如果是 big file 格式的 Temporary Tablespace ,那麼就只能新建一個 Temporary Tablespace 再把舊的 Temporary Tablespace 刪除。


建立 Standby DB 時, Temp File 並不會隨著 Data File 一起 Restore , Standby 在 mount 狀態時並不會使用 Temp File ,只有在 open read only 才會產生 Temp File ,而 Standby 並無法使用 alter tablespace 的指令新增 / 刪除 Temp File ,或者是重建 Temporary Tablespace ,那麼要如何在 Standby 更改 Temp File 位置 ?


解決方法:

由於 Standby 在 mount 狀態下 Temp File 並不會被使用到,因此只要在 mount 狀態下直接更改 Temp File 路徑即可,使用 rman 就可以達成 :

### Temp 位於 filesystem ###

RMAN> run {

        set newname for tempfile '/oradata/oracl/temp01.dbf' to '/oradata/oracl/temp02.dbf';

       switch tempfile all;}


### Temp 位於 ASM ###

RMAN> run {

       set newname for tempfile 7 to '+DATA2';

       switch tempfile all;}


更改之後可以查詢 v$temp 確認路徑已更改 :

### Temp 位於 filesystem ###

SQL> select file#,name from v$tempfile;

     FILE# NAME

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

         1   /oradata/oracl/temp02.dbf


### Temp 位於 ASM ###

SQL> select file#,name from v$tempfile;

     FILE# NAME

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

         7   +DATA2


之後在 Standby open read only 就會在新的路徑產生新的 Temp File 。


沒有留言:

張貼留言