rac歸檔模式/非歸檔模式下檔案建至本地儲存修復方法-ORA-01157

shawnloong發表於2018-07-01
rac歸檔模式下檔案建至本地儲存修復方法(以下為測試,生產環境慎重操作)
模擬誤操作
節點1新增資料檔案

點選(此處)摺疊或開啟

  1. SQL> alter tablespace netdata add datafile 'netdata03.dbf' size 20M;

節點2查詢

點選(此處)摺疊或開啟

  1. SQL> select file_name from dba_data_files;
  2. ERROR:
  3. ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
  4. ORA-01110: data file 7: '/u01/app/oracle/product/11.2.0/db_1/dbs/netdata02.dbf'

將錯誤新增datafile offline

點選(此處)摺疊或開啟

  1. SQL> alter database datafile 7 offline;
  2. Database altered.
修改檔案路徑

點選(此處)摺疊或開啟

  1. SQL> alter database rename file '/u01/app/oracle/product/11.2.0/db_1/dbs/netdata02.dbf' to '+DATA1/DEVDB/DATAFILE/netdata02.dbf';


  2. Database altered.
recovery datafile

點選(此處)摺疊或開啟

  1. SQL> recover datafile 7;
  2. Media recovery complete.
datafile online

點選(此處)摺疊或開啟

  1. SQL> alter database datafile 7 online;


  2. Database altered.

節點2查詢已經正常

點選(此處)摺疊或開啟

  1. SQL> select file_name from dba_data_files;


  2. FILE_NAME
  3. --------------------------------------------------------------------------------
  4. +DATA1/devdb/datafile/users.269.937046643
  5. +DATA1/devdb/datafile/undotbs1.276.937046643
  6. +DATA1/devdb/datafile/sysaux.277.937046643
  7. +DATA1/devdb/datafile/system.268.937046635
  8. +DATA1/devdb/datafile/undotbs2.267.937047083
  9. +DATA1/devdb/datafile/netdata.284.937049537
  10. +DATA1/devdb/datafile/netdata02.dbf


  11. 7 rows selected.
rac非歸檔模式下檔案建至本地儲存修復方法

點選(此處)摺疊或開啟

  1. SQL> archive log list;
  2. Database log mode No Archive Mode
  3. Automatic archival Disabled
  4. Archive destination USE_DB_RECOVERY_FILE_DEST
  5. Oldest online log sequence 175
  6. Current log sequence 177
  7. SQL>

  8. SQL> show parameters cluster;


  9. NAME TYPE VALUE
  10. ------------------------------------ ----------- ------------------------------
  11. cluster_database boolean TRUE
  12. cluster_database_instances integer 2
  13. cluster_interconnects string
誤操作模擬

點選(此處)摺疊或開啟

  1. SQL> alter tablespace netdata add datafile 'netdata03.dbf' size 20M;

  2. Tablespace altered.

  3. SQL> select file_name from dba_data_files;
  4. ERROR:
  5. ORA-01157: cannot identify/lock data file 8 - see DBWR trace file
  6. ORA-01110: data file 8: '/u01/app/oracle/product/11.2.0/db_1/dbs/netdata03.dbf'
嘗試offline報錯

點選(此處)摺疊或開啟

  1. SQL> alter database datafile 8 offline;
  2. alter database datafile 8 offline
  3. *
  4. ERROR at line 1:
  5. ORA-01145: offline immediate disallowed unless media recovery enabled



關庫

點選(此處)摺疊或開啟

  1. [grid@rac1-213-11 ~]$ srvctl stop database -d devdb -o immediate
cp檔案至asm

點選(此處)摺疊或開啟

  1. [grid@rac1-213-11 ~]$ asmcmd
  2. ASMCMD> pwd
  3. +DATA1/DEVDB/DATAFILE
  4. ASMCMD> cp /u01/app/oracle/product/11.2.0/db_1/dbs/netdata03.dbf .
  5. copying /u01/app/oracle/product/11.2.0/db_1/dbs/netdata03.dbf -> +DATA1/DEVDB/DATAFILE/netdata03.dbf
  6. ASMCMD> quit
啟動到mount

點選(此處)摺疊或開啟

  1. [grid@rac1-213-11 ~]$ srvctl start database -d devdb -o mount


修改檔案路徑

點選(此處)摺疊或開啟

  1. [root@rac1-213-11 ~]# su - oracle
  2. [oracle@rac1-213-11 ~]$ sqlplus / as sysdba
  3. SQL*Plus: Release 11.2.0.4.0 Production on Sun Jul 1 22:02:50 2018
  4. Copyright (c) 1982, 2013, Oracle. All rights reserved.
  5. Connected to:
  6. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
  7. With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
  8. Data Mining and Real Application Testing options
  9. SQL> alter database rename file '/u01/app/oracle/product/11.2.0/db_1/dbs/netdata03.dbf' to '+DATA1/DEVDB/DATAFILE/netdata03.dbf';
  10. Database altered.
節點2查詢 正常

點選(此處)摺疊或開啟

  1. SQL> select open_mode from v$database;

  2. OPEN_MODE
  3. --------------------
  4. READ WRITE



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

相關文章