ORACLE RAC中SPFILE文件路径修改

[oracle@mml1 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Mar 14 19:08:23 2025
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup;
ORACLE instance started.

Total System Global Area 4999608360 bytes
Fixed Size 8906792 bytes
Variable Size 1056964608 bytes
Database Buffers 3925868544 bytes
Redo Buffers 7868416 bytes
Database mounted.
Database opened.
SQL> ALTER SYSTEM SET spfile='+DATA/EISOO/PARAMETERFILE/spfieeisoo.ora' SCOPE=SPFILE;
ALTER SYSTEM SET spfile='+DATA/EISOO/PARAMETERFILE/spfieeisoo.ora' SCOPE=SPFILE
*
ERROR at line 1:
ORA-32017: failure in updating SPFILE
ORA-32019: The parameter SPFILE cannot be updated in the server parameter file.


SQL> EXIT、

在RAC下spfile位置的修改与单节点环境不完全一致,有些地方需要特别注意,否则可能修改会失败。
SPFILE放在ASM中一个不正确的目录(+ARCH)中,现在想把它放在另外一个目录(+DATA)下。

以下是具体步骤:

1. 原spfile位置

1 SQL> show parameter spfile
2 spfile string +ARCH/spfiledorcl.ora

2. 拷贝spfile到其他目录

1 cp spfiledorcl.ora +DATA
2 copying +data/spfileorcl.ora -> +data/spfileorcl.ora

3. 修改所有节点$ORACLE_HOME/dbs/initorcl.ora下的参数文件

1 [oracle@dwdb04 dbs]$ vi initdorcl2.ora
2
3 SPFILE='+ARCH/spfiledorcl.ora'
4 替换为
5 SPFILE='+DATA/spfiledorcl.ora'

4. 通过sqlplus方式重启实例

 

1 SQL> shutdown immediate
2 SQL> startup
3
4 ORACLE instance started.
5
6 Total System Global Area 5.2429E+10 bytes
7 Fixed Size 2193872 bytes
8 Variable Size 3707766320 bytes
9 Database Buffers 4.8671E+10 bytes
10 Redo Buffers 48136192 bytes
11 Database mounted.
12 Database opened.
13
14 SQL > show parameter spfile
15
16 NAME TYPE VALUE
17
18 spfile string +DATA/spfiledorcl.ora

 

可以发现,spfile已经修改成功。

5. 但是如果用过srvctl重启数据库,发现spfile又变回来了:

 

1 oracle用户下执行
2 srvctl config database -d orcl -a
3 srvctl modify database -d orcl -p '+DATA/spfileorcl.ora'
4 srvctl config database -d orcl -a
5
6 su - grid
7 srvctl stop database -d orcl
8 srvctl start database -d orcl

6. 原因及解决

这是为什么呢?实际上在RAC环境中,我们更多时候是用srvctl来管理RAC资源,而srvctl的信息来自ocr,
包括spfile的位置信息。我们刚才那样做虽然修改了参数文件的位置,但是ocr并不知道,它还用原来的文件启动数据库。

我们可以用srvctl查看数据库的配置信息来确认:

 

 

1 [oracle@nhi-oa01 dbs]$ srvctl config database -d orcl -a
2 Database unique name: orcl
3 Database name: orcl
4 Oracle home: /u01/app/oracle/product/11.2.0/db_1
5 Oracle user: oracle
6 Spfile: +ARCH/spfileorcl.ora
7 Domain:
8 Start options: open
9 Stop options: immediate
10 Database role: PRIMARY
11 Management policy: AUTOMATIC
12 Server pools: orcl
13 Database instances: orcl1,orcl2
14 Disk Groups: DATA,ARC
15 Mount point paths:
16 Services:
17 Type: RAC
18 Database is enabled
19 Database is administrator managed

 

可以看到,SPFILE的位置指向是+ARCH。解决方法是通过srvctl修改SPFILE的位置。

 

1 srvctl modify database -d orcl -p '+DATA/spfileorcl.ora'
2
3 [oracle@nhi-oa01 dbs]$ srvctl config database -d orcl -a
4 Database unique name: orcl
5 Database name: orcl
6 Oracle home: /u01/app/oracle/product/11.2.0/db_1
7 Oracle user: oracle
8 Spfile: +ARCH/spfileorcl.ora
9 Domain:
10 Start options: open
11 Stop options: immediate
12 Database role: PRIMARY
13 Management policy: AUTOMATIC
14 Server pools: orcl
15 Database instances: orcl1,orcl2
16 Disk Groups: DATA,ARC
17 Mount point paths:
18 Services:
19 Type: RAC
20 Database is enabled
21 Database is administrator managed

 

7.总结

在RAC环境下修改spfile:
1. 需要修改$ORACLE_HOME/dbs下的相关文件,指向新文件
2. 需要用srvctl修改config信息,指向新文件

原文链接:https://blog.csdn.net/m0_38048955/article/details/115453640

THE END