Rman的基本命令介绍
本篇内容主要讲解“Rman的基本命令介绍”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Rman的基本命令介绍”吧!
成都创新互联公司是一家专注于成都做网站、成都网站设计、成都外贸网站建设与策划设计,金城江网站建设哪家好?成都创新互联公司做网站,专注于网站建设10余年,网设计领域的专业建站公司;建站业务涵盖:金城江等地区。金城江做网站价格咨询:18982081108
可以用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的基本命令介绍”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
网站名称:Rman的基本命令介绍
网页网址:http://ybzwz.com/article/jdigds.html