您好,登錄后才能下訂單哦!
本篇內(nèi)容主要講解“Rman的基本命令介紹”,感興趣的朋友不妨來看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來帶大家學(xué)習(xí)“Rman的基本命令介紹”吧!
可以用RMAN環(huán)境來打開和關(guān)閉數(shù)據(jù)庫(kù):
[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語(yǔ)句:
RMAN> sql 'alter system switch logfile';
using target database control file instead of recovery catalog
sql statement: alter system switch logfile
基本的備份命令:
全庫(kù)備份:
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ù)庫(kù)的resetlog_id
%c: 備份片的復(fù)制數(shù)
%d: Oracle的數(shù)據(jù)庫(kù)名稱
%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ù)庫(kù)名稱;
%D:位于該月中的天數(shù)(DD);
%M:位于該年中的月份(MM);
%F:一個(gè)基于DBID唯一的名稱,這個(gè)格式的形式為c-xxx-YYYYMMDD-QQ,其中xxx位該數(shù)據(jù)庫(kù)的DBID,YYYYMMDD為日期,QQ是一個(gè)1-256的序列;
%n:數(shù)據(jù)庫(kù)名稱,并且會(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ù)庫(kù)之間的一個(gè)連接,"allocate channel"命令在目標(biāo)數(shù)據(jù)庫(kù)啟動(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í)際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。