在一節點上進行全備 肯定備份路徑,並賦予屬組 mkdir /rmanbackup chown oracle:oinsatll /rmanbackup 進入rman進行全備 rman target / run { allocate channel d1 type disk; backup incremental level 0 format '/rmanbackup/orcl_full_%U' database include current controlfile; delete noprompt obsolete; sql 'alter system archive log current'; backup format '/rmanbackup/orcl_arch_full_%U' archivelog all not backed up delete input; crosscheck backup; delete noprompt expired backup; release channel d1; } 將生成的備份傳到單機環境 cd /rmanbackup scp * oracle@192.168.100.199:/rmanbackup/ (單機上已備好此路徑) 建立pfile文件並修改傳送到單機環境對應目錄下 SQL> create pfile='/rmanbackup/initorcl.ora' from spfile='/u02/app/oracle/product/11.2.0/db_home/dbs/spfileorcl1.ora.bak'; vi initorcl.ora *.audit_file_dest='/u01/app/oracle/admin/orcl/adump' *.audit_trail='NONE' *.compatible='11.2.0.4.0' *.control_files='/u01/app/oracle/oradata/orcl/control01.dbf' *.db_block_size=8192 *.db_create_file_dest='/u01/app/oracle/oradata/' *.db_create_online_log_dest_1='/u01/app/oracle/oradata/' *.db_domain='' *.db_files=2000 *.db_name='orcl' *.deferred_segment_creation=FALSE *.diagnostic_dest='/u01/app/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)' *.enable_ddl_logging=TRUE *.event='28401 TRACE NAME CONTEXT FOREVER, LEVEL 1' *.log_archive_dest_1='LOCATION=/arch' *.log_archive_format='%t_%s_%r.dbf' *.max_dump_file_size='25m' *.open_cursors=300 *.pga_aggregate_target=288358400 *.processes=1500 *.remote_login_passwordfile='exclusive' *.sec_case_sensitive_logon=FALSE *.sessions=1655 *.sga_max_size=1100m *.sga_target=1100m scp initorcl.ora oracle@192.168.100.199://u01/app/oracle/product/11.2.0/dbhome_1/dbs/ 單機環境上 用傳過來的pfile生成spfile文件 SQL> create spfile from pfile; SQL> startup nomount; 恢復控制文件 RMAN> restore controlfile from '/rmanbackup/orcl_full_19ra5tlf_1_1'; RMAN> alter database mount; 檢查並標記控制文件中存在,可是實際已經不存在的備份文件。 RMAN>crosscheck backup; 清理控制文件中存在,可是實際已經不存在的備份文件。 RMAN>delete noprompt expired backup; 將備份註冊到rman RMAN> catalog backuppiece '/rmanbackup/orcl_full_19ra5tlf_1_1'; RMAN> catalog backuppiece '/rmanbackup/orcl_full_18ra5tih_1_1'; RMAN> catalog backuppiece '/rmanbackup/orcl_arch_full_1ara5tnb_1_1'; 如今咱們肯定的點到媒介恢復應該恢復數據庫上運行。 RMAN> list backup of archivelog all; 根據備份信息,恢復數據文件及數據庫 RMAN> RUN { set until sequence 84 thread 1; SET NEWNAME FOR DATAFILE 1 to '/u01/app/oracle/oradata/orcl/system.dbf'; SET NEWNAME FOR DATAFILE 2 to '/u01/app/oracle/oradata/orcl/sysaux.dbf'; SET NEWNAME FOR DATAFILE 3 to '/u01/app/oracle/oradata/orcl/undotbs1.dbf'; SET NEWNAME FOR DATAFILE 4 to '/u01/app/oracle/oradata/orcl/users.dbf'; SET NEWNAME FOR DATAFILE 5 to '/u01/app/oracle/oradata/orcl/undotbs2.dbf'; SET NEWNAME FOR DATAFILE 6 to '/u01/app/oracle/oradata/orcl/huyuwu.dbf'; SET NEWNAME FOR DATAFILE 7 to '/u01/app/oracle/oradata/orcl/syd.dbf'; SET NEWNAME FOR DATAFILE 8 to '/u01/app/oracle/oradata/orcl/syd2.dbf'; SET NEWNAME FOR DATAFILE 9 to '/u01/app/oracle/oradata/orcl/syd1.dbf'; SET NEWNAME FOR DATAFILE 10 to '/u01/app/oracle/oradata/orcl/syd3.dbf'; SET NEWNAME FOR DATAFILE 11 to '/u01/app/oracle/oradata/orcl/syd4.dbf'; RESTORE DATABASE; SWITCH DATAFILE ALL; recover database; } 查看日誌文件 SQL> select member from v$logfile; 修改日誌文件 alter database rename file '+DATA/orcl/onlinelog/group_redo06a.log' to '/u01/app/oracle/oradata/orcl/redo6_1.log'; alter database rename file '+FRA/orcl/onlinelog/group_redo06b.log' to '/u01/app/oracle/oradata/orcl/redo6_2.log'; alter database rename file '+DATA/orcl/onlinelog/redo0001a.log' to '/u01/app/oracle/oradata/orcl/redo1_1.log'; alter database rename file '+FRA/orcl/onlinelog/redo0001b.log' to '/u01/app/oracle/oradata/orcl/redo1_2.log'; alter database rename file '+DATA/orcl/onlinelog/group_redo02a.log' to '/u01/app/oracle/oradata/orcl/redo2_1.log'; alter database rename file '+FRA/orcl/onlinelog/group_redo02b.log' to '/u01/app/oracle/oradata/orcl/redo2_2.log'; alter database rename file '+DATA/orcl/onlinelog/redo0003a.log' to '/u01/app/oracle/oradata/orcl/redo3_1.log'; alter database rename file '+FRA/orcl/onlinelog/redo0003b.log' to '/u01/app/oracle/oradata/orcl/redo3_2.log'; alter database rename file '+DATA/orcl/onlinelog/group_redo04a.log' to '/u01/app/oracle/oradata/orcl/redo4_1.log'; alter database rename file '+FRA/orcl/onlinelog/group_redo04b.log' to '/u01/app/oracle/oradata/orcl/redo4_2.log'; alter database rename file '+DATA/orcl/onlinelog/redo0005a.log' to '/u01/app/oracle/oradata/orcl/redo5_1.log'; alter database rename file '+FRA/orcl/onlinelog/redo0005b.log' to '/u01/app/oracle/oradata/orcl/redo5_2.log'; alter database rename file '+FRA/orcl/onlinelog/group_redo07a.log' to '/u01/app/oracle/oradata/orcl/redo7_1.log'; alter database rename file '+DATA/orcl/onlinelog/group_redo07b.log' to '/u01/app/oracle/oradata/orcl/redo7_2.log'; alter database rename file '+DATA/orcl/onlinelog/redo0008a.log' to '/u01/app/oracle/oradata/orcl/redo8_1.log'; alter database rename file '+FRA/orcl/onlinelog/redo0008b.log' to '/u01/app/oracle/oradata/orcl/redo8_2.log'; 打開數據庫 alter database open resetlogs; 查看redo log 信息,並刪除無效日誌組 查看redo log 信息,並刪除無效日誌組(節點2日誌) select THREAD#, STATUS, ENABLED from v$thread; THREAD# STATUS ENABLED ---------- ------ -------- 1 OPEN PUBLIC 2 CLOSED PUBLIC select group# from v$log where THREAD#=2; GROUP# ---------- 3 4 6 8 SQL> alter database disable thread 2; SQL> alter database drop logfile group 3; SQL> alter database drop logfile group 4; SQL> alter database drop logfile group 6; SQL> alter database drop logfile group 8; SQL> select THREAD#, STATUS, ENABLED from v$thread; THREAD# STATUS ENABLED ---------- ------ -------- 1 OPEN PUBLIC 查看undo表空間,並刪除節點2(在此不使用)的undo表空間 SQL> sho parameter undo; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ undo_management string AUTO undo_retention integer 900 undo_tablespace string UNDOTBS1 SQL> select tablespace_name from dba_tablespaces where contents='UNDO'; TABLESPACE_NAME ------------------------------ UNDOTBS1 UNDOTBS2 SQL> drop tablespace UNDOTBS2 including contents and datafiles; SQL> select name from v$tempfile; NAME -------------------------------------------------------------------------------- /u01/app/oracle/oradata/ORCL/datafile/o1_mf_temp_cr602c5z_.tmp SQL> select tablespace_name from dba_tablespaces where contents='TEMPORARY'; TABLESPACE_NAME ------------------------------ TEMP SQL> create temporary tablespace TEMP1 tempfile '/u01/app/oracle/oradata/orcl/temp01.dbf' size 50M; SQL> alter database default temporary tablespace TEMP1; SQL> drop tablespace TEMP including contents and datafiles; 查看監聽狀態並配置,編輯tnsname.ora文件。(mos文檔沒有) 經過如下命令建立密碼文件,注意密碼文件的位置(mos文檔沒有) [oracle@orc1 dbs]$ orapwd file=orapwracdb1 password=oracle entries=30