小编给大家分享一下如何查看oracle归档日志路径1,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!
查看oracle归档日志路径
1.修改归档日志的格式
默认格式是:“ %t_%s_%r.dbf”,我们尝试将格式修改为“%t_%s_%r.arch”,这是一个静态参数,需要重新启动数据库才生效。
sys@ora10g> show parameter log_archive_format
NAME TYPE VALUE
--------------------- ----------- --------------------------------------
log_archive_format string %t_%s_%r.dbf
sys@ora10g> alter system set log_archive_format='%t_%s_%r.arch' scope=spfile;
System altered.
2.修改修改归档日志的位置
1)使用“archive log list”命令查看一下默认情况下归档日志存放的位置
sys@ora10g> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 98
Next log sequence to archive 100
Current log sequence 100
2)上面结果提到USE_DB_RECOVERY_FILE_DEST这个Archive destination,其实我们可以去掉“USE_”使用“DB_RECOVERY_FILE_DEST”得到数据库中的参数详解。
sys@ora10g> show parameter DB_RECOVERY_FILE_DEST
NAME TYPE VALUE
--------------------- ----------- --------------------------------------
db_recovery_file_dest string /oracle/app/oracle/flash_recovery_area
3)将db_recovery_file_dest参数置空
alter system set db_recovery_file_dest = '' scope=spfile;
4)以防万一,将log_archive_dest参数也置空
alter system set log_archive_dest = '' scope=spfile;
5)我们这里采用的生效参数是log_archive_dest_1,修改方法如下。请注意语法
alter system set log_archive_dest_1 = 'location=/oracle/arch/ora10g' scope=spfile;
6)重新启动数据库,使上述所有修改的参数生效。
sys@ora10g> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
sys@ora10g>
sys@ora10g> startup;
ORACLE instance started.
Total System Global Area 2.1475E+10 bytes
Fixed Size 2111160 bytes
Variable Size 2399144264 bytes
Database Buffers 1.9059E+10 bytes
Redo Buffers 14663680 bytes
Database mounted.
Database opened.
7)确认修改成功
(1)第一种确认方法:使用“archive log list”命令关注“Archive destination”信息
sys@ora10g> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oracle/arch/ora10g
Oldest online log sequence 121
Next log sequence to archive 123
Current log sequence 123
(2)第二种确认方法:手工归档一下,通过v$archived_log视图确认
sys@ora10g> alter system switch logfile;
System altered.
sys@ora10g> col NAME for a40
sys@ora10g> alter session set nls_date_format = 'yyyy-mm-dd hh34:mi:ss';
Session altered.
sys@ora10g> select recid, name, first_time from v$archived_log;
RECID NAME FIRST_TIME
---------- ---------------------------------------- -------------------
1 2009-06-06 01:38:39
2 2009-06-06 05:50:32
... 这省略之前的归档日志信息 ...
132 /oracle/arch/ora10g/1_123_688786498.arch 2009-09-20 11:26:26
8)上面的修改过程,也可以通过直接修改pfile文件达到目的
列一下修改之后的关键参数内容:
$ cat $ORACLE_HOME/dbs/initora10g.ora
这里省略不关心的其他参数
*.log_archive_format='%t_%s_%r.arch'
*.db_recovery_file_dest=''
*.log_archive_dest=''
*.log_archive_dest_1='location=/oracle/arch/ora10g'
3.修改流程介绍完毕,我们再一起讨论一些有趣的现象。
1)有趣现象一:使用log_archive_dest参数,不使用上面提到的log_archive_dest_1参数一样可以达到修改归档路径的目的
精简式列一下这个修改流程:
(1)修改归档文件格式
alter system set log_archive_format='%t_%s_%r.arch' scope=spfile;
(2)将db_recovery_file_dest置空
alter system set db_recovery_file_dest = '' scope=spfile;
(3)将log_archive_dest_1置空
alter system set log_archive_dest_1 = '' scope=spfile;
(4)启用log_archive_dest参数
alter system set log_archive_dest = '/oracle/arch/ora10g' scope=spfile;
(5)重启数据库使上面的所有参数生效
shutdown immediate;
startup;
(6)当然,上面的过程一样可以通过修改pfile的方法来完成
修改后的pfile关键参数内容如下:
*.log_archive_format='%t_%s_%r.arch'
*.db_recovery_file_dest=''
*.log_archive_dest='/oracle/arch/ora10g'
*.log_archive_dest_1=''
上面的方法一样可以达到修改归档路径的目的,不过不推荐使用log_archive_dest这个参数,在10g中,建议您使用log_archive_dest_n参数完成修改。
2)有趣现象二:如果db_recovery_file_dest和log_archive_dest两个参数同时设置,会在这两个目录中同时产生归档日志
(1)修改pfile,实验可以使用如下参数进行
*.log_archive_format='%t_%s_%r.arch'
*.db_recovery_file_dest='/oracle/app/oracle/flash_recovery_area'
*.log_archive_dest='/oracle/arch/ora10g'
*.log_archive_dest_1=''
(2)使用pfile重新启动数据库
sys@ora10g> shutdown immediate;
sys@ora10g> startup pfile = '/oracle/app/oracle/product/10.2.0/db_1/dbs/initora10g.ora';
(3)“有趣”现象出现了
sys@ora10g> alter system switch logfile;
sys@ora10g> alter system switch logfile;
sys@ora10g> col NAME for a40
sys@ora10g> alter session set nls_date_format = 'yyyy-mm-dd hh34:mi:ss';
sys@ora10g> select recid, name, first_time from v$archived_log;
RECID NAME FIRST_TIME
---------- ---------------------------------------- -------------------
137 /oracle/arch/ora10g/1_128_688786498.arch 2009-09-20 12:09:29
138 /oracle/arch/ora10g/1_129_688786498.arch 2009-09-20 12:09:29
139 /oracle/arch/ora10g/1_130_688786498.arch 2009-09-20 12:09:30
140 /oracle/app/oracle/flash_recovery_area/O 2009-09-20 12:09:30
RA10G/archivelog/2009_09_20/o1_mf_1_130_
5ccccmw6_.arc
141 /oracle/arch/ora10g/1_131_688786498.arch 2009-09-20 12:20:03
142 /oracle/app/oracle/flash_recovery_area/O 2009-09-20 12:20:03
RA10G/archivelog/2009_09_20/o1_mf_1_131_
5cccd5kt_.arc
(4)结论
两个目录都会生成归档日志,内容是一样的;
/oracle/app/oracle/flash_recovery_area目录下生成的归档文件的格式没有受log_archive_format参数影响,也就是说:log_archive_format的参数只对log_archive_dest和log_archive_dest_n生效。
3)有趣现象三:db_recovery_file_dest和log_archive_dest_n同时设置时,只有log_archive_dest_n的目录产生日志
(1)修改pfile,实验可以使用如下参数进行
*.log_archive_format='%t_%s_%r.arch'
*.db_recovery_file_dest='/oracle/app/oracle/flash_recovery_area'
*.log_archive_dest=''
*.log_archive_dest_1='location=/oracle/arch/ora10g'
(2)使用pfile重新启动数据库
sys@ora10g> shutdown immediate;
sys@ora10g> startup pfile = '/oracle/app/oracle/product/10.2.0/db_1/dbs/initora10g.ora';
(3)实验结果如下
sys@ora10g> alter system switch logfile;
sys@ora10g> alter system switch logfile;
sys@ora10g> col NAME for a40
sys@ora10g> alter session set nls_date_format = 'yyyy-mm-dd hh34:mi:ss';
sys@ora10g> select recid, name, first_time from v$archived_log;
RECID NAME FIRST_TIME
---------- ---------------------------------------- -------------------
138 /oracle/arch/ora10g/1_129_688786498.arch 2009-09-20 12:09:29
139 /oracle/arch/ora10g/1_130_688786498.arch 2009-09-20 12:09:30
140 /oracle/app/oracle/flash_recovery_area/O 2009-09-20 12:09:30
RA10G/archivelog/2009_09_20/o1_mf_1_130_
5ccccmw6_.arc
141 /oracle/arch/ora10g/1_131_688786498.arch 2009-09-20 12:20:03
142 /oracle/app/oracle/flash_recovery_area/O 2009-09-20 12:20:03
RA10G/archivelog/2009_09_20/o1_mf_1_131_
5cccd5kt_.arc
143 /oracle/arch/ora10g/1_132_688786498.arch 2009-09-20 12:20:21
144 /oracle/arch/ora10g/1_133_688786498.arch 2009-09-20 12:32:58
以上是“如何查看oracle归档日志路径1”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!