数据库归档1、查看、更改归档路径在ORACLE10G中,默认的归档路径为$ORACLE_BASE/flash_recovery_area。
对于这个路径,ORACLE有一个限制,就是默认只能有2G的空间给归档日志使用,可以使用下面两个SQL语句去查看它的限制select * from v$recovery_file_dest;show parameter db_recovery_file_dest(这个更友好直观一些)当归档日志数量大于2G时,那么就会由于没有更多的空间去容纳更多的归档日志会报无法继续归档的错误。
如:RA-19809: limit exceeded for recovery filesORA-19804: cannot reclaim 10017792 bytes disk space from 2147483648 limit ARC0: Error 19809 Creating archive log file to'/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2007_04_30/o1_mf _1_220_0_.arc'这时我们可以修改它的默认限制,比如说将它增加到5G或更多,也可以将归档路径重新置到别的路径,就不会有这个限制了。
更改限制语句如下:alter system set db_recovery_file_dest_size=5368709102;或者直接修改归档的路径即可alter system set log_archive_dest_1='location=/u01/archivelog' scope =both;2、修改归档模式sql> archive log list;sql> shutdown immediate;sql> startup mount;sql> alter database archivelog;alter database noarchivelogsql> alter database open;sql> archive log list;3、确认归档是否生效alter system switch logfile;看对应的归档位置时候有archivelog产生。
该参数已废弃,只要开启了archivelog就自动归档。
4、设置归档文件格式当数据库处理ARCHIVELOG模式时,如果进行日志切换,后台进程将自动生成归档日志。
归档日志的默认位置为%ORACLE_HOEM%\RDBMS,在Oracle 11g中,归档日志的默认文件名格式为ARC%S%_%R%T。
为了改变归档日志的位置和名称格式,必须改变相应的初始化参数。
初始化参数LOG_ARCHIVE_FORMAT用于指定归档日志的文件名称格式,设置该初始化参数时,可以指定以下匹配符:%s 日志序列号。
%S 日志序列号,但带有前导0。
%t 重做线程号。
%T 重做线程号,但带有前导0。
%a 活动ID号。
%d 数据库ID号。
%r RESETLOGS的ID值。
需要注意,在Oracle 11g中,配置归档日志文件格式时,必须带有%s,%t 和%r匹配符,其他匹配符可有可无。
配置了归档文件格式后,必须重新启动数据库。
例如:SQL> alter system set log_archive_format='%s_%t_%r.arc'scope=spfile;系统已更改。
SQL> shutdown immediate;SQL> startup修改初始化参数LOG_ARCHIVE_FORMAT并重启数据库后,实始化参数配置将会生效。
进行日志切换时,会生成该格式的归档日志文件。
5、归档模式启停1.archive log stop;2.archive log start;6、查看归档日志select name from v$archived_log;7、归档相关参数log_archive_dest &LOG_ARCHIVE_DEST_n使用log_archive_dest参数最多可设置2个归档路径,通过log_archive_dest设置一个主归档路径,通过LOG_ARCHIVE_DUPLEX_DEST 参数设置一个从归档路径。
所有的路径必须是本地的,该参数的设置格式如下:LOG_ARCHIVE_DEST = '/disk1/archive'LOG_ARCHIVE_DUPLEX_DEST = '/disk2/archive'LOG_ARCHIVE_DEST_n 参数可以设置最多10个不同的归档路径,通过设置关键词location或service,该参数指向的路径可以是本地或远程的。
LOG_ARCHIVE_DEST_1 = 'LOCATION = /disk1/archive'LOG_ARCHIVE_DEST_2 = 'LOCATION = /disk2/archive'LOG_ARCHIVE_DEST_3 = 'LOCATION = /disk3/archive'如果要归档到远程的standby数据库,可以设置service:LOG_ARCHIVE_DEST_4 = 'SERVICE = standby1'可见,这两个参数都可以设置归档路径,不同的是后者可以设置远程归档到standby端,而前者只能归档到本地,且最多同时归档到2个路径下。
log_archive_dest_n&DB_RECOVERY_FILE_DEST参数都可以用来存放归档日志,但二者的关系是:不设置log_archive_dest_n时,使用DB_RECOVERY_FILE_DEST来存文件;当设置了log_archive_dest_n时,则使用log_archive_dest_n来存放归档日志。
8、查看归档日志所占空间select * from V$FLASH_RECOVERY_AREA_USAGE;9、删除归档日志文件今天一早,同事说Oracle数据库连接不上。
用Sqlplus测试一下,报如下错:ORA-00257 archiver error. Connect internal only, until freed.原因比较明显,应该是归档日志文件太多造成磁盘或者设备空间不足。
官方的解释就基本如此:•Cause: The archiver process received an error while trying to archive a redo log. If the problem is not resolved soon, the database will stop executing transactions. The most likely cause of this message is the destination device is out of space to store the redo log file. •Action: Check the archiver trace file for a detailed description of the problem. Also, verify that the device specified in the initialization parameter ARCHIVE_LOG_DEST is set up properly for archiving.•通常,在正式的也就是生产环境下,Oracle是启用归档模式的(SQL>alter database archivelog;)。
因此,Oracle系统会不断的产生归档日志。
可以先查看一下已有的归档日志:• 1.telnet 到主机:telnet 10.10.2.41••AIX Version 5(C) Copyrights by IBM and by others 1982, 2005.login: rootroot's Password:************************************************************************** ****** ** ** Welcome to AIX Version 5.2! ** ** ** Please see the README file in /usr/lpp/bos for information pertinent to ** this release of the AIX Operating System. ** ** *************************************************************************** *****Last unsuccessful login: Thu Jul 30 00:06:26 BEIST 2009 on /dev/pts/0 from smnpcbackup Last login: Sat Aug 8 10:37:11 BEIST 2009 on /dev/pts/0 from 10.10.10.211•• 2.切换用户到oracleroot@p630_1#:/> su - oracle•• 3.进入rmanp630_1#oracle> rmanRecovery Manager: Release 9.2.0.8.0 - 64bit ProductionCopyright (c) 1995, 2002, Oracle Corporation. All rights reserved.4.连接到目标数据库RMAN> connect target /connected to target database: RAC9I (DBID=654968050)5.查看所有日志情况RMAN> list archivelog all;using target database controlfile instead of recovery catalogList of Archived Log CopiesKey Thrd Seq S Low Time Name------- ---- ------- - --------- ----960 1 522 A 01-AUG-09 /archlog1/Arch1_522.arc962 1 523 A 02-AUG-09 /archlog1/Arch1_523.arc964 1 524 A 04-AUG-09 /archlog1/Arch1_524.arc972 1 525 A 05-AUG-09 /archlog1/Arch1_525.arc967 1 526 A 06-AUG-09 /archlog1/Arch1_526.arc973 1 527 A 06-AUG-09 /archlog1/Arch1_527.arc974 1 528 A 07-AUG-09 /archlog1/Arch1_528.arc简单地,我们可以到OS下把这些物理文件delete掉。