文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

Oracle 11g physical dataguard之快照备用

2024-04-02 19:55

关注

在oracle 10g要准备一个读写备用的数据库还是很繁琐的,准备好dataguard后得手动创建还原点,手动停日志传送,手动激活并强制打开,测试完了,如果主备的SCN差太多,你还得做增量备份追,统计了下需15步,和搭一个physical standby的步骤差不多了,所以用的极少。到11g里终于解放了,启用快照备库只需3步(当然中间重启的次数不算),恢复到实时应用备用也只需2步,日志还是继续传,需要镜像库测试的朋友,可以放心用了(用dataguard borker更简单)。当然转换成Snapshot Standby,是有些附加条件的(没有的参照前文去搭建一个):
1 数据库闪回得打开;
2 db_recovery_file_dest_size还是要有足够的空间的;
3 如果使用的保护模式是Maximum Protection模式,必须有其他的Standby与之相匹配,否则小心主库宕机。
手动做的步骤如下:
1检查闪回

 SQL> select flashback_on,database_role,open_mode from v$database;  
FLASHBACK_ON       DATABASE_ROLE    OPEN_MODE
------------------ ---------------- --------------------
NO                 PHYSICAL STANDBY READ ONLY WITH APPLY

当前Standby状态是只读Apply状态,这个时候需要终止Apply过程,并且切换回mount状态。否则是不允许进行convert动作的。

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
SQL> alter database flashback on;
alter database flashback on
*
ERROR at line 1:
ORA-38706: Cannot turn on FLASHBACK DATABASE logging.
ORA-38709: Recovery Area is not enabled.

报错了,这个错误好解决:

 SQL> show parameter db_recovery_file

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string
db_recovery_file_dest_size           big integer 51000M
SQL> alter system set db_recovery_file_dest='/data';
SQL> alter database flashback on;
SQL> select flashback_on from v$database; 
FLASHBACK_ON
------------------
YES

2 转换

SQL> alter database convert to snapshot standby;
SQL> alter  database open; 

有兴趣的可以看下alert_sid.log
End: Standby Redo Logfile archival
RESETLOGS after incomplete recovery UNTIL CHANGE 1974538
Resetting resetlogs activation ID 1662850232 (0x631d14b8)
Online log /data/db/onlinelog/group_1.261.899048765: Thread 1 Group 1 was previously cleared
Online log /data/db/onlinelog/group_2.260.899048765: Thread 1 Group 2 was previously cleared
Online log /data/db/onlinelog/group_3.277.899049819: Thread 2 Group 3 was previously cleared
Online log /data/db/onlinelog/group_4.278.899049819: Thread 2 Group 4 was previously cleared
Online log /data/db/onlinelog/group_5.280.908381663: Thread 1 Group 5 was previously cleared
Online log /data/db/onlinelog/group_6.281.908381749: Thread 1 Group 6 was previously cleared
Online log /data/db/onlinelog/group_7.282.908381877: Thread 1 Group 7 was previously cleared
检查下当前数据库状态:

 SQL> select open_mode, database_role, protection_mode from v$database;

OPEN_MODE            DATABASE_ROLE    PROTECTION_MODE
-------------------- ---------------- --------------------
READ WRITE           SNAPSHOT STANDBY MAXIMUM AVAILABILITY

已经变成可写状态,查询flash_back开始的SCN:

 SQL> select oldest_flashback_scn, oldest_flashback_time from v$flashback_database_log;

OLDEST_FLASHBACK_SCN OLDEST_FLASH
-------------------- ------------
             1974537 17-MAY-17

从这里开始可以对备库进行任何操作:

SQL> create table  test  as select * from all_objects; 
Table created. 
SQL> select count(*) from test; 
  COUNT(*)
----------
     14629 
SQL> drop table STAGE_TERADATA_OFFLINE_PKEYS purge; 
Table dropped.

切回:
1 关库,切换

 SQL>shutdown immediate
SQL>startup mount;
SQL> alter database convert to physical standby;

这里查看alert_sid.log可以看到
Flashback Restore Start
Flashback Restore Complete
Drop guaranteed restore point
删除了还原点
2 关库,关闪回,启用real time apply

SQL>shutdown immediate;
SQL>startup mount;
SQL>alter database flashback off;
SQL>alter database open; 
SQL>RECOVER  managed standby database using current logfile disconnect from session  
SQL>select open_mode, database_role, protection_mode,current_SCN from v$database;
OPEN_MODE            DATABASE_ROLE    PROTECTION_MODE      CURRENT_SCN
-------------------- ---------------- -------------------- -----------
READ ONLY WITH APPLY PHYSICAL STANDBY MAXIMUM AVAILABILITY     1977350

检查下刚才测试的数据:

 [oracle@ora9-2 data]$ sqlplus scott/test 
SQL*Plus: Release 11.2.0.4.0 Production on Wed May 17 08:42:08 2017 
Copyright (c) 1982, 2013, Oracle.  All rights reserved. 
ERROR:
ORA-28002: the password will expire within 18446744073709551614 days  
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select count(*) from test; 
select count(*) from test
                     *
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> select * from STAGE_TERADATA_OFFLINE_PKEYS; 
no rows selected

该有的还在,不该有的也没有了,挺好。

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-数据库
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯