RMAN备份与恢复之DataBase

时间:2022-01-05 07:23:37

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. 从Eclipse迁移到Android Studio

    Google正式推出了Android Studio 1.0,Android默认的开发工具也由Eclipse变成了intellij,对Eclipse的支持肯定会越来越少了,对于Android开发者来说, ...

  2. java基础算法之冒泡排序

    接触冒泡算法还是大一了,学习C语言的冒泡算法.现在唯一记得就是冒泡与选择了.出来刚刚工作的时候觉的算法基本没撒用处,现在发现这些都是很好的基础.因此自己也准备重新拾起这些知识. 冒泡排序 泡排序是一种 ...

  3. RESTful架构详解(转)

    1. 什么是REST REST全称是Representational State Transfer,中文意思是表述(编者注:通常译为表征)性状态转移. 它首次出现在2000年Roy Fielding的 ...

  4. http://blog.csdn.net/shirdrn/article/details/6270506

    http://blog.csdn.net/shirdrn/article/details/6270506

  5. Spring基于 Annotation 的简单介绍

    tyle="margin:20px 0px 0px; font-size:14px; line-height:26px; font-family:Arial"> 1.使用 @ ...

  6. 获取安卓的SH1安全码

     用于获取手机联系人 信息   public static String sHA1(Context context) { try { PackageInfo info = context.getPac ...

  7. newcoder-最长树链-树/gcd

    https://ac.nowcoder.com/acm/problem/13233 链接:https://ac.nowcoder.com/acm/problem/13233来源:牛客网 题目描述 树链 ...

  8. 【Java基础】JAVA不可变类(immutable)机制与String的不可变性

    一.不可变类简介 不可变类:所谓的不可变类是指这个类的实例一旦创建完成后,就不能改变其成员变量值.如JDK内部自带的很多不可变类:Interger.Long和String(8种基本数据类型的包装类和S ...

  9. 如何在Windows 7/8/10中使用热键来调整音量?

    有时,您需要一个热键来调整Windows PC中的音量.例如:播放全屏视频或游戏时需要调整音量. 有一个简单的方法可以做到: 安装并运行Perfect Hotkey软件.   配置键盘快捷键以进行音量 ...

  10. 解决requests获取源代码时中文乱码问题

    用requests获取源代码时,如果是中文网页,就可能会出现乱码,下面我以中关村的网站为例: import requests url = 'http://desk.zol.com.cn/meinv/' ...