二、日志文件的OMF管理
日志文件管理参数:db_create_online_log_dest_n
db_create_online_log_dest_n:Oracle创建联机日志文件和控制文件时,在未明确指定路径的情况下的缺省路径
--查看日志文件的参数,下面是未作设置的db_create_online参数
SQL> SHOW PARAMETER db_create_online
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_create_online_log_dest_1 string
db_create_online_log_dest_2 string
db_create_online_log_dest_3 string
db_create_online_log_dest_4 string
db_create_online_log_dest_5 string
--从上面可以看出系统预留了一个日志组个成员来形成OMF,一般情况下我们仅仅需要个成员即可。因为在此设定个参数文件
--下面是未设定的情况下创建日志文件,则默认为在数据文件路径及闪回区各放一个文件,因为上述两个路径都是OMF路径,如下:
SQL> SELECT MEMBER FROM v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/redo03.log
/u01/app/oracle/oradata/orcl/redo02.log
/u01/app/oracle/oradata/orcl/redo01.log
/u01/app/oracle/oradata/orcl/ORCL/onlinelog/o1_mf_4_5vtgzjyz_.log
/u01/app/oracle/flash_recovery_area/ORCL/onlinelog/o1_mf_4_5vtgzlhb_.log
SQL> SHOW PARAMETER db_create_file_dest
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest string /u01/app/oracle/oradata/orcl
SQL> show parameter db_recovery_file_dest
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /u01/app/oracle/flash_recovery
_area
db_recovery_file_dest_size big integer 2G
--将日志文件存放到指定的disk1,disk2下面
SQL> ho mkdir /u01/app/oracle/disk1
SQL> ho mkdir /u01/app/oracle/disk2
SQL> ALTER SYSTEM SET db_create_online_log_dest_1 = '/u01/app/oracle/disk1';
System altered.
SQL> ALTER SYSTEM SET db_create_online_log_dest_2 = '/u01/app/oracle/disk2';
System altered.
SQL> ALTER DATABASE ADD logfile;
Database altered.
SQL> SELECT * FROM v$logfile; /*可以看到新的日志文件放到disk1,disk2下面*/
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- ---------------------------------------- ---
3 ONLINE /u01/app/oracle/oradata/orcl/redo03.log NO
2 ONLINE /u01/app/oracle/oradata/orcl/redo02.log NO
1 ONLINE /u01/app/oracle/oradata/orcl/redo01.log NO
4 ONLINE /u01/app/oracle/oradata/orcl/ORCL/online NO
log/o1_mf_4_5vtgzjyz_.log
4 ONLINE /u01/app/oracle/flash_recovery_area/ORCL YES
/onlinelog/o1_mf_4_5vtgzlhb_.log
5 ONLINE /u01/app/oracle/disk1/ORCL/onlinelog/o1_ NO
mf_5_5vtlpxo0_.log
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- ---------------------------------------- ---
5 ONLINE /u01/app/oracle/disk2/ORCL/onlinelog/o1_ NO
mf_5_5vtlpz4d_.log
SQL> alter database drop logfile group 5;
Database altered.
/*删除日志文件组*/
SQL> ALTER DATABASE DROP logfile GROUP 4;
Database altered.
SQL> SELECT group#,member FROM v$logfile;
GROUP# MEMBER
---------- ----------------------------------------
3 /u01/app/oracle/oradata/orcl/redo03.log
2 /u01/app/oracle/oradata/orcl/redo02.log
1 /u01/app/oracle/oradata/orcl/redo01.log
SQL> ho ls /u01/app/oracle/disk1/ORCL/onlinelog/o1_mf_5_5vtlpxo0_.log;
ls: /u01/app/oracle/disk1/ORCL/onlinelog/o1_mf_5_5vtlpxo0_.log: No such file or directory
总结:
1.当定义了db_recovery_file_dest 和db_create_file_dest路径,且没有定义db_create_online_log_dest_n的时候,
则OMF将日志文件存放在db_recovery_file_dest和db_create_file_dest路径下,而且日志组下为个成员
2.当定义了db_create_online_log_dest_1则将日志文件存放到db_create_online_log_dest_1
和db_create_file_dest路径下,且日志组下为个成员
3.当定义了db_create_online_log_dest_1和db_create_online_log_dest_2则存放到
db_create_online_log_dest_1和db_create_online_log_dest_2下
4.当定义了多个db_create_online_log_dest_n,则为每个组n个日志成员,且多路复用
5.增加日志文件的方法;
alter database add logfile;
alter database add logfile [group n];
alter database add logfile member '
' to group [n]
/*add logfile member这个方法仅使用未使用OMF的日志文件,对于已经运用了OMF的日志组,无法使用该功能添加日志文件*/
6.删除日志文件组时,对于OMF的日志文件组,其对应的物理文件同时被删除
alter database drop logfile group [n]