1,配置归档日志的格式
当数据库处于archivelog模式时,如果进行日志切换,后台进程将自动生成归档日志。归档日志的默认位置为%oracle_home%\rdbms,在Oracle database 11g中,归档日志的默认文件名格式为arc%s_%r.%t。为了改变归档日志的位置和名称格式,必须改变相应的初始化参数。
默认的归档日志格式是
sql> show parameter log_archive_format;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_format string %a_%t_%s_%r.dbf
sql>
sql> select z1.*,'aaaaa' as name from Z1;
ID NAME
---------- -----
1 aaaaa
sql>
2,规定日志格式
初始化参数log_archive_format用于指定归档日志的文件名格式,设置该初始化参数时,可以指定以下匹配符:
-> %s:日志序列号
-> %S:日志序列号(带有前导0)。
-> %t: 重做线程编号。
-> %T: 重做线程编号(带有前导0)
-> %a:活动ID号
-> %d:数据库ID号
-> %r:RESETLOGS的值。
配置归档日志文件格式时,必须带有%s、%t和%r匹配符,而其他匹配符号可有可无。配置了归档文件格式后,必须重启数据库。
在线设置归档日志格式:
设置命令:
alter system set log_archive_format=’%T_%a_%t_%s_%r.dbf’ scope=spfile;
执行过程:
sql> alter system set log_archive_format='%a_%t_%s_%r.dbf' scope=spfile;
System altered.
sql> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
sql> startup;
ORACLE instance started.
Total System Global Area 2.0176E+10 bytes
Fixed Size 2261928 bytes
Variable Size 3422555224 bytes
Database Buffers 1.6710E+10 bytes
Redo Buffers 41463808 bytes
Database mounted.
Database opened.
sql> show parameter log_archive_format;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_format string %d_%n_%s_%t_%r.dbf
sql>
sql> alter system switch logfile;
System altered.
sql>
3,设置归档路径
datagurad里面设置:
sql> alter system set log_archive_dest_1='location=/oracle/app/oracle/archivelogs LGWR VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=powerdes_m1' scope=spfile;
System altered.
sql>
普通单实例设置
sql> alter system set log_archive_dest_1='location=/oracle/app/oracle/archivelogs' scope=spfile;
System altered.
sql> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
sql> startup;
ORACLE instance started.
Total System Global Area 2.0176E+10 bytes
Fixed Size 2261928 bytes
Variable Size 3422555224 bytes
Database Buffers 1.6710E+10 bytes
Redo Buffers 41463808 bytes
Database mounted.
Database opened.
sql> alter system switch logfile;
System altered.
sql>