11G开启归档模式
在oracle 11g,开启archive log模式时,默认归档目录为db_recovery_file_dest指定。此参数在pfile/spfile中可以指定:
db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
更改归档模式
需要在mount状态下,更改归档模式。
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 1258291200 bytes
Fixed Size 1219160 bytes
Variable Size 318768552 bytes
Database Buffers 922746880 bytes
Redo Buffers 15556608 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 15
Next log sequence to archive 17
Current log sequence 17
更改归档日志目录
更改log_archive_dest_1参数可更改归档日志目录(pfile/spfile中参数db_recovery_file_dest指定的目录将无效)
SQL> alter system set log_archive_dest_1='location=/data/oracle/log1/archive_log'; 最后的目录名称需要为archive_log!
System altered.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /data/oracle/log1/archive_log
Oldest online log sequence 26
Next log sequence to archive 28
Current log sequence 28
实际上从Oracle 10g开始,可以生成多份一样的日志,保存多个位置,以防不测,方法如下:
SQL>alter system set log_archive_dest_2='location=/data/oracle/log2/archive_log';
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /data/oracle/log2/archive_log 只能看到最新设置的归档目录。
Oldest online log sequence 30
Next log sequence to archive 32
Current log sequence 32
SQL> alter system archive log current;
System altered.
SQL> select name from v$archived_log;
NAME
--------------------------------------------------------------------------------
/data/oracle/log1/archive_log1_6637_737857592.dbf
/data/oracle/log2/archive_log1_6637_737857592.dbf
2rows selected.
将log_archive_log设置为默认值时,归档目录将会变为?/dbs/arch。
SQL> alter system set log_archive_dest_1='';
System altered.
SQL> alter system set log_archive_dest_2=''
2 ; ;号最后敲入按回车
System altered.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination ?/dbs/arch
Oldest online log sequence 33
Next log sequence to archive 35
Current log sequence 35
SQL> shutdown immediat
重启数据库后,归档目录变回为db_recovery_file_dest指定的目录。
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 33
Next log sequence to archive 35
Current log sequence 35
修改日志文件命名格式:
SQL> alter system set log_archive_max_processes = 5;
SQL> alter system set log_archive_format = "archive_%t_%s_%r.log" scope=spfile;
*****************************************************************************************************************
SQL>archive log list;
如果显示为ENABLE则表示已成功归档
或 SQL>select log_mode from v$database;
如果为ARCHIVELOG则表示已成功归档
********************************************************************************
SQL> show parameter db_recovery
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /data/oracle/flash_recovery_area
db_recovery_file_dest_size big integer 4231m
可以修改db_recovery_file_dest_size参数的大小
SQL>alter system set db_recovery_file_dest_size=21474836480
评论回复