Oracle 11G归档格式修改错误不能open的解决办法

2026-03-29 08:35:06

1、以下内容是自己测试总结,也许有错误:

log_archive_format知识:

%s log sequence number

%S log sequence number, zero filled    (日志序列号,左边补0)

%t thread number

%Tthread number, zero filled    (归档?号,好像不是进程号,左边补0)

%a activation ID

%d database ID   (不是数据库名,是一串数字)

%r resetlogs ID that ensures unique names are constructed for the archived log files across multiple incarnations of the database

其中%s/%t/%r 必须都包含,缺少任何一个都会报错,大小写不能同时存在。

2、自己环境下:

Linux默认归档格式:%t_%s_%r.dbf

-rw-r-----. 1 oracle oinstall     3584 May 11 15:53 1_12_879293371.dbf

windows 默认归档格式:ARC%S_%R.%T

Oracle 11G归档格式修改错误不能open的解决办法

3、修改错误:

SQL> alter system set log_archive_format='$ORACLE_SID_%t_%s_%r.dbf' scope=spfile;

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.---正常关闭

SQL> startup;

ORACLE instance started.

Total System Global Area  881037312 bytes

Fixed Size                  2218392 bytes

Variable Size             515901032 bytes

Database Buffers          356515840 bytes

Redo Buffers                6402048 bytes

Database mounted.

Database opened.                -----正常打开

SQL> show parameter log_archive_format;

SQL> alter system switch logfile;

System altered.

SQL> alter system checkpoint;

System altered.

SQL> alter system switch logfile;    

^Calter system switch logfile           

*

ERROR at line 1:

ORA-01013: user requested cancel of current operation ----------因为执行没反应,所以ctrl+c取消操作

SQL> alter system archive log current;

alter system archive log current

*

ERROR at line 1:

ORA-16038: log 1 sequence# 41 cannot be archived    ------------不能归档

ORA-00312: online log 1 thread 1: '/data/orcl/redo01.log'

ORA-00312: online log 1 thread 1: '/data/orcl/redo01b.log'

ORA-07217: sltln: environment variable cannot be evaluated.

(此时数据库仍处于打开状态,只是不能归档,重新执行第一条语句修改归档格式为正确格式,然后重启即可。)

4、如果上一步直接重启了,数据库会打不开:

SQL> startup force;

ORACLE instance started.

Total System Global Area  881037312 bytes

Fixed Size                  2218392 bytes

Variable Size             515901032 bytes

Database Buffers          356515840 bytes

Redo Buffers                6402048 bytes

Database mounted.  ----数据库已挂载

ORA-03113: end-of-file on communication channel (数据库不能打开)

Process ID: 26859

Session ID: 191 Serial number: 3

查看报警日志:

tail -50 $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace/alert_$ORACLE_SID.log

日志:

........

alter database open

Fri Jun 26 11:12:38 2015

LGWR: STARTING ARCH PROCESSES

Fri Jun 26 11:12:38 2015

ARC0 started with pid=20, OS id=27066

ARC0: Archival started

LGWR: STARTING ARCH PROCESSES COMPLETE

ARC0: STARTING ARCH PROCESSES

Errors in file /oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_26985.trc:

ORA-07217: sltln: environment variable cannot be evaluated.

Errors in file /oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_26985.trc:

ORA-16038: log 4 sequence# 36 cannot be archived

ORA-00312: online log 4 thread 1: '/data/orcl/redo04a.log'

ORA-00312: online log 4 thread 1: '/data/orcl/redo04b.log'

ORA-07217: sltln: environment variable cannot be evaluated.

USER (ospid: 26985): terminating the instance due to error 16038

-------提示log 4 sequence# 36 cannot be archived不能归档

5、解决办法:

因为归档格式是写入参数文件的,所以修改参数文件中的

log_archive_format为正确格式就能正常打开了。

SQL> create pfile from spfile;

File created.

SQL> exit

[oracle@192 dbs]$ vi initorcl.ora  

*.log_archive_format='orcl_%t_%s_%r.dbf'(格式修改为正确格式就行了)

[oracle@192 dbs]$ sqlplus / as sysdba

SQL> startup pfile=$ORACLE_HOME/dbs/initorcl.ora;

数据正常打开

SQL> show parameter log_archive_format;

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

log_archive_format                   string      orcl_%t_%s_%r.dbf

[oracle@192 arch]$ ll $ORACLE_HOME/dbs/arch--格式正确,问题解决

-rw-r-----. 1 oracle oinstall     6144 Jun 26 13:23 orcl_1_38_879293371.dbf

让后需要把pfile中的内容写回spfile

SQL>create spfile from pfile;

SQL>startup force;--OK

同样修改参数文件也可以用如下方式:

SQL> create pfile from spfile;

File created.

SQL> exit

[oracle@192 dbs]$ vi initorcl.ora  

*.log_archive_format='orcl_%t_%s_%r.dbf'(格式修改为正确格式就行了)

[oracle@192 dbs]$ sqlplus / as sysdba

SQL> create spfile from pfile;

SQL>startup;--OK

猜你喜欢