Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Restore data files that were accidentally deleted by rm

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

one。 Analog data file deletion

[oracle@node1] $sqlplus / as sysdba SQL*Plus: Release 11.2.0.3.0 Productionon Sat Dec31 22:00:52 2011 Copyright (c) 1982, 2011, Oracle. All rights reserved. -- Database version Connected to: Oracle Database11g Enterprise Edition Release 11.2.0.3.0-64bit Production With the Partitioning, Oracle Label Security, OLAP, Data Mining, Oracle DatabaseVault and Real Application Testing options-- all data files SQL > selectname from v$datafile NAME-/ opt/oracle/oradata/ora11g/system01.dbf / opt/oracle/oradata/ora11g/sysaux01.dbf / opt/oracle/oradata/ora11g/undotbs01.dbf / opt / oracle/oradata/ora11g/users01.dbf / opt/oracle/oradata/ora11g/example01.dbf-- Delete the example01.dbf data file SQL >! rm / opt/oracle/oradata/ora11g/example01.dbf SQL >! ls-l / opt/oracle/oradata/ora11g/example01.dbf ls: / opt/oracle/oradata/ora11g/example01.dbf: there is no such file or directory-- because the data file was deleted Failed to create table SQL > createtable t_xifenfei tablespace example 2 as select* from dba_tables As select * fromdba_tables * ERROR atline 2: ORA-01116: error in opening databasefile 5 ORA-01110: data file 5 VOTERGULAR ORA-27041 OTA 11g Unip. Example01.dbf' ORA-27041: unableto open file Linux-x86_64 Error: 2:No such file or directory Additional information: 3

two。 Retrieve the data file

-- find dbw process spid [oracle@node1 ~] $ps-ef | grepdbw | grep-v grep oracle 18387 10 Dec22? 00:00:12 ora_dbw0_ora11g-- View all file handles of this process [oracle@node1 ~] $ll/proc/18387/fd total 0 lr-x- 1 oracle oinstall 64 12-31 22:03 0-> / dev/null lashWX-1 oracle oinstall 64 12-31 22:03 1-> / dev/null Lr-x- 1 oracle oinstall 64 12-31 22:03 10-> / dev/zero lr-x- 1 oracle oinstall 64 12-31 22:03 11-> / dev/zero lr-x- 1 oracle oinstall 64 12-31 22:03 12-> / opt/oracle/product/11.2.0/db_1/rdbms/mesg/orazhs.msb lrwx- 1 oracle oinstall 64 12-31 22:03 13-> / opt / oracle/product/11.2.0/db_1/dbs/hc_ora11g.dat lr-x- 1 oracle oinstall 64 12-31 22:03 14-> / proc/18387/fd lr-x- 1 oracle oinstall 64 12-31 22:03 15-> / dev/zero lr-x- 1 oracle oinstall 64 12-31 22:03 16-> / opt/oracle/product/11.2.0/db_1/rdbms/mesg/oraus .msb lrwx- 1 oracle oinstall 64 12-31 22:03 17-> / opt/oracle/product/11.2.0/db_1/dbs/hc_ora11g.dat lrwx- 1 oracle oinstall 64 12-31 22:03 18-> / opt/oracle/product/11.2.0/db_1/dbs/lkORA11G lr-x- 1 oracle oinstall 64 12-31 22:03 19-> / opt/oracle/product/11.2.0 / db_1/rdbms/mesg/orazhs.msb lmurwx1 oracle oinstall 64 12-31 22:03 2-> / dev/null lr-x- 1 oracle oinstall 64 12-31 22:03 20-> / opt/oracle/product/11.2.0/db_1/rdbms/mesg/oraus.msb lrwx- 1 oracle oinstall 64 12-31 22:03 21-> socket: [441562] lrwx- 1 oracle oinstall 64 12-31 22:03 12-> / opt/oracle/oradata/ora11g/control01.ctl lrwx- 1 oracle oinstall 64 12-31 22:03 257-> / opt/oracle/oradata/ora11g/system01.dbf lrwx- 1 oracle oinstall 64 12-31 22:03 258-> / opt/oracle/oradata/ora11g/sysaux01.dbf lrwx- 1 oracle oinstall 64 12-31 22:03 259-> / opt/oracle/oradata/ora11g/undotbs01.dbf lrwx-- -1 oracle oinstall 64 12-31 22:03 260-> / opt/oracle/oradata/ora11g/users01.dbf lrwx- 1 oracle oinstall 64 12-31 22:03 261-> / opt/oracle/oradata/ora11g/example01.dbf (deleted) lrwx- 1 oracle oinstall 64 12-31 22:03 262-> / opt/oracle/oradata/ora11g/temp01.dbf lr-x- 1 oracle oinstall 64 12-31 22:03 3-> / dev / null lr-x- 1 oracle oinstall 64 12-31 22:03 4-> / dev/null lrwx- 1 oracle oinstall 64 12-31 22:03 5-> / opt/oracle/product/11.2.0/db_1/dbs/hc_ora11g.dat lr-x- 1 oracle oinstall 64 12-31 22:03 6-> / dev/null lr-x- 1 oracle oinstall 64 12-31 22:03 7-> / dev/null lr-x- 1 oracle oinstall 64 12-31 22:03 8-> / dev/null lr-x- 1 oracle oinstall 64 12-31 22:03 9-> / dev/null-restore data file via handle [deleted data file will be marked (deleted)] [oracle@node1 ~] $cp / proc/18387/fd/261/opt/oracle/oradata/ora11g/example01.dbf-confirm the data text The piece has been successfully restored [oracle@node1 ~] $ll/opt/oracle/oradata/ora11g/example01.dbf-rw-r- 1 oracle oinstall 362422272 12-31 22:05/opt/oracle/oradata/ora11g/example01.dbf

three。 Data file online

SQL > alterdatabase datafile 5 offline; Database altered.

SQL > recover datafile 5; Media recovery complete.

SQL > alterdatabase datafile 5 online; Database altered.

SQL > createtable t_xifenfei tablespace example 2 as select* from dba_tables; Table created.

four。 Supplementary explanation

When you accidentally delete a data file using the os command, do not restart the database or operating system hurriedly. You can retrieve the data file through the handle related to the dbwn process.

If it is a unix system, you may need to find the handle through lsof and then implement it through cp

[root@xifenfei ~] # tar xjf lsof_4.86.tar.bz2 [root@xifenfei lsof_4.86] # tar xvf lsof_4.86_src.tar [root@xifenfei lsof_4.86_src] #. / Configure No target dialect was specified. Usage: Configure:-clean: clean up previous configuration-d |-dialects: display a list of supported dialect versions-h |-help: display help information-n: avoid AFS, customization And inventory checks (* USE-d TO GET TESTED DIALECT VERSION NUMBERS****): aix | aixgcc: IBM AIX xlc (aix) or gcc (aixgcc) darwin: Apple Darwin decosf: DEC OSF/1 digital_unix | du: Digital UNIX freebsd: FreeBSD hpux | hpuxgcc: HP-UX cc (hpux) or gcc (hpuxgcc) linux: Linux netbsd: NetBSD nextstep | next | ns | nxt: NEXTSTEP openbsd: OpenBSD openstep | os: OPENSTEP osr | sco: SCO OpenServer < 6.0.0, SCO devloper's compiler osrgcc | scogcc: SCO OpenServer < 6.0.0, gcc compiler osr6: gcc compiler osr6 6.0.0 SCO compiler solaris | solariscc: Solaris gcc (solaris) or cc (solariscc) tru64: Tru64 UNIX unixware | uw: SCO | Caldera UnixWare [root@xifenfei lsof_4.86_src] #. / Configure linux [root@xifenfei lsof_4.86_src] # make [root@xifenfei lsof_4.86_src] # make install

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report