免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
打印 上一主题 下一主题

增量备份问题 [复制链接]

论坛徽章:
0
11 [报告]
发表于 2011-08-05 15:04 |只看该作者
我原来做的例子是全库的,但RMAN也支持部分的。你自己测试一下。RMAN单表空间和单数据文件的我做过,应该没问题。我这里指的是增量的。

论坛徽章:
0
12 [报告]
发表于 2011-08-05 15:34 |只看该作者
我原来做的例子是全库的,但RMAN也支持部分的。你自己测试一下。RMAN单表空间和单数据文件的我做过,应该没 ...
tacsoft 发表于 2011-08-05 15:04



    感谢,我正在查找rman增量备份表空间的语法


顺便请教下 我用以下的命令建立表空间后这个user101.dbf最大就是250M吗?

CREATE TABLESPACE USER1 DATAFILE

  '/u01/app/oracle/oradata/orcl/user101.dbf' SIZE 250M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED

LOGGING

ONLINE

PERMANENT

EXTENT MANAGEMENT LOCAL AUTOALLOCATE

BLOCKSIZE 8K

SEGMENT SPACE MANAGEMENT AUTO

FLASHBACK ON;

论坛徽章:
0
13 [报告]
发表于 2011-08-05 15:37 |只看该作者
不是,初始体积250MB,AUTOEXTEND自动扩展。每次扩展10MB, UNLIMITED无限制。除非达到你的硬盘限制空间。

论坛徽章:
0
14 [报告]
发表于 2011-08-07 17:53 |只看该作者
我原来做的例子是全库的,但RMAN也支持部分的。你自己测试一下。RMAN单表空间和单数据文件的我做过,应该没 ...
tacsoft 发表于 2011-08-05 15:04



   
    RMAN做单表空间的0级和增量备份能不能给个例子,我在网上找例子试没有成功,在家没有环境,谢谢

论坛徽章:
0
15 [报告]
发表于 2011-08-08 08:28 |只看该作者
这是我找到的
增量备份

backup incremental level 0 tablespace user;
  create database hr.t15_a(a number) tablespace user;
  insert into t15_a values(1);
  backup incremental level 1 tablespace user;(增加88k)

论坛徽章:
0
16 [报告]
发表于 2011-08-08 08:35 |只看该作者
在英文网站上找到的,这句就可以。
RMAN> backup incremental level 0 tablespace users;

论坛徽章:
0
17 [报告]
发表于 2011-08-08 21:18 |只看该作者
楼主的问题正是我目前急需解决的问题,我在csdn的oracle和sql server版都提出过类似问题,但都无解。
“如何同步两台不能互连的电脑中的数据库数据?”
SQL Server版本 http://topic.csdn.net/u/20110804 ... 9863&r=74779162
Oracle版本 http://topic.csdn.net/u/20110805 ... d-459f0e09953c.html

论坛徽章:
0
18 [报告]
发表于 2011-08-11 16:26 |只看该作者
在英文网站上找到的,这句就可以。
RMAN> backup incremental level 0 tablespace users;
tacsoft 发表于 2011-08-08 08:35



    现在我是这样搞的,用RMAN分别做了用户表空间(test_ts)的0级备份、1级和2级备份 脚本如下(不知道有不对的地方没,请指导)
  1. #!/bin/bash
  2. # incremental level 0 backup script

  3. source /home/oracle/.bash_profile
  4. current_day=`date +%Y%m%d`
  5. BAK_DIR=/home/oracle/RBACKUP/$current_day
  6. current_day=`date +%Y%m%d`
  7. mkdir -p $BAK_DIR
  8. rman target  / <<EOF
  9. run{
  10.     allocate channel cha1 type disk;
  11.     backup
  12.     incremental level  0
  13.     format '$BAK_DIR/inc0_%u_%T'
  14.     tag Sunday_inc0
  15.     tablespace test_ts;
  16.     release channel cha1;
  17.     }
  18. EOF
复制代码

  1. #!/bin/bash
  2. # incremental level 1 backup script

  3. source /home/oracle/.bash_profile
  4. current_day=`date +%Y%m%d`
  5. BAK_DIR=/home/oracle/RBACKUP/$current_day
  6. current_day=`date +%Y%m%d`
  7. mkdir -p $BAK_DIR
  8. rman target  / <<EOF
  9. run{
  10.     allocate channel cha1 type disk;
  11.     backup
  12.     incremental level  1
  13.     format '$BAK_DIR/inc1_%u_%T'
  14.     tag inc1
  15.     tablespace test_ts;
  16.     release channel cha1;
  17.     }
  18. EOF
复制代码
  1. #!/bin/bash
  2. # incremental level 2 backup script

  3. source /home/oracle/.bash_profile
  4. current_day=`date +%Y%m%d`
  5. BAK_DIR=/home/oracle/RBACKUP/$current_day
  6. current_day=`date +%Y%m%d`
  7. mkdir -p $BAK_DIR
  8. rman target  / <<EOF
  9. run{
  10.     allocate channel cha1 type disk;
  11.     backup
  12.     incremental level  2
  13.     format '$BAK_DIR/inc2_%u_%T'
  14.     tag inc2
  15.     tablespace test_ts;
  16.     release channel cha1;
  17.     }
  18. EOF
复制代码
现在的问题有两个(我删除了这个用户的一个表test)
1.在我在本机上在执行
RMAN> restore tablespace test_ts;
RMAN> recover tablespace test_ts;
并没有恢复这个表,请问要把备份0级或1级或2级恢复要怎么做?

2.如果我把这三个备份放到另一到机器上Oracle的版本和用户名字还有表空间名字都一样的话,应该怎么来恢复呢?谢谢

论坛徽章:
0
19 [报告]
发表于 2011-08-11 21:06 |只看该作者
本帖最后由 tacsoft 于 2011-08-11 21:13 编辑

这句有点问题,应该恢复前面的时间点或者SCN,不写时间或者SCN,RMAN并不知道你想要恢复到什么位置,我觉得该句只给你恢复到当前位置了,所以什么都没有。
RMAN> recover tablespace test_ts;

我找到一个例子,我觉得还行:
rman增量备份和恢复(基于时间基点恢复)的一个例子

RMAN> backup incremental level=0 database plus archivelog delete all input;


Starting backup at 2009-11-27 09:31:31
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=1 recid=67 stamp=704021491
channel ORA_DISK_1: starting piece 1 at 2009-11-27 09:31:33
channel ORA_DISK_1: finished piece 1 at 2009-11-27 09:31:34
piece

handle=/u01/app/flash_recovery_area/VICTOR/backupset/2009_11_27/o1_mf_annnn_TAG200

91127T093131_5jybzo2h_.bkp tag=TAG20091127T093131 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=/u01/app/flash_recovery_area/VICTOR/archivelog/2009_11_27/o1_mf_1_1_5jybz

mdc_.arc recid=67 stamp=704021491
Finished backup at 2009-11-27 09:31:34

Starting backup at 2009-11-27 09:31:34
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/oracle/app/oradata/victor/system01.dbf
input datafile fno=00002 name=/oracle/app/oradata/victor/undotbs01.dbf
input datafile fno=00003 name=/oracle/app/oradata/victor/sysaux01.dbf
input datafile fno=00005 name=/oracle/app/oradata/victor/example01.dbf
input datafile fno=00006 name=/oradata/coe/coe01.dbf
input datafile fno=00007 name=/oradata/coe/coe02.dbf
input datafile fno=00008 name=/oradata/coe/coe03.dbf
input datafile fno=00004 name=/oracle/app/oradata/victor/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2009-11-27 09:31:34
channel ORA_DISK_1: finished piece 1 at 2009-11-27 09:32:09
piece

handle=/u01/app/flash_recovery_area/VICTOR/backupset/2009_11_27/o1_mf_nnnd0_TAG200

91127T093134_5jybzpl9_.bkp tag=TAG20091127T093134 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
Finished backup at 2009-11-27 09:32:09

Starting backup at 2009-11-27 09:32:09
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=2 recid=68 stamp=704021529
channel ORA_DISK_1: starting piece 1 at 2009-11-27 09:32:10
channel ORA_DISK_1: finished piece 1 at 2009-11-27 09:32:11
piece

handle=/u01/app/flash_recovery_area/VICTOR/backupset/2009_11_27/o1_mf_annnn_TAG200

91127T093209_5jyc0tv9_.bkp tag=TAG20091127T093209 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=/u01/app/flash_recovery_area/VICTOR/archivelog/2009_11_27/o1_mf_1_2_5jyc0

sn0_.arc recid=68 stamp=704021529
Finished backup at 2009-11-27 09:32:11

Starting Control File and SPFILE Autobackup at 2009-11-27 09:32:11
piece

handle=/u01/app/flash_recovery_area/VICTOR/autobackup/2009_11_27/o1_mf_s_704021532

_5jyc0wdq_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2009-11-27 09:32:13

RMAN> exit


Recovery Manager complete.

[oracle@lxp1 ~]$ rman target /

Recovery Manager: Release 10.2.0.4.0 - Production on Fri Nov 27 09:37:38 2009

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

connected to target database: VICTOR (DBID=266005057)

RMAN> backup incremental level=1 database plus archivelog delete all input;


Starting backup at 2009-11-27 09:38:03
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=142 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=3 recid=69 stamp=704021884
channel ORA_DISK_1: starting piece 1 at 2009-11-27 09:38:05
channel ORA_DISK_1: finished piece 1 at 2009-11-27 09:38:06
piece

handle=/u01/app/flash_recovery_area/VICTOR/backupset/2009_11_27/o1_mf_annnn_TAG200

91127T093804_5jyccxss_.bkp tag=TAG20091127T093804 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=/u01/app/flash_recovery_area/VICTOR/archivelog/2009_11_27/o1_mf_1_3_5jycc

w0b_.arc recid=69 stamp=704021884
Finished backup at 2009-11-27 09:38:06

Starting backup at 2009-11-27 09:38:06
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/oracle/app/oradata/victor/system01.dbf
input datafile fno=00002 name=/oracle/app/oradata/victor/undotbs01.dbf
input datafile fno=00003 name=/oracle/app/oradata/victor/sysaux01.dbf
input datafile fno=00005 name=/oracle/app/oradata/victor/example01.dbf
input datafile fno=00006 name=/oradata/coe/coe01.dbf
input datafile fno=00007 name=/oradata/coe/coe02.dbf
input datafile fno=00008 name=/oradata/coe/coe03.dbf
input datafile fno=00004 name=/oracle/app/oradata/victor/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2009-11-27 09:38:07
channel ORA_DISK_1: finished piece 1 at 2009-11-27 09:38:42
piece

handle=/u01/app/flash_recovery_area/VICTOR/backupset/2009_11_27/o1_mf_nnnd1_TAG200

91127T093807_5jycczg6_.bkp tag=TAG20091127T093807 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
Finished backup at 2009-11-27 09:38:42

Starting backup at 2009-11-27 09:38:42
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=4 recid=70 stamp=704021922
channel ORA_DISK_1: starting piece 1 at 2009-11-27 09:38:43
channel ORA_DISK_1: finished piece 1 at 2009-11-27 09:38:44
piece

handle=/u01/app/flash_recovery_area/VICTOR/backupset/2009_11_27/o1_mf_annnn_TAG200

91127T093842_5jycf3on_.bkp tag=TAG20091127T093842 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=/u01/app/flash_recovery_area/VICTOR/archivelog/2009_11_27/o1_mf_1_4_5jycf

2gm_.arc recid=70 stamp=704021922
Finished backup at 2009-11-27 09:38:44

Starting Control File and SPFILE Autobackup at 2009-11-27 09:38:44
piece

handle=/u01/app/flash_recovery_area/VICTOR/autobackup/2009_11_27/o1_mf_s_704021924

_5jycf57s_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2009-11-27 09:38:45

RMAN> exit


Recovery Manager complete.
[oracle@lxp1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Fri Nov 27 09:38:57 2009

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

......
.......
........这里加了一些表和表里加入了一些数据

SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss')t1 from dual;

T1
-------------------
2009-11-27 09:40:43

SQL> alter system switch logfile;

System altered.


SQL> alter system switch logfile;

System altered.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 -

Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@lxp1 ~]$ rman target /

Recovery Manager: Release 10.2.0.4.0 - Production on Fri Nov 27 09:42:02 2009

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

connected to target database (not started)

RMAN> startup nomount;

Oracle instance started

Total System Global Area     272629760 bytes

Fixed Size                     1266996 bytes
Variable Size                146803404 bytes
Database Buffers             121634816 bytes
Redo Buffers

RMAN>  restore controlfile from

'/u01/app/flash_recovery_area/VICTOR/autobackup/2009_11_27/o1_mf_s_704021924_5jycf

57s_.bkp';

Starting restore at 2009-11-27 09:47:34
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
output filename=/oracle/app/oradata/victor/control01.ctl
output filename=/oracle/app/oradata/victor/control02.ctl
output filename=/oracle/app/oradata/victor/control03.ctl
Finished restore at 2009-11-27 09:47:37


RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> restore database;

Starting restore at 2009-11-27 09:48:15
Starting implicit crosscheck backup at 2009-11-27 09:48:15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
Crosschecked 7 objects
Finished implicit crosscheck backup at 2009-11-27 09:48:16

Starting implicit crosscheck copy at 2009-11-27 09:48:16
using channel ORA_DISK_1
Finished implicit crosscheck copy at 2009-11-27 09:48:16

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name:

/u01/app/flash_recovery_area/VICTOR/archivelog/2009_11_27/o1_mf_1_5_5jyck26d_.arc
File Name:

/u01/app/flash_recovery_area/VICTOR/archivelog/2009_11_27/o1_mf_1_6_5jyckk1h_.arc
File Name:

/u01/app/flash_recovery_area/VICTOR/autobackup/2009_11_27/o1_mf_s_704021924_5jycf5

7s_.bkp

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /oracle/app/oradata/victor/system01.dbf
restoring datafile 00002 to /oracle/app/oradata/victor/undotbs01.dbf
restoring datafile 00003 to /oracle/app/oradata/victor/sysaux01.dbf
restoring datafile 00004 to /oracle/app/oradata/victor/users01.dbf
restoring datafile 00005 to /oracle/app/oradata/victor/example01.dbf
restoring datafile 00006 to /oradata/coe/coe01.dbf
restoring datafile 00007 to /oradata/coe/coe02.dbf
restoring datafile 00008 to /oradata/coe/coe03.dbf
channel ORA_DISK_1: reading from backup piece

/u01/app/flash_recovery_area/VICTOR/backupset/2009_11_27/o1_mf_nnnd0_TAG20091127T0

93134_5jybzpl9_.bkp
channel ORA_DISK_1: restored backup piece 1
piece

handle=/u01/app/flash_recovery_area/VICTOR/backupset/2009_11_27/o1_mf_nnnd0_TAG200

91127T093134_5jybzpl9_.bkp tag=TAG20091127T093134
channel ORA_DISK_1: restore complete, elapsed time: 00:00:36
Finished restore at 2009-11-27 09:48:53

RMAN> recover database until time "TO_DATE('2009-11-27 09:40:43','YYYY-MM-DD

HH24:MI:SS')";
2> 3>
Starting recover at 2009-11-27 09:49:13
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /oracle/app/oradata/victor/system01.dbf
destination for restore of datafile 00002:

/oracle/app/oradata/victor/undotbs01.dbf
destination for restore of datafile 00003: /oracle/app/oradata/victor/sysaux01.dbf
destination for restore of datafile 00004: /oracle/app/oradata/victor/users01.dbf
destination for restore of datafile 00005:

/oracle/app/oradata/victor/example01.dbf
destination for restore of datafile 00006: /oradata/coe/coe01.dbf
destination for restore of datafile 00007: /oradata/coe/coe02.dbf
destination for restore of datafile 00008: /oradata/coe/coe03.dbf
channel ORA_DISK_1: reading from backup piece

/u01/app/flash_recovery_area/VICTOR/backupset/2009_11_27/o1_mf_nnnd1_TAG20091127T0

93807_5jycczg6_.bkp
channel ORA_DISK_1: restored backup piece 1
piece

handle=/u01/app/flash_recovery_area/VICTOR/backupset/2009_11_27/o1_mf_nnnd1_TAG200

91127T093807_5jycczg6_.bkp tag=TAG20091127T093807
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

starting media recovery

archive log thread 1 sequence 5 is already on disk as file

/u01/app/flash_recovery_area/VICTOR/archivelog/2009_11_27/o1_mf_1_5_5jyck26d_.arc
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=4
channel ORA_DISK_1: reading from backup piece

/u01/app/flash_recovery_area/VICTOR/backupset/2009_11_27/o1_mf_annnn_TAG20091127T0

93842_5jycf3on_.bkp
channel ORA_DISK_1: restored backup piece 1
piece

handle=/u01/app/flash_recovery_area/VICTOR/backupset/2009_11_27/o1_mf_annnn_TAG200

91127T093842_5jycf3on_.bkp tag=TAG20091127T093842
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archive log

filename=/u01/app/flash_recovery_area/VICTOR/archivelog/2009_11_27/o1_mf_1_4_5jyd0

wg0_.arc thread=1 sequence=4
channel default: deleting archive log(s)
archive log

filename=/u01/app/flash_recovery_area/VICTOR/archivelog/2009_11_27/o1_mf_1_4_5jyd0

wg0_.arc recid=76 stamp=704022556
archive log

filename=/u01/app/flash_recovery_area/VICTOR/archivelog/2009_11_27/o1_mf_1_5_5jyck

26d_.arc thread=1 sequence=5
media recovery complete, elapsed time: 00:00:02
Finished recover at 2009-11-27 09:49:19


RMAN> alter database open resetlogs;

论坛徽章:
0
20 [报告]
发表于 2011-08-12 10:08 |只看该作者
这句有点问题,应该恢复前面的时间点或者SCN,不写时间或者SCN,RMAN并不知道你想要恢复到什么位置,我觉得 ...
tacsoft 发表于 2011-08-11 21:06



首先非常感谢tacsoft一直支持我,指导我
    这个例子是针对数据库全库的和表空间还是有区别的,再一个如果在另一台机器上恢复的话,另一台机器上没有备份的日志记录比如控制文件之类的,
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP