oracle之 RAC本地資料檔案遷移至ASM

張衝andy發表於2017-09-16

系統環境:
CentOS release 6.7 (Final)
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit

操作過程:

1、新增資料檔案或者建立表空間時,誤操作將路徑指定為單節點本地

SQL> alter tablespace users add datafile '/home/oracle/test.dbf' size 4m;
Tablespace altered.


SQL> 
set line 180
col file_name for a60 
col tablespace_name for a15 
select file_name,file_id,online_status,tablespace_name from dba_data_files;

FILE_NAME FILE_ID ONLINE_ TABLESPACE_NAME
------------------------------------------------------------ ---------- ------- ---------------
+DATA/devdb/datafile/users.259.936769201 4 ONLINE USERS
+DATA/devdb/datafile/undotbs1.258.936769201 3 ONLINE UNDOTBS1
+DATA/devdb/datafile/sysaux.257.936769199 2 ONLINE SYSAUX
+DATA/devdb/datafile/system.256.936769199 1 SYSTEM SYSTEM
+DATA/devdb/datafile/example.265.936769441 5 ONLINE EXAMPLE
/home/oracle/test.dbf 6 ONLINE USERS
6 rows selected.

2.乾淨關閉RAC2,RAC1
srvctl stop database -d XXX

3.將RAC1啟動mount狀態
SQL> startup mount;

4.透過RMAN CP命令複製資料檔案
node1-> rman target /
connected to target database: DEVDB (DBID=841499351, not open)

RMAN> copy datafile '/home/oracle/test.dbf' to '+data';

Starting backup at 2017/09/17 02:13:03
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=36 instance=devdb1 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/home/oracle/test.dbf
output file name=+DATA/devdb/datafile/users.273.954900787 tag=TAG20170917T021305 RECID=3 STAMP=954900786
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2017/09/17 02:13:07

Starting Control File and SPFILE Autobackup at 2017/09/17 02:13:07
piece handle=+FLASH/devdb/autobackup/2017_09_17/s_954900552.304.954900789 comment=NONE
Finished Control File and SPFILE Autobackup at 2017/09/17 02:13:10

5.在 ASM 中查詢 /home/oracle/test.dbf 對映過來對應的 ASM 檔名
ASMCMD> cd data/devdb/datafile
ASMCMD> pwd
+data/devdb/datafile
ASMCMD> ls -lt user*
Type Redund Striped Time Sys Name
DATAFILE UNPROT COARSE SEP 17 03:00:00 Y USERS.273.954900787
DATAFILE UNPROT COARSE SEP 17 03:00:00 Y USERS.259.936769201
說明: /home/oracle/test.dbf 對應為 USERS 表空間, 所以這裡為 user*

6.在sqlplus中將資料庫啟動到mount狀態,rename資料檔案
SQL> alter database rename file '/home/oracle/test.dbf' to '+DATA/devdb/datafile/USERS.273.954900787';

7.將rac1,rac2啟動
#RAC1
SQL> alter database open;
Database altered.
SQL>

#RAC2
SQL> startup;


附:SYSTEM資料檔案移植步驟(過程說明): 
1. Stop DB.
2. Move the datafile using asmcmd.
3. Mount the DB.
4. Rename the datafile.
5. Open the DB.
6. On other RAC nodes you still need to bounce the database because it is SYSTEM tablespace, otherwise you will keep getting errors ORA-01516 or original error ORA-01157: cannot identify/lock data file.

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

相關文章