zoukankan      html  css  js  c++  java
  • RMAN备份与恢复之DataBase

    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;}                                       --释放通道
    View Code

      注意:备份时,可先将控制文件备份设置为自动备份! 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;
    }
    备份全库
  • 相关阅读:
    zindex在IE中的迷惑(一)
    IE “+” CSS Hack研究
    display:inlineblock的深入理解
    CSS解决未知高度垂直居中
    zindex在IE中的迷惑(二)
    三角的一个特殊做法
    图片垂直居中的使用技巧
    简单form标准化实例(一):整体布局
    简单form标准化实例(二):语义结构
    CSS定义通用透明效果
  • 原文地址:https://www.cnblogs.com/HondaHsu/p/4876619.html
Copyright © 2011-2022 走看看