RMAN-异机恢复 增量方式

本文模拟异机RMAN增量方式进行恢复数据库
1.原库创建表空间/temp表空间/用户
create tablespace usergy datafile '/u01/app/oracle/oradata/orcl/usergy_data01.dbf’size 32m
autoextend on
next 32m maxsize 2048m
extent management local;

create temporary tablespace temp1 
tempfile '/u01/app/oracle/oradata/orcl/user_temp1.dbf' 
size 32m 
autoextend on 
next 32m maxsize 2048m
extent management local;

create user gy identified by gy default tablespace usergy  temporary tablespace temp1; 
grant connect,resource,create session to gy;
grant create any table to gy;

2.模拟数据点1.(创建表1)
sqlplus /nolog
conn gy/gy;

create table AA(id number(4) primary key,name varchar2(20),age number(4));

insert into AA values(1,‘Mrs wang’,25);
insert into AA values(2,‘Mr gui’,25);
commit;

检查数据点

SQL> select * from AA;

        ID NAME                        AGE
---------- -------------------- ----------
         1 Mrs wang                     25
         2 Mr gui                       25

SQL>

3.原库信息查询
3.1数据文件信息

set linesize 300
col file_name for a90
select file_name from dba_data_files;

FILE_NAME
------------------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/users01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/system01.dbf

3.2 控制文件信息

SQL> show parameter control

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string      /u01/app/oracle/oradata/orcl/c
                                                 ontrol01.ctl, /u01/app/oracle/
                                                 oradata/orcl/control02.ctl
control_management_pack_access       string      DIAGNOSTIC+TUNING
SQL> 

3.3 实例名/DB_NAME/DB_UNIQUE_NMAE

SQL> show parameter name 

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
cell_offloadgroup_name               string
db_file_name_convert                 string      /u01/app/oracle/oradata/orcldg
                                                 , /u01/app/oracle/oradata/orcl
db_name                              string      orcl
db_unique_name                       string      ORCL
global_names                         boolean     FALSE
instance_name                        string      orcl
lock_name_space                      string
log_file_name_convert                string      /u01/app/oracle/oradata/orcldg
                                                 , /u01/app/oracle/oradata/orcl
processor_group_name                 string

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      ORCL

3.4 Onlinelog 信息

SQL> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER                                                                                     IS_
---------- ------- ------- ------------------------------------------------------------------------------------------ ---
         3         ONLINE  /u01/app/oracle/oradata/orcl/redo03.log                                                    NO
         2         ONLINE  /u01/app/oracle/oradata/orcl/redo02.log                                                    NO
         1         ONLINE  /u01/app/oracle/oradata/orcl/redo01.log                                                    NO
         4         STANDBY /u01/app/oracle/oradata/stdredo/redo04.log                                                 NO
         5         STANDBY /u01/app/oracle/oradata/stdredo/redo05.log                                                 NO
         6         STANDBY /u01/app/oracle/oradata/stdredo/redo06.log                                                 NO
         7         STANDBY /u01/app/oracle/oradata/stdredo/redo07.log                                                 NO

7 rows selected.

SQL> 

3.5 记录dbid(恢复的controlfile中会记录dbid,这里我们可以提前记录dbid)

SQL> select dbid from v$database;

      DBID
----------
1509591956

SQL> 

4.原库level 0 备份
4.1 创建备份目录

[root@Jerry ~]# cd /
[root@Jerry /]# mkdir backup
[root@Jerry /]# chown -R oracle:oinstall backup/
[root@Jerry /]# 

4.2 开始备份

#!/bin/bash
ORACLE_BASE=/u01/app/oracle
export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_HOME
ORACLE_SID=orcl
export ORACLE_SID
PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
export PATH
rman target / msglog=/backup/rman_bk_`date ''+%Y%m%d%H%M%S''`.log  append <<EOF;
run{
    allocate channel c1 type disk;
    allocate channel c2 type disk;
    allocate channel c3 type disk;
    backup incremental level 0 tag 'db0' format '/backup/db0%u_%s_%p' database;
    sql 'alter system archive log current';
    backup format '/backup/arch%u_%s_%p' archivelog all; #备份归档可选,可以单独定期备份
    backup current controlfile format '/backup/ctl-%T-%U.bak';
    release channel c1;
    release channel c2;
    release channel c3;
    }

4.3 备份level0 日志输出

[oracle@Jerry ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Tue Dec 25 03:49:22 2018

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1509591956)

RMAN> run{
2>     allocate channel c1 type disk;
3>     allocate channel c2 type disk;
4>     allocate channel c3 type disk;
5>     backup incremental level 0 tag 'db0' format '/backup/db0%u_%s_%p' database;
6>     sql 'alter system archive log current';
7>     backup format '/backup/arch%u_%s_%p' archivelog all; #备份归档可选,可以单独定期备份
8>     backup current controlfile format '/backup/ctl-%T-%U.bak';
9>     release channel c1;
10>     release channel c2;
11>     release channel c3;
12>     }

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=38 device type=DISK

allocated channel: c2
channel c2: SID=33 device type=DISK

allocated channel: c3
channel c3: SID=42 device type=DISK

Starting backup at 25-DEC-18
channel c1: starting incremental level 0 datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
channel c1: starting piece 1 at 25-DEC-18
channel c2: starting incremental level 0 datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel c2: starting piece 1 at 25-DEC-18
channel c3: starting incremental level 0 datafile backup set
channel c3: specifying datafile(s) in backup set
input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/usergy_data01.dbf
channel c3: starting piece 1 at 25-DEC-18
channel c3: finished piece 1 at 25-DEC-18
piece handle=/backup/db037tlkjap_103_1 tag=DB0 comment=NONE
channel c3: backup set complete, elapsed time: 00:00:03
channel c1: finished piece 1 at 25-DEC-18
piece handle=/backup/db035tlkjap_101_1 tag=DB0 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:15
channel c2: finished piece 1 at 25-DEC-18
piece handle=/backup/db036tlkjap_102_1 tag=DB0 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:15
Finished backup at 25-DEC-18

Starting Control File and SPFILE Autobackup at 25-DEC-18
piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-1509591956-20181225-0a comment=NONE
Finished Control File and SPFILE Autobackup at 25-DEC-18

sql statement: alter system archive log current

Starting backup at 25-DEC-18
current log archived
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=27 RECID=33 STAMP=995755963
input archived log thread=1 sequence=28 RECID=34 STAMP=995755968
input archived log thread=1 sequence=29 RECID=35 STAMP=995758248
input archived log thread=1 sequence=30 RECID=36 STAMP=995758248
input archived log thread=1 sequence=31 RECID=37 STAMP=995758248
input archived log thread=1 sequence=32 RECID=38 STAMP=995758248
input archived log thread=1 sequence=33 RECID=39 STAMP=995758285
input archived log thread=1 sequence=34 RECID=40 STAMP=995758285
input archived log thread=1 sequence=35 RECID=41 STAMP=995758285
input archived log thread=1 sequence=36 RECID=42 STAMP=995758285
input archived log thread=1 sequence=37 RECID=43 STAMP=995758307
channel c1: starting piece 1 at 25-DEC-18
channel c2: starting archived log backup set
channel c2: specifying archived log(s) in backup set
input archived log thread=1 sequence=38 RECID=44 STAMP=995762413
input archived log thread=1 sequence=39 RECID=45 STAMP=995762413
input archived log thread=1 sequence=40 RECID=46 STAMP=995762415
input archived log thread=1 sequence=41 RECID=47 STAMP=995762415
input archived log thread=1 sequence=42 RECID=48 STAMP=995762427
input archived log thread=1 sequence=43 RECID=49 STAMP=99576
  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值