您好,欢迎访问一九零五行业门户网

【只读表空间--恢复-1】

1只读 ---备份只读 故障 只读 还原有故障的数据文件 2只读 ---备份只读 可写 故障 还原备份数据文件,重做recover 3只读 ---备份可写 只读 故障 还原备份数据文件,recover 1 进入rman,确保是否有备份的文件: [oracle@oracle ~]$ rman target /recovery man
1>只读 ---备份只读 故障 只读 还原有故障的数据文件
2>只读 ---备份只读 可写 故障 还原备份数据文件,重做recover
3>只读 ---备份可写 只读 故障 还原备份数据文件,recover
1>
进入rman,确保是否有备份的文件:
[oracle@oracle ~]$ rman target /recovery manager: release 10.2.0.5.0 - production on thu nov 6 09:44:08 2014copyright (c) 1982, 2007, oracle. all rights reserved.connected to target database: jadl10g (dbid=2011508104)rman> list backup of tablespace users;using target database control file instead of recovery cataloglist of backup sets===================bs key type lv size device type elapsed time completion time------- ---- -- ---------- ----------- ------------ ---------------1 full 609.23m disk 00:00:38 06-nov-14bp key: 1 status: available compressed: no tag: tag20141106t063059piece name: /u01/oracle/flash_recovery_area/jadl10g/backupset/2014_11_06/o1_mf_nnndf_tag20141106t063059_b5o994hx_.bkplist of datafiles in backup set 1file lv type ckp scn ckp time name---- -- ---- ---------- --------- ----4 full 422818 06-nov-14 /u01/oracle/oradata/jadl10g/users01.dbf
修改表空间为只读表空间:
[oracle@oracle ~]$ sqlplus / as sysdbasql*plus: release 10.2.0.5.0 - production on thu nov 6 09:45:35 2014copyright (c) 1982, 2010, oracle. all rights reserved.connected to:oracle database 10g enterprise edition release 10.2.0.5.0 - 64bit productionwith the partitioning, oracle label security, olap, data mining scoring engineand real application testing optionssql> alter tablespace users read only;tablespace altered.
进入rman,重新备份数据库,删除以前备份的可以节省空间使用delete backup命令可以删除;
[oracle@oracle ~]$ rman target /recovery manager: release 10.2.0.5.0 - production on thu nov 6 09:50:29 2014copyright (c) 1982, 2007, oracle. all rights reserved.connected to target database: jadl10g (dbid=2011508104)rman> backup database; --备份数据库starting backup at 06-nov-14using target database control file instead of recovery catalogallocated channel: ora_disk_1channel ora_disk_1: sid=159 devtype=diskchannel ora_disk_1: starting full datafile backupsetchannel ora_disk_1: specifying datafile(s) in backupsetinput datafile fno=00001 name=/u01/oracle/oradata/jadl10g/system01.dbfinput datafile fno=00003 name=/u01/oracle/oradata/jadl10g/sysaux01.dbfinput datafile fno=00005 name=/u01/oracle/oradata/jadl10g/example01.dbfinput datafile fno=00002 name=/u01/oracle/oradata/jadl10g/undotbs01.dbfinput datafile fno=00004 name=/u01/oracle/oradata/jadl10g/users01.dbfchannel ora_disk_1: starting piece 1 at 06-nov-14channel ora_disk_1: finished piece 1 at 06-nov-14piece handle=/u01/oracle/flash_recovery_area/jadl10g/backupset/2014_11_06/o1_mf_nnndf_tag20141106t095036_b5onzdz1_.bkp tag=tag20141106t095036 comment=nonechannel ora_disk_1: backup set complete, elapsed time: 00:00:55channel ora_disk_1: starting full datafile backupsetchannel ora_disk_1: specifying datafile(s) in backupsetincluding current control file in backupsetincluding current spfile in backupsetchannel ora_disk_1: starting piece 1 at 06-nov-14channel ora_disk_1: finished piece 1 at 06-nov-14piece handle=/u01/oracle/flash_recovery_area/jadl10g/backupset/2014_11_06/o1_mf_ncsnf_tag20141106t095036_b5oo15kf_.bkp tag=tag20141106t095036 comment=nonechannel ora_disk_1: backup set complete, elapsed time: 00:00:02finished backup at 06-nov-14rman> exitrecovery manager complete.
删除users表空间(只读的文件)
[oracle@oracle ~]$ rm /u01/oracle/oradata/jadl10g/users01.dbf
连接到db,执行查询发现报错:
[oracle@oracle ~]$ sqlplus / as sysdbasql*plus: release 10.2.0.5.0 - production on thu nov 6 09:52:33 2014copyright (c) 1982, 2010, oracle. all rights reserved.connected to:oracle database 10g enterprise edition release 10.2.0.5.0 - 64bit productionwith the partitioning, oracle label security, olap, data mining scoring engineand real application testing optionssql> select * from scott.dept;select * from scott.dept*error at line 1:ora-01116: error in opening database file 4ora-01110: data file 4: '/u01/oracle/oradata/jadl10g/users01.dbf'ora-27041: unable to open filelinux-x86_64 error: 2: no such file or directoryadditional information: 3sql> exitdisconnected from oracle database 10g enterprise edition release 10.2.0.5.0 - 64bit productionwith the partitioning, oracle label security, olap, data mining scoring engineand real application testing options
连接到rman:
[oracle@oracle ~]$ rman target /recovery manager: release 10.2.0.5.0 - production on thu nov 6 09:53:40 2014copyright (c) 1982, 2007, oracle. all rights reserved.connected to target database: jadl10g (dbid=2011508104)rman> sql 'alter database datafile 4 offline '; --数据文件脱机using target database control file instead of recovery catalogsql statement: alter database datafile 4 offlinerman> restore datafile 4; --恢复数据文件,此处可以是文件的路径 restore datafile '/u01/oracle/oradata/jadl10g/users01.dbf';starting restore at 06-nov-14allocated channel: ora_disk_1channel ora_disk_1: sid=136 devtype=diskchannel ora_disk_1: starting datafile backupset restorechannel ora_disk_1: specifying datafile(s) to restore from backup setrestoring datafile 00004 to /u01/oracle/oradata/jadl10g/users01.dbfchannel ora_disk_1: reading from backup piece /u01/oracle/flash_recovery_area/jadl10g/backupset/2014_11_06/o1_mf_nnndf_tag20141106t095036_b5onzdz1_.bkpchannel ora_disk_1: restored backup piece 1piece handle=/u01/oracle/flash_recovery_area/jadl10g/backupset/2014_11_06/o1_mf_nnndf_tag20141106t095036_b5onzdz1_.bkp tag=tag20141106t095036channel ora_disk_1: restore complete, elapsed time: 00:00:02finished restore at 06-nov-14rman> sql 'alter database datafile 4 online '; ---连接数据文件sql statement: alter database datafile 4 onlinerman> exitrecovery manager complete.
连接到db,执行查询发现可以查询到结果:
[oracle@oracle ~]$ sqlplus / as sysdbasql*plus: release 10.2.0.5.0 - production on thu nov 6 09:55:00 2014copyright (c) 1982, 2010, oracle. all rights reserved.connected to:oracle database 10g enterprise edition release 10.2.0.5.0 - 64bit productionwith the partitioning, oracle label security, olap, data mining scoring engineand real application testing optionssql> select * from scott.dept;deptno dname loc---------- -------------- -------------10 accounting new york20 research dallas30 sales chicago40 operations boston2>
连接db,修改表空间为可写:
[oracle@oracle ~]$ sqlplus / as sysdbasql*plus: release 10.2.0.5.0 - production on thu nov 6 10:04:27 2014copyright (c) 1982, 2010, oracle. all rights reserved.connected to:oracle database 10g enterprise editio【本文来自鸿网互联 (http://www.68idc.cn)】n release 10.2.0.5.0 - 64bit productionwith the partitioning, oracle label security, olap, data mining scoring engineand real application testing optionssql> alter tablespace users read write;tablespace altered.sql> exitdisconnected from oracle database 10g enterprise edition release 10.2.0.5.0 - 64bit productionwith the partitioning, oracle label security, olap, data mining scoring engineand real application testing options
删除users表空间(可写的表空间):
[oracle@oracle ~]$ rm /u01/oracle/oradata/jadl10g/users01.dbf
连接到db,执行查询发现报错:
[oracle@oracle ~]$ sqlplus / as sysdbasql*plus: release 10.2.0.5.0 - production on thu nov 6 10:05:32 2014copyright (c) 1982, 2010, oracle. all rights reserved.connected to:oracle database 10g enterprise edition release 10.2.0.5.0 - 64bit productionwith the partitioning, oracle label security, olap, data mining scoring engineand real application testing optionssql> select * from scott.dept;select * from scott.dept*error at line 1:ora-01116: error in opening database file 4ora-01110: data file 4: '/u01/oracle/oradata/jadl10g/users01.dbf'ora-27041: unable to open filelinux-x86_64 error: 2: no such file or directoryadditional information: 3sql> exitdisconnected from oracle database 10g enterprise edition release 10.2.0.5.0 - 64bit productionwith the partitioning, oracle label security, olap, data mining scoring engineand real application testing options
连接到rman:
[oracle@oracle ~]$ rman target /recovery manager: release 10.2.0.5.0 - production on thu nov 6 10:06:31 2014copyright (c) 1982, 2007, oracle. all rights reserved.connected to target database: jadl10g (dbid=2011508104)rman> sql 'alter database datafile 4 offline ';using target database control file instead of recovery catalogsql statement: alter database datafile 4 offlinerman> restore datafile 4;starting restore at 06-nov-14allocated channel: ora_disk_1channel ora_disk_1: sid=159 devtype=diskchannel ora_disk_1: starting datafile backupset restorechannel ora_disk_1: specifying datafile(s) to restore from backup setrestoring datafile 00004 to /u01/oracle/oradata/jadl10g/users01.dbfchannel ora_disk_1: reading from backup piece /u01/oracle/flash_recovery_area/jadl10g/backupset/2014_11_06/o1_mf_nnndf_tag20141106t095036_b5onzdz1_.bkpchannel ora_disk_1: restored backup piece 1piece handle=/u01/oracle/flash_recovery_area/jadl10g/backupset/2014_11_06/o1_mf_nnndf_tag20141106t095036_b5onzdz1_.bkp tag=tag20141106t095036channel ora_disk_1: restore complete, elapsed time: 00:00:01finished restore at 06-nov-14rman> recover datafile 4;starting recover at 06-nov-14using channel ora_disk_1starting media recoverymedia recovery complete, elapsed time: 00:00:03finished recover at 06-nov-14rman> sql 'alter database datafile 4 online ';sql statement: alter database datafile 4 onlinerman> exitrecovery manager complete.
连接到db,执行查询发现可以查询到结果:
[oracle@oracle ~]$ sqlplus / as sysdbasql*plus: release 10.2.0.5.0 - production on thu nov 6 10:08:18 2014copyright (c) 1982, 2010, oracle. all rights reserved.connected to:oracle database 10g enterprise edition release 10.2.0.5.0 - 64bit productionwith the partitioning, oracle label security, olap, data mining scoring engineand real application testing optionssql> select * from scott.dept;deptno dname loc---------- -------------- -------------10 accounting new york20 research dallas30 sales chicago40 operations boston
其它类似信息

推荐信息