废话就不多说了,开始。。。
rman 10g备份与恢复
海明教师第三讲
一、nocatalog备份
备份archivelog
backup database plus archivelog delete input 备份数据文件,控制文件,参数文件,档归日志文件,然后把备份完的档归日志文件停止删除)
备份表空间
backup tablespace users(对应的表空间)
备份控制文件
backup current controlfile
backup database include current controlfile
启动听监
lsnrctl start/stop/status
====================================================================================
验实:
Recovery Manager complete.
[oracle@redhat ~]$ rman nocatalog
Recovery Manager: Release 10.2.0.1.0 - Production on 星期六 4月 20 04:51:36 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
RMAN> connect target sys/123456
connected to target database: WOLF (DBID=3778783462)
using target database control file instead of recovery catalog
1、全备
RMAN> backup database plus archivelog delete input;
Starting backup at 20-4月 -13
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=158 devtype=DISK
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=2 recid=11 stamp=813214354
channel ORA_DISK_1: starting piece 1 at 20-4月 -13
channel ORA_DISK_1: finished piece 1 at 20-4月 -13
piece handle=/oracle/ora10g/flash_recovery_area/WOLF/backupset/2013_04_20/o1_mf_annnn_TAG20130420T045234_8q4otorc_.bkp
tag=TAG20130420T045234 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/oracle/ora10g/flash_recovery_area/WOLF/archivelog/2013_04_20/o1_mf_1_2_8q4otkmz_.arc recid=11 stamp=813214354
Finished backup at 20-4月 -13
Starting backup at 20-4月 -13
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/oracle/ora10g/oradata/wolf/system01.dbf
input datafile fno=00003 name=/oracle/ora10g/oradata/wolf/sysaux01.dbf
input datafile fno=00002 name=/oracle/ora10g/oradata/wolf/undotbs01.dbf
input datafile fno=00005 name=/oracle/ora10g/oradata/wolf/rmanwolf.dbf
input datafile fno=00004 name=/oracle/ora10g/oradata/wolf/users01.dbf
channel ORA_DISK_1: starting piece 1 at 20-4月 -13
channel ORA_DISK_1: finished piece 1 at 20-4月 -13
piece handle=/oracle/ora10g/flash_recovery_area/WOLF/backupset/2013_04_20/o1_mf_nnndf_TAG20130420T045240_8q4otrlk_.bkp
tag=TAG20130420T045240 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:06:45
Finished backup at 20-4月 -13
Starting backup at 20-4月 -13
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=3 recid=12 stamp=813214765
channel ORA_DISK_1: starting piece 1 at 20-4月 -13
channel ORA_DISK_1: finished piece 1 at 20-4月 -13
piece handle=/oracle/ora10g/flash_recovery_area/WOLF/backupset/2013_04_20/o1_mf_annnn_TAG20130420T045925_8q4p7h2y_.bkp
tag=TAG20130420T045925 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/oracle/ora10g/flash_recovery_area/WOLF/archivelog/2013_04_20/o1_mf_1_3_8q4p7fts_.arc recid=12 stamp=813214765
Finished backup at 20-4月 -13
Starting Control File and SPFILE Autobackup at 20-4月 -13
piece handle=/oracle/ora10g/flash_recovery_area/WOLF/autobackup/2013_04_20/o1_mf_s_813214768_8q4p7jrs_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 20-4月 -13
RMAN>
-----------------------------------------------------------------------------------------------------------
2、备份表空间
RMAN> report schema;
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 480 SYSTEM *** /oracle/ora10g/oradata/wolf/system01.dbf
2 25 UNDOTBS1 *** /oracle/ora10g/oradata/wolf/undotbs01.dbf
3 240 SYSAUX *** /oracle/ora10g/oradata/wolf/sysaux01.dbf
4 5 USERS *** /oracle/ora10g/oradata/wolf/users01.dbf
5 20 RMAN_WOLF *** /oracle/ora10g/oradata/wolf/rmanwolf.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 20 TEMP 32767 /oracle/ora10g/oradata/wolf/temp01.dbf
RMAN> backup tablespace rman_wolf;
Starting backup at 20-4月 -13
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00005 name=/oracle/ora10g/oradata/wolf/rmanwolf.dbf
channel ORA_DISK_1: starting piece 1 at 20-4月 -13
channel ORA_DISK_1: finished piece 1 at 20-4月 -13
piece handle=/oracle/ora10g/flash_recovery_area/WOLF/backupset/2013_04_20/o1_mf_nnndf_TAG20130420T050523_8q4plm6l_.bkp tag=TAG20130420T050523 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 20-4月 -13
Starting Control File and SPFILE Autobackup at 20-4月 -13
piece handle=/oracle/ora10g/flash_recovery_area/WOLF/autobackup/2013_04_20/o1_mf_s_813215126_8q4plq2t_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 20-4月 -13
RMAN> list backupset
------------------------------------------------------------------------------
3、备份控制文件 (备份多分控制文件,在恢复时他会自动去找最新的那个)
RMAN> backup current controlfile;
Starting backup at 20-4月 -13
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
channel ORA_DISK_1: starting piece 1 at 20-4月 -13
channel ORA_DISK_1: finished piece 1 at 20-4月 -13
piece handle=/oracle/ora10g/flash_recovery_area/WOLF/backupset/2013_04_20/o1_mf_ncnnf_TAG20130420T052003_8q4qg39b_.bkp tag=TAG20130420T052003 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 20-4月 -13
Starting Control File and SPFILE Autobackup at 20-4月 -13
piece handle=/oracle/ora10g/flash_recovery_area/WOLF/autobackup/2013_04_20/o1_mf_s_813216006_8q4qg6y1_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 20-4月 -13
二、rman备份有两种模式
http://blog.csdn.net/yujin2010good/article/details/8828216
1、备份集(backupset)默认
2、镜像备份(image copies)
copy datafile 。。。。to。。。。。
RMAN> report schema;
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 480 SYSTEM *** /oracle/ora10g/oradata/wolf/system01.dbf
2 25 UNDOTBS1 *** /oracle/ora10g/oradata/wolf/undotbs01.dbf
3 240 SYSAUX *** /oracle/ora10g/oradata/wolf/sysaux01.dbf
4 5 USERS *** /oracle/ora10g/oradata/wolf/users01.dbf
5 20 RMAN_WOLF *** /oracle/ora10g/oradata/wolf/rmanwolf.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 20 TEMP 32767 /oracle/ora10g/oradata/wolf/temp01.dbf
RMAN> copy datafile 5 to '/oracle/ora10g/rman_wolfbak.dbf'
2> ;
Starting backup at 20-4月 -13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=/oracle/ora10g/oradata/wolf/rmanwolf.dbf
output filename=/oracle/ora10g/rman_wolfbak.dbf tag=TAG20130420T053733 recid=1 stamp=813217057
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:08
Finished backup at 20-4月 -13
Starting Control File and SPFILE Autobackup at 20-4月 -13
piece handle=/oracle/ora10g/flash_recovery_area/WOLF/autobackup/2013_04_20/o1_mf_s_813217061_8q4rh5p4_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 20-4月 -13
RMAN> list copy;
specification does not match any archive log in the recovery catalog
List of Datafile Copies
Key File S Completion Time Ckp SCN Ckp Time Name
------- ---- - --------------- ---------- --------------- ----
1 5 A 20-4月 -13 481685 20-4月 -13 /oracle/ora10g/rman_wolfbak.dbf
======================================================================================================================
海明教师第四讲
1、单命令
backup database等等 就是一个分号,
2、批命令
run{
allocate channel cha1 type disk;
backup format “/oracle/ora10g/rmanback/full_%T"
tag full_backup_wolf
database;
release channel cha1;
}
上面两条命令的作用相同
如通道分配,即使不写,oracle rman也会自动分配,缺省就会分配一个channel
输出是磁盘disk,当然也可以是tps(磁带)
format指定了存放的路径和格式
tag意思是打个标签,没有指定时,为rman缺省打上去的
release也是自动
format(备份的文件名是什么样的,标识)
%c 备份片的拷贝数
%d 数据库名称
%D 位于该月中的第几天 (DD)
%M 位于该年中的第几月 (MM)
%F 一个基于DBID唯一的名称,这个格式的形式为c-IIIIIIIIII-YYYYMMDD-QQ,其中IIIIIIIIII为该数据库的DBID,YYYYMMDD为
日期,QQ是一个1-256的序列
%n 数据库名称,向右填补到最大八个字符
%u 一个八个字符的名称代表备份集与创建时间
%p 该备份集中的备份片号,从1开始到创建的文件数
%U 一个唯一的文件名,代表%u_%p_%c
%s 备份集的号
%t 备份集时间戳
%T 年月日格式(YYYYMMDD)
channel(通道)
一个通道是rman和目标数据库的连接,allocate channel命令在目标数据库上启动一个服务器进程,同时必须定义服务器进程执
行备份或者恢复操作使用的i/o类型。
通道控制命令可以用来:
控制rman使用的O/S资源
影响并行度
指定i/o带宽的限制 设置limit read rate参数
定义备份片大小的限制 设置limit kbytes
指定当前打开文件的限制值 设置limit maxopenfiles
channel就是为了控制备份的行为。引入channel大大提高灵活性。可以分配多个channel,可以定义不同的备份。
验实
[oracle@redhat ~]$ rman
Recovery Manager: Release 10.2.0.1.0 - Production on 星期六 4月 20 10:57:35 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
RMAN> connect target /
connected to target database: WOLF (DBID=3778783462)
RMAN> run{
2> allocate channel cha1 type disk;
3> backup format "/oracle/ora10g/rmanback/full_%T"
4> tag full_backup_wolf
5> database;
6> release channel cha1;
7> }
allocated channel: cha1
channel cha1: sid=132 devtype=DISK
Starting backup at 20-4月 -13
channel cha1: starting full datafile backupset
channel cha1: specifying datafile(s) in backupset
input datafile fno=00001 name=/oracle/ora10g/oradata/wolf/system01.dbf
input datafile fno=00003 name=/oracle/ora10g/oradata/wolf/sysaux01.dbf
input datafile fno=00002 name=/oracle/ora10g/oradata/wolf/undotbs01.dbf
input datafile fno=00005 name=/oracle/ora10g/oradata/wolf/rmanwolf.dbf
input datafile fno=00004 name=/oracle/ora10g/oradata/wolf/users01.dbf
channel cha1: starting piece 1 at 20-4月 -13
channel cha1: finished piece 1 at 20-4月 -13
piece handle=/oracle/ora10g/rmanback/full_20130420 tag=FULL_BACKUP_WOLF comment=NONE
channel cha1: backup set complete, elapsed time: 00:04:45
Finished backup at 20-4月 -13
Starting Control File and SPFILE Autobackup at 20-4月 -13
piece handle=/oracle/ora10g/flash_recovery_area/WOLF/autobackup/2013_04_20/o1_mf_s_813238627_8q5fk44n_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 20-4月 -13
released channel: cha1
文章结束给大家分享下程序员的一些笑话语录: 人脑与电脑的相同点和不同点,人脑会记忆数字,电脑也会记忆数字;人脑会记忆程序,电脑也会记忆程序,但是人脑具有感知能力,这种能力电脑无法模仿,人的记忆会影响到人做任何事情,但是电脑只有程序软件。比尔还表示,人脑与电脑之间最重要的一个差别就是潜意识。对于人脑存储记忆的特别之处,比尔表示,人脑并不大,但是人脑重要的功能是联络,人脑会把同样的记忆存储在不同的地方,因此记忆读取的速度就不相同,而这种速度取决于使用的频率和知识的重要性。人脑的记忆存储能力会随着年龄增长而退化,同时记忆的质量也会随着年龄退化。经典语录网