dataguard环境下redolog的管理

1.主库redo管理
SQL> select GROUP#,SEQUENCE#,BYTES/1024/1024,STATUS from v$log;


    GROUP#  SEQUENCE# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------------
         1         10              50 CURRENT
         2          8              50 ACTIVE
         3          9              50 ACTIVE


SQL> alter system switch logfile;


System altered.


SQL> /


System altered.


SQL> select GROUP#,SEQUENCE#,BYTES/1024/1024,STATUS from v$log;


    GROUP#  SEQUENCE# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------------
         1         10              50 ACTIVE
         2         11              50 ACTIVE
         3         12              50 CURRENT


SQL> alter system checkpoint;


System altered.


SQL> select GROUP#,SEQUENCE#,BYTES/1024/1024,STATUS from v$log;


    GROUP#  SEQUENCE# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------------
         1         10              50 INACTIVE
         2         11              50 INACTIVE
         3         12              50 CURRENT
         
SQL> alter database drop logfile group 1;


Database altered.


SQL> alter database add logfile group 1 '/U01/app/oracle/oradata/airdb/redo01_01.log' size 128M reuse;    


Database altered.


SQL> select GROUP#,SEQUENCE#,BYTES/1024/1024,STATUS from v$log;


    GROUP#  SEQUENCE# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------------
         1          0             128 UNUSED
         2         11              50 INACTIVE
         3         12              50 CURRENT
SQL> alter database drop logfile group 2;


Database altered.


SQL> alter database add logfile group 2 '/U01/app/oracle/oradata/airdb/redo02_01.log' size 128M reuse;


Database altered.


SQL> alter system switch logfile;


System altered.


SQL> alter database drop logfile group 3;
alter database drop logfile group 3
*
ERROR at line 1:
ORA-01624: log 3 needed for crash recovery of instance airdb (thread 1)
ORA-00312: online log 3 thread 1: '/U01/app/oracle/oradata/airdb/redo03.log'




SQL> alter system checkpoint;


System altered.


SQL> alter database drop logfile group 3;


Database altered.


SQL> alter database add logfile group 3 '/U01/app/oracle/oradata/airdb/redo03_01.log' size 128M reuse;


Database altered.


SQL> alter database add logfile group 4 '/U01/app/oracle/oradata/airdb/redo04_01.log' size 128M reuse;


Database altered.
SQL> select GROUP#,SEQUENCE#,BYTES/1024/1024,STATUS from v$log;


    GROUP#  SEQUENCE# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------------
         1         13             128 CURRENT
         2          0             128 UNUSED
         3          0             128 UNUSED
         4          0             128 UNUSED


SQL> alter system switch logfile;


System altered.


SQL> /


System altered.


SQL> select GROUP#,SEQUENCE#,BYTES/1024/1024,STATUS from v$log;


    GROUP#  SEQUENCE# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------------
         1         13             128 ACTIVE
         2         14             128 ACTIVE
         3         15             128 CURRENT
         4          0             128 UNUSED


2.主库standby redo管理
SQL> select GROUP#,SEQUENCE#,BYTES/1024/1024,STATUS from v$standby_log;


    GROUP#  SEQUENCE# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------
         5          0             128 UNASSIGNED
         6          0             128 UNASSIGNED
         7          0             128 UNASSIGNED
         8          0             128 UNASSIGNED
         9          0             128 UNASSIGNED


SQL> alter database drop standby logfile group 9;


Database altered.


SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 9 '/U01/app/oracle/oradata/airdb/std_redo09_01.log' SIZE 128M reuse;


Database altered.


SQL> select GROUP#,SEQUENCE#,BYTES/1024/1024,STATUS from v$standby_log;


    GROUP#  SEQUENCE# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------
         5          0             128 UNASSIGNED
         6          0             128 UNASSIGNED
         7          0             128 UNASSIGNED
         8          0             128 UNASSIGNED
         9          0             128 UNASSIGNED
SQL> select group#,type, member from v$logfile order by group#;


    GROUP# TYPE    MEMBER
---------- ------- --------------------------------------------------
         1 ONLINE  /U01/app/oracle/oradata/airdb/redo01_01.log
         2 ONLINE  /U01/app/oracle/oradata/airdb/redo02_01.log
         3 ONLINE  /U01/app/oracle/oradata/airdb/redo03_01.log
         4 ONLINE  /U01/app/oracle/oradata/airdb/redo04_01.log
         5 STANDBY /U01/app/oracle/oradata/airdb/std_redo05_01.log
         6 STANDBY /U01/app/oracle/oradata/airdb/std_redo06_01.log
         7 STANDBY /U01/app/oracle/oradata/airdb/std_redo07_01.log
         8 STANDBY /U01/app/oracle/oradata/airdb/std_redo08_01.log
         9 STANDBY /U01/app/oracle/oradata/airdb/std_redo09_01.log
         
3.备库redo管理
SQL> select GROUP#,SEQUENCE#,BYTES/1024/1024,STATUS from v$log;


    GROUP#  SEQUENCE# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------------
         1         55             256 CURRENT
         2         54             256 CLEARING
         3         51             256 CLEARING
         4         52             256 CLEARING


SQL> alter database drop logfile group 2;
alter database drop logfile group 2
*
ERROR at line 1:
ORA-01156: recovery or flashback in progress may need access to files
!


DGMGRL> edit database sbfodb set state=apply-off;


SQL> alter database drop logfile group 2;
alter database drop logfile group 2
*
ERROR at line 1:
ORA-01275: Operation DROP LOGFILE is not allowed if standby file management is
automatic.


DGMGRL>edit database sbfodb set property StandbyFileManagement=manual;


SQL> alter database drop logfile group 2;
alter database drop logfile group 2
*
ERROR at line 1:
ORA-01624: log 2 needed for crash recovery of instance airdb (thread 1)
ORA-00312: online log 2 thread 1: '/U01/app/oracle/oradata/airdb/redo02_01.log'




SQL> alter database clear logfile group 2;


Database altered.


SQL> alter database drop logfile group 2;


Database altered.
SQL> select GROUP#,SEQUENCE#,BYTES/1024/1024,STATUS from v$log;


    GROUP#  SEQUENCE# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------------
         1         55             256 CURRENT
         3         51             256 CLEARING
         4         52             256 CLEARING


SQL> ALTER DATABASE ADD  LOGFILE GROUP 2 '/U01/app/oracle/oradata/airdb/redo02_01.log' SIZE 128M reuse;


Database altered.


SQL> select GROUP#,SEQUENCE#,BYTES/1024/1024,STATUS from v$log;


    GROUP#  SEQUENCE# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------------
         1         55             256 CURRENT
         2          0             128 UNUSED
         3         51             256 CLEARING
         4         52             256 CLEARING


SQL> alter database clear logfile group 3;


Database altered.


SQL> alter database drop logfile group 3;


Database altered.


SQL> alter database clear logfile group 4;


Database altered.


SQL> alter database drop logfile group 4;


Database altered.


SQL> select GROUP#,SEQUENCE#,BYTES/1024/1024,STATUS from v$log;


    GROUP#  SEQUENCE# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------------
         1         55             256 CURRENT
         2          0             128 UNUSED


SQL> ALTER DATABASE ADD  LOGFILE GROUP 3 '/U01/app/oracle/oradata/airdb/redo03_01.log' SIZE 128M reuse;


Database altered.


SQL> ALTER DATABASE ADD  LOGFILE GROUP 4 '/U01/app/oracle/oradata/airdb/redo04_01.log' SIZE 128M reuse;


Database altered.


SQL> alter database clear logfile group 1;


Database altered.


SQL> alter database drop logfile group 1;
alter database drop logfile group 1
*
ERROR at line 1:
ORA-01623: log 1 is current log for instance airdb (thread 1) - cannot drop
ORA-00312: online log 1 thread 1: '/U01/app/oracle/oradata/airdb/redo01_01.log'


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


System altered.




SQL> select GROUP#,SEQUENCE#,BYTES/1024/1024,STATUS from v$log;


    GROUP#  SEQUENCE# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------------
         1          0             256 CLEARING
         2         56             128 CURRENT
         3          0             128 UNUSED
         4          0             128 UNUSED


SQL>  alter database clear logfile group 1;


Database altered.


SQL> alter database drop logfile group 1;


Database altered.


SQL>  ALTER DATABASE ADD  LOGFILE GROUP 1 '/U01/app/oracle/oradata/airdb/redo01_01.log' SIZE 128M reuse;


Database altered.


SQL> select GROUP#,SEQUENCE#,BYTES/1024/1024,STATUS from v$log;


    GROUP#  SEQUENCE# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------------
         1          0             128 UNUSED
         2         56             128 CURRENT
         3          0             128 UNUSED
         4          0             128 UNUSED






3.备库standby redo管理
SQL> show parameter stand


NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
standby_archive_dest                 string      ?/dbs/arch
standby_file_management              string      auto
SQL> select open_mode from v$database;


OPEN_MODE
--------------------
READ ONLY WITH APPLY


SQL> select GROUP#,SEQUENCE#,BYTES/1024/1024,STATUS from v$standby_log;


    GROUP#  SEQUENCE# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------
         5          0             256 UNASSIGNED
         6         56             256 ACTIVE
         7          0             256 UNASSIGNED
         8          0             256 UNASSIGNED
         9          0             256 UNASSIGNED


SQL> alter database drop standby logfile group 5;
alter database drop standby logfile group 5
*
ERROR at line 1:
ORA-01156: recovery or flashback in progress may need access to files




DGMGRL> edit database s_airdb set state=apply-off;
Succeeded.




SQL> alter database drop standby logfile group 5;


Database altered.


SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 '/U01/app/oracle/oradata/airdb/std_redo05_01.log' SIZE 128M reuse;


Database altered.


SQL> alter database drop standby logfile group 6;
alter database drop standby logfile group 6
*
ERROR at line 1:
ORA-00261: log 6 of thread 1 is being archived or modified
ORA-00312: online log 6 thread 1:
'/U01/app/oracle/oradata/airdb/stredo06_01.log'
需要切换日志,先处理其他组


SQL> alter database drop standby logfile group 7;


Database altered.


SQL> alter database drop standby logfile group 8;


Database altered.


SQL> alter database drop standby logfile group 9;


Database altered.


SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 '/U01/app/oracle/oradata/airdb/std_redo07_01.log' SIZE 128M reuse;
Database altered.
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 8 '/U01/app/oracle/oradata/airdb/std_redo08_01.log' SIZE 128M reuse;
Database altered.
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 9 '/U01/app/oracle/oradata/airdb/std_redo09_01.log' SIZE 128M reuse;
Database altered.




SQL> select GROUP#,SEQUENCE#,BYTES/1024/1024,STATUS from v$standby_log;


    GROUP#  SEQUENCE# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------
         5          0             128 UNASSIGNED
         6         56             256 ACTIVE
         7          0             128 UNASSIGNED
         8          0             128 UNASSIGNED
         9          0             128 UNASSIGNED


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


System altered.


SQL> select GROUP#,SEQUENCE#,BYTES/1024/1024,STATUS from v$standby_log;


    GROUP#  SEQUENCE# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------
         5         57             128 ACTIVE
         6          0             256 UNASSIGNED
         7          0             128 UNASSIGNED
         8          0             128 UNASSIGNED
         9          0             128 UNASSIGNED


SQL> alter database drop standby logfile group 6;


Database altered.


SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 '/U01/app/oracle/oradata/airdb/std_redo06_01.log' SIZE 128M reuse;


Database altered.


SQL> select GROUP#,SEQUENCE#,BYTES/1024/1024,STATUS from v$standby_log;


    GROUP#  SEQUENCE# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------
         5         57             128 ACTIVE
         6          0             128 UNASSIGNED
         7          0             128 UNASSIGNED
         8          0             128 UNASSIGNED
         9          0             128 UNASSIGNED

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26390465/viewspace-1794496/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/26390465/viewspace-1794496/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值