现象:
建库时忘了指定archivelog的位置,以及LOG_ARCHIVE_DEST,LOG_ARCHIVE_DEST_n,和DB_RECOVERY_FILE_DEST,oracle会自动地指向dbcreate的location,就是+DG1,为了方便管理,想将其重定向到/u99f,输入了下列命令:
SQL> alter system set log_archive_dest='/u99f' scope=both;
alter system set log_archive_dest='/u99f' scope=both
*
ERROR at line 1:
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-16018: cannot use LOG_ARCHIVE_DEST with LOG_ARCHIVE_DEST_n or
DB_RECOVERY_FILE_DEST
oracle已经提示了错误,可还是一根筋地输入:
SQL> alter system set log_archive_dest='/u99f' scope=spfile;
System altered.
重新启动实例,失败了。
原因:
og_archive_dest与log_archive_dest_n这两个参数是不能够同时设置值、共存的。
Cause: One of the following events caused an incompatibility: 1) Parameter LOG_
ARCHIVE_DEST or LOG_ARCHIVE_DUPLEX_DEST was in use when the
specified LOG_ARCHIVE_DEST_n (n = 1...31) or DB_RECOVERY_FILE_DEST
parameter was encountered while fetching initialization parameters. 2) Parameter
LOG_ARCHIVE_DEST or LOG_ARCHIVE_DUPLEX_DEST was in use when an
attempt was made to use an ALTER SYSTEM or ALTER SESSION command to
define a value for the specified LOG_ARCHIVE_DEST_n or DB_RECOVERY_
FILE_DEST parameter. 3) An ALTER SYSTEM ARCHIVE LOG START TO
command was in effect when the specified LOG_ARCHIVE_DEST_n parameter
was encountered while fetching initialization parameters. 4) An ALTER SYSTEM
ARCHIVE LOG START TO command was in effect when an attempt was made to
use an ALTER SYSTEM or ALTER SESSION command to define a value for the
specified LOG_ARCHIVE_DEST_n parameter.
解决:
oracle:Action: Eliminate any incompatible parameter definitions.等于没说。
查看spfile:[ora10g][/u01/app/oracle/product/10.2.0/db_1/dbs]$more initsales.ora
SPFILE='+DG1/sales/spfilesales.ora'
$>sqlplus /nolog
SQL> conn sys/oracle as sysdba
Connected to an idle instance.
注意:在“已连接到空闲例程”的状态下,是可以create pfile from spfile的,这点以后注意,以idle的方式连进数据库的时候就已经可以读到spfile的“内容”了,你可以"create pfile from spfile"给弄出来。
SQL>create pfile='/tmp/pfile' from SPFILE='+DG1/sales/spfilesales.ora';
File created
看一下pfile:
。。。。
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=+DG1/'
*.log_archive_dest_1='/u99f'
*.log_archive_format='%t_%s_%r.dbf'
。。。。
粗体表示冲突。
改成:
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=+DG1/'
*.log_archive_dest=''
*.log_archive_format='%t_%s_%r.dbf'
SQL> startup pfile='/tmp/wtpfile';
ORACLE instance started.
Total System Global Area 381681664 bytes
Fixed Size 1273828 bytes
Variable Size 113246236 bytes
Database Buffers 264241152 bytes
Redo Buffers 2920448 bytes
Database mounted.
Database opened.
现在instance可以启动了。
将spfile改回原状:
SQL> create spfile='+DG1/sales/spfilesales.ora' from pfile='/tmp/wtpfile';
File created.
关闭实例
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
注意:现在是以pfile启动,这时initsales.ora已经不是原来的那一行:
SPFILE='+DG1/sales/spfilesales.ora'
而变成:
[ora10g][/u01/app/oracle/product/10.2.0/db_1/dbs]$more initsales.ora
sales.__db_cache_size=264241152
sales.__java_pool_size=4194304
sales.__large_pool_size=4194304
sales.__shared_pool_size=104857600
sales.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/sales/adump'
*.background_dump_dest='/u01/app/oracle/admin/sales/bdump'
*.compatible='10.2.0.5.0'
*.control_files='+DG1/sales/controlfile/current.273.770052071'
*.core_dump_dest='/u01/app/oracle/admin/sales/cdump'
*.db_block_size=8192
*.db_create_file_dest='+DG1'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='sales'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=salesXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=+DG1/'
*.log_archive_dest='/u99f'
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=126877696
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=381681664
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/sales/udump'
如果此时重新启动实例,还是会有报错信息:
sql>startup
ORA-16019: cannot use LOG_ARCHIVE_DEST_1 with LOG_ARCHIVE_DEST or LOG_ARCHIVE_DUPLEX_DEST
这是因为上次启动是用pfile启动的,那么本次启动还是会用pfile,由于startup是没指定路径,还是会自动去找上面的initsales.ora。
注意:oracle实例启动查找文件的顺序是 spfileSID.ora-〉spfile.ora-〉initSID.ora-〉init.ora(spfile优先于pfile)。
重新更改initsales.ora:
[ora10g][/u01/app/oracle/product/10.2.0/db_1/dbs]$vi initsales.ora
加入:
SPFILE='+DG1/sales/spfilesales.ora',save,重启instance成功。
查看是否是以spfile启动:
SQL> Select isspecified,count(*) from v$spparameter group by isspecified;
ISSPECIFIED COUNT(*)
------------ ----------
TRUE 23
FALSE 237
如果isspecified里有true,表明用spfile进行了指定配置
至此,救赎成功。