- 浏览: 1334036 次
- 性别:
- 来自: 成都
文章分类
- 全部博客 (471)
- 原创文章 (4)
- Database (84)
- J2SE (63)
- Web (26)
- Javascript (30)
- Lucene (11)
- os (13)
- 算法 (8)
- Webservice (1)
- Open projects (18)
- Hibernate (18)
- Spring (15)
- Css (2)
- J2ee (2)
- 综合技术 (18)
- 安全管理 (13)
- PatternsInJava (27)
- NIO (5)
- Ibatis (2)
- 书籍收藏 (1)
- quartz (7)
- 并发编程 (15)
- oracle问题 (2)
- ios (60)
- coco2d-iphone (3)
- C++ (6)
- Zookeeper (2)
- golang (4)
- animation (2)
- android (1)
最新评论
-
dandingge123:
【引用】限制UITextField输入长度的方法 -
qja:
...
对List顺序,逆序,随机排列实例代码 -
安静听歌:
现在在搞这个,,,,,哎~头都大了,,,又freemarker ...
通用大型网站页面静态化解决方案(一) -
springdata-jpa:
java quartz定时任务demo教程源代码下载,地址:h ...
Quartz 配置参考 -
马清天:
[b][/b][list][*]引用[u][/u][/list ...
通用大型网站页面静态化解决方案(一)
RMAN备份方案
RMAN也可以进行联机备份,而且备份与恢复方法将比OS备份更简单可靠。
1、连接数据库,创建测试表并插入记录
SQL*Plus: Release 8.1.6.0.0 - Production on Tue May 6 13:46:32 2003
(c) Copyright 1999 Oracle Corporation. All rights reserved.
SQL> connect internal/password as sysdba;
Connected.
SQL> create table test(a int) tablespace users;
Table created
SQL> insert into test values(1);
1 row inserted
SQL> commit;
Commit complete
2、备份数据库表空间users
C:\> rman
Recovery Manager: Release 8.1.6.0.0 - Production
RMAN> connect rcvcat rman/rman@back
RMAN-06008: connected to recovery catalog database
RMAN> connect target internal/virpure
RMAN-06005: connected to target database: TEST (DBID=1788174720)
RMAN> run{
2> allocate channel c1 type disk;
3> backup tag 'tsuser ' format 'd:\backup\tsuser_%u_%s_%p '
4> tablespace users;
5> release channel c1;
6> }
RMAN-03022: compiling command: allocate
RMAN-03023: executing command: allocate
RMAN-08030: allocated channel: c1
RMAN-08500: channel c1: sid=16 devtype=DISK
RMAN-03022: compiling command: backup
RMAN-03025: performing implicit partial resync of recovery catalog
RMAN-03023: executing command: partial resync
RMAN-08003: starting partial resync of recovery catalog
RMAN-08005: partial resync complete
RMAN-03023: executing command: backup
RMAN-08008: channel c1: starting full datafile backupset
RMAN-08502: set_count=5 set_stamp=494177612 creation_time=16-MAY-03
RMAN-08010: channel c1: specifying datafile(s) in backupset
RMAN-08522: input datafile fno=00003 name=D:\ORACLE\ORADATA\TEST\USER01.DBF
RMAN-08013: channel c1: piece 1 created
RMAN-08503: piece handle=D:\BACKUP\TSUSER_05EN93AC_5_1 comment=NONE
RMAN-08525: backup set complete, elapsed time: 00:00:01
RMAN-03023: executing command: partial resync
RMAN-08003: starting partial resync of recovery catalog
RMAN-08005: partial resync complete
RMAN-03022: compiling command: release
RMAN-03023: executing command: release
RMAN-08031: released channel: c1
RMAN>
3、继续在测试表中插入记录
SQL> insert into test values(2);
1 row inserted
SQL> commit;
Commit complete
SQL> select * from test;
A
---------------------------------------
1
2
SQL> alter system switch logfile;
System altered.
SQL> r
1* alter system switch logfile;
System altered.
4、关闭数据库,模拟丢失数据文件
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down
C:\> del D:\ORACLE\ORADATA\TEST\USER01.DBF
5、启动数据库,检查错误
SQL> startup
ORACLE instance started.
Total System Global Area 102020364 bytes
Fixed Size 70924 bytes
Variable Size 85487616 bytes
Database Buffers 16384000 bytes
Redo Buffers 77824 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 3 - see DBWR trace file
ORA-01110: data file 3: 'D:\ORACLE\ORADATA\TEST\USER01.DBF '
6、先打开数据库
SQL> alter database datafile 3 offline drop;
Database altered.
SQL> alter database open;
Database altered.
7、恢复该表空间
恢复脚本可以是恢复单个数据文件
run{
allocate channel c1 type disk;
restore datafile 3;
recover datafile 3;
sql 'alter database datafile 3 online ';
release channel c1;
}
也可以是,恢复表空间
run{
allocate channel c1 type disk;
restore tablespace users;
recover tablespace users;
sql 'alter database datafile 3 online ';
release channel c1;
}
过程如下:
C:\> rman
Recovery Manager: Release 8.1.6.0.0 - Production
RMAN> connect rcvcat rman/rman@back
RMAN-06008: connected to recovery catalog database
RMAN> connect target internal/virpure
RMAN-06005: connected to target database: TEST (DBID=1788174720)
RMAN> run{
2> allocate channel c1 type disk;
3> restore datafile 3;
4> recover datafile 3;
5> sql 'alter database datafile 3 online ';
6> release channel c1;
7> }
RMAN-03022: compiling command: allocate
RMAN-03023: executing command: allocate
RMAN-08030: allocated channel: c1
RMAN-08500: channel c1: sid=13 devtype=DISK
RMAN-03022: compiling command: restore
RMAN-03022: compiling command: IRESTORE
RMAN-03023: executing command: IRESTORE
RMAN-08016: channel c1: starting datafile backupset restore
RMAN-08502: set_count=5 set_stamp=494177612 creation_time=16-MAY-03
RMAN-08089: channel c1: specifying datafile(s) to restore from backup set
RMAN-08523: restoring datafile 00003 to D:\ORACLE\ORADATA\TEST\USER01.DBF
RMAN-08023: channel c1: restored backup piece 1
RMAN-08511: piece handle=D:\BACKUP\TSUSER_05EN93AC_5_1 tag=TSUSER params=NULL
RMAN-08024: channel c1: restore complete
RMAN-03023: executing command: partial resync
RMAN-08003: starting partial resync of recovery catalog
RMAN-08005: partial resync complete
RMAN-03022: compiling command: recover
RMAN-03022: compiling command: recover(1)
RMAN-03022: compiling command: recover(2)
RMAN-03022: compiling command: recover(3)
RMAN-03023: executing command: recover(3)
RMAN-08054: starting media recovery
RMAN-03022: compiling command: recover(4)
RMAN-06050: archivelog thread 1 sequence 332 is already on disk as file D:\ORACLE\ORADATA\TEST\ARCHIVE\TESTT001S00332.ARC
RMAN-06050: archivelog thread 1 sequence 333 is already on disk as file D:\ORACLE\ORADATA\TEST\ARCHIVE\TESTT001S00333.ARC
RMAN-06050: archivelog thread 1 sequence 334 is already on disk as file D:\ORACLE\ORADATA\TEST\ARCHIVE\TESTT001S00334.ARC
RMAN-03023: executing command: recover(4)
RMAN-08515: archivelog filename=D:\ORACLE\ORADATA\TEST\ARCHIVE\TESTT001S00332.ARC thread=1 sequence=332
RMAN-08055: media recovery complete
RMAN-03022: compiling command: sql
RMAN-06162: sql statement: alter database datafile 3 online
RMAN-03023: executing command: sql
RMAN-03022: compiling command: release
RMAN-03023: executing command: release
RMAN-08031: released channel: c1
RMAN>
8、检查数据是否完整
SQL> alter database open;
Database altered.
SQL> select * from test;
A
---------------------------------------
1
2
说明:
1、RMAN也可以实现单个表空间或数据文件的恢复,恢复过程可以在mount下或open方式下,如果在open方式下恢复,可以减少down机时间
2、如果损坏的是一个数据文件,建议offline并在open方式下恢复
3、这里可以看到,RMAN进行数据文件与表空间恢复的时候,代码都比较简单,而且能保证备份与恢复的可靠性,所以建议采用RMAN的备份与恢复
RMAN也可以进行联机备份,而且备份与恢复方法将比OS备份更简单可靠。
1、连接数据库,创建测试表并插入记录
SQL*Plus: Release 8.1.6.0.0 - Production on Tue May 6 13:46:32 2003
(c) Copyright 1999 Oracle Corporation. All rights reserved.
SQL> connect internal/password as sysdba;
Connected.
SQL> create table test(a int) tablespace users;
Table created
SQL> insert into test values(1);
1 row inserted
SQL> commit;
Commit complete
2、备份数据库表空间users
C:\> rman
Recovery Manager: Release 8.1.6.0.0 - Production
RMAN> connect rcvcat rman/rman@back
RMAN-06008: connected to recovery catalog database
RMAN> connect target internal/virpure
RMAN-06005: connected to target database: TEST (DBID=1788174720)
RMAN> run{
2> allocate channel c1 type disk;
3> backup tag 'tsuser ' format 'd:\backup\tsuser_%u_%s_%p '
4> tablespace users;
5> release channel c1;
6> }
RMAN-03022: compiling command: allocate
RMAN-03023: executing command: allocate
RMAN-08030: allocated channel: c1
RMAN-08500: channel c1: sid=16 devtype=DISK
RMAN-03022: compiling command: backup
RMAN-03025: performing implicit partial resync of recovery catalog
RMAN-03023: executing command: partial resync
RMAN-08003: starting partial resync of recovery catalog
RMAN-08005: partial resync complete
RMAN-03023: executing command: backup
RMAN-08008: channel c1: starting full datafile backupset
RMAN-08502: set_count=5 set_stamp=494177612 creation_time=16-MAY-03
RMAN-08010: channel c1: specifying datafile(s) in backupset
RMAN-08522: input datafile fno=00003 name=D:\ORACLE\ORADATA\TEST\USER01.DBF
RMAN-08013: channel c1: piece 1 created
RMAN-08503: piece handle=D:\BACKUP\TSUSER_05EN93AC_5_1 comment=NONE
RMAN-08525: backup set complete, elapsed time: 00:00:01
RMAN-03023: executing command: partial resync
RMAN-08003: starting partial resync of recovery catalog
RMAN-08005: partial resync complete
RMAN-03022: compiling command: release
RMAN-03023: executing command: release
RMAN-08031: released channel: c1
RMAN>
3、继续在测试表中插入记录
SQL> insert into test values(2);
1 row inserted
SQL> commit;
Commit complete
SQL> select * from test;
A
---------------------------------------
1
2
SQL> alter system switch logfile;
System altered.
SQL> r
1* alter system switch logfile;
System altered.
4、关闭数据库,模拟丢失数据文件
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down
C:\> del D:\ORACLE\ORADATA\TEST\USER01.DBF
5、启动数据库,检查错误
SQL> startup
ORACLE instance started.
Total System Global Area 102020364 bytes
Fixed Size 70924 bytes
Variable Size 85487616 bytes
Database Buffers 16384000 bytes
Redo Buffers 77824 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 3 - see DBWR trace file
ORA-01110: data file 3: 'D:\ORACLE\ORADATA\TEST\USER01.DBF '
6、先打开数据库
SQL> alter database datafile 3 offline drop;
Database altered.
SQL> alter database open;
Database altered.
7、恢复该表空间
恢复脚本可以是恢复单个数据文件
run{
allocate channel c1 type disk;
restore datafile 3;
recover datafile 3;
sql 'alter database datafile 3 online ';
release channel c1;
}
也可以是,恢复表空间
run{
allocate channel c1 type disk;
restore tablespace users;
recover tablespace users;
sql 'alter database datafile 3 online ';
release channel c1;
}
过程如下:
C:\> rman
Recovery Manager: Release 8.1.6.0.0 - Production
RMAN> connect rcvcat rman/rman@back
RMAN-06008: connected to recovery catalog database
RMAN> connect target internal/virpure
RMAN-06005: connected to target database: TEST (DBID=1788174720)
RMAN> run{
2> allocate channel c1 type disk;
3> restore datafile 3;
4> recover datafile 3;
5> sql 'alter database datafile 3 online ';
6> release channel c1;
7> }
RMAN-03022: compiling command: allocate
RMAN-03023: executing command: allocate
RMAN-08030: allocated channel: c1
RMAN-08500: channel c1: sid=13 devtype=DISK
RMAN-03022: compiling command: restore
RMAN-03022: compiling command: IRESTORE
RMAN-03023: executing command: IRESTORE
RMAN-08016: channel c1: starting datafile backupset restore
RMAN-08502: set_count=5 set_stamp=494177612 creation_time=16-MAY-03
RMAN-08089: channel c1: specifying datafile(s) to restore from backup set
RMAN-08523: restoring datafile 00003 to D:\ORACLE\ORADATA\TEST\USER01.DBF
RMAN-08023: channel c1: restored backup piece 1
RMAN-08511: piece handle=D:\BACKUP\TSUSER_05EN93AC_5_1 tag=TSUSER params=NULL
RMAN-08024: channel c1: restore complete
RMAN-03023: executing command: partial resync
RMAN-08003: starting partial resync of recovery catalog
RMAN-08005: partial resync complete
RMAN-03022: compiling command: recover
RMAN-03022: compiling command: recover(1)
RMAN-03022: compiling command: recover(2)
RMAN-03022: compiling command: recover(3)
RMAN-03023: executing command: recover(3)
RMAN-08054: starting media recovery
RMAN-03022: compiling command: recover(4)
RMAN-06050: archivelog thread 1 sequence 332 is already on disk as file D:\ORACLE\ORADATA\TEST\ARCHIVE\TESTT001S00332.ARC
RMAN-06050: archivelog thread 1 sequence 333 is already on disk as file D:\ORACLE\ORADATA\TEST\ARCHIVE\TESTT001S00333.ARC
RMAN-06050: archivelog thread 1 sequence 334 is already on disk as file D:\ORACLE\ORADATA\TEST\ARCHIVE\TESTT001S00334.ARC
RMAN-03023: executing command: recover(4)
RMAN-08515: archivelog filename=D:\ORACLE\ORADATA\TEST\ARCHIVE\TESTT001S00332.ARC thread=1 sequence=332
RMAN-08055: media recovery complete
RMAN-03022: compiling command: sql
RMAN-06162: sql statement: alter database datafile 3 online
RMAN-03023: executing command: sql
RMAN-03022: compiling command: release
RMAN-03023: executing command: release
RMAN-08031: released channel: c1
RMAN>
8、检查数据是否完整
SQL> alter database open;
Database altered.
SQL> select * from test;
A
---------------------------------------
1
2
说明:
1、RMAN也可以实现单个表空间或数据文件的恢复,恢复过程可以在mount下或open方式下,如果在open方式下恢复,可以减少down机时间
2、如果损坏的是一个数据文件,建议offline并在open方式下恢复
3、这里可以看到,RMAN进行数据文件与表空间恢复的时候,代码都比较简单,而且能保证备份与恢复的可靠性,所以建议采用RMAN的备份与恢复
发表评论
-
mysql主从热备配置(含innodb)终极版
2012-12-25 13:10 2654转自 http://blogread.cn/it/articl ... -
sqlite3中的数据类型
2012-12-10 21:37 1339(转)http://www.cnblogs.com/kfqco ... -
Mac下MySql卸载方法
2012-09-10 23:57 1057Mac下MySql卸载方法 mac下mysql的D ... -
mac os x mysql数据库utf8配置
2012-09-10 23:29 2284进入mysql console: 输入 mysql& ... -
ON DUPLICATE KEY UPDATE
2012-08-07 01:47 1095(转自)http://blog.csdn.net/kesaih ... -
MySQL单列索引和组合索引的区别介绍
2012-08-07 01:31 1108(转自)http://blog.cs ... -
centos下MySQL主从同步配置
2012-08-03 13:14 1561(转自)http://apps.hi.baidu.com ... -
sql语句中left join、inner join中的on与where的区别
2012-06-13 13:24 1265table a(id, type): id t ... -
分组取前N记录
2012-05-31 16:24 1130(转)http://blog.csdn.net/ac ... -
如何一条sql语句取出分组数据中值最大的
2012-05-30 23:59 2370--按某一字段分组取最大(小)值所在行的数据(2007-10- ... -
存储过程与函数的区别
2011-09-28 19:35 1161... -
oracle
2011-04-06 17:46 1052学习笔记 -
PLSQL Developer + Oracle客户端简易安装方法
2011-03-17 00:10 14384Oracle 10g绿色客户端 pl ... -
SELECT INTO FROM与INSERT INTO SELECT
2011-01-26 15:52 34121.INSERT INTO SELECT语句 ... -
浅谈unique列上插入重复值的MySQL解决方案
2011-01-25 11:33 1783本文的unique列上插入重复值解决方案,主要基于MySQL平 ... -
:Oracle 中对Merge语句的增强 和去重复新增
2011-01-25 11:11 2325在Oracle 10g之前,merge语句支持匹配更新和不匹配 ... -
单行函数(仅对单个表达式或一行进行处理)
2011-01-23 18:49 1275例如:select sum(qty) from sales ... -
oracle中的事务控制命令
2011-01-23 18:45 2113事务提交有显示提交:使用commit命令来提交所有未提交的更新 ... -
oracle全文检索
2011-01-23 18:18 61591.全文检索和普通检索的区别 不使用Oracle text功 ... -
Oracle快照原理及实现总结
2011-01-23 16:41 2474Oracle数据库的快照是一个表,它包含有对一个本地或远程数据 ...
相关推荐
### Oracle数据库Rman备份方案详解 #### 一、概述 Oracle RMAN(Recovery Manager)是一种功能强大的工具,用于管理Oracle数据库的备份、恢复及灾难恢复。本文将详细介绍如何使用RMAN来制定Oracle数据库的备份策略...
Oracle 数据库 RMAN 备份方案 Oracle 数据库 RMAN 备份方案是一个生产环境验证实施的备份解决方案,旨在保护 Oracle 数据库的数据安全和可用性。本方案通过使用 Oracle 的 RMAN 工具,提供了一个完整的备份和恢复...
RMAN备份技术解决方案 RMAN(Recovery Manager)是一种强大的数据库备份工具,由 Oracle 公司提供,用于保护和恢复 Oracle 数据库。该解决方案旨在提供一个完整的 RMAN 备份方案,涵盖了 Linux/AIX 和 Windows 等...
RMAN并不支持客户端连接服务器进行备份,所以仍然需要在服务器使用RMAN备份。由于服务器空间不足,需备份至异地。 知识点三:使用RMAN实现异地备份 可以通过映射远程共享目录实现备份。具体步骤包括: 1. 在PC2上...
RMAN备份命令详解 RMAN(Recovery Manager)是Oracle数据库备份和恢复的工具,提供了多种备份方式和恢复选项。下面是RMAN备份命令的详细解释: 一、切换服务器归档模式 在开始备份之前,需要切换服务器到归档模式...
这是自己亲手研究完oracle 的rman备份后写的备份和恢复方案
### Oracle 11g RMAN备份与恢复初步方案解析 #### 一、RMAN备份与恢复概述 **RMAN(Recovery Manager)**是Oracle提供的一种强大工具,主要用于数据库的备份、还原及恢复操作。RMAN支持从Oracle 8及更高版本的...
"Linux环境下RMAN备份实例脚本" 本文档介绍了在Linux环境下使用RMAN进行数据库备份的实例脚本。RMAN(Recovery Manager)是Oracle数据库中的一个备份和恢复工具,用于管理和维护数据库的备份和恢复。 背景 _target...
本文将深入探讨“rman备份脚本(已测试)”这一主题,包括RMAN的基本概念、备份脚本的构成、以及如何在生产环境中应用。 RMAN是Oracle数据库自带的一个命令行工具,它提供了全面的数据保护方案,支持多种备份类型,如...
### Oracle数据库RMAN备份与恢复技术详解 #### 引言 在信息技术领域,数据安全与完整性至关重要。Oracle数据库,作为全球领先的数据库管理系统之一,提供了多种数据保护机制,其中RMAN(Recovery Manager,恢复...
"rman备份策略及脚本"是数据库管理员必须掌握的关键技能,它涉及到如何有效地保护数据,确保在出现故障时能快速恢复。下面将详细讲解RMAN备份策略以及相关的脚本编写。 首先,RMAN备份策略通常包括以下几种类型: ...
该方法可以提供一种可靠的备份解决方案,保护数据库免受数据丢失的风险。 Oracle 数据库在线备份原理是基于 Oracle 数据库的基本概念和机制,包括表、数据查询语句、DML 语句和 DDL 语句等。该原理可以提供一种可靠...
### RMAN备份与恢复知识点详解 #### 一、概述 RMAN(Recovery Manager)是Oracle数据库提供的一个强大且功能全面的数据备份与恢复工具。它主要用于实现对Oracle数据库的完整或部分备份,以及在出现故障时进行恢复。...
本书《Oracle Database 11g RMAN备份与恢复》不仅对前一版本的内容进行了修订,也增加了许多新内容,以帮助读者掌握最新的RMAN使用方法。 在学习RMAN之前,需要对Oracle数据库的基础备份与恢复有所了解。Oracle...
### Oracle RMAN 增量备份方案 #### 一、Oracle RMAN 概述与增量备份简介 Oracle Recovery Manager(RMAN)是Oracle数据库提供的一个强大的工具,它可以帮助管理员进行数据库备份、恢复以及灾难恢复等工作。RMAN...
本文将深入探讨Linux下RMAN备份的基本概念、常用命令以及实践中的注意事项。 RMAN是Oracle数据库自带的一个命令行工具,它能够执行各种备份策略,包括完整备份、增量备份和差异备份。RMAN的备份可以是文件系统上的...
以下是对"windows下oracle rman备份 计划任务"这一主题的详细解释。 首先,了解RMAN的基本概念是非常重要的。RMAN是一种命令行工具,可以直接与数据库实例交互,执行备份和恢复操作。它可以备份数据文件、控制文件...
### RMAN备份与恢复知识点详解 #### 一、RMAN简介 RMAN(Recovery Manager)是Oracle数据库中用于执行备份、恢复以及灾难恢复的重要工具。它提供了强大的自动化功能,可以进行在线或离线的数据备份,并支持增量备份...