共計(jì) 5797 個(gè)字符,預(yù)計(jì)需要花費(fèi) 15 分鐘才能閱讀完成。
本篇內(nèi)容主要講解“Rman 的基本命令介紹”,感興趣的朋友不妨來看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓丸趣 TV 小編來帶大家學(xué)習(xí)“Rman 的基本命令介紹”吧!
可以用 RMAN 環(huán)境來打開和關(guān)閉數(shù)據(jù)庫:
[oracle@rosan ~]$ rman target /
Recovery Manager: Release 10.2.0.4.0 – Production on Mon Jul 21 15:01:20 2014
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1370475407)
RMAN
connected to target database: ORCL (DBID=1300072061)
RMAN shutdown immediate;
using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down
RMAN
RMAN startup;
connected to target database (not started)
Oracle instance started
database mounted
database opened
Total System Global Area 515899392 bytes
Fixed Size 1268412 bytes
Variable Size 457180484 bytes
Database Buffers 54525952 bytes
Redo Buffers 2924544 bytes
RMAN
執(zhí)行 sql 語句:
RMAN sql alter system switch logfile
using target database control file instead of recovery catalog
sql statement: alter system switch logfile
基本的備份命令:
全庫備份:
SYS@orcl10g alter system set db_recovery_file_dest_size=4G scope=both;
// 修改閃回恢復(fù)區(qū)的大小為 4G
RMAN backup database;
指定備份路徑:
RMAN backup database format /u01/backup/bak_%U
備份表空間:
RMAN backup tablespace mytbs2;
備份數(shù)據(jù)文件:
SYS@orcl10g select tablespace_name,file_name ,bytes/1048576 size_M from dba_data_files order by tablespace_name;
TABLESPACE_NAME FILE_NAME SIZE_M
—————————— ————————————————– ———-
EXAMPLE /u01/app/oracle/oradata/orcl/example01.dbf 100
FLASHTBS /oracle_new/datafiles/flashtbs01.dbf 4
IND_TBS /oracle_new/datafiles/ind_tbs01.dbf 10
MYTBS2 /u01/app/oracle/newdata/mytbs201.dbf 5
MYTBS3 /u01/app/oracle/newdata/mytbs301.dbf 10
NEW_TBS /oracle_new/datafiles/new_tbs01.dbf 10
PART1 /oracle_new/datafiles/part01.dbf 10
PART2 /u01/app/oracle/part/part02.dbf 10
PART3 /u01/app/oracle/part/part03.dbf 10
SYSAUX /u01/app/oracle/oradata/orcl/sysaux01.dbf 280
SYSTEM /oracle_new/datafiles/system01.dbf 490
UNDO2 /u01/app/oracle/newdata/undo2.dbf 50
UNDOTBS1 /u01/app/oracle/oradata/orcl/undotbs01.dbf 30
UNDO_NEW /oracle_new/datafiles/undo01.dbf 100
USERS /u01/app/oracle/oradata/orcl/users01.dbf 441.25
RMAN backup datafile /oracle_new/datafiles/new_tbs01.dbf
備份控制文件:
RMAN backup current controlfile;
備份歸檔日志:
RMAN backup archivelog all;
備份控制文件的同時(shí)備份歸檔日志:
RMAN backup current controlfile plus archivelog;
備份參數(shù)文件:
RMAN backup spfile;
備份文件的命名格式:
format:
%a:Oracle 數(shù)據(jù)庫的 resetlog_id
%c: 備份片的復(fù)制數(shù)
%d: Oracle 的數(shù)據(jù)庫名稱
%D: 當(dāng)前時(shí)間的 DD
%e:歸檔序號(hào)
%f: 絕對(duì)文件編號(hào)
%F:基于 DBID+ 時(shí)間 確定唯一名稱
%U:%u_%p_%c
單命令: backup database;
批命令:
rman run{
2 allocate channel cha1 type disk;
3 backup
4 format /u01/rmanbak/full_%t
5 tag full-backup // 標(biāo)簽可以順便起,沒關(guān)系
6 database;
7 release channel cha1;
8 }
這個(gè) run 中有 3 條命令,分別用分號(hào)來進(jìn)行分割.
format:
%c:備份片的拷貝數(shù) (從 1 開始編號(hào));
%d:數(shù)據(jù)庫名稱;
%D:位于該月中的天數(shù)(DD);
%M:位于該年中的月份(MM);
%F:一個(gè)基于 DBID 唯一的名稱,這個(gè)格式的形式為 c -xxx-YYYYMMDD-QQ, 其中 xxx 位該數(shù)據(jù)庫的 DBID,YYYYMMDD 為日期,QQ 是一個(gè) 1 -256 的序列;
%n:數(shù)據(jù)庫名稱,并且會(huì)在右側(cè)用 x 字符進(jìn)行填充,使其保持長(zhǎng)度為 8;
%u:是一個(gè)由備份集編號(hào)和建立時(shí)間壓縮后組成的 8 字符名稱。利用 %u 可以為每個(gè)備份集產(chǎn)生一個(gè)唯一的名稱;
%p:表示備份集中的備份片的編號(hào),從 1 開始編號(hào);
%U:是 %u_%p_%c 的簡(jiǎn)寫形式,利用它可以為每一個(gè)備份片段(既磁盤文件) 生成一個(gè)唯一的名稱,這是最常用的命名方式;
%t:備份集時(shí)間戳;
%T: 年月日格式(YYYYMMDD);
channel 的概念:一個(gè) channel 是 rman 于目標(biāo)數(shù)據(jù)庫之間的一個(gè)連接,allocate channel 命令在目標(biāo)數(shù)據(jù)庫啟動(dòng)一個(gè)服務(wù)器進(jìn)程,同時(shí)必須定義服務(wù)器進(jìn)程執(zhí)行備份和恢復(fù)操作使
用的 I / O 類型
通道控制命令可以用來:
控制 rman 使用的 OS 資源
影響并行度
指定 I / O 帶寬的限制值(設(shè)置 limit read rate 參數(shù))
指定備份片大小的限制(設(shè)置 limit kbytes)
指定當(dāng)前打開文件的限制值(設(shè)置 limit maxopenfiles)
列出備份信息的命令:
list
RMAN list backup;
// 列出所有的備份信息;
RMAN list backup of;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found : expecting one of: archivelog, controlfile, database, datafile, spfile, tablespace
RMAN-01007: at line 1 column 15 file: standard input
// 分類查看備份信息
RMAN list backup of spfile;
report 報(bào)表顯示命令:
RMAN configure retention policy to redundancy 3;
RMAN report need backup;
// 根據(jù)當(dāng)前的備份保留策略,查看哪些數(shù)據(jù)對(duì)象,沒有滿足備份要求;
RMAN report need backup tablespace system;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 3
Report of files with less than 3 redundant backups
File #bkps Name
—- —– —————————————————–
1 2 /oracle_new/datafiles/system01.dbf
RMAN report need backup tablespace part1;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 3
Report of files with less than 3 redundant backups
File #bkps Name
—- —– —————————————————–
// 查看某些具體的表空間是否滿足備份需求;如果沒有滿足,會(huì)顯示需要備份的數(shù)據(jù)對(duì)象;
// 如果滿足,則沒有顯示;
RMAN report obsolete;
// 根據(jù)備份保留策略,查看哪些備份集,或備份鏡像 copy,已經(jīng)超出了備份需求,不再需要了。
delete 命令:
RMAN delete obsolete;
// 刪除過期的備份;
RMAN delete backupset 29;
// 刪除特定的備份集;
RMAN delete expired archivelog all;
// 刪除失效的歸檔日志文件
RMAN delete backup;
// 刪除所有的備份;
crosscheck:
交叉檢驗(yàn)命令
RMAN crosscheck;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found : expecting one of: archivelog, backup, backuppiece, backupset, copy, controlfilecopy, datafilecopy, proxy
RMAN-01007: at line 1 column 11 file: standard input
RMAN crosscheck archivelog all;
RMAN crosscheck backupset 32;
using channel ORA_DISK_1
crosschecked backup piece: found to be EXPIRED
backup piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2012_03_14/o1_mf_nnndf_TAG20120314T143542_7p0h2ydh_.bkp recid=32 stamp=777911742
Crosschecked 1 objects
RMAN delete expired backup;
// 刪除失效的備份;
**********************************************
如何以 copy 的形式備份數(shù)據(jù):
RMAN backup as copy tablespace bak;
RMAN list copy of tablespace BAK
RMAN delete copy;
到此,相信大家對(duì)“Rman 的基本命令介紹”有了更深的了解,不妨來實(shí)際操作一番吧!這里是丸趣 TV 網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!