oracle启用归档日志
Posted sorliran
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle启用归档日志相关的知识,希望对你有一定的参考价值。
1、查看归档信息
SQL> archive log list Database log mode No Archive Mode Automatic archival Disabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 244 Current log sequence 246
当前数据库未开启归档
2、设置归档目录
oracle默认使用闪回恢复区DB_RECOVERY_FILE_DEST作为归档路径
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 3882M
闪回恢复区在安装过程中有限制其大小,如果闪回恢复区满了,归档日志会无法写入而导致数据库hang住,解决办法可以增加闪回区大小或者修改归档路径
3、修改归档路径
修改log_archive_dest_1参数可修改归档日志路径(pfile/spfile中参数db_recovery_file_dest指定的目录将无效)
实际上从Oracle 10g开始,可以生成多份一样的日志,保存多个位置,以防不测。多个位置通过设置不同的log_archive_dest_n 参数实现,archive log list输出中的Archive destination路径只显示最新修改的路径。
SQL> show parameter log_archive_dest_1 NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ log_archive_dest_1 string log_archive_dest_10 string log_archive_dest_11 string log_archive_dest_12 string log_archive_dest_13 string log_archive_dest_14 string log_archive_dest_15 string log_archive_dest_16 string log_archive_dest_17 string log_archive_dest_18 string log_archive_dest_19 string
修改归档路径为/u01/app/oracle/archive_log
SQL> alter system set log_archive_dest_1=‘location=/u01/app/oracle/archive_log‘ scope=spfile; System altered.
重启生效
4、修改归档日志格式
SQL> alter system set log_archive_format=‘ARC%S_%R.%T_%D.dbf‘ scope=spfile; System altered.
重启生效
5、开启归档
需要在mount状态下开启数据库归档
重启至mount
SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> startup mount ORACLE instance started. Total System Global Area 1603411968 bytes Fixed Size 2213776 bytes Variable Size 989857904 bytes Database Buffers 603979776 bytes Redo Buffers 7360512 bytes Database mounted.
开启数据库归档
SQL> alter database archivelog; Database altered.
查看归档情况
SQL> archive log list Database log mode Archive Mode Automatic archival Enabled Archive destination /u01/app/oracle/archive_log Oldest online log sequence 244 Next log sequence to archive 246 Current log sequence 246
ALTER DATABASE FORCE LOGGING;
开启强制归档
打开数据库
SQL> alter database open; Database altered.
6、确认数据库为归档模式
SQL> select log_mode from v$database; LOG_MODE ------------ ARCHIVELOG SQL> select archiver from v$instance; ARCHIVE ------- STARTED
7、强制日志切换
先查看当前归档日志视图和归档日志路径:
SQL> select name from v$archived_log; no rows selected
[[email protected] archive_log]$ ll total 0
没有归档日志
下面执行强制日志切换
SQL> alter system switch logfile; System altered.
再次查看视图
SQL> select name from v$archived_log; NAME -------------------------------------------------------------------------------- /u01/app/oracle/archive_log/ARC0000000246_0963417259.0001_6833bc69.dbf
有归档日志产生,验证成功
//TODO
RMAN归档日志清理
以上是关于oracle启用归档日志的主要内容,如果未能解决你的问题,请参考以下文章