11g数据库redo log file扩容

项目需求:

搭建完成数据库发现数据库只有3组,每组一个成员,每个数据文件为20M。计划把数据库组增加到5组,每组2个成员,每个数据文件扩大到200M。

1、查看数据库重做日志的现有配置:
vSQL> select group#,sequence#,members,bytes,status,archived from v$log;

    GROUP#  SEQUENCE#    MEMBERS      BYTES STATUS       ARC
---------- ---------- ---------- ---------- ---------------- ---
     1    199          1   52428800 CURRENT      NO
     2    197          1   52428800 INACTIVE         NO
     3    198          1   52428800 INACTIVE         NO

备注:发现有三组重做日志组,每组1个成员,数据文件大小为50M。

2、查看数据库每个重做日志文件存放的位置:
SQL> select * from v$logfile;
    GROUP# STATUS  TYPE    MEMBER             IS_
---------- ------- ------- ------------------------------ ---
     3     ONLINE  /ora_data/orcl/redo03.log      NO
     2     ONLINE  /ora_data/orcl/redo02.log      NO
     1     ONLINE  /ora_data/orcl/redo01.log      NO
3、在数据库中添加两个新的重做日志组,第四组和第五组,每个组2个成员,日志文件大小为200M:
SQL> alter database add LOGFILE
  2  ('/ora_data/orcl/redo04a.log',
  3  '/ora_data/orcl/redo04b.log')
  4  size 200M;

Database altered.
SQL> alter database add LOGFILE
  2  ('/ora_data/orcl/redo05a.log',
  3  '/ora_data/orcl/redo05b.log')
  4  size 200M;

Database altered.
4、添加完以后查看日志信息:
SQL> select group#,sequence#,members,bytes,status,archived from v$log;

    GROUP#  SEQUENCE#    MEMBERS      BYTES STATUS       ARC
---------- ---------- ---------- ---------- ---------------- ---
     1    199          1   52428800 CURRENT      NO
     2    197          1   52428800 INACTIVE         NO
     3    198          1   52428800 INACTIVE         NO
     4      0          2  209715200 UNUSED       YES
     5      0          2  209715200 UNUSED       YES

SQL> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER             IS_
---------- ------- ------- ------------------------------ ---
     3     ONLINE  /ora_data/orcl/redo03.log      NO
     2     ONLINE  /ora_data/orcl/redo02.log      NO
     1     ONLINE  /ora_data/orcl/redo01.log      NO
     4     ONLINE  /ora_data/orcl/redo04a.log     NO
     4     ONLINE  /ora_data/orcl/redo04b.log     NO
     5     ONLINE  /ora_data/orcl/redo05a.log     NO
     5     ONLINE  /ora_data/orcl/redo05b.log     NO

7 rows selected.
5、因为当前日志组是第一组,所以决定先删除第3组重做日志,进行更改(成员加到2个,文件大小变为200M):
SQL> alter database drop logfile group 3;

Database altered.
SQL> select group#,sequence#,members,bytes,status,archived from v$log;

    GROUP#  SEQUENCE#    MEMBERS      BYTES STATUS       ARC
---------- ---------- ---------- ---------- ---------------- ---
     1    199          1   52428800 CURRENT      NO
     2    197          1   52428800 INACTIVE         NO
     4      0          2  209715200 UNUSED       YES
     5      0          2  209715200 UNUSED       YES

SQL> alter database add logfile group 3
  2  ('/ora_data/orcl/redo03a.log',
  3  '/ora_data/orcl/redo03b.log')
  4  size 200M;

Database altered.
SQL> select group#,sequence#,members,bytes,status,archived from v$log;

    GROUP#  SEQUENCE#    MEMBERS      BYTES STATUS       ARC
---------- ---------- ---------- ---------- ---------------- ---
     1    199          1   52428800 CURRENT      NO
     2    197          1   52428800 INACTIVE         NO
     3      0          2  209715200 UNUSED       YES
     4      0          2  209715200 UNUSED       YES
     5      0          2  209715200 UNUSED       YES
6、因为当前日志组是第一组,所以决定先删除第2组重做日志,进行更改(成员加到2个,文件大小变为200M):
SQL> alter database drop logfile group 2;

Database altered.

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

    GROUP#  SEQUENCE#    MEMBERS      BYTES STATUS       ARC
---------- ---------- ---------- ---------- ---------------- ---
     1    199          1   52428800 CURRENT      NO
     3      0          2  209715200 UNUSED       YES
     4      0          2  209715200 UNUSED       YES
     5      0          2  209715200 UNUSED       YES

SQL> alter database add logfile group 2
  2  ('/ora_data/orcl/redo02a.log',
  3  '/ora_data/orcl/redo02b.log')
  4  size 200M;

Database altered.

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

    GROUP#  SEQUENCE#    MEMBERS      BYTES STATUS       ARC
---------- ---------- ---------- ---------- ---------------- ---
     1    199          1   52428800 CURRENT      NO
     2      0          2  209715200 UNUSED       YES
     3      0          2  209715200 UNUSED       YES
     4      0          2  209715200 UNUSED       YES
     5      0          2  209715200 UNUSED       YES
7、因为当前日志组是第一组,所以不能直接删除,我们需要进行手动切换后,让他变为INACTIVE状态,然后再删除并添加(成员加到2个,文件大小变为200M):
SQL> alter system switch logfile;   /手动切换重做日志组

System altered.

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

    GROUP#  SEQUENCE#    MEMBERS      BYTES STATUS       ARC
---------- ---------- ---------- ---------- ---------------- ---
     1    199          1   52428800 ACTIVE       NO
     2    200          2  209715200 CURRENT      NO
     3      0          2  209715200 UNUSED       YES
     4      0          2  209715200 UNUSED       YES
     5      0          2  209715200 UNUSED       YES

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

    GROUP#  SEQUENCE#    MEMBERS      BYTES STATUS       ARC
---------- ---------- ---------- ---------- ---------------- ---
     1    199          1   52428800 INACTIVE         NO
     2    200          2  209715200 CURRENT      NO
     3      0          2  209715200 UNUSED       YES
     4      0          2  209715200 UNUSED       YES
     5      0          2  209715200 UNUSED       YES

删除group 1重做日志组,并重建:

SQL> alter database drop logfile group 1;

Database altered.
SQL> alter database add logfile group 1
  2  ('/ora_data/orcl/redo01a.log',
  3  '/ora_data/orcl/redo01b.log')
  4  size 200M;

Database altered.

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

    GROUP#  SEQUENCE#    MEMBERS      BYTES STATUS       ARC
---------- ---------- ---------- ---------- ---------------- ---
     1      0          2  209715200 UNUSED       YES
     2    200          2  209715200 CURRENT      NO
     3      0          2  209715200 UNUSED       YES
     4      0          2  209715200 UNUSED       YES
     5      0          2  209715200 UNUSED       YES
SQL> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER                   IS_
---------- ------- ------- ---------------------------------------- ---
     3     ONLINE  /ora_data/orcl/redo03a.log           NO
     2     ONLINE  /ora_data/orcl/redo02a.log           NO
     1     ONLINE  /ora_data/orcl/redo01a.log           NO
     4     ONLINE  /ora_data/orcl/redo04a.log           NO
     4     ONLINE  /ora_data/orcl/redo04b.log           NO
     5     ONLINE  /ora_data/orcl/redo05a.log           NO
     5     ONLINE  /ora_data/orcl/redo05b.log           NO
     3     ONLINE  /ora_data/orcl/redo03b.log           NO
     2     ONLINE  /ora_data/orcl/redo02b.log           NO
     1     ONLINE  /ora_data/orcl/redo01b.log           NO
8、上述步骤做完以后,多切几次日志组:
SQL> alter system switch logfile;

System altered.

SQL> /

System altered.
SQL> /

System altered.

SQL> /

System altered.

SQL> /
System altered.

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

    GROUP#  SEQUENCE#    MEMBERS      BYTES STATUS       ARC
---------- ---------- ---------- ---------- ---------------- ---
     1    206          2  209715200 CURRENT      NO
     2    205          2  209715200 INACTIVE         NO
     3    202          2  209715200 INACTIVE         NO
     4    203          2  209715200 INACTIVE         NO
     5    204          2  209715200 INACTIVE         NO

总结:上述步骤就完成了redo log group的相关改造工作。重做日志组由3组增加到5组,每组由1个成员增加到2个成员,每个日志文件大小由20M增加为200M。

9、查看重做日志的切换次数:
column h0 format 999
column h1 format 999
column h2 format 999
column h3 format 999
column h4 format 999
column h5 format 999
column h6 format 999
column h7 format 999
column h8 format 999
column h9 format 999
column h10 format 999
column h11 format 999
column h12 format 999
column h13 format 999
column h14 format 999
column h15 format 999
column h16 format 999
column h17 format 999
column h18 format 999
column h19 format 999
column h20 format 999
column h21 format 999
column h22 format 999
column h23 format 999
column avg format 999.99
column day format a6

SELECT TRUNC (first_time) "Date", TO_CHAR (first_time, 'Dy') "Day", COUNT (1) "Total",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '00', 1, 0)) h0,
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '01', 1, 0)) "h1",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '02', 1, 0)) "h2",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '03', 1, 0)) "h3",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '04', 1, 0)) "h4",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '05', 1, 0)) "h5",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '06', 1, 0)) "h6",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '07', 1, 0)) "h7",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '08', 1, 0)) "h8",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '09', 1, 0)) "h9",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '10', 1, 0)) "h10",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '11', 1, 0)) "h11",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '12', 1, 0)) "h12",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '13', 1, 0)) "h13",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '14', 1, 0)) "h14",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '15', 1, 0)) "h15",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '16', 1, 0)) "h16",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '17', 1, 0)) "h17",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '18', 1, 0)) "h18",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '19', 1, 0)) "h19",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '20', 1, 0)) "h20",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '21', 1, 0)) "h21",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '22', 1, 0)) "h22",
SUM (DECODE (TO_CHAR (first_time, 'hh24'), '23', 1, 0)) "h23", to_char(ROUND (COUNT (1) / 24, 2),'fm99999999990.00') "Avg"
FROM gv$log_history
WHERE first_time >= trunc(SYSDATE) - 30
and thread# = inst_id
GROUP BY TRUNC (first_time), TO_CHAR (first_time, 'Dy')
ORDER BY 1 DESC;

Date            Day     Total    H0   h1   h2   h3   h4     h5   h6   h7    h8   h9  h10  h11  h12    h13  h14  h15  h16  h17  h18  h19  h20    h21  h22  h23 Avg
------------------- ------ ---------- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---------------------------------------------
2017-09-14 00:00:00 Thu         6     6    0    0    0    0      0    0    0     0    0    0    0    0      0    0    0     0    0    0    0    0      0    0    0 0.25
2017-09-13 00:00:00 Wed         4     0    0    0    0    0      0    0    0     0    0    0    0    0      0    0    0     0    0    0    0    4      0    0    0 0.17
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,686评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,668评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 158,160评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,736评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,847评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,043评论 1 291
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,129评论 3 410
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,872评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,318评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,645评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,777评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,470评论 4 333
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,126评论 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,861评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,095评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,589评论 2 362
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,687评论 2 351

推荐阅读更多精彩内容

  • 数据库基础(面试常见题) 一、数据库基础 Oracle对象有哪些? 答案:表,表空间,用户,视图,索引,存储过程,...
    莓是草莓的莓阅读 1,710评论 0 0
  • [TOC] 数据库复习 数据库应用系统开发方法 数据库基本概念 数据 定义:描述事物的符号序列 计算机中数据分为两...
    Onion99阅读 1,495评论 0 1
  • 1.数据库三范式是什么? 第一范式:表中每个字段都不能再分。 第二范式:满足第一范式并且表中的非主键字段都依赖于主...
    杰伦哎呦哎呦阅读 2,860评论 0 28
  • 第一课 表空间的创建管理 (一)表空间概述 一个数据库可以多个表空间一个表空间对应多个数据文件,一个表空间可以包含...
    __神经蛙__阅读 1,976评论 0 0
  • 表情是什么,我认为表情就是表现出来的情绪。表情可以传达很多信息。高兴了当然就笑了,难过就哭了。两者是相互影响密不可...
    Persistenc_6aea阅读 124,540评论 2 7