Oracle principle: archiving and log files

One, online log, online log group

Oracle online redo logs are placed under /oracle/oradata/orcl, there are 3 REDO.logs, which record all operations on the database. When the user operates the database, the background process LGWR will write the redo entries in the log buffer to the redo log. When the database is unexpectedly down and restarted, the redo log can come in handy. When the database is started, it rolls before and then rolls back. Things that have been submitted before the downtime will not be lost, and things that have not been submitted will not be retained.

 The archive log file is the backup of the online redo log file. The online redo log file is also known as the online log file or the online log file.

Logs are organized through online log groups. One oracle will open two log file groups. One log group has many writable log files. When one log group is full, it will switch to the next log group to continue writing logs. When it is full, it will start to write the first log group, and it will continue in a loop. The v$log dynamic view can see the log file group information. The size of log files in the same log group is the same, but the size of different log groups can be different.

Second, the meaning of archiving and non-archiving 

 When the database is in a non-archive mode: when the online log group is switched, the log information in the full online log group (the switched log group) will be discarded. If the log is missing, the database information cannot be restored. This method can avoid instance failures, such as downtime, but cannot avoid media failures, such as hard disk damage.

When the database is in archive mode: then all logs will be kept, and the full log group will be archived to the archive directory by the background process ARCH. The user can fully restore the database in the mode again. The default archive log file path is ..\flash_recovery_area\orcl\ONLINELOG. Manually switch the archive log: alter system switch logfile; 

Third, the adjustment of the Oracle archiving method

----角色为SYSDBA----
archive log list; ---查看数据库归档状态
shutdown immediate;   --关闭数据库
startup mount;        --装载数据库
alter database archivelog; --设置归档模式,非归档为noarchivelog
alter database open;  --打开数据库
archive log list;

 

 

Four, log file, log file group, archive information query

select * from v$log  ; --查询日志组
select * from v$logfile;   --查询日志
select * from v$archived_log --查询已归档的日志

alter database add logfile member 'D:\ORACLE\ORADATA\ORCL\REDOTEST.LOG' to group 1;  --添加日志文件到组
alter database add logfile group 4 'D:\ORACLE\ORADATA\ORCL\REDOTEST.ora' size 10M;  --添加日志组
SHOW PARAMETERS log_archive_dest; --查看归档日志位置信息


archive log list; ---查看数据库归档状态
alter system switch logfile; --手动切换归档日志
 alter system set  log_archive_dest_1 = 'location=D:\oracle\testlog'; --更改归档日志路径位置

alter system set  log_archive_dest_state_9 = 'defer'; --停用归档日志9,允许用enable

When the group status is INACTIVE, the log file group can be cleared, and the status becomes Unused after clearing;

alter database clear logfile group 2; --清空日志组2的内容

 

Guess you like

Origin blog.csdn.net/superSmart_Dong/article/details/106737770
Recommended