Active DATAGUARD 备库…
来源:互联网 发布:华泰证券总部待遇 知乎 编辑:程序博客网 时间:2024/06/05 05:29
自:http://ylw6006.blog.51cto.com/470441/1040501
在部署完active dataguard后,不但可以将只读的查询交给备库执行,还可以把日常的数据库备份工作放在备库上执行,从而减轻主库的压力,充分的发挥服务器资源,下面演示下利用备库备份来还原主库数据的过程!
一:主库上创建表空间,并在表空间上建表,插入测试数据,同时检查备库的同步情况
- SQL> createtablespace test01 datafile '/u01/app/oracle/oradata/db1/test01.dbf'size 10M;
Tablespace created. - SQL>
create table rman tablespace test01 as select object_id,object_name from dba_objects; - Table
created. -
- SQL>
select count(*) from rman; -
-
COUNT(*) - ----------
-
76379 -
- [oracle@db2
db1]$ sqlplus /nolog - SQL*Plus:
Release 11.2.0.3.0 Production on Mon Oct 29 11:37:38 2012 - Copyright
(c) 1982, 2011, Oracle. All rights reserved. -
- SQL>
conn /as sysdba - Connected.
- SQL>
select count(*) from rman; -
-
COUNT(*) - ----------
-
76379
二:在备库上使用rman对新建的表空间test01进行备份
- [oracle@db2
db1]$ rman target / - Recovery
Manager: Release 11.2.0.3.0 - Production on Mon Oct 29 11:38:01 2012 - Copyright
(c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. - connected
to DBID=1387827106)target database: DB1 ( -
- RMAN>
report schema; -
- RMAN>
backup tablespace test01 format '/home/oracle/test01_%U'; -
- Starting
backup at 2012-10-29-11:38:50 - allocated
channel: ORA_DISK_1 - channel
ORA_DISK_1: SID=1device type=DISK - channel
ORA_DISK_1: starting full datafile backup set - channel
ORA_DISK_1: specifying datafile(s) in backup set - input
datafile number=00034file name=/u01/app/oracle/oradata/db1/test01.dbf - channel
ORA_DISK_1: starting piece 1 at 2012-10-29-11:38:51 - channel
ORA_DISK_1: finished piece 1 at 2012-10-29-11:38:52 - piece
handle=/home/oracle/test01_03novc2b_1_1 tag=TAG20121029T113851 comment=NONE - channel
ORA_DISK_1: backup set complete, elapsed time: 00:00:01 - Finished
backup at 2012-10-29-11:38:52
三:关闭主库后删除表空间数据文件,模拟数据丢失场景
- [oracle@db1
~]$ sqlplus /nolog - SQL*Plus:
Release 11.2.0.3.0 Production on Mon Oct 29 11:39:49 2012 - Copyright
(c) 1982, 2011, Oracle. All rights reserved. -
- SQL>
conn /as sysdba - Connected.
- SQL>
shutdown immediate - Database
closed. - Database
dismounted. - ORACLE
instance shut down. - SQL>
exit -
- [oracle@db1
~]$ rm -rf /u01/app/oracle/oradata/db1/test01.dbf
四:重新启动主库,只能启动到mount状态
- [oracle@db1
~]$ sqlplus /nolog - SQL*Plus:
Release 11.2.0.3.0 Production on Mon Oct 29 11:41:42 2012 - Copyright
(c) 1982, 2011, Oracle. All rights reserved. - SQL>
conn /as sysdba - Connected
to an idle instance. - SQL>
startup - ORACLE
instance started. -
- Total
System Global Area 1536602112 bytes - Fixed
Size 2228624 bytes - Variable
Size 1174408816 bytes - Database
Buffers 352321536 bytes - Redo
Buffers 7643136 bytes - Database
mounted. - ORA-01157:
cannot identify/lock data file 34 - see DBWR trace file - ORA-01110:
data file 34: '/u01/app/oracle/oradata/db1/test01.dbf' -
- SQL>
select open_mode,database_role from v$database; -
- OPEN_MODE
DATABASE_ROLE - --------------------
---------------- - MOUNTED
PRIMARY
五:将备库的备份数据复制到主库,并使用catalog命令注册到主库的控制文件中
- [oracle@db2
~]$ scp test01_03novc2b_1_1 db1:/home/oracle/ - [oracle@db1
~]$ rman target / - Recovery
Manager: Release 11.2.0.3.0 - Production on Mon Oct 29 11:45:02 2012 - Copyright
(c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. - connected
to DBID=1387827106,target database: DB1 ( not open) -
- RMAN>
list backup of tablespace test01; - specification
does not match any backup in the repository -
- RMAN>
catalog backuppiece '/home/oracle/test01_03novc2b_1_1'; -
- cataloged
backup piece - backup
piece handle=/home/oracle/test01_03novc2b_1_1RECID=42 STAMP=797946436 -
- RMAN>
list backup of tablespace test01; -
- List
of SetsBackup - ===================
-
- BS
Key Type LV Size Device Type Elapsed Time Completion Time - -------
---- -- ---------- ----------- ------------ ------------------- - 42
Full 3.98M DISK 00:00:00 2012-10-29-11:38:51 -
BP Key: 42 Status: AVAILABLE Compressed: NO Tag: TAG20121029T113851 -
Piece Name: /home/oracle/test01_03novc2b_1_1 -
List of Datafiles in backup set 42 -
File LV Type Ckp SCN Ckp Time Name -
---- -- ---- ---------- ------------------- ---- -
34 Full 10350465 2012-10-29-11:35:32 /u01/app/oracle/oradata/db1/test01.dbf
六:还原和恢复表空间test01,并将主库启动到读写状态,测试主备库数据实时同步情况
- RMAN>
restore tablespace test01; - Starting
restore at 2012-10-29-11:47:50 - allocated
channel: ORA_DISK_1 - channel
ORA_DISK_1: SID=21device type=DISK -
- 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 00034 to /u01/app/oracle/oradata/db1/test01.dbf - channel
ORA_DISK_1: reading from backup piece /home/oracle/test01_03novc2b_1_1 - channel
ORA_DISK_1: handle=/home/oracle/test01_03novc2b_1_1piece tag=TAG20121029T113851 - channel
ORA_DISK_1: restored backup piece 1 - channel
ORA_DISK_1: restore complete, elapsed time: 00:00:01 - Finished
restore at 2012-10-29-11:47:52 -
- RMAN>
recover tablespace test01; - Starting
recover at 2012-10-29-11:48:02 - using
channel ORA_DISK_1 -
- starting
media recovery - media
recovery complete, elapsed time: 00:00:01 -
- Finished
recover at 2012-10-29-11:48:03 -
- RMAN>
alter database open; - database
opened -
- [oracle@db1
~]$ sqlplus /nolog - SQL*Plus:
Release 11.2.0.3.0 Production on Mon Oct 29 11:48:47 2012 - Copyright
(c) 1982, 2011, Oracle. All rights reserved. -
- SQL>
conn /as sysdba - Connected.
- SQL>
truncate table rman; - Table
truncated. -
- [oracle@db2
~]$ sqlplus /nolog - SQL*Plus:
Release 11.2.0.3.0 Production on Mon Oct 29 11:49:12 2012 - Copyright
(c) 1982, 2011, Oracle. All rights reserved. -
- SQL>
conn /as sysdba - Connected.
- SQL>
select count(*) from rman; -
-
COUNT(*) - ----------
-
0
0 0
- Active DATAGUARD 备库…
- Active Report IIS配置及web.confi…
- redo log 的active和ina…
- oracle11g dataguard 安装手册
- 集线器 交换机 路由器 网桥 …
- 使用BBED修改SCN …
- PHP访问Windows的Active Directory…
- Hive安装 …
- android o…
- android …
- [转] 彼尔…
- “constructors not allowed …
- 关于alter system switch lo…
- MPMoviePlayerController …
- HDU 1075 What Are You Talking …
- HDOJ 1017 A Mathematical Cur…
- HDOJ 1039 Easier Done Than Sa…
- HDOJ 4245 A Famous Music Comp…
- 解决span自动换行以及样式margin的问题
- 为什么虚拟机系统无法正常启动窗口
- rman catalog 注销目标…
- 10进制和16进制的简单互换
- 单点登录(01) ------单点登录SSO的介绍和CAS+选型
- Active DATAGUARD 备库…
- SQLSERVER 2008 R2还原…
- 基于Activiti的流程应用开发平台JSAAS-WF V5.3
- 557. Reverse Words in a String III
- JAVA的四种引用
- LMODE=3什么意思
- Fixing Corrupt System&…
- -sh: ORACLE_BASE=/u01/dev:&…
- webstorm(10.0.2)设置测试服务器 -- 局域网内其他设备访问