Rman的基本命令介绍

37次阅读
没有评论

共计 5797 个字符,预计需要花费 15 分钟才能阅读完成。

本篇内容主要讲解“Rman 的基本命令介绍”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让丸趣 TV 小编来带大家学习“Rman 的基本命令介绍”吧!

可以用 RMAN 环境来打开和关闭数据库:
[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  

执行 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;
// 修改闪回恢复区的大小为 4G

RMAN backup database;

指定备份路径:

RMAN backup database format /u01/backup/bak_%U

备份表空间:
RMAN backup tablespace mytbs2;

备份数据文件:
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;

备份控制文件的同时备份归档日志:
RMAN backup current controlfile plus archivelog;

备份参数文件:
RMAN backup spfile;

备份文件的命名格式:
format:
%a:Oracle 数据库的 resetlog_id
%c: 备份片的复制数
%d: Oracle 的数据库名称
%D: 当前时间的 DD
%e:归档序号
%f: 绝对文件编号
%F:基于 DBID+ 时间 确定唯一名称
%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 // 标签可以顺便起,没关系
 6 database;
 7 release channel cha1;
 8 }

这个 run 中有 3 条命令,分别用分号来进行分割.
format:
%c:备份片的拷贝数 (从 1 开始编号);
%d:数据库名称;
%D:位于该月中的天数(DD);
%M:位于该年中的月份(MM);
%F:一个基于 DBID 唯一的名称,这个格式的形式为 c -xxx-YYYYMMDD-QQ, 其中 xxx 位该数据库的 DBID,YYYYMMDD 为日期,QQ 是一个 1 -256 的序列;
%n:数据库名称,并且会在右侧用 x 字符进行填充,使其保持长度为 8;
%u:是一个由备份集编号和建立时间压缩后组成的 8 字符名称。利用 %u 可以为每个备份集产生一个唯一的名称;
%p:表示备份集中的备份片的编号,从 1 开始编号;
%U:是 %u_%p_%c 的简写形式,利用它可以为每一个备份片段(既磁盘文件) 生成一个唯一的名称,这是最常用的命名方式;
%t:备份集时间戳;
%T: 年月日格式(YYYYMMDD);
channel 的概念:一个 channel 是 rman 于目标数据库之间的一个连接,allocate channel 命令在目标数据库启动一个服务器进程,同时必须定义服务器进程执行备份和恢复操作使
用的 I / O 类型
通道控制命令可以用来:
      控制 rman 使用的 OS 资源
      影响并行度
      指定 I / O 带宽的限制值(设置 limit read rate 参数)
      指定备份片大小的限制(设置 limit kbytes)
      指定当前打开文件的限制值(设置 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 报表显示命令:
RMAN configure retention policy to redundancy 3;

RMAN report need backup;
// 根据当前的备份保留策略,查看哪些数据对象,没有满足备份要求;

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
—- —– —————————————————–
// 查看某些具体的表空间是否满足备份需求;如果没有满足,会显示需要备份的数据对象;
// 如果满足,则没有显示;

RMAN report obsolete;
// 根据备份保留策略,查看哪些备份集,或备份镜像 copy,已经超出了备份需求,不再需要了。

delete 命令:
RMAN delete obsolete;
// 删除过期的备份;

RMAN delete backupset 29;
// 删除特定的备份集;

RMAN delete expired archivelog all;
// 删除失效的归档日志文件

RMAN delete backup;
// 删除所有的备份;

crosscheck:
交叉检验命令

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 的形式备份数据:
RMAN backup as copy tablespace bak;

RMAN list copy of tablespace BAK

RMAN delete copy;

到此,相信大家对“Rman 的基本命令介绍”有了更深的了解,不妨来实际操作一番吧!这里是丸趣 TV 网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-08-03发表,共计5797字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)