ORACLE RAC 更改实例名

规划后的实例名 fqzdb
ip
fqzdb01 192.168.2.33
fqzdb02  192.168.2.34


2.1.1 扫描磁盘(下面的操作没有特别提示,默认为两个节点都操作)
在两个节点上使用root用户执行cfgmg命令识别同步过来的存储磁盘
Method error (/usr/lib/methods/cfgpkcs11 -l pkcs11 ):
0514-040 Error initializing a device into the kernel.---------报错可忽略


扫描完成后,系统/dev目录下会生成hdisk2......hdisk33磁盘

2.1.2 磁盘修改权限
修改磁盘的权限至660,属组修改为Oracle用户组,打开no_reserve属性

root用户在/dev目录下执行:
chdev -l hdisk2 -a reserve_policy=no_reserve
chdev -l hdisk3 -a reserve_policy=no_reserve
chdev -l hdisk4 -a reserve_policy=no_reserve
chdev -l hdisk5 -a reserve_policy=no_reserve


chmod 660 rhdisk2
chmod 660 rhdisk3
chmod 660 rhdisk4
chmod 660 rhdisk5

chown grid:oinstall rhdisk2
chown grid:oinstall rhdisk3
chown grid:oinstall rhdisk4
chown grid:oinstall rhdisk5

2.1.3 Mount Disk Group
使用grid用户在两个节点上执行
[root@prodb01a /]# su - grid
[grid@prodb01a /home/grid]> sqlplus / as sysasm

SQL*Plus: Release 12.1.0.2.0 Production on Thu Feb 14 11:54:51 2019

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

SQL> select name,state from v$asm_diskgroup;

NAME STATE
------------------------------ -----------
DG_fqz_CRS MOUNTED
FQZDATADG DISMOUNTED

SQL> alter diskgroup FQZDATADG mount force;

Diskgroup altered.

2.1.4 启动数据库
Oracle用户执行
export ORACLE_SID=prodb
sqlplus / as sysdba
SQL> startup pfile='/home/oracle/pfile.ora'

2.2 修改相关名称实施步骤
(本套数据库修改名称定为 prodb )
2.2.1 数据库启动至mount状态
RAC需要首先将cluster_database置为false后重启数据库至mount状态
[oracle@prodb01a /home/oracle]> sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Thu Feb 14 11:05:48 2019

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options

[oracle@prodb01a /home/oracle]> sqlplus / as sysdba

SQL> startup mount
ORACLE instance started.

Total System Global Area 4.2950E+10 bytes
Fixed Size 7727872 bytes
Variable Size 1.3959E+10 bytes
Database Buffers 2.8857E+10 bytes
Redo Buffers 126488576 bytes
Database mounted.
SQL> quit

2.2.2 修改Dbname、Dbid
Oracle用户在1节点上使用nid命令执行
[oracle@prodb01a /home/oracle]> nid target=/ dbname=prodb

DBNEWID: Release 12.1.0.2.0 - Production on Thu Feb 14 11:11:00 2019

Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.

Connected to database PRODB (DBID=3182511783)

Connected to server version 12.1.0

Control Files in database:

Change database ID and database name PRODB to prodb? (Y/[N]) => y
...........................
Database name changed to prodb
Modify parameter file and generate a new password file before restarting.
Database ID for database prodb changed to 3926312005.
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.

2.2.3 重启数据库
[oracle@prodb01a /home/oracle]> sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Thu Feb 14 11:12:20 2019

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

Connected to an idle instance.

SQL> create pfile=’/home/oracle/pfile.ora’ from spfile=’+PRODBDATA2/PRODBST/spfilePRODB.ora’;
SQL>exit

[oracle@prodb01a /home/oracle]> vi pfile.ora
修改db_name='prodb'
去掉db_unique_name参数

SQL> startup mount pfile=’/home/oracle/pfile.ora’
ORACLE instance started.

Total System Global Area 4.2950E+10 bytes
Fixed Size 7727872 bytes
Variable Size 1.3959E+10 bytes
Database Buffers 2.8857E+10 bytes
Redo Buffers 126488576 bytes
Database mounted.

SQL> alter database open resetlogs;

Database altered.

SQL> show parameter db_name

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string prodb

2.2.4 修改pfile中的实例名
1节点实例名prodb1
2节点实例名PRODB

修改参数文件(直接使用1节点已修改好的参数文件/home/oracle/pfile.ora,因此无需执行此步骤)

[oracle@prodb01a /home/oracle]> sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Thu Feb 14 11:12:20 2019

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

Connected to an idle instance.

SQL> shut immediate

SQL>exit
[oracle@prodb01a /home/oracle]> vi pfile.ora

修改如下选项
*.db_name='prodb'
*.db_recovery_file_dest=''
prodb1.instance_number=1
PRODB.instance_number=2
prodb1.undo_tablespace='UNDOTBS1'
PRODB.undo_tablespace='UNDOTBS2'

File created.

2.2.5 修改Disk Droup Name
将diskgroup name:BKSERVERDATA 修改为FQZDATADG
Grid两个节点执行:
[grid@prodb02a /home/grid]> sqlplus / as sysasm

SQL*Plus: Release 12.1.0.2.0 Production on Thu Feb 14 14:47:50 2019

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

SQL> alter diskgroup PRODBDATA2 dismount;

Diskgroup altered.

Grid用户在1节点执行:
[grid@prodb01a/home/oracle] renamedg phase=both dgname=PRODBDATA2 newdgname=FQZDATADG verbose=true

移除原Disk Group
[grid@prodb01a/home/oracle] srvctl remove diskgroup -g PRODBDATA2 -f


重建控制文件并修改其中数据文件、日志文件路径
[oracle@prodb01a/home/oracle] vi pfile.ora
修改cluster_database=false

SQL> startup mount pfile=‘/home/oracle/pfile.ora’;

SQL> alter database backup controlfile to trace as ‘/home/oracle/con.trl’

SQL>shut immediate

SQL>startup nomount pfile=’/home/oracle/pfile.ora’;

粘贴con.trl文件中内容并编辑新的磁盘组名,在sqlplus中运行
SQL>
CREATE CONTROLFILE REUSE DATABASE "prodb" RESETLOGS FORCE LOGGING NOARCHIVELOG
MAXLOGFILES 320
MAXLOGMEMBERS 5
MAXDATAFILES 2000
MAXINSTANCES 32
MAXLOGHISTORY 2337
LOGFILE
GROUP 1 '+FQZDATADG/prodb/ONLINELOG/group_1.508.1000913293' SIZE 500M BLOCKSIZE 512,
GROUP 2 '+FQZDATADG/prodb/ONLINELOG/group_2.509.1000913293' SIZE 500M BLOCKSIZE 512,
GROUP 5 '+FQZDATADG/prodb/ONLINELOG/group_5.512.1000913295' SIZE 500M BLOCKSIZE 512,
GROUP 6 '+FQZDATADG/prodb/ONLINELOG/group_6.513.1000913295' SIZE 500M BLOCKSIZE 512,
GROUP 7 '+FQZDATADG/prodb/ONLINELOG/group_7.514.1000913295' SIZE 500M BLOCKSIZE 512,
GROUP 8 '+FQZDATADG/prodb/ONLINELOG/group_8.515.1000913295' SIZE 500M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'+FQZDATADG/PRODBst/datafile/system.350.998332449',
'+FQZDATADG/PRODBst/datafile/sysaux.358.998332809',
'+FQZDATADG/PRODBst/datafile/undotbs1.303.998331203',
'+FQZDATADG/PRODBst/datafile/undotbs2.370.998333315',
'+FQZDATADG/PRODBst/datafile/users.258.998330009',
'+FQZDATADG/PRODBst/datafile/tbs_acctchk.477.998335675',
CHARACTER SET ZHS16GBK
;

SQL>alter database open resetlogs;

[oracle@prodb01a/home/oracle] vi pfile.ora
修改cluster_database=true

SQL>create spfile=’+FQZDATADG/prodb/spfileprodb.ora’ from pfile='/home/oracle/pfile.ora';

SQL> shut immediate
ORA-01507: database not mounted
ORACLE instance shut down.

2.2.6 重新注册数据库信息
Oracle用户在一个节点上执行
srvctl add database -d prodb -o /oracle/app/oracle/12.1.0 -p ’+FQZDATADG/prodb/spfileprodb.ora’
srvctl add instance -d prodb -i prodb1 -n prodbdb01a.gzrc.com
srvctl add instance -d prodb -i PRODB -n prodbdb02a.gzrc.com
启动数据库
[Oracle@prodbdb01a/home/oracle] srvctl start database -d prodb

至此完成prodb数据库迁移切换工作

原文地址:https://www.cnblogs.com/dqliuq1215/p/13766646.html