Oracle归档日志总结
1.打开归档日志
sqlplus / as sysdba
sql> shutdown immediate;
sql> startup mount; #打开控制文件,不打开数据文件
sql> alter database archivelog; #将数据库切换为归档模式
sql> alter database open; #将数据文件打开
sql> archive log list; #查看此时是否处于归档模式
查看日志模式
SQL> select log_mode from v$database;
查看归档是否启动
SQL> select archiver from v$instance;
2.禁用归档日志
sql> archive log list; #查看是否是归档方式
sql> alter system set log_archive_start=false scope=spfile;
sql> shutdown immediate;
sql> startup mount; #打开控制文件,不打开数据文件
sql> alter database noarchivelog; #将数据库切换为非归档模式
sql> alter database open; #将数据文件打开
sql> archive log list; #查看此时便处于非归档模式
3.查看是不是归档方式及归档的路径
sql> archive log list; #查看是不是归档方式
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 98
Next log sequence to archive 100
Current log sequence 100
根据上面的USE_DB_RECOVERY_FILE_DEST,来查找DB_RECOVERY_FILE_DEST
sys@ora10g> show parameter DB_RECOVERY_FILE_DEST
NAME TYPE VALUE
--------------------- ----------- --------------------------------------
db_recovery_file_dest string /Oracle/app/oracle/flash_recovery_area
4.修改归档日志的路径
sql> archive log list; #查看是不是归档方式
sql> alter system set log_archive_start=true scope=spfile; #启用主动归档
sql> alter system set log_archive_dest=''location=/oracle/ora9/oradata/arch'' scope=spfile;#设置归档路径
sql> alter system set log_archive_dest_1=''location=/oracle/ora9/oradata/arch1'' scope=spfile;
sql> alter system set log_archive_dest_2=''location=/oracle/ora9/oradata/arch2'' scope=spfile;
#如果归档到两个位置,则可以通过上边方法实现
sql> alter system set log_archive_format=''arch_%d_%t_%r_%s.log'' #设置归档日记款式
日志切换
sql> alter system switch logfile;
这次日志切换将归档写到两个目标地,
即上边的/oracle/ora9/oradata/arch1和/oracle/ora9/oradata/arch1,
5.查看现在归档日志的大小
select sum(a.BLOCK_SIZE*a.BLOCKS)/1024/1024 from v$archived_log a where a.DELETED='NO';
6.查看归档日志最大大小
show parameter db_recovery_file_dest_size;
7.设置归档日志最大值,处理归档日志满,无法启动
startup nomount;
alter system set db_recovery_file_dest_size = 4G;
alter database mount;
alter database on;
8.查看归档日志的使用率
select PERCENT_SPACE_USED from V$FLASH_RECOVERY_AREA_USAGE where file_type LIKE 'ARCHIVED LOG';
9.获取闪回区的使用率
select sum(PERCENT_SPACE_USED ) from V$RECOVERY_AREA_USAGE;