如何查询数据库恢复需要用到哪些归档日志
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何查询数据库恢复需要用到哪些归档日志相关的知识,希望对你有一定的参考价值。
参考技术A 1、常用命令 SQL> show parameter log_archive_dest; SQL> archive log list; SQL> select * from V$FLASH_RECOVERY_AREA_USAGE; ARCHIVELOG 96.62 0 141 SQL> select sum(percent_space_used)*3/100 from v$flash_recovery_area_usage; 2.9904 SQL> show parameter recover; db_recovery_file_dest string /u01/oracle/flash_recovery_area db_recovery_file_dest_size big integer 2G 2、删除日志 cd $ORACLE_BASE/flash_recovery_area/orcl/archivelog 转移或清除对应的归档日志, 删除一些不用的日期目录的文件,注意保留最后几个文件在删除归档日志后,必须用RMAN维护控制文件,否则空间显示仍然不释放。 3、rman target sys/password RMAN> crosscheck archivelog all; RMAN> delete expired archivelog all; 或者 RMAN> delete archivelog until time “sysdate-1″; 4、再查 SQL> select * from V$FLASH_RECOVERY_AREA_USAGE; 5、修改大小 SQL> alter system set db_recovery_file_dest_size=4G scope=both;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
以上是关于如何查询数据库恢复需要用到哪些归档日志的主要内容,如果未能解决你的问题,请参考以下文章