环境说明: 本实验环境是一个节点的rac + 单节点 asm dg     database 与 grid 版本是 11.2.0.4 。
提别提醒 如果是多节点集群,操作时需要特别注意 thread 。

一. 主库操作
 
1.1 查看redo 信息
SQL> col member for a60
SQL> select group#,type, member from v$logfile;

GROUP# TYPE    MEMBER
---------- ------- --------------------------------------------------------
         3 ONLINE  +DATA/devdb/onlinelog/group_3.263.936769395
         3 ONLINE  +FLASH/devdb/onlinelog/group_3.259.936769401
         2 ONLINE  +DATA/devdb/onlinelog/group_2.262.936769383
         2 ONLINE  +FLASH/devdb/onlinelog/group_2.258.936769389
         1 ONLINE  +DATA/devdb/onlinelog/group_1.261.936769373
         1 ONLINE  +FLASH/devdb/onlinelog/group_1.257.936769379
         4 STANDBY +DATA/devdb/onlinelog/group_4.267.938494955
         4 STANDBY +FLASH/devdb/onlinelog/group_4.278.938494963
         5 STANDBY +DATA/devdb/onlinelog/group_5.268.938494969
         5 STANDBY +FLASH/devdb/onlinelog/group_5.279.938494975
         6 STANDBY +DATA/devdb/onlinelog/group_6.269.938494981
         6 STANDBY +FLASH/devdb/onlinelog/group_6.280.938494985
         7 STANDBY +DATA/devdb/onlinelog/group_7.270.938495005
         7 STANDBY +FLASH/devdb/onlinelog/group_7.281.938495013

14 rows selected.

SQL> select group#,thread#,archived,status, bytes/1024/1024 from v$log;

GROUP#    THREAD# ARC STATUS           BYTES/1024/1024
---------- ---------- --- ---------------- ---------------
         1          1 YES INACTIVE                      50
         2          1 YES INACTIVE                      50
         3          1 NO  CURRENT                       50

1.2 修改standby redo

SQL> alter database drop logfile group 4;

Database altered.

SQL> alter database drop logfile group 5;

Database altered.

SQL> alter database drop logfile group 6;

Database altered.

SQL> alter database drop logfile group 7;

Database altered.

SQL> select group#,type, member from v$logfile;

GROUP# TYPE    MEMBER
---------- ------- ------------------------------------------------
         3 ONLINE  +DATA/devdb/onlinelog/group_3.263.936769395
         3 ONLINE  +FLASH/devdb/onlinelog/group_3.259.936769401
         2 ONLINE  +DATA/devdb/onlinelog/group_2.262.936769383
         2 ONLINE  +FLASH/devdb/onlinelog/group_2.258.936769389
         1 ONLINE  +DATA/devdb/onlinelog/group_1.261.936769373
         1 ONLINE  +FLASH/devdb/onlinelog/group_1.257.936769379

6 rows selected.

添加standby redo

SQL> alter database add standby logfile thread 1 group 4 size 60m,group 5 size 60m,group 6 size 60m,group 7 size 60m;

Database altered.

SQL>  select group#,type, member from v$logfile;

GROUP# TYPE    MEMBER
---------- ------- --------------------------------------------------
         3 ONLINE  +DATA/devdb/onlinelog/group_3.263.936769395
         3 ONLINE  +FLASH/devdb/onlinelog/group_3.259.936769401
         2 ONLINE  +DATA/devdb/onlinelog/group_2.262.936769383
         2 ONLINE  +FLASH/devdb/onlinelog/group_2.258.936769389
         1 ONLINE  +DATA/devdb/onlinelog/group_1.261.936769373
         1 ONLINE  +FLASH/devdb/onlinelog/group_1.257.936769379
         4 STANDBY +DATA/devdb/onlinelog/group_4.267.938747301
         4 STANDBY +FLASH/devdb/onlinelog/group_4.278.938747305
         5 STANDBY +DATA/devdb/onlinelog/group_5.268.938747309
         5 STANDBY +FLASH/devdb/onlinelog/group_5.279.938747313
         6 STANDBY +DATA/devdb/onlinelog/group_6.269.938747317
         6 STANDBY +FLASH/devdb/onlinelog/group_6.280.938747321
         7 STANDBY +DATA/devdb/onlinelog/group_7.270.938747325
         7 STANDBY +FLASH/devdb/onlinelog/group_7.281.938747327

14 rows selected.

1.3 修改Online redo

SQL> select group#,thread#,archived,status, bytes/1024/1024 from v$log;

GROUP#    THREAD# ARC STATUS           BYTES/1024/1024
---------- ---------- --- ---------------- ---------------
         1          1 YES INACTIVE                      50
         2          1 YES INACTIVE                      50
         3          1 NO  CURRENT                       50

先处理inactive, 它表示已经完成规定的,可以删除。

SQL> alter database drop logfile group 1;

Database altered.

注意: 至少要2个redo组

SQL> alter database add logfile thread 1 group 1 size 60m;

Database altered.

SQL>  select group#,thread#,archived,status, bytes/1024/1024 from v$log;

GROUP#    THREAD# ARC STATUS           BYTES/1024/1024
---------- ---------- --- ---------------- ---------------
         1          1 YES UNUSED                        60
         2          1 YES INACTIVE                      50
         3          1 NO  CURRENT                       50

SQL> alter database drop logfile group 2;

Database altered.

SQL> alter database add logfile thread 1 group 2 size 60m;

Database altered.

SQL> alter system switch logfile;

System altered.

SQL>  select group#,thread#,archived,status, bytes/1024/1024 from v$log;

GROUP#    THREAD# ARC STATUS           BYTES/1024/1024
---------- ---------- --- ---------------- ---------------
         1          1 NO  CURRENT                       60
         2          1 YES UNUSED                        60
         3          1 YES ACTIVE                        50

说明:ACTIVE 表示正在归档

等一会后

SQL>  select group#,thread#,archived,status, bytes/1024/1024 from v$log;

GROUP#    THREAD# ARC STATUS           BYTES/1024/1024
---------- ---------- --- ---------------- ---------------
         1          1 NO  CURRENT                       60
         2          1 YES UNUSED                        60
         3          1 YES INACTIVE                      50

SQL> alter database drop logfile group 3;

Database altered.

SQL>  alter database add logfile thread 1 group 3 size 60m;

Database altered.

SQL>  select group#,thread#,archived,status, bytes/1024/1024 from v$log;

GROUP#    THREAD# ARC STATUS           BYTES/1024/1024
---------- ---------- --- ---------------- ---------------
         1          1 NO  CURRENT                       60
         2          1 YES UNUSED                        60
         3          1 YES UNUSED                        60
 OK,至此,主库完成。

二. 备库操作

2.1 查看信息
SQL> col member for a60
SQL>  select group#,type, member from v$logfile;

GROUP# TYPE    MEMBER
---------- ------- --------------------------------------------------
         3 ONLINE  +DATA/phydb/onlinelog/group_3.268.938177101
         3 ONLINE  +FLASH/phydb/onlinelog/group_3.262.938177103
         2 ONLINE  +DATA/phydb/onlinelog/group_2.267.938177097
         2 ONLINE  +FLASH/phydb/onlinelog/group_2.261.938177099
         1 ONLINE  +DATA/phydb/onlinelog/group_1.266.938177093
         1 ONLINE  +FLASH/phydb/onlinelog/group_1.260.938177095
         4 STANDBY +DATA/phydb/onlinelog/group_4.262.938176937
         4 STANDBY +FLASH/phydb/onlinelog/group_4.256.938176939
         5 STANDBY +DATA/phydb/onlinelog/group_5.263.938176941
         5 STANDBY +FLASH/phydb/onlinelog/group_5.257.938176943
         6 STANDBY +DATA/phydb/onlinelog/group_6.264.938176945
         6 STANDBY +FLASH/phydb/onlinelog/group_6.258.938176945
         7 STANDBY +DATA/phydb/onlinelog/group_7.265.938176947
         7 STANDBY +FLASH/phydb/onlinelog/group_7.259.938176949

14 rows selected.

SQL> select group#,thread#,archived,status, bytes/1024/1024 from v$log;

GROUP#    THREAD# ARC STATUS           BYTES/1024/1024
---------- ---------- --- ---------------- ---------------
         1          1 YES CURRENT                       50
         2          1 YES CLEARING                      50
         3          1 YES CLEARING                      50

2.2 处理standby redo

对于standby 上redo的处理之前,我们要先停掉redo 的apply:否则报错 ORA-01156

SQL> alter database recover managed standby database cancel;

SQL> alter database drop logfile group 4;

Database altered.

SQL> alter database drop logfile group 5;

Database altered.

SQL> alter database drop logfile group 6;

Database altered.

SQL> alter database drop logfile group 7;

Database altered.

SQL>  alter database add standby logfile thread 1 group 4 size 60m,group 5 size 60m,group 6 size 60m,group 7 size 60m;

Database altered.

SQL> select group#,type, member from v$logfile;

GROUP# TYPE    MEMBER
---------- ------- -------------------------------------------------
         3 ONLINE  +DATA/phydb/onlinelog/group_3.268.938177101
         3 ONLINE  +FLASH/phydb/onlinelog/group_3.262.938177103
         2 ONLINE  +DATA/phydb/onlinelog/group_2.267.938177097
         2 ONLINE  +FLASH/phydb/onlinelog/group_2.261.938177099
         1 ONLINE  +DATA/phydb/onlinelog/group_1.266.938177093
         1 ONLINE  +FLASH/phydb/onlinelog/group_1.260.938177095
         4 STANDBY +DATA/phydb/onlinelog/group_4.265.938720451
         4 STANDBY +FLASH/phydb/onlinelog/group_4.259.938720453
         5 STANDBY +DATA/phydb/onlinelog/group_5.264.938720457
         5 STANDBY +FLASH/phydb/onlinelog/group_5.258.938720463
         6 STANDBY +DATA/phydb/onlinelog/group_6.263.938720465
         6 STANDBY +FLASH/phydb/onlinelog/group_6.257.938720469
         7 STANDBY +DATA/phydb/onlinelog/group_7.262.938720471
         7 STANDBY +FLASH/phydb/onlinelog/group_7.256.938720475

14 rows selected.

2.3 处理online redo

先将standby_file_management设为手动:

SQL> alter system set standby_file_management=manual;
System altered.

SQL>  alter database clear logfile group 2;

Database altered.

SQL> alter database drop logfile group 2;

Database altered.

SQL> alter database add logfile thread 1 group 2 size 60m;

Database altered.

SQL>  select group#,thread#,archived,status, bytes/1024/1024 from v$log;

GROUP#    THREAD# ARC STATUS           BYTES/1024/1024
---------- ---------- --- ---------------- ---------------
         1          1 YES CURRENT                       50
         2          1 YES UNUSED                        60
         3          1 YES CLEARING                      50

SQL> alter database clear logfile group 3;

Database altered.

SQL> alter database drop logfile group 3;

Database altered.

SQL> alter database add logfile thread 1 group 3 size 60m;

Database altered.

SQL> select group#,thread#,archived,status, bytes/1024/1024 from v$log;

GROUP#    THREAD# ARC STATUS           BYTES/1024/1024
---------- ---------- --- ---------------- ---------------
         1          1 YES CURRENT                       50
         2          1 YES UNUSED                        60
         3          1 YES UNUSED                        60

SQL>  alter database recover managed standby database disconnect from session;

Database altered.

SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT='AUTO';

System altered.

-- 到主库手动切换几次redo

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

--查看备库的redo:

SQL> select group#,thread#,archived,status, bytes/1024/1024 from v$log;

GROUP#    THREAD# ARC STATUS           BYTES/1024/1024
---------- ---------- --- ---------------- ---------------
         1          1 YES CLEARING                      50
         2          1 YES CLEARING                      60
         3          1 YES CURRENT                       60
SQL> alter database recover managed standby database cancel;

Database altered.

SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT='MANUAL';

System altered.

SQL> select group#,thread#,archived,status, bytes/1024/1024 from v$log;

GROUP#    THREAD# ARC STATUS           BYTES/1024/1024
---------- ---------- --- ---------------- ---------------
         1          1 YES CLEARING                      50
         2          1 YES CLEARING                      60
         3          1 YES CURRENT                       60
SQL> alter database clear logfile group 1;

Database altered.

SQL> alter database drop logfile group  1;

Database altered.

SQL> alter database add logfile thread 1 group 1 size 60m;

Database altered.

SQL>  select group#,thread#,archived,status, bytes/1024/1024 from v$log;

GROUP#    THREAD# ARC STATUS           BYTES/1024/1024
---------- ---------- --- ---------------- ---------------
         1          1 YES UNUSED                        60
         2          1 YES CLEARING                      60
         3          1 YES CURRENT                       60

SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT='AUTO';

System altered.

SQL> alter database recover managed standby database using current logfile disconnect from session;

Database altered.

主库测试:

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)
--------------
            77

备库查看是否同步:

SQL> select sequence#,applied from v$archived_log;
       。。。。。
        76 YES
        77 IN-MEMORY

69 rows selected.

一切正常。

dataguard 下主备 online redo 与 standby redo log resize 重建的更多相关文章

  1. Oracle Dataguard HA (主备,灾备)方案部署调试

    包括: centos6.5 oracle11gR2 DataGuard安装 dataGuard 主备switchover角色切换 数据同步测试 <一,>DG数据库数据同步测试1,正常启动主 ...

  2. DG_Oracle DataGuard Failover主备节点切换(案例)

    2014-03-09 Created By BaoXinjian Thanks and Regards

  3. DG_Oracle DataGuard Switchover主备节点切换(案例)

    2014-06-09 Created By BaoXinjian Thanks and Regards http://wenku.baidu.com/view/dc9f00d349649b6648d7 ...

  4. 24 | MySQL是怎么保证主备一致的?

    在前面的文章中,我不止一次地和你提到了binlog,大家知道binlog可以用来归档,也可以用来做主备同步,但它的内容是什么样的呢?为什么备库执行了binlog就可以跟主库保持一致了呢?今天我就正式地 ...

  5. OceanBase中主备Rootserver如何管理切换

    主RootServer会不断给备RootServer发送lease.被RootServer收到该lease后会保存到几个变量中: int ObCheckRunnable::renew_lease(co ...

  6. 24 mysql怎么保证主备一致

    Mysql主备的基本原理 在状态1中,客户端直接访问节点A,而节点B只是备库,只是将A的binlog全部同步过来并应用到本地,这样可以保持节点B和节点A的数据是相同的. 当需要切换的时候,就变成状态2 ...

  7. (摘)DataGuard物理standby管理 - 主备切换

    DataGuard物理standby管理 - 主备切换 Dataguard的切换分为两种,switchover和failover. switchover一般用于数据库或硬件升级,这时只需要较短时间中断 ...

  8. DG_Oracle DataGuard Primary/Standby物理主备节点安装实践(案例)

    2014-09-09 Created By BaoXinjian

  9. GoldenGate 传统抽取进程随 DataGuard 主备快速切换的方案(ADG 模式)

    环境描述: 1.节点描述 节点 IP 节点描述 11.6.76.221 GG 抽取端 / DG 节点,数据库版本号为 Oracle-11.2.0.3,与 11.6.76.222 组成 DataGuar ...

随机推荐

  1. android开发系列之数据存储

    在我们的android实际开发过程,必不可少的一种行为操作对象就是数据.有些数据,对于用户而言是一次性的,这就要求我们每次进到App的时候,都需要去刷新数据.有些数据,对于用户而言又是具有一定时效性的 ...

  2. 分区容量大于16TB的格式化

    File systems do have limits. Thats no surprise. ext3 had a limit at 16 TB file system size. If you n ...

  3. jsp获取web.xml 里的配置项

    ServletContext servletContext = request.getSession().getServletContext();                String titl ...

  4. 在dev目录创建一个字符设备驱动的流程

    1.struct file_operations 字符设备文件接口 1: static int mpu_open(struct inode *inode, struct file *file) 2: ...

  5. Eclipse工程前面有个红色的感叹号的解决办法

    今天从SVN下载下工程之后,编译完,发现有两个工程有个红色的感叹号,一直没找到什么原因,问百度老师,发现问题的解决办法了. 1.先在控制台上点击Problems 如果控制台没有Problems,点击工 ...

  6. TP框架部分---空控制器

    <?php namespace Admin\Controller; use Think\Controller; class DengLuController extends Controller ...

  7. 用 Apache POI 读取 XLSX 数据

    最近因为项目的原因,需要从一些 Microsoft Office Excel 文件读取数据并加载到数据库. Google了一下方法,发现其实可以用的 Java 第三方库很多,最著名的是 Apache ...

  8. sed 简单用法

    sed的一个简单用法: eg:在某一个文件中的一个aaa字段前后添加某些字段. 在aaa前面添加字段:sed -ne 's/aaa/&HELLO/p' test 输出结果:aaaHELLO 在 ...

  9. IDEA tomcat三步实现热部署

    IDEA tomcat三步实现热部署 添加Artifacts选项 添加Artifacts选项,XXXwar 和 XXXwar exploded二选一,若要热部署须选后者. 设置tomcat部署方案 设 ...

  10. Java AQS详解(转)

    原文地址 一.概述 谈到并发,不得不谈ReentrantLock:而谈到ReentrantLock,不得不谈AbstractQueuedSynchronizer(AQS)! 类如其名,抽象的队列式的同 ...