Docs/数据库/oracle/归档日志处理.md

123 lines
No EOL
2.5 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 查看归档日志使用情况
```sql
sqlplus / as sysdba
select * from v$recovery_file_dest;
select * from V$FLASH_RECOVERY_AREA_USAGE;
```
## 查询日志目录位置
```sql
show parameter recover;
```
## 计算fast_recovery_area已经占用的空间
```sql
select sum(percent_space_used)*3/100 from v$flash_recovery_area_usage;
```
## 修改fast_recovery_aread的空间
```sql
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE=8g;
```
## rman清理日志
```sql
rman target /
```
## 删除过期归档日志
```sql
crosscheck archivelog all;
delete expired archivelog all;
```
## 删除昨天以前的归档日志
```sql
delete noprompt archivelog until time 'sysdate-1';
```
# 其他
## 显示rman配置
```sql
show all;
```
## 报告目标数据库的物理结构
```sql
report schema;
```
## 报告陈旧备份
```sql
report obsolete;
```
## 报告不可恢复的数据文件
```sql
report unrecoverable;
```
## 列出备份信息
```sql
list backup;
list backup summary;
list backup of database;
list backup of tablespace table_name;
list backup of controlfile;
list backup of spfile;
list backupset id;
```
## 校验备份
```sql
crosscheck backup;
crosscheck backup of database;
crosscheck backup of tablespace system;
crosscheck backup of controlfile;
crosscheck backup of spfile;
crosscheck backup of archivelog all;
```
## 校验没有备份过的归档日志
```sql
crosscheck archivelog all;
delete noprompt expired archivelog all;
```
## 刪除所有的Archivelog files
```sql
delete archivelog all; 
```
## 強制刪除昨天以前的archivelog files
```sql
delete force archivelog until time 'sysdate -1';
delete noprompt force archivelog until time 'sysdate -2';
```
## 刪除所有过期的Archivelog files
```sql
delete expired archivelog all;
```
## 删除陈旧备份
```sql
delete obsolete;
delete noprompt obsolete;
```
## 删除所有expired的备份包括归档日志、控制文件、备份聚
```sql
delete expired backup;
```
## 删除所有备份
```sql
delete backup;
```
## 改为长期备份
```sql
change backupset id unavailable;
change backupset id keep forever logs;
change backupset id keep until time 'sysdate+30' logs;
change backupset id nokeep;
```
## 改为基于时间的备份
```sql
configure retention policy to recovery window of 30 days;
```
## 改为基于冗余数量的备份
```sql
configure retention policy to redundancy n ;
```
## 取消备份保留策略
```sql
configure retention policy to none;
```
## 设置归档日志存放在其它位置
```sql
set archivelog destination to 'e: emp';
```