[實驗-視頻過程]oracle熱備份-單個表空間-備份和恢復操作演示
針對一個表空間的恢復
1、創建表空間
drop tablespace test_backup including contents and datafiles;
CREATE TABLESPACE test_backup DATAFILE '/u01/app/oracle/oradata/orcl/test_back.dbf' SIZE 10M autoextend on;
2、寫入測試數據,創建測試表
drop table test_backup purge;
CREATE TABLE test_backup
(
aa NUMBER,
bb VARCHAR2(10)
) TABLESPACE test_backup;
3、插入測試數據,第一條。
insert into test_backup values (1,'test_back1');
commit;
4、將數據庫設置備份模式
SQL> ALTER TABLESPACE test_backup BEGIN BACKUP;
Tablespace altered.
5、拷貝數據文件至備份文件中
host cp /u01/app/oracle/oradata/orcl/test_back.dbf /home/backup/xuejiayue/
6、結束備份模式
SQL> ALTER TABLESPACE test_backup END BACKUP;
Tablespace altered.
7、切換日志
SQL> ALTER SYSTEM SWITCH LOGFILE;
System altered.
8、此時再插入數據,插入第二條數據(此時已經備份完成)。
SQL> insert into test_backup values (2,'test_back2');
1 row created.
SQL> commit;
Commit complete.
9、模擬故障,刪除數據庫文件
host rm -rf /u01/app/oracle/oradata/orcl/test_back.dbf
10、重啟數據庫
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
startup
11、測試數據表,應該報數據文件錯誤
SQL> select * from test_backup;
select * from test_backup
*
ERROR at line 1:
ORA-00376: file 6 cannot be read at this time
ORA-01110: data file 6: '/u01/app/oracle/oradata/orcl/test_back.dbf'
12、恢復數據庫單個表空間數據庫文件。
SQL> ALTER DATABASE DATAFILE 6 OFFLINE DROP
2 ;
Database altered.
SQL> host cp /home/backup/xuejiayue/test_back.dbf /u01/app/oracle/oradata/orcl/test_back.dbf
SQL> RECOVER DATAFILE 6
Media recovery complete.
SQL> ALTER DATABASE DATAFILE 6 ONLINE;
Database altered.
12、恢復完成,測試數據。
SQL> select * from test_backup;
AA BB
---------- ----------
1 test_back1
2 test_back2
結果是:兩條數據文件都在!!!
視頻地址
http://v.youku.com/v_show/id_XMTM2MzI0NjcyMA==.html