Oracle开启归档日志

Posted DATA数据猿

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle开启归档日志相关的知识,希望对你有一定的参考价值。

Oracle开启归档日志

  初次安装Oracle数据,没有特殊调整的情况下,归档日志默认是NoArchivelog模式。当数据库未开启归档日志时,Oracle不会归档联机重做日志文件。因此,当在线重做日志文件满时,会被覆盖掉。这样会导致在数据库需要恢复的时候,没有旧的归档日志,就没办法恢复。

[oracle@ea9446c43596 /]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Tue Dec 6 13:25:24 2022

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select log_mode from v$database;

LOG_MODE
------------
NOARCHIVELOG

1 关闭数据库

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

2 数据库以挂载模式打开

SQL> startup mount
ORACLE instance started.

Total System Global Area 1603411968 bytes
Fixed Size                  2213776 bytes
Variable Size             402655344 bytes
Database Buffers         1191182336 bytes
Redo Buffers                7360512 bytes
Database mounted.

3 使数据库处于归档模式

SQL> alter database archivelog;

Database altered.

4 打开数据库

SQL> alter database open;

Database altered.

5 修改归档日志存储路径

自行创建归档日志文件夹

[oracle@ea9446c43596 /]$ cd /home/oracle/app/oracle/oradata/
[oracle@ea9446c43596 oradata]$ mkdir archlogs
[oracle@ea9446c43596 oradata]$ cd helowin/ & pwd
[1] 1167
/home/oracle/app/oracle/oradata


alter system set log_archive_dest_1='location=/home/oracle/app/oracle/oradata/archlogs';

修改归档日志存储路径

SQL> alter system set log_archive_dest_1='location=/home/oracle/app/oracle/oradata/archlogs';

System altered.

6 查看归档日志状态

SQL> select log_mode from v$database;

LOG_MODE
------------
ARCHIVELOG

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/app/oracle/oradata/archlogs
Oldest online log sequence     1
Next log sequence to archive   2
Current log sequence           2

7 查看归档日志

暂时不清楚Oracle生成归档日志的规则;

第二天查看时,已经在对应目录生成归档日志

RMAN> list archivelog all;

using target database control file instead of recovery catalog
List of Archived Log Copies for database with db_unique_name HELOWIN
=====================================================================

Key     Thrd Seq     S Low Time
------- ---- ------- - ---------
1       1    2       A 06-DEC-22
        Name: /home/oracle/app/oracle/oradata/archlogs/1_2_900206934.dbf

以上是关于Oracle开启归档日志的主要内容,如果未能解决你的问题,请参考以下文章

Oracle 开启归档日志以及关闭归档日志

Oracle RMAN删除归档日志脚本

Oracle RMAN删除归档日志脚本

oracle 日志文件丢了,怎么解决? 开启了归档日志!

oracle 删除归档日志

oracle rac 11g修改开启归档并修改归档日志路径