Oracle ADG Snapshot Standby体验

这篇具有很好参考价值的文章主要介绍了Oracle ADG Snapshot Standby体验。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

本文参考了OBE文章Using Snapshot Standby

Snapshot Standby的概念

参见这里。

A snapshot standby database is a fully updatable standby database. It receives and archives redo data from a primary database, but does not apply it.

Redo data received from the primary database is applied when a snapshot standby database is converted back into a physical standby database, after discarding all local updates to the snapshot standby database.

A snapshot standby database typically diverges from its primary database over time because redo data from the primary database is not applied as it is received. Local updates to the snapshot standby database cause additional divergence. The data in the primary database is fully protected however, because a snapshot standby can be converted back into a physical standby database at any time, and the redo data received from the primary is then applied.

A snapshot standby database provides disaster recovery and data protection benefits that are similar to those of a physical standby database. Snapshot standby databases are best used in scenarios where the benefit of having a temporary, updatable snapshot of the primary database justifies increased time to recover from primary database failures.

准备工作,搭建ADG环境

搭建了一个标准的ADG配置,一个Primary,一个Physical Standby。

$ dgmgrl
DGMGRL for Linux: Release 19.0.0.0.0 - Production on Mon Jul 31 03:18:49 2023
Version 19.19.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys
Password:
Connected to "DB0730_n5p_fra"
Connected as SYSDBA.
DGMGRL> show configuration

Configuration - DB0730_n5p_fra_DB0730_8th_fra

  Protection Mode: MaxPerformance
  Members:
  DB0730_n5p_fra - Primary database
    DB0730_8th_fra - Physical standby database

Fast-Start Failover:  Disabled

Configuration Status:
SUCCESS   (status updated 15 seconds ago)

确认FlashBack Database特性已开启

Snapshot Standby 依赖于Flashback Database,详见这里。此时Flashback Database的作用为:

Flashback Database is used to convert a snapshot standby database back into a physical standby database.

确认主备数据库均已开启Flashback Database,并且默认的保留期为24小时:

SQL> select FLASHBACK_ON from v$database;

FLASHBACK_ON
------------------
YES

SQL> show parameter flashback

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_flashback_retention_target        integer     1440

将Physical Standby数据库转换为Snapshot Standby 数据库

在转换之前,确认此时并没有restore point:

SQL> select * from V$RESTORE_POINT;

no rows selected

将Physical Standby转换为Snapshot Standby:

DGMGRL> convert database DB0730_8th_fra to snapshot standby;
Converting database "db0730_8th_fra" to a Snapshot Standby database, please wait...
Database "db0730_8th_fra" converted successfully

-- 以下是另一种方法
-- SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY;

此时在备库上已自动创建了有保障的恢复点:

SELECT NAME, SCN, TIME, DATABASE_INCARNATION#,
        GUARANTEE_FLASHBACK_DATABASE,STORAGE_SIZE
        FROM V$RESTORE_POINT;

NAME                                             SCN        TIME                               DATABASE_INCARNATION#    GUARANTEE_FLASHBACK_DATABASE    STORAGE_SIZE    
SNAPSHOT_STANDBY_REQUIRED_07/31/2023 03:22:47       1952214 31-JUL-23 03.22.47.000000000 AM                           2 YES                                  1073741824 

此时的配置如下,注意其中的Snapshot standby

DGMGRL> show configuration

Configuration - DB0730_n5p_fra_DB0730_8th_fra

  Protection Mode: MaxPerformance
  Members:
  DB0730_n5p_fra - Primary database
    DB0730_8th_fra - Snapshot standby database
      Warning: ORA-16855: transport lag has exceeded specified threshold

Fast-Start Failover:  Disabled

Configuration Status:
WARNING   (status updated 29 seconds ago)

上面输出中ORA-16855的错误是正常的,可以看下要求的delay是多少:

SQL> show parameter log_archive_dest_n

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2                   string      service="DB0730_8th_fra", ASYN
                                                 C NOAFFIRM delay=0 optional co
                                                 mpression=disable max_failure=
                                                 0 reopen=300 db_unique_name="D
                                                 B0730_8th_fra" net_timeout=30,
                                                  valid_for=(online_logfile,all
                                                 _roles)

DGMGRL也可以看:

DGMGRL> show database verbose "DB0730_n5p_fra" DelayMins
  DelayMins = '0'

可以看到,要求的为0,而实际的滞后为36分钟:

SQL> SELECT * FROM v$dataguard_stats WHERE name LIKE '%lag%';

SOURCE_DBID SOURCE_DB_UNIQUE_NAME            NAME
----------- -------------------------------- --------------------------------
VALUE
----------------------------------------------------------------
UNIT                           TIME_COMPUTED
------------------------------ ------------------------------
DATUM_TIME                         CON_ID
------------------------------ ----------
 1907664404 DB0730_n5p_fra                   transport lag
+00 00:36:14
day(2) to second(0) interval   07/31/2023 03:59:02
07/31/2023 03:59:00                     0


SOURCE_DBID SOURCE_DB_UNIQUE_NAME            NAME
----------- -------------------------------- --------------------------------
VALUE
----------------------------------------------------------------
UNIT                           TIME_COMPUTED
------------------------------ ------------------------------
DATUM_TIME                         CON_ID
------------------------------ ----------
 1907664404 DB0730_n5p_fra                   apply lag
+00 00:36:16
day(2) to second(0) interval   07/31/2023 03:59:02
07/31/2023 03:59:00                     0

更新数据库并确认Redo仍在复制

登录备库,查询表v$managed_standby,记录其BLOCK#的值:

SELECT
    v$managed_standby.status,
    v$managed_standby.sequence#,
    v$managed_standby.block#
FROM
    v$managed_standby
WHERE
    v$managed_standby.client_process = 'LGWR'

STATUS       SEQUENCE#    BLOCK#    
RECEIVING              36      1135

清空备库中某表,同时也可以证明Snapshot Standby是可写的:

SQL> select count(*) from date_dim;

  COUNT(*)
----------
      2556

SQL> truncate table date_dim;

Table truncated.

SQL> select count(*) from date_dim;

  COUNT(*)
----------
         0

在主库中将此表数据翻倍:

SQL> select count(*) from date_dim;

  COUNT(*)
----------
      2556

SQL> insert into date_dim select * from date_dim;

2556 rows created.

SQL> commit;

Commit complete.

SQL> select count(*) from date_dim;

  COUNT(*)
----------
      5112

再次查询表v$managed_standby,记录其BLOCK#的值,此时由1135变为了2836:

SELECT
    v$managed_standby.status,
    v$managed_standby.sequence#,
    v$managed_standby.block#
FROM
    v$managed_standby
WHERE
    v$managed_standby.client_process = 'LGWR'
    
STATUS       SEQUENCE#    BLOCK#    
RECEIVING              36      2836 

BLOCK#的定义为:

Last processed archived redo log block number

将Snapshot Standby 还原为Physical Standby

关于这一步,以下文档非常有用:

  • Data Guard Physical Standby - Converting a Snapshot Standby back to a Physical Standby using Data Guard Broker (Doc ID 1546657.1)

注意要用口令而非以下方式登录dgmgrl,否则在后续操作过程中会报错:

$ dgmgrl / as sysdba
...
DGMGRL> convert database DB0730_8th_fra to physical standby;
Converting database "db0730_8th_fra" to a Physical Standby database, please wait...
Oracle Clusterware is restarting database "DB0730_8th_fra" ...
ORA-01017: invalid username/password; logon denied


Please complete the following steps and reissue the CONVERT command:
        shut down instance "DB0730" of database "DB0730_8th_fra"
        start up instance "DB0730" of database "DB0730_8th_fra"

应该用connect sys命令登录:

$ dgmgrl
DGMGRL for Linux: Release 19.0.0.0.0 - Production on Mon Jul 31 04:29:42 2023
Version 19.19.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys
Password:
Connected to "DB0730_n5p_fra"
Connected as SYSDBA.
DGMGRL> show configuration

Configuration - DB0730_n5p_fra_DB0730_8th_fra

  Protection Mode: MaxPerformance
  Members:
  DB0730_n5p_fra - Primary database
    DB0730_8th_fra - Snapshot standby database

Fast-Start Failover:  Disabled

Configuration Status:
SUCCESS   (status updated 31 seconds ago)

DGMGRL> convert database DB0730_8th_fra to physical standby;
Converting database "db0730_8th_fra" to a Physical Standby database, please wait...
Oracle Clusterware is restarting database "DB0730_8th_fra" ...
Connected to "DB0730_8th_fra"
Continuing to convert database "db0730_8th_fra" ...
Database "db0730_8th_fra" converted successfully
DGMGRL> show configuration

Configuration - DB0730_n5p_fra_DB0730_8th_fra

  Protection Mode: MaxPerformance
  Members:
  DB0730_n5p_fra - Primary database
    DB0730_8th_fra - Physical standby database
      Warning: ORA-16809: multiple warnings detected for the member

Fast-Start Failover:  Disabled

Configuration Status:
WARNING   (status updated 11 seconds ago)

以上输出中的警告是临时的,过一会就正常了:文章来源地址https://www.toymoban.com/news/detail-621290.html

DGMGRL> show configuration

Configuration - DB0730_n5p_fra_DB0730_8th_fra

  Protection Mode: MaxPerformance
  Members:
  DB0730_n5p_fra - Primary database
    DB0730_8th_fra - Physical standby database

Fast-Start Failover:  Disabled

Configuration Status:
SUCCESS   (status updated 15 seconds ago)

在备库中确认数据已复制,并且只读

SQL> show con_name

CON_NAME
------------------------------
ORCLPDB1
SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 ORCLPDB1                       MOUNTED

SQL> alter pluggable database orclpdb1 open;

Pluggable database altered.

SQL> alter session set container=orclpdb1;

Session altered.

SQL> select count(*) from ssb.date_dim;

  COUNT(*)
----------
      5112

SQL> truncate table ssb.date_dim;
truncate table ssb.date_dim
                   *
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-16000: database or pluggable database open for read-only access

参考

  • Flashback Database Best Practices & Performance (Doc ID 565535.1)
  • Data Guard Physical Standby - Converting a Snapshot Standby back to a Physical Standby using Data Guard Broker (Doc ID 1546657.1)
  • Managing Physical and Snapshot Standby Databases
  • Using Snapshot Standby Database. (Doc ID 443720.1)

到了这里,关于Oracle ADG Snapshot Standby体验的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • oracle 19c容器数据库data dump数据泵传输数据(4)---网络传输

    Transporting a Database Over the Network: Example 这个的方式导入可以不需要传输dmp文件,我原本是想从11g导入到pdb2的,但是因为版本的原因,就直接实验从pdb1导入到pdb2吧。 这种方式和前面完全传输的方式类似,不需要事先在目标数据库创建相同的表空间,而且不也不用有导出数据文

    2024年01月18日
    浏览(42)
  • 【转载】oracle学习之路(4)Oracle---windows下安装oracle19c

    转载文档源文链接:Oracle---windows下安装oracle19c 网路地址:https://www.oracle.com/database/technologies/oracle-database-software-downloads.html#19c 在D盘新建文件夹oracle19c(注意:解压后的安装包不能为中文路径,且不要有空格这台特殊的,且数据库安装完成后安装包也不能删除。)。 将WINDOWS.X6

    2024年03月26日
    浏览(41)
  • Hadoop集群 手动主备切换 (Active - Standby)

    手动切换 node01 备用节点 StandbyNameNode 为 主节点 ActiveNameNode,node02为备用节点SNN 查看节点状态 hdfs haadmin -getServiceState nn1 命令切换节点状态 到 hadoop 目录下执行: 1、将 NN2 切换为 Standby 备用节点 bin/hdfs haadmin -transitionToStandby --forcemanual nn2 2、将 NN1 切换为 Active 备用节点 bin/hd

    2024年02月03日
    浏览(24)
  • Hadoop HA集群两个NameNode都是standby或者主NameNode是standby,从NameNode是active的情况集锦

    这里说一下配置Hadoop HA集群可能出现的两种情况,第一种就是两个NameNode都是standby,第二种就是主Master是standby,从Master是active。 针对Hadoop 1.x中可能出现的NameNode单点故障(SPOF)或者短时间无法使用的情况,Hadoop 2.x 通过增加一个NameNode的方式进行了改善,而增加一个NameNode后

    2024年02月12日
    浏览(32)
  • <Oracle>《Linux 下安装Oracle数据库 - Oracle 19C By CentOS 8 》(第三部分)

    2.5.1 修改centos主机名 类型 英文 解释 静态 Static hostname 内核主机名,是系统在启动时从/etc/hostname自动初始化的主机名。 瞬态 Tansient hostname 系统运行时临时分配的主机名,例如,通过DHCP或mDNS服务器分配。 灵活 Pretty hostname 有人叫做“别名”主机名,允许使用自由形式(包括

    2024年02月11日
    浏览(45)
  • docker 安装 oracle19c

    docker 安装 oracle19c 拉取镜像 创建挂载目录 授权 安装 或者讲字符集修改为 AL32UTF8 安装过程中可以通过日志监控安装情况 连接 Oracle 数据库 打开容器终端 sqlplus登录 sysdba身份登录,默认进入CDB 进入CDB 进入PDB 查看连接模式 网页登录 https://ip:5500/em sqldeveloper Oracle SQL Developer Do

    2024年02月10日
    浏览(41)
  • Docker安装Oracle19c

    1.下载镜像 到 https://hub.docker.com 搜索合适的镜像,这里选择banglamon/oracle193db:19.3.0-ee。  拉取镜像 docker pull banglamon/oracle193db:19.3.0-ee 这里走了点弯路,这个镜像安装后实例无法正常启动,而且挂载的目录下面没有生成文件,想办法启动以后sqlplus能用,但容器外部连接报ora-1

    2023年04月21日
    浏览(34)
  • docker部署oracle 19c

    步骤2:规划镜像数据存储路径 进入容器后有个 setPassword.sh 脚本 步骤5: 检查新生成的容器的时区 jdbc连接: 原因: 在表空间“USERS”无权限 解决办法: 查看当前用户所属表空间: 修改表空间:  

    2024年02月04日
    浏览(28)
  • docker 安装Oracle19c

    如下操作基于已经装好docker 环境 1.下载镜像 docker pull registry.cn-hangzhou.aliyuncs.com/zhuyijun/oracle:19c 通过docker images 命令查看 如下图:已经有oracle 19c镜像。  2.创建挂载文件 # 创建文件 mkdir -p /mydata/oracle/oradata # 授权,不授权会导致后面安装失败 chmod 777 /mydata/oracle/oradata 3.安装Or

    2024年02月04日
    浏览(36)
  • Oracle 19c 安装(Linux)

    操作系统基础配置 本章节所有操作使用root用户 关闭防火墙和SELINUX 关闭selinux: 编辑/etc/selinux/config 文件 RPM包安装 Oracle安装需要以下RPM包: compat-libcap1-1.10-1 (x86_64) gcc-4.4.4-13.el6 (x86_64) gcc-c+±4.4.4-13.el6 (x86_64) glibc-devel-2.12-1.7.el6 (x86_64) libaio-devel-0.3.107-10.el6 (x86_64) libstdc+±devel-

    2024年02月02日
    浏览(46)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包