Chinaunix首页 | 论坛 | 博客
  • 博客访问: 168956
  • 博文数量: 137
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 30
  • 用 户 组: 普通用户
  • 注册时间: 2019-01-10 10:08
文章分类
文章存档

2008年(137)

我的朋友

分类: Oracle

2008-06-05 11:56:21

1,切换日志文件:
    1.1, 切换前:
    SQL> select group#,sequence#,bytes,members,status from v$log;

    GROUP#  SEQUENCE#      BYTES    MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
         1        215   52428800          1 CURRENT
         2        213   52428800          1 INACTIVE
         3        214   52428800          1 INACTIVE
    1.2 切换日志文件
        SQL> alter system switch logfile;
    1.3 切换后:
    SQL> select group#,sequence#,bytes,members,status from v$log;

    GROUP#  SEQUENCE#      BYTES    MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
         1        215   52428800          1 ACTIVE
         2        216   52428800          1 CURRENT
         3        214   52428800          1 INACTIVE

2,强制checkpoint:
    SQL> alter system checkpoint;

3,坚持数据库日志模式(归档模式或非归档模式)
    SQL> archive log list

3,切换到归档/非归档模式
    SQL> startup mount
    SQL> alter database archivelog/noarchivelog
    SQL> alter database open;

4,显示当前归档日志组和成员:
    SQL> select GROUP#,member from v$logfile;
   
5,添加redo log组:
   5.1 SQL> alter database add logfile group 4 ('/oracle/oradata/orcl/redo04.log') size 4m;
   5.2 检查新加入的log状态
       SQL>  select group#,sequence#,bytes,members,status from v$log;

    GROUP#  SEQUENCE#      BYTES    MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
         1        215   52428800          1 INACTIVE
         2        216   52428800          1 CURRENT
         3        214   52428800          1 INACTIVE
         4          0    4194304          1 UNUSED
    (虽然这里是UNUSED的状态,但是通过切换日志文件或者数据库自动切换,该文件会被改为active状态)
   
6,添加新的文件到group 1
    SQL> alter database add logfile member '/oracle/oradata/orcl/redo05.log' to group 1;
    SQL> select group#,sequence#,bytes,members,status from v$log;

    GROUP#  SEQUENCE#      BYTES    MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
         1        219   52428800          2 CURRENT
         2        216   52428800          1 ACTIVE
         3        218   52428800          1 ACTIVE
         4        217    4194304          1 ACTIVE
    这里的group组中的member就变为2;
    SQL> select member from v$logfile where group#=1;

    MEMBER
    -----------------------------------------------------------------------------
    /oracle/oradata/orcl/redo01.log
    /oracle/oradata/orcl/redo05.log

7,给数据库文件改名
    SQL> alter database rename file '/oracle/oradata/orcl/redo05.log' to '/oracle/oradata/orcl/redo06.log';
    这里如果数据库是当前被使用的,无法改名;如果redo06.log文件不存在,数据库无法获得其信息,无法改名,数据库文件如果已经存在在数据库中,无法改名(可以先创建号固定大小的数据库文件改名)

8, 删除新增的group 4
    SQL> alter database drop logfile group 4;

9,删除新增的group 1的logfile;
    SQL> alter database drop logfile member '/oracle/oradata/orcl/redo06.log';

10,清空logfile:
    SQL> alter database clear logfile '/oracle/oradata/orcl/redo01.log'
   
    SQL>  select group#,sequence#,bytes,members,status from v$log;

    GROUP#  SEQUENCE#      BYTES    MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
         1          0   52428800          1 UNUSED
         2        220   52428800          1 CURRENT
         3        218   52428800          1 INACTIVE
阅读(3485) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~