oracle 利用flashback将备库激活为read wirte(10g 及上)

oracle 利用flashback将备库激活为read wirte(10g 及上)
环境:
OS: CENTOS 6.5 X64
DB: ORACLE 10.2.0.5
主库操作:
SQL> alter system switch logfile;

System altered.

SQL>

备库操作
取消归档应用
SQL> alter database recover managed standby database cancel;

Database altered.

SQL> 

创建还原点

SQL>  create restore point restore_point_dg guarantee flashback database;

Restore point created.

SQL> 

主库操作
将备库的归档目的设置为defer(这样后台不会报错,防止主库传输数据到备库)

官方解释
defer
Specifies that valid destination information and attributes are preserved, but the destination is excluded from archiving operations until re-enable
SQL> alter system set log_archive_dest_state_2=defer;

将备库激活为read/wirte
SQL> alter database activate standby database;

Database altered.

SQL> alter database open;

Database altered.

SQL> 

备库状态为read/write
SQL> select open_mode from v$database;

OPEN_MODE
----------
READ WRITE

SQL> 

这样我们可以在备库Export操作了
[[email protected] backup]$ expdp directory=backup dumpfile=test1`date +%F`.dmp logfile=test1`date +%F`.log schemas=test1

Export: Release 10.2.0.5.0 - 64bit Production on Monday, 15 September, 2014 22:37:17

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

Username: / as sysdba

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYS"."SYS_EXPORT_SCHEMA_01":  /******** AS SYSDBA directory=backup dumpfile=test12014-09-15.dmp logfile=test12014-09-15.log schemas=test1
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "TEST1"."TEST"                              4.960 KB       5 rows
Master table "SYS"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_SCHEMA_01 is:
  /u01/app/oracle/dump/test12014-09-15.dmp
Job "SYS"."SYS_EXPORT_SCHEMA_01" successfully completed at 22:37:31

[[email protected] backup]$ 

主库操作
主库上添加记录
SQL> insert into test values(10);

1 row created.

SQL> insert into test values(10);

1 row created.

SQL> insert into test values(10);

1 row created.

SQL> insert into test values(11);

1 row created.

SQL> insert into test values(11);

1 row created.

SQL> commit;

Commit complete.

System altered.

SQL> 

SQL> conn / as sysdba
Connected.
SQL> alter system switch logfile;

System altered.

SQL> 

备库操作
备库上删除表
[[email protected] backup]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Mon Sep 15 22:40:53 2014

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

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

SQL> conn test1/test1
Connected.
SQL> drop table test purge;

Table dropped.

SQL> 

准备重新恢复到dg备库环境
SQL> startup mount force;
ORACLE instance started.

Total System Global Area  704643072 bytes
Fixed Size		    2098912 bytes
Variable Size		  192940320 bytes
Database Buffers	  503316480 bytes
Redo Buffers		    6287360 bytes
Database mounted.
SQL> 

闪回数据库
SQL>  flashback database to restore point restore_point_dg;

Flashback complete.

SQL> 

SQL> shutdown immediate;
ORA-01507: database not mounted

ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.

Total System Global Area  704643072 bytes
Fixed Size		    2098912 bytes
Variable Size		  192940320 bytes
Database Buffers	  503316480 bytes
Redo Buffers		    6287360 bytes
SQL> alter database mount standby database; #或者alter database convert to physical standby;

Database altered.

主库操作
SQL> alter system set log_archive_dest_state_2=enable scope=both;

System altered.

SQL> 

备库操作,检查进程是否正常

SQL> select process,status from v$managed_standby;

PROCESS   STATUS
--------- ------------
ARCH	  CONNECTED
ARCH	  CONNECTED
ARCH	  CONNECTED
MRP0	  WAIT_FOR_LOG
RFS	  IDLE
RFS	  IDLE

6 rows selected.

SQL> 

主库操作
切换日志
SQL> alter system switch logfile;

System altered.

SQL> 

备库已正常
FS[1]: Successfully opened standby log 8: ‘/u01/app/oracle/oradata/netdata/st_redo08a.log‘
Mon Sep 15 22:50:22 CST 2014
Media Recovery Log /u01/app/oracle/archive/netdata/1_79_857898543.arc
Media Recovery Waiting for thread 1 sequence 80
时间: 2024-10-21 20:46:55

oracle 利用flashback将备库激活为read wirte(10g 及上)的相关文章

ORACLE Physical Standby 级联备库搭建

搭建oracle 级联DG 现在db与dg1是一套DG ,在此基础上搭建级联备库: 数据库版本 11.2.0.4 db_name=prod db为主库,dg1为备库,dg2为级联备库:DB_UNIQUE_NAME DATABASE_ROLEdb primary 10.100.12.10 dg1 standby1 10.100.12.11 dg2 standby2 10.100.12.12 三个库的LOG_FILE_NAME_CONVERT,DB_FILE_NAME_CONVERT路径一致####

【原创】oracle ORA-01157 ORA-01110 DataGuard 备库 临时表空间报错

简要: 当查询数据库数据时,提示临时表空间异常,报错ORA-01157 ORA-01110,经过对数据文件处理后,已经解决此故障. 环境:Oracle 11g RAC For Linux 6,该库为DataGuard备库 1. 查询数据时报错,如下: ERROR:ORA-01157: cannot identify/lock data file 226 - see DBWR trace fileORA-01110: data file 226: '+DG_DATA02/racdb/blsp_te

备库简介

备库类型:1.物理备库:2.逻辑备库:3.快照备库. 可以同时配置1个或多个类型的备库 1.物理备库 是主库的块对块的拷贝,应用重做日志,通过从主库接受重做数据应用到物理备库上的机制 可以以read only模式打开,11g之后可以配置active DG以只读模式打开应用重做数据 物理备库的好处: 1. 灾难恢复和高可用 2. 数据保护 支持多有的DDL和DML操作 3. 减小主库负载 以只读模式打开,用于报表和查询 4. 性能 底层拷贝,绕过SQL级别代码层 2. 逻辑备库 通过SQL应用更新

搭建逻辑备库

1. 搭建物理备库 2. 在物理备库上停止重做应用,如果备库是RAC,则必须停止所有执行以下语句以外的实例 SQL> alter database recover managed standby database cancel; Database altered. 3. 为角色转换准备主库 这一步仅在执行切换时有用 修改初始化参数: alter system set LOG_ARCHIVE_DEST_1='LOCATION=/oradata/arch/ VALID_FOR=(ONLINE_LOG

oracle11g dataguard 备库数据同步的检查方法

概述: 一.环境 主库: ip地址:192.168.122.203 oracle根目录:/data/db/oracle SID:qyq 数据文件路径/data/db/oracle/oradata/qyq 归档文件路径:/data/db/oracle/archive' 备库: ip地址:192.168.122.204 oracle根目录:/data/app/oracle SID:qyq 数据文件路径/data/app/oracle/oradata/qyq 归档文件路径:/data/app/orac

DG unresolvable gap gap sequence备库恢复

案例 环境:2节点RAC asm + 单实例DG备库 ,备库用的是文件系统来存放数据文件,未用ASM:RAC一节点上部署有ogg. 在主库上通过在线重定义对表做分区,创建分区表空间时备库上创建数据文件失败, 导致日志传到备库无法应用,备库停止日志应用. rman备份清理归档的脚本无法及时清理归档导到主库.备库归档磁盘空间均出现满的现象,ogg进程不工作,进程正常,只是time since chkpt 持续升高. 清理了归档后,备库可以接收日志但不应用.查看DG switchover_status

利用ORACLE 11g 新特性创建物理备库

准备工作: 主库启用归档 在所有系统上安装oralce 11g软件 备库创建必要的目录 创建监听,配置tnsname文件 第一步: 将主库的密码文件cp一份到备库中 第二步: 主备库的参数文件修改: 主库参数文件如: matrix.__db_cache_size=83886080 matrix.__java_pool_size=4194304 matrix.__large_pool_size=4194304 matrix.__oracle_base='/u2/oracle'#ORACLE_BAS

Oracle 11g Data Guard 之物理备库角色转换

一.物理备库的Switchover操作 本节主要内容是物理备库的switchover操作,该操作起始于主库,结束于目标备库. 1.确认主库可以切换为standby角色 SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE; 如果结果显示TO STANDBY或者SESSIONS ACTIVE,则表明主库可以切换为standby角色,否则,切换操作将不可行,因为redo传输不是配置错误就是不能正常进行. 2.主库启动switchover 执行如下SQL语句将主库

OGG 从Oracle备库同步数据至kafka

OGG 从Oracle备库同步数据至kafka Table of Contents 1. 目的 2. 环境及规划 3. 安装配置JDK 3.1. 安装jdk 3.2. 配置环境变量 4. 安装Dataguard 4.1. 安装备库软件 4.2. 配置dataguard 4.2.1. 主库 4.2.2. 备库 4.3. 完成操作 4.4. 启动实时复制 5. zookeeper集群 5.1. 上传并解压 5.2. 配置 5.3. 创建myid文件 5.4. 配置环境变量 5.5. 启动和查看服务