ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 在RAC中用NID修改数据库名称

在RAC中用NID修改数据库名称

原创 Linux操作系统 作者:space6212 时间:2019-06-16 17:00:07 0 删除 编辑
在rac中修改db_name的步骤与单实例步骤差不多,主要是要修改一些与cluster相关的参数。


停止所有实例,然后把其中一个实例启动到mount状态下:
SQL> startup mount
ORACLE instance started.

Total System Global Area 1476395008 bytes
Fixed Size 2030200 bytes
Variable Size 268436872 bytes
Database Buffers 1191182336 bytes
Redo Buffers 14745600 bytes
Database mounted.

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options

尝试用NID修改数据库名称:
bash-3.00$ nid target=sys/testrac dbname=pretrade logfile=~/nid1.log

查看日志:
bash-3.00$ more nid1.log

DBNEWID: Release 10.2.0.3.0 - Production on 星期四 9月 27 23:00:44 2007

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

Connected to database TRADEDB (DBID=4181457554)

NID-00120: Database should be mounted exclusively


Change of database name failed during validation - database is intact.
DBNEWID - Completed with validation errors.

发现有报错,这个因为当前数据库是rac,需要修改cluster_database=false,这也就是用nid修改rac数据库名称与修改单实例数据库名称的一个主要区别。

接着修改参数继续尝试:
bash-3.00$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.3.0 - Production on 星期四 9月 27 23:01:09 2007

Copyright (c) 1982, 2006, Oracle. All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options

SQL> alter system set cluster_database=false scope=spfile;

System altered.

SQL> shutdown immediate
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 1476395008 bytes
Fixed Size 2030200 bytes
Variable Size 268436872 bytes
Database Buffers 1191182336 bytes
Redo Buffers 14745600 bytes
Database mounted.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
bash-3.00$ nid target=sys/testrac dbname=pretrade logfile=~/nid2.log
bash-3.00$ vi nid2.log


DBNEWID: Release 10.2.0.3.0 - Production on 320307306332313304 9324302 27 23:03:24 2007

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

Connected to database TRADEDB (DBID=4181457554)

Connected to server version 10.2.0

Control Files in database:
+DATA/controlfile/control1
+DATA/controlfile/control2
+DATA/controlfile/control3

Changing database ID from 4181457554 to 3201410814
Changing database name from TRADEDB to PRETRADE
Control File +DATA/controlfile/control1 - modified
Control File +DATA/controlfile/control2 - modified
Control File +DATA/controlfile/control3 - modified
Datafile +DATA/datafile/system1.ora - dbid changed, wrote new name
Datafile +DATA/datafile/undotbs11.ora - dbid changed, wrote new name
......
Datafile +DATA/datafile/sysaux2.ora - dbid changed, wrote new name
Datafile +DATA/datafile/gpo1.ora - dbid changed, wrote new name
Datafile +DATA/datafile/gpo2.ora - dbid changed, wrote new name
Datafile +DATA/datafile/temp01.ora - dbid changed, wrote new name
Control File +DATA/controlfile/control1 - dbid changed, wrote new name
Control File +DATA/controlfile/control2 - dbid changed, wrote new name
Control File +DATA/controlfile/control3 - dbid changed, wrote new name
Instance shut down

Database name changed to PRETRADE.
Modify parameter file and generate a new password file before restarting.
Database ID for database PRETRADE changed to 3201410814.
All previous backups and archived redo logs for this database are unusable.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.

从日志可以看到,数据库名称修改成功。
重新把cluster_database设置为true,并把db_name参数修改为新的名称:
bash-3.00$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.3.0 - Production on 星期四 9月 27 23:04:19 2007

Copyright (c) 1982, 2006, Oracle. All Rights Reserved.

Connected to an idle instance.

SQL> startup mount
ORACLE instance started.

Total System Global Area 1476395008 bytes
Fixed Size 2030200 bytes
Variable Size 268436872 bytes
Database Buffers 1191182336 bytes
Redo Buffers 14745600 bytes
ORA-01103: database name 'PRETRADE' in control file is not 'TRADEDB'


SQL> alter system set db_name=pretrade scope=spfile;

System altered.

SQL> alter system set cluster_database=true scope=spfile;

System altered.

SQL> shutdown immediate
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 1476395008 bytes
Fixed Size 2030200 bytes
Variable Size 268436872 bytes
Database Buffers 1191182336 bytes
Redo Buffers 14745600 bytes
Database mounted.

最后在打开的时候open resetlogs即可。
SQL> alter database open resetlogs;

把rac环境的其他节点也启动,至此,dbname修改完成。

如果nid修改时报错:
ID-00135: There are 1 active threads

则表示有活动进程,可能原因是:
1、上次数据库不是干净关闭的
2、有其他人在操作这个数据库

最简单的办法是停止监听,然后把数据库干净关闭再做操作。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/231499/viewspace-63860/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2005-01-25

  • 博文量
    245
  • 访问量
    172111