oracle如何重做日志组

  1、查询数据库中的重做日志组

  SQL> select * from v$log;

  GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME

  1 1 64 52428800 512 1 NO CURRENT 1522229 17-MAY-19 2.8147E+14

  2 1 62 52428800 512 1 NO INACTIVE 1502072 16-MAY-19 1515210 17-MAY-19

  3 1 63 52428800 512 1 NO INACTIVE 1515210 17-MAY-19 1522229 17-MAY-19

  2、具体查看日志文件详情(位置)

  SQL> select * from v$logfile;

  GROUP# STATUS TYPE MEMBER IS_RECOVERY_DEST_FILE

  3 ONLINE /u01/app/oraData/orcl/redo03.log NO

  2 ONLINE /u01/app/oraData/orcl/redo02.log NO

  1 ONLINE /u01/app/oraData/orcl/redo01.log NO

  3、创建重做日志组

  SQL> alter database add logfile ('/u01/app/oraData/orcl/hbk01.rdo','/u01/app/oraData/orcl/hbk02.rdo') size 5M;

  Database altered.

  SQL> select * from v$logfile;

  GROUP# STATUS TYPE MEMBER IS_RECOVERY_DEST_FILE

  3 ONLINE /u01/app/oraData/orcl/redo03.log NO

  2 ONLINE /u01/app/oraData/orcl/redo02.log NO

  1 ONLINE /u01/app/oraData/orcl/redo01.log NO

  4 ONLINE /u01/app/oraData/orcl/hbk01.rdo NO

  4 ONLINE /u01/app/oraData/orcl/hbk02.rdo NO

  可以看到多了两个重做日志文件hbk01.rdo,hbk02.rdo,组的编号为4,查询v$log可以知道4号组的status为UNUSED,表示新建状态,未使用。

  SQL> select * from v$log;

  GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME

  1 1 64 52428800 512 1 NO CURRENT 1522229 17-MAY-19 2.8147E+14

  2 1 62 52428800 512 1 NO INACTIVE 1502072 16-MAY-19 1515210 17-MAY-19

  3 1 63 52428800 512 1 NO INACTIVE 1515210 17-MAY-19 1522229 17-MAY-19

  4 1 0 5242880 512 2 YES UNUSED 0 0

  可以看出我们创建重做日志组的编号默认系统产生

  我们也可以知道组编号

  SQL> alter database add logfile group 8 ('/u01/app/oraData/orcl/hbk10.rdo') size 5M;

  Database altered.

  SQL> select * from v$logfile;

  GROUP# STATUS TYPE MEMBER IS_RECOVERY_DEST_FILE

  4、删除重做日志组

  删除重做日志组只是更新了控制文件,被删除的组所拥有的重做日志文件并没有从操作系统中删除,需要手工删除,而且只能删除状态是INAVTIVE的重做日志组,如果想删除当前(CURRENT)的重做日志组,必须手工切换,可以使用alter system switch logfile,而且每个数据库至少需要有两组重做日志组,因为要循环使用。

  删除之前先查询下

  SQL> select group#,status from v$log;

  GROUP# STATUS

  1 CURRENT

  2 INACTIVE

  3 INACTIVE

  4 UNUSED

  8 UNUSED

  像组2和组3都可以删,而组1为当前使用,不能删,除非切换使用日志组。删除之前先记下文件位置,方便手动执行操作系统rm删除命令

  alter database drop logfile group 2;

  5、删除日志成员

  需要注意的是,一个日志组中至少需要保留一个成员,而且只能删除状态不是ONLINE或CURRENT的日志成员。

  SQL> select * from v$logfile;无锡正规妇科 http://www.xasgyy.net/

  GROUP# STATUS TYPE MEMBER IS_RECOVERY_DEST_FILE

  SQL> alter database drop logfile member '/u01/app/oraData/orcl/hbk10.rdo';

  alter database drop logfile member '/u01/app/oraData/orcl/hbk10.rdo'

  ERROR at line 1:

  ORA-00362: member is required to form a valid logfile in group 8

  ORA-01517: log member: '/u01/app/oraData/orcl/hbk10.rdo'

  SQL> alter database drop logfile member '/u01/app/oraData/orcl/hbk8.rdo';

  Database altered.

  7、查看重做日志是否归档

  SQL> select group#,status,archived from v$log;

  GROUP# STATUS ARC

  1 INACTIVE NO

  2 INACTIVE NO

  3 INACTIVE NO

  4 INACTIVE NO

  8 CURRENT NO

  NO表示未归档,YES表示已归档。

  因为我的没有开启归档模式,所以都显示NO

  SQL> select name,log_mode from v$database;

  NAME LOG_MODE

  ORCL NOARCHIVELOG

posted @ 2019-05-27 14:15  tiana_Z  阅读(643)  评论(0编辑  收藏  举报