[20180423]flashback tablespace与snapshot standby.txt

--//缺省建立表空间是打开flashback on,如果某个表空间flashback off,在dg启动snapshot standby时注意,可能"回不来",
--//通过测试说明问题.

1.环境:
SCOTT@book> @ ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

2.设置备库tea表空间关闭flashback.

SCOTT@book> alter tablespace tea flashback off;
Tablespace altered.

SCOTT@book> select * from v$tablespace;
         TS# NAME      INC BIG FLA ENC
------------ --------- --- --- --- ---
           0 SYSTEM    YES NO  YES
           1 SYSAUX    YES NO  YES
           2 UNDOTBS1  YES NO  YES
           4 USERS     YES NO  YES
           3 TEMP      NO  NO  YES
           6 EXAMPLE   YES NO  YES
           7 TEA       YES NO  NO
7 rows selected.

--//tea表空间FLASHBACK_ON设置为NO.注意这些信息应该记录在控制文件,你可以发现备库还是On .
--//备库:
SYS@bookdg> select flashback_on from v$database;
FLASHBACK_ON
------------------
NO

SYS@bookdg> select * from v$tablespace;
       TS# NAME                 INC BIG FLA ENC
---------- -------------------- --- --- --- ---
         0 SYSTEM               YES NO  YES
         1 SYSAUX               YES NO  YES
         2 UNDOTBS1             YES NO  YES
         4 USERS                YES NO  YES
         3 TEMP                 NO  NO  YES
         6 EXAMPLE              YES NO  YES
         7 TEA                  YES NO  YES
7 rows selected.
--//备库还是yes,tea表空间.

SYS@bookdg> alter tablespace tea flashback off;
alter tablespace tea flashback off
                     *
ERROR at line 1:
ORA-16000: database open for read-only access
--//无法在open read only修改.

SYS@bookdg> startup mount
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.
SYS@bookdg> alter tablespace tea flashback off;
Tablespace altered.

SYS@bookdg> select * from v$tablespace;
       TS# NAME                 INC BIG FLA ENC
---------- -------------------- --- --- --- ---
         0 SYSTEM               YES NO  YES
         1 SYSAUX               YES NO  YES
         2 UNDOTBS1             YES NO  YES
         4 USERS                YES NO  YES
         3 TEMP                 NO  NO  YES
         6 EXAMPLE              YES NO  YES
         7 TEA                  YES NO  NO
7 rows selected.
--//OK,现在成功.

3.备库打开snapshot standby:
--//参考http://blog.itpub.net/267265/viewspace-2134547/
--//实际上就是保证存储点,只要闪回区足够,许多dml操作没有问题,在转换physical standby时,返回原来的存储点;

--//备库:
SYS@bookdg> alter database convert to snapshot standby;
Database altered.

SYS@bookdg> select database_role from v$database;
DATABASE_ROLE
----------------
SNAPSHOT STANDBY

SYS@bookdg> alter database open ;
Database altered.

SCOTT@bookdg> create table tt1 tablespace tea as select * from dba_objects;
Table created.

--//在主库也产生一些日志对于tea表空间:
SCOTT@book> create table empx tablespace tea as select * from emp;
Table created.

--//现在转换为physical standby
--//备库:
SYS@bookdg> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SYS@bookdg> startup mount
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.

SYS@bookdg> alter database convert to physical standby ;
alter database convert to physical standby
*
ERROR at line 1:
ORA-38753: Cannot flashback data file 6; no flashback log data.
ORA-01110: data file 6: '/mnt/ramdisk/book/tea01.dbf'

--//可以发现备库的数据文件6无法转换,这个应该引起足够重视,在备库转换为snapshot standby时,注意检查表空间是否flashvback是否都是on的状态.
$ oerr ora 38753
38753, 00000, "Cannot flashback data file %s; no flashback log data."
// *Cause:  An attempt to perform a FLASHBACK DATABASE failed because the file
//          does not have enough flashback log data to cover the time to
//          flash back.  Either the file did not have flashback generation
//          enabled for it, or had flashback generation turned off for it
//          some time during the time span of the flashback.
// *Action: The file cannot be flashed back.  The file must be taken offline
//          or the tablespace dropped before continuing with the FLASHBACK
//          DATABASE command.

4.恢复:
--//简单一点,主库tea表空间设置为read only;
--//主库:
SCOTT@book> alter tablespace tea read only;
Tablespace altered.

$ scp /mnt/ramdisk/book/tea01.dbf oracle@192.168.100.40:/mnt/ramdisk/book/
tea01.dbf                            100%   40MB  40.0MB/s   00:01

--//备库:
SYS@bookdg> alter database convert to physical standby ;
alter database convert to physical standby
*
ERROR at line 1:
ORA-38753: Cannot flashback data file 6; no flashback log data.
ORA-01110: data file 6: '/mnt/ramdisk/book/tea01.dbf'
--//不行:

SYS@bookdg> alter tablespace tea flashback on;
Tablespace altered.

SYS@bookdg> alter database convert to physical standby ;
alter database convert to physical standby
*
ERROR at line 1:
ORA-19926: Database cannot be converted at this time

--//根本不能这样转换.

SYS@bookdg> alter tablespace tea offline;
alter tablespace tea offline
*
ERROR at line 1:
ORA-01109: database not open

SYS@bookdg> alter database datafile 6 offline;
Database altered.

--//关闭备库重来.
SYS@bookdg> startup mount
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.

SYS@bookdg> alter database convert to physical standby ;
Database altered.

SYS@bookdg> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.

SYS@bookdg> startup mount
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.

SYS@bookdg> alter database datafile 6 online;
Database altered.

SYS@bookdg> alter database recover managed standby database using current logfile disconnect ;
Database altered.

SYS@bookdg> @ &r/dg/dg
PROCESS       PID STATUS       CLIENT_P GROUP# THREAD#  SEQUENCE#     BLOCK#     BLOCKS DELAY_MINS
--------- ------- ------------ -------- ------ ------- ---------- ---------- ---------- ----------
ARCH         2394 CONNECTED    ARCH     N/A          0          0          0          0          0
ARCH         2396 CONNECTED    ARCH     N/A          0          0          0          0          0
ARCH         2398 CONNECTED    ARCH     N/A          0          0          0          0          0
RFS          2403 IDLE         UNKNOWN  N/A          0          0          0          0          0
RFS          2405 IDLE         LGWR     2            1        789         50          1          0
ARCH         2400 CLOSING      ARCH     4            1        788          1        183          0
MRP0         2407 APPLYING_LOG N/A      N/A          1        789         50     102400          0
7 rows selected.
--//日志开始传输并应用.

SYS@bookdg> alter database recover managed standby database cancel ;
Database altered.

SYS@bookdg> alter database open read only;
Database altered.

SYS@bookdg> alter database recover managed standby database using current logfile disconnect ;
Database altered.

SYS@bookdg> select count(*) from scott.empx;
  COUNT(*)
----------
        14

SYS@bookdg> select count(*) from scott.tt1;
select count(*) from scott.tt1
                           *
ERROR at line 1:
ORA-00942: table or view does not exist
--//测试时建立的表不存在.
        
--//主库执行:
SCOTT@book> alter tablespace tea read write;
Tablespace altered.

SCOTT@book> delete from empx where rownum=1;
1 row deleted.

SCOTT@book> commit ;
Commit complete.

--//在备库检查,发现少一条记录.
SYS@bookdg> select count(*) from scott.empx;
  COUNT(*)
----------
        13

总结:
--//这个在以后工作中注意,在转换snapshot standby,注意表空间flaashback是否在on状态.

[20180423]flashback tablespace与snapshot standby.txt的更多相关文章

  1. 聊聊Oracle 11g的Snapshot Standby Database(上)

    Oracle 11g是Data Guard的重要里程碑版本.在11g中,Active DataGuard.Advanced Compression等特性大大丰富了Data Guard的功能和在实践领域 ...

  2. Oracle 11g中的snapshot standby特性

    在Oracle 11g中,data guard最吸引人的,除了active data guard的实时查询特性(即可以以只读方式打开物理standby数据库的同时MRP进程能继续做recover),快 ...

  3. 聊聊Oracle 11g的Snapshot Standby Database(下)

    3.Snapshot Standby行为研究 下面我们分析一下Snapshot Standby的工作性质和行为性质.我们在主库方向研究当前状态. --主库日志情况 SQL> select gro ...

  4. Snapshot Standby

    INTRODUCTION Snapshot standby database是ORACLE 11g的新特性.允许Physical standby短时间的使用read write模式. Snapshot ...

  5. snapshot standby database

    快照备库接收和归档主库发送来的redo,但是不会应用:切换成physical standby之后会自动开启redo apply.快照standby不可以参加主备切换:在最大保护性模式下,如果只有一个备 ...

  6. 转 Oracle Transportable TableSpace(TTS) 传输表空间 说明

    ############1   迁移数据库的集中方法 三.相关技术 迁移方式 优势 不足1 Export and import • 对数据库版本,以及系统平台没有要求 • 不支持并发,速度慢• 停机时 ...

  7. V4 Reduce Transportable Tablespace Downtime using Cross Platform Incremental Backup (Doc ID 2471245.1)

    V4 Reduce Transportable Tablespace Downtime using Cross Platform Incremental Backup (Doc ID 2471245. ...

  8. Oracle 11.2.0.4.0 Dataguard部署和日常维护(6)-Dataguard Snapshot篇

    1. 检查当前主备库同步状态 on primary select ads.dest_id,max(sequence#) "Current Sequence", max(log_se ...

  9. [Oracle] 临时将Physical Standby激活

    Oracle 10g/11g下如何将物理Standby库临时激活用于测试 在实际运营环境中, 我们经常碰到类似这样的需求: 譬如想不影响现网业务评估DB补丁在现网环境中运行的时间, 或者是想在做DB切 ...

随机推荐

  1. DataFrame基本操作

    这些操作在网上都可以百度得到,为了便于记忆自己再根据理解总结在一起.---------励志做一个优雅的网上搬运工 1.建立dataframe (1)Dict to Dataframe df = pd. ...

  2. python lxml库生成xml文件-节点命名空间问题

    lxml库,处理xml很强大,官方文档:https://lxml.de/tutorial.html#namespaces 例如: 我们要生成如下格式的报文: <ttt:jesson xmlns: ...

  3. ubuntu16.04 程序开机自启动设置及启动优化

    使用过程中,为了方便使用,有一些程序需要开机时自启动应用,下面将介绍一下ubuntu16.04下程序的开机自启动设置方法. 1  建立一个可执行程序的运行脚本如 keepalive.sh.内部写入要执 ...

  4. Spring Data JPA例子[基于Spring Boot、Mysql]

    关于Spring Data Spring社区的一个顶级工程,主要用于简化数据(关系型&非关系型)访问,如果我们使用Spring Data来开发程序的话,那么可以省去很多低级别的数据访问操作,如 ...

  5. [git与github]__git与github简单了解

    前言 关于版本控制,版本控制是一种记录一个或若干文件内容变化,以便将来查阅特定版本修订情况的系统. 我们通过版本控制系统可以解决的问题:可以非常方便的查看我们的源码文件的历代更新版本.或将我们的项目源 ...

  6. Linux_CentOS-服务器搭建 <二>

    Tomat安装: 说明: 源码安装,下载地址:http://tomcat.apache.org/.我下了个apache-tomcat-7.0.42.tar.gz 安装开始: 配置环境. JDK: vi ...

  7. MySQL数据库设计规范

    1. 规范背景与目的 MySQL数据库与 Oracle. SQL Server 等数据库相比,有其内核上的优势与劣势.我们在使用MySQL数据库的时候需要遵循一定规范,扬长避短.本规范旨在帮助或指导R ...

  8. SQL 必知必会·笔记<17>使用存储过程

    存储过程就是为以后使用而保存的一条或多条SQL 语句.可将其视为批文件,虽然它们的作用不仅限于批处理. 1. 存储过程的优点和缺点 存储过程的优点: 使用存储过程有三个主要的好处,即简单.安全.高性能 ...

  9. 记录前台页面一些jQuery笔记

    不知不觉工作两个月了,在这两个月,我成长很快学的很多,刚开始的时候,很多问题不懂,很多技术不会,当然作为实习阶段,很多不会的问题我都会去请教别人,在这里得感谢那些帮助我的人,但是经常去问别人问题,首先 ...

  10. ZooKeeper概念与应用

    Zookeeper是开源的分布式协调服务,提供了分布式数据一致性的解决方案. Zookeeper 可用作配置中心和分布式锁服务,在 Dubbo.Kafka.Spark等分布式集群上得到广泛应用. ZN ...