oracle 11g手工熱備-表空間
阿新 • • 發佈:2018-01-25
shu mat glob 備份 插入數據 mod 插入 rtu rm -rf 手工熱備必須在歸檔模式下進行,只讀表空間不能做熱備,臨時表空間不需要做熱備。
SYS@PROD> archive log list;——開啟了歸檔 Database log mode Archive Mode Automatic archival Enabled Archive destination /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch Oldest online log sequence 1 Next log sequence to archive 1 Current log sequence 1 SYS@PROD> SYS@PROD> create table t8(id number) tablespace users;——創建表並插入數據提交 Table created. SYS@PROD> insert into t8 values(88); 1 row created. SYS@PROD> commit; Commit complete. SYS@PROD> select * from t8; ID ---------- 88 SYS@PROD> alter tablespace users begin backup;——開始熱備users表空間 Tablespace altered. [oracle@enmoedu1 ~]$ cp users01.dbf /home/oracle/——備份用戶表空間數據文件 SYS@PROD> alter tablespace users end backup; ——結束備份users表空間 Tablespace altered.
關閉數據庫,刪除users數據文件,然後再啟動數據庫
SYS@PROD> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. 刪除users數據文件 [oracle@enmoedu1 PROD]$ rm -rf users01.dbf SYS@PROD> startup ORACLE instance started. Total System Global Area 835104768 bytes Fixed Size 2257840 bytes Variable Size 536874064 bytes Database Buffers 289406976 bytes Redo Buffers 6565888 bytes Database mounted. ORA-01157: cannot identify/lock data file 4 - see DBWR trace file ORA-01110: data file 4: ‘/u01/app/oracle/oradata/PROD/users01.dbf‘——報錯,找不到數據文件
拷貝備份好的users數據文件到數據庫原目錄
mv /home/oracle/users01.dbf /u01/app/oracle/oradata/PROD ——拷貝數據文件 SYS@PROD> select open_mode from v$database; OPEN_MODE -------------------- MOUNTED SYS@PROD> alter database open; alter database open * ERROR at line 1: ORA-01113: file 4 needs media recovery ORA-01110: data file 4: ‘/u01/app/oracle/oradata/PROD/users01.dbf‘ --------查詢users數據文件的id為4----------- select file_name,file_id,tablespace_name from dba_data_files where tablespace_name=‘USERS‘; FILE_NAME FILE_ID TABLESPACE_NAME -------------------------------------------------- ---------- ------------------------------ /u01/app/oracle/oradata/PROD/users01.dbf 4 USERS SYS@PROD> recover datafile 4;——恢復數據文件4號 Media recovery complete. SYS@PROD> alter database open;——打開數據文件 Database altered. SYS@PROD> select open_mode from v$database; OPEN_MODE -------------------- READ WRITE SYS@PROD> select * from t8; ID ---------- 88
oracle 11g手工熱備-表空間