在Oracle 11g,开启archive log模式时,默认归档目录为db_recovery_file_dest指定。此参数在pfile/spfile中可以指定:
db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
更改归档模式
需要在mount状态下,更改归档模式。
sql>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
sql>startup mount
ORACLE instance started.
--如果安装多个库,会报错,找不到句柄
exit 再用管理员进入
Total System Global Area 1258291200 bytes
Fixed Size 1219160 bytes
Variable Size 318768552 bytes
Database Buffers 922746880 bytes
Redo Buffers 15556608 bytes
Database mounted.
sql>alter database archivelog;
Database altered.
sql>alter database open;
Database altered.
sql>archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destinationUSE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 15
Next log sequence to archive 17
Current log sequence 17
更改log_archive_dest_1参数可更改归档日志目录(pfile/spfile中参数db_recovery_file_dest指定的目录将无效)
sql> alter system set log_archive_dest_1='location=/data/oracle/log1/archive_log';最后的目录名称需要为archive_log!
Linux:alter system set log_archive_dest_1='location=/u01/oracle/log/archive_log';
System altered.
sql> archive log list;
Database log modeArchive Mode
Automatic archivalEnabled
Archive destination/data/oracle/log1/archive_log
Oldest online log sequence26
Next log sequence to archive28
Current log sequence28
实际上从Oracle 10g开始,可以生成多份一样的日志,保存多个位置,以防不测,方法如下:
sql>alter system set log_archive_dest_2='location=/data/oracle/log2/archive_log';
sql> archive log list;
Database log modeArchive Mode
Automatic archivalEnabled
Archive destination/data/oracle/log2/archive_log只能看到最新设置的归档目录。
Oldest online log sequence30
Next log sequence to archive32
Current log sequence32
sql> alter system archive log current;
更新一下
System altered.
sql>select name from v$archived_log;
NAME
--------------------------------------------------------------------------------
/data/oracle/log1/archive_log1_6637_737857592.dbf
/data/oracle/log2/archive_log1_6637_737857592.dbf
2rows selected.
未试 设置为默认值
将log_archive_log设置为默认值时,归档目录将会变为?/dbs/arch。
sql> alter system set log_archive_dest_1='';
System altered.
sql> alter system set log_archive_dest_2=''
2;;号最后敲入按回车
System altered.
sql> archive log list;
Database log modeArchive Mode
Automatic archivalEnabled
Archive destination?/dbs/arch
Oldest online log sequence33
Next log sequence to archive35
Current log sequence35
sql> shutdown immediate;
重启数据库后,归档目录变回为db_recovery_file_dest指定的目录。
startup mount;
sql> archive log list;
Database log modeArchive Mode
Automatic archivalEnabled
Archive destinationUSE_DB_RECOVERY_FILE_DEST
Oldest online log sequence33
Next log sequence to archive35
Current log sequence35
sql> alter system set log_archive_max_processes = 5;
sql> alter system set log_archive_format = "archive_%t_%s_%r.log" scope=spfile;
*****************************************************************************************************************
sql>archive log list;
如果显示为ENABLE则表示已成功归档
或sql>select log_mode from v$database;
如果为ARCHIVELOG则表示已成功归档
********************************************************************************
sql> show parameter db_recovery
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /data/oracle/flash_recovery_area
db_recovery_file_dest_size big integer4231m
可以修改db_recovery_file_dest_size参数的大小
sql>alter system set db_recovery_file_dest_size=21474836480
Shutdown immediate;
Startup;
完成
以下未测试:
查看oracle数据库是否归档和修改归档模式
http://wenku.baidu.com/view/862b79d1b14e852458fb57fb.html
ORACLE11G归档清理操作方式
http://wenku.baidu.com/view/9b65e47402768e9951e7386a.html
数据库归档模式管理
http://wenku.baidu.com/view/d46089a1b0717fd5360cdc9a.html**http://baike.baidu.com/view/3431413.htm
两种方法:
1、配置RMAN自动管理ARCHIVELOG。也可在RMAN中将数据备份到磁带上,然后将过期的ARCHIVELOG删除;
2、可以手工来处理,步骤如下
1)将/oracle下的相关ARCHIVELOG日志文件移到别的文件系统下(保留一段时间的ARCHIVELOG日志即可,其他的可移走,用系统命令mv移走)。然后打包、压缩,备份到介质上,此时可将这些移出的文件删除。注意:别在原来的/oracle打包了,否则空间占满了就有些麻烦了。
2)以oracle用户登录,执行rman target /。如有多个实例此时执行rman target 用户名/密码@实例名,进入rman
3)在rman中执行
RMAN>list archivelog all; /*列出所有的归档日志文件
RMAN>crosscheck archivelog all; /*与物理归档日志文件保持同步,之前移走了一部分文件,因此执行此命令后会在/oracle目录下找不到的归档日志标记为expired
RMAN>list expired archivelog all; /*列出所有expired(过期)的归档日志文件,此时你就可看到移走的归档日志文件均被标记为expired
RMAN>delete expired archivelog all; /*在oracle中删除所有过期的expired文件
RMAN>list archivelog all; /*再列出所有的归档日志文件,就可发现移走的日志文件被删掉了
RMAN>exit /*退出
http://hi.baidu.com/xyqq163/item/b16e73c32d705f25a0b50a97
oracle数据库归档模式维护管理
一 设置为归档方式
------------------------
01.1 sql> archive log list; #查看是不是归档方式
02.2 sql> alter system set log_archive_start=true scope=spfile; #启用主动归档
03. sql> alter system set log_archive_dest='location=/oracle/ora9/oradata/arch' scope=spfile;
04. #设置归档路径
05. sql> alter system set log_archive_dest_1='location=/oracle/ora9/oradata/arch1' scope=spfile;
06. sql> alter system set log_archive_dest_2='location=/oracle/ora9/oradata/arch2' scope=spfile;
07. #如果归档到两个位置,则可以通过上边方法实现
08. sql> alter system set log_archive_format='arch_%d_%t_%r_%s.log' #设置归档日记款式
09.3 sql> shutdown immediate;
10.4 sql> startup mount; #打开控制文件,不打开数据文件
11.5 sql> alter database archivelog; #将数据库切换为归档模式
12.6 sql> alter database open; #将数据文件打开
13.7 sql> archive log list; #查看此时是否处于归档模式
14.8 查询以确定数据库位于archivelog模式中且归档过程正在运行
15.sql> select log_mode from v$database;
16.sql> select archiver from v$instance;
17.9 日志切换
18.sql> alter system switch logfile;
19.10 这次日志切换将归档写到两个目标地,
20. 1,即第二步的/oracle/ora9/oradata/arch1和/oracle/ora9/oradata/arch1,要是要对目录确认
21.
22.在oracle情况中运行如下查询:
23.sql> select name from v$archived_log;
二 设置非归档方式
------------------------------------------
01.1 sql> archive log list; #查看是否是归档方式
02.2 sql> alter system set log_archive_start=false scope=spfile; #禁用自动归档
03.3 sql> shutdown immediate;
04.4 sql> startup mount; #打开控制文件,不打开数据文件
05.5 sql> alter database noarchivelog; #将数据库切换为非归档模式
06.6 sql> alter database open; #将数据文件打开
07.7 sql> archive log list; #查看此时便处于非归档模式
日常维护常用语句:
1.查询每日归档备份大小情况:
SELECT TRUNC(FIRST_TIME) "日期",TRUNC(SUM(BLOCKS*BLOCK_SIZE)/1024/1024/1024,2) "大小(GB/DAY)" FROM V$ARCHIVED_LOG GROUP BY TRUNC(FIRST_TIME) ORDER BY 1 DESC;
2.查看归档空间占用情况:
select NAME,SPACE_LIMIT/1024/1024/1024,SPACE_USED/1024/1024/1024,NUMBER_OF_FILES from V$RECOVERY_FILE_DEST;
#查看大小单位为Gb
1.查询系统使用的是哪一组日志文件: select * from v$log; 2.查询正在使用的组所对应的日志文件: select * from v$logfile; 3.强制日志切换: alter system switch logfile; 4.查询历史日志: select * from v$log_history; 5.查询日志的归档模式: select dbid,name,created,log_mode from v$database; 6.查询归档日志的信息: select recid,stamp,thread#,sequence#,name from v$archived_log; 7.增加与删除日志文件组 alter database add logfile group 1 ('/home1/oracle/oradata/ora8i/log1a.log'),'/home2/oracle/oradata/ora8i/log1b.log') size 100M; alter database drop logfile group 1; 8.增加与删除日志成员 alter database add logfile member '/home1/oracle/oradata/ora8i/log1a.log' to group 1,'/home1/oracle/oradata/ora8i/log2a.log' to group 2; alter database drop logfile member '/home1/oracle/oradata/ora8i/log1a.log' ; 9.日志文件移动 alter database rename file '/home1/oracle/oradata/ora8i/log1a.log' to '/home2/oracle/oradata/ora8i/log1a.log'; 执行该命令之前必须保证该日志文件物理上已经移动到新目录 10.清除日志文件 alter database clear logfile '/home1/oracle/oradata/ora8i/log1a.log'; 该命令不能用删除组及组成员命令删除日志时使用
http://www.2cto.com/database/201109/104615.html