1   准备

[oracle@TEST144239 /]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.3.0 Production on Mon Oct 12 11:58:35 2015

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

SQL> conn sys/Sina.2015@study as sysdba
Connected.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /data2/orcl/recover_log/archive_log
Oldest online log sequence 22
Next log sequence to archive 24
Current log sequence 24

1.1检查数据库归档状态

RMAN>configure controlfile autobackup on;--自动备份控制文件置为on状态,将自动备份控制文件和参数文件

[oracle@TEST144239 ~]$ rman target sys/Sina.2015@study

1.2RMAN登陆目标

2 备份与恢复全库

  通常默认在/u01/app/oracle/fast_recovery_area/ORCL/ ,若需要特定指定备份数据存储位置时,可以创建备份数据库存储的目录。

  如指定/data2/backup/为备份位置:

  示例:RMAN> backup database format '/data2/backup/whole_%d_%U';  --备份整个数据库

  示例:RMAN> backup as compressed backupset

     2> database format ''/data2/backup/whole_%d_%U';  --备份整个数据库并压缩备份集

示例:

RMAN> run{
2> allocate channel ch1 type disk --手动分配一个通道
3> maxpiecesize=2g;   --指定备份片的大小为2g
4> backup as compressed backupset --压缩备份集
5> format '/data2/backup/whole_%d_%U' filesperset=3 --指定备份集中允许容纳的文件数为个
6> database;
7> release channel ch1;} --释放通道

  注意:备份时,可先将控制文件备份设置为自动备份! RMAN> configure controlfile autobackup on;--自动备份控制文件置为on状态,将自动备份控制文件和参数文件

[oracle@TEST144239 /]$ mkdir /data2/backup

2.1创建备份数据存储目录

RMAN>  backup as compressed backupset database plus archivelog;

Starting backup at 12-OCT-15
current log archived
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=12 RECID=1 STAMP=892728339
input archived log thread=1 sequence=13 RECID=2 STAMP=892736557
input archived log thread=1 sequence=14 RECID=3 STAMP=892753270
input archived log thread=1 sequence=15 RECID=4 STAMP=892768262
channel ORA_DISK_1: starting piece 1 at 12-OCT-15
channel ORA_DISK_2: starting compressed archived log backup set
channel ORA_DISK_2: specifying archived log(s) in backup set
input archived log thread=1 sequence=16 RECID=5 STAMP=892791995
input archived log thread=1 sequence=17 RECID=6 STAMP=892803633
input archived log thread=1 sequence=18 RECID=7 STAMP=892815402
input archived log thread=1 sequence=19 RECID=8 STAMP=892828012
input archived log thread=1 sequence=20 RECID=9 STAMP=892843267
channel ORA_DISK_2: starting piece 1 at 12-OCT-15
channel ORA_DISK_3: starting compressed archived log backup set
channel ORA_DISK_3: specifying archived log(s) in backup set
input archived log thread=1 sequence=21 RECID=10 STAMP=892857631
input archived log thread=1 sequence=22 RECID=11 STAMP=892882839
input archived log thread=1 sequence=23 RECID=12 STAMP=892891106
input archived log thread=1 sequence=24 RECID=13 STAMP=892900945
input archived log thread=1 sequence=25 RECID=14 STAMP=892901057
input archived log thread=1 sequence=26 RECID=15 STAMP=892901228
input archived log thread=1 sequence=27 RECID=16 STAMP=892901372
input archived log thread=1 sequence=28 RECID=17 STAMP=892901532
channel ORA_DISK_3: starting piece 1 at 12-OCT-15
channel ORA_DISK_3: finished piece 1 at 12-OCT-15
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_12/o1_mf_annnn_TAG20151012T145139_c1pp3xr2_.bkp tag=TAG20151012T145139 comment=NONE
channel ORA_DISK_3: backup set complete, elapsed time: 00:00:15
channel ORA_DISK_3: starting compressed archived log backup set
channel ORA_DISK_3: specifying archived log(s) in backup set
input archived log thread=1 sequence=29 RECID=18 STAMP=892901677
input archived log thread=1 sequence=30 RECID=19 STAMP=892909146
input archived log thread=1 sequence=31 RECID=20 STAMP=892909170
input archived log thread=1 sequence=32 RECID=21 STAMP=892909211
input archived log thread=1 sequence=33 RECID=22 STAMP=892911098
channel ORA_DISK_3: starting piece 1 at 12-OCT-15
channel ORA_DISK_1: finished piece 1 at 12-OCT-15
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_12/o1_mf_annnn_TAG20151012T145139_c1pp3wp6_.bkp tag=TAG20151012T145139 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:20
channel ORA_DISK_2: finished piece 1 at 12-OCT-15
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_12/o1_mf_annnn_TAG20151012T145139_c1pp3ww1_.bkp tag=TAG20151012T145139 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:22
channel ORA_DISK_3: finished piece 1 at 12-OCT-15
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_12/o1_mf_annnn_TAG20151012T145139_c1pp4hhj_.bkp tag=TAG20151012T145139 comment=NONE
channel ORA_DISK_3: backup set complete, elapsed time: 00:00:06
Finished backup at 12-OCT-15 Starting backup at 12-OCT-15
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/data2/orcl/system01.dbf
input datafile file number=00003 name=/data2/orcl/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 12-OCT-15
channel ORA_DISK_2: starting compressed full datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00002 name=/data2/orcl/sysaux01.dbf
input datafile file number=00004 name=/data2/orcl/users01.dbf
channel ORA_DISK_2: starting piece 1 at 12-OCT-15
channel ORA_DISK_2: finished piece 1 at 12-OCT-15
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_12/o1_mf_nnndf_TAG20151012T145203_c1pp4phv_.bkp tag=TAG20151012T145203 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:55
channel ORA_DISK_1: finished piece 1 at 12-OCT-15
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_12/o1_mf_nnndf_TAG20151012T145203_c1pp4o7j_.bkp tag=TAG20151012T145203 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:16
Finished backup at 12-OCT-15 Starting backup at 12-OCT-15
current log archived
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=34 RECID=23 STAMP=892911204
channel ORA_DISK_1: starting piece 1 at 12-OCT-15
channel ORA_DISK_1: finished piece 1 at 12-OCT-15
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_12/o1_mf_annnn_TAG20151012T145325_c1pp76vh_.bkp tag=TAG20151012T145325 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 12-OCT-15 Starting Control File and SPFILE Autobackup at 12-OCT-15
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/autobackup/2015_10_12/o1_mf_s_892911216_c1pp7o9p_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 12-OCT-15

2.2RMAN备份全库

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1 RMAN> run{
2> restore database;
3> recover database;
4> }; Starting restore at 12-OCT-15
Starting implicit crosscheck backup at 12-OCT-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=63 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=129 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=193 device type=DISK
Crosschecked 7 objects
Crosschecked 50 objects
Finished implicit crosscheck backup at 12-OCT-15 Starting implicit crosscheck copy at 12-OCT-15
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
Crosschecked 6 objects
Finished implicit crosscheck copy at 12-OCT-15 searching for all files in the recovery area
cataloging files...
cataloging done List of Cataloged Files
=======================
File Name: /u01/app/oracle/fast_recovery_area/ORCL/autobackup/2015_10_12/o1_mf_s_892911216_c1pp7o9p_.bkp using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3 channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00002 to /data2/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /data2/orcl/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_12/o1_mf_nnndf_TAG20151012T145203_c1pp4phv_.bkp
channel ORA_DISK_2: starting datafile backup set restore
channel ORA_DISK_2: specifying datafile(s) to restore from backup set
channel ORA_DISK_2: restoring datafile 00001 to /data2/orcl/system01.dbf
channel ORA_DISK_2: restoring datafile 00003 to /data2/orcl/undotbs01.dbf
channel ORA_DISK_2: reading from backup piece /u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_12/o1_mf_nnndf_TAG20151012T145203_c1pp4o7j_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_12/o1_mf_nnndf_TAG20151012T145203_c1pp4phv_.bkp tag=TAG20151012T145203
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:01
channel ORA_DISK_2: piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_12/o1_mf_nnndf_TAG20151012T145203_c1pp4o7j_.bkp tag=TAG20151012T145203
channel ORA_DISK_2: restored backup piece 1
channel ORA_DISK_2: restore complete, elapsed time: 00:01:25
Finished restore at 12-OCT-15 Starting recover at 12-OCT-15
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3 starting media recovery archived log for thread 1 with sequence 34 is already on disk as file /data2/orcl/redo01.log
archived log for thread 1 with sequence 35 is already on disk as file /data2/orcl/redo02.log
archived log for thread 1 with sequence 36 is already on disk as file /data2/orcl/redo03.log
archived log file name=/data2/orcl/redo01.log thread=1 sequence=34
archived log file name=/data2/orcl/redo02.log thread=1 sequence=35
archived log file name=/data2/orcl/redo03.log thread=1 sequence=36
media recovery complete, elapsed time: 00:00:18
Finished recover at 12-OCT-15 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: "advise, allocate, alter, backup, @, catalog, change, configure, connect, convert, copy, create, crosscheck, delete, drop, duplicate, exit, flashback, grant, host, import, list, mount, open, print, quit, recover, register, release, repair, replace, report, reset, restore, resync, revoke, run, send, set, show, shutdown, spool, sql, startup, switch, transport, unregister, upgrade, validate, {, "
RMAN-01007: at line 0 column 3 file: standard input [oracle@ZTE-TEST144239 onlinelog]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.3.0 Production on Mon Oct 12 16:31:51 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

2.3恢复数据库

示例:

run {
allocate channel ch1 type disk
maxpiecesize=2g;
backup as compressed backupset
format '/NewBackup/rman_backup/whole_%d_%U.bks' filesperset=3
tag dbfull
database ;
crosscheck archivelog all;
delete expired archivelog all;
sql 'alter system archive log current';
backup archivelog all
format '/NewBackup/rman_backup/%d_%s_%p_%t.arch'
tag dbarch;
backup spfile
format '/NewBackup/rman_backup/%d_%s_%p_%t.spfile'
tag dbspfile;
backup
format '/NewBackup/rman_backup/%d_%s_%p_%t.ctl'
tag dbctl
current controlfile;
release channel ch1;
}

备份全库

RMAN备份与恢复之DataBase的更多相关文章

  1. RMAN备份与恢复之spfile

    1.备份spfile 有关控制文件及参数文件备份的几种形式: 单独备份控制文件及参数文件 RMAN> backup current controlfile; 备份数据文件时包含控制文件 RMAN ...

  2. Oracle RMAN 备份及不完全恢复(删除archievelog)

    RMAN备份命令 backup Database format='/home/oracle/backup/bak_full_%U_%T' tag='bak_full'; sql 'alter syst ...

  3. Oracle备份恢复之rman备份oracle数据库

    备份需求和rman备份 oracle数据库的备份相关问答: 1)备份时数据库处于何种状态? 备份时数据库处于OPEN状态,这样数据库可以正常工作. 2)备份的数据备份在什么地方? 备份在本地磁盘. 3 ...

  4. DG环境数据库RMAN备份策略制定

    DG环境数据库RMAN备份策略制定: 主库(Primary) 全库备份 归档备份 删除历史文件夹 备库(Standby) 删除归档 引用说明 主库(Primary) $ crontab -l 0 1 ...

  5. 记录一则RMAN备份策略修正案例

    背景:在给某客户处理问题时,发现客户数据库的备份空间即将用尽,进一步查看发现是用户数据库的当前RMAN备份策略存在潜在问题,需要修改备份策略. 环境:SunOS 5.10 + Oracle 11.2. ...

  6. RMAN备份脚本一列分享

    在ORACLE数据库中,RMAN备份的脚本非常多,下面介绍一例shell脚本如何通过RMAN备份,以及FTP上传RMAN备份文件以及归档日志文件的脚本. fullback.sh 里面调用RMAN命令做 ...

  7. oracle数据库rman备份计划及恢复

    1.rman完全恢复的前提条件:历史的datafile,controlfile和spfile备份,加上完整的archivelog和完好的redolog. 2.rman备份脚本: a.RMAN 0级备份 ...

  8. RMAN 备份及策略

    更详细信息请转http://blog.chinaunix.net/uid-21187846-id-3017363.html 天,这里修改为15天:这样比较保险,到时候恢复时也可以找到当时的备份元数据: ...

  9. Oracle RMAN 备份一例

    Oracle RMAN备份一例: Solaris 10 + Oracle 11.2.0.3 Shell:csh,安装有bash,脚本调用bash 备份策略:周日0级备份,周一~周六1级备份,每6小时备 ...

随机推荐

  1. [!!!!!]Inno Setup教程-常见问题解答

    [转]Inno Setup教程-常见问题解答 功能 * 翻译 Inno Setup 文字  * 它支持 MBCS (多字节字符集) 吗?  * 将来会支持 Windows Installer 吗?   ...

  2. 使用Inno Setup 打包.NET程序,并自动安装.Net Framework

    使用Inno Setup 打包.NET程序,并自动安装.Net Framework http://www.cnblogs.com/xiaogangqq123/archive/2012/03/19/24 ...

  3. 【转】Fast Entity Component System

    http://entity-systems.wikidot.com/fast-entity-component-system Summary Create a generic System class ...

  4. linux查看系统的启动时间和运行时间

    1. uptime命令 输出:09:32:17 up 8:41, 1 user, load average: 0.01, 0.00, 0.00 其中8:41代表系统已经运行8小时41分 2.查看/pr ...

  5. 【Modal】

    1.Bootstrap Modal 文档里标签.属性.方法.事件都写的很清楚 2.AngularUI - Bootstrap UI Bootstrap 2.1 $scope.open = functi ...

  6. 【Sublime Text 3】插件

    TrailingSpacer 高亮显示多余的空格和Tab HTML-CSS-JS Prettify

  7. 九 EJB

    一 EJB 1. 定义:EJB 就是一组用 Java 语言编写的包含字段和方法的代码体,而这些代码的核心任务就是实现纯粹的业务逻辑. 2. EJB 和 JavaBean 的相同点: a) 都有 get ...

  8. Highcharts ajax获取json对象动态生成报表生成 .

    http://blog.csdn.net/wsk7860/article/details/8751061 最近做个项目,项目经理想做一个统计报表,在网上查看些资料就选用Highchars 这里和大家分 ...

  9. js confirm用法

    <script> $('.tzshanchu').click(function(){ if(confirm('是否确认删除')){ alert('删除了') } });</scrip ...

  10. ES6 - 对象

    ES6为对象带来的新特性. 对象传统的写法: let person={ 'name':'Lily', 'say':function(){ alert('hello!'); } } 1.ES6中写法更简 ...