【翻译自mos文章】在unix/linux中使用文件描述符(FileDescripto
在unix/linux中使用文件描述符(File Descriptors)来找回被删掉的文件(数据文件or redo log) 参考原文: Retrieve deleted files on Unix / Linux using File Descriptors (Doc ID 444749.1) 适用于: Oracle Database - Enterprise Edition - Version 8.1
在unix/linux中使用文件描述符(File Descriptors)来找回被删掉的文件(数据文件or redo log)参考原文:
Retrieve deleted files on Unix / Linux using File Descriptors (Doc ID 444749.1)
适用于:
Oracle Database - Enterprise Edition - Version 8.1.7.0 to 11.2.0.3 [Release 8.1.7 to 11.2]
Linux x86
Oracle Solaris on SPARC (64-bit)
Linux x86-64
***Checked for relevance on 24-Nov-2010***
目标:在数据库没有被重启的情况下,从操作系统中找回被删掉的datafile和logfile
解决方案:
当符合下列状态时,我们可以借助unix/linux中的proc 文件系统,找回(retrieve)被删除的datafile和logfile
1.) Database is not restarted.
2.) Server is not restarted.
3.) The file was not offline before deletion.
后台进程(DBWR, PMON, SMON etc)访问被本数据库打开的所有datafiles,因此,借助于lsof命令,可以看到被进程open的 文件列表。
被进程打开的任何一个文件,都有一个文件描述符(fd)与该文件相关联。若是该文件被从操作系统中误删除了,该文件的条目(entry)并没有从proc 文件系统中被删除,借助于该entry,我们可以重建被删除的file(datafile or logfile)
如下是一个例子:
1.) Create a tablespace SQL> create tablespace my_test datafile '/emea/rdbms/64bit/app/oracle/oradata/EMR102U6/my_test_01.dbf' size 200k; Tablespace created. 2.) Accidentally, the datafile belonging to this tablespace was deleted $ rm /emea/rdbms/64bit/app/oracle/oradata/EMR102U6/my_test_01.dbf 3.) Try resizing the datafile SQL> alter database datafile '/emea/rdbms/64bit/app/oracle/oradata/EMR102U6/my_test_01.dbf' resize 250k; alter database datafile '/emea/rdbms/64bit/app/oracle/oradata/EMR102U6/my_test_01.dbf' resize 250k * ERROR at line 1: ORA-01565: error in identifying file '/emea/rdbms/64bit/app/oracle/oradata/EMR102U6/my_test_01.dbf' ORA-27037: unable to obtain file status SVR4 Error: 2: No such file or directory Additional information: 3
抢救该文件的步骤
1.)找到dbwr进程的os pid
--> $ ps -ef |grep '
$ ps -ef |grep EMR102U6|grep dbw emrdbms 21943 1 0 10:27:08 ? 0:00 ora_dbw0_EMR102U6
$ lsof -p 21943 |grep /emea/rdbms/64bit/app/oracle/oradata/EMR102U6/my_test_01.dbf Command PID USER FD TYPE DEVICE SIZE/OFF NODE NAME oracle 21943 emrdbms 270uW VREG 304,25 212992 11273825 /emea/rdbms/64bit/app/oracle/oradata/EMR102U6/my_test_01.dbf
If you are using NAS then the file name in the above command may not be displayed properly and hence this procedure should not be used under these circumstances.
注意上面的fd值--270
3.)到fd目录下
--> $ cd /proc/
$ cd /proc/21943/fd/
4.)将该表空间read onlyalter tablespace my_test read only;
read only 允许用户select 该表空间,但不允许 对该表空间的insert ,update,delete
5.)对该文件做一个copy
$ cat 270 > /emea/rdbms/64bit/app/oracle/oradata/EMR102U6/my_test_01.dbf
6.)为了确保 该file 的copy在 copy后没有被使用,执行如下:a) Take datafile offline alter tablespace my_test offline; Query the view v$datafile to verify the datafile is offline: select status from v$datafile where file#=<file number>; b) Bring datafile back online alter tablespace my_test online;
7.)将该表空间置为read write
alter tablespace my_test read write;
select tablespace_name,status from dba_tablespaces where tablespace_name='MY_TEST';
8.)对该数据文件的resize操作就正常了。
SQL> alter database datafile '/emea/rdbms/64bit/app/oracle/oradata/EMR102U6/my_test_01.dbf' resize 250k;
Database altered.
注意:该过程也适用于找回被删除的 current redo logfile

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

VS Code 系統要求:操作系統:Windows 10 及以上、macOS 10.12 及以上、Linux 發行版處理器:最低 1.6 GHz,推薦 2.0 GHz 及以上內存:最低 512 MB,推薦 4 GB 及以上存儲空間:最低 250 MB,推薦 1 GB 及以上其他要求:穩定網絡連接,Xorg/Wayland(Linux)

雖然 Notepad 無法直接運行 Java 代碼,但可以通過借助其他工具實現:使用命令行編譯器 (javac) 編譯代碼,生成字節碼文件 (filename.class)。使用 Java 解釋器 (java) 解釋字節碼,執行代碼並輸出結果。

VS Code擴展安裝失敗的原因可能包括:網絡不穩定、權限不足、系統兼容性問題、VS Code版本過舊、殺毒軟件或防火牆干擾。通過檢查網絡連接、權限、日誌文件、更新VS Code、禁用安全軟件以及重啟VS Code或計算機,可以逐步排查和解決問題。

Linux系統的五個基本組件是:1.內核,2.系統庫,3.系統實用程序,4.圖形用戶界面,5.應用程序。內核管理硬件資源,系統庫提供預編譯函數,系統實用程序用於系統管理,GUI提供可視化交互,應用程序利用這些組件實現功能。

Visual Studio Code (VSCode) 是一款跨平台、開源且免費的代碼編輯器,由微軟開發。它以輕量、可擴展性和對眾多編程語言的支持而著稱。要安裝 VSCode,請訪問官方網站下載並運行安裝程序。使用 VSCode 時,可以創建新項目、編輯代碼、調試代碼、導航項目、擴展 VSCode 和管理設置。 VSCode 適用於 Windows、macOS 和 Linux,支持多種編程語言,並通過 Marketplace 提供各種擴展。它的優勢包括輕量、可擴展性、廣泛的語言支持、豐富的功能和版

VS Code 可以在 Mac 上使用。它具有強大的擴展功能、Git 集成、終端和調試器,同時還提供了豐富的設置選項。但是,對於特別大型項目或專業性較強的開發,VS Code 可能會有性能或功能限制。

要查看 Git 倉庫地址,請執行以下步驟:1. 打開命令行並導航到倉庫目錄;2. 運行 "git remote -v" 命令;3. 查看輸出中的倉庫名稱及其相應的地址。

VS Code 全稱 Visual Studio Code,是一個由微軟開發的免費開源跨平台代碼編輯器和開發環境。它支持廣泛的編程語言,提供語法高亮、代碼自動補全、代碼片段和智能提示等功能以提高開發效率。通過豐富的擴展生態系統,用戶可以針對特定需求和語言添加擴展程序,例如調試器、代碼格式化工具和 Git 集成。 VS Code 還包含直觀的調試器,有助於快速查找和解決代碼中的 bug。
