oracle rac更换存储,从一个存储所有的磁盘组,将数据库迁移到另一个磁盘组,两个磁盘组所在的存储不到。使用正常的停机运维窗口,使用离线转移数据文件的方式,防止在线drop disk,然后做rebalance出错误,环境无法恢复的情况。
系统环境
oracle rac 11.2.0.4.0
linux 64
Vitual Box虚拟机
收集原有环境信息
数据文件
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DATADG/rac/datafile/system.256.921946869
+DATADG/rac/datafile/sysaux.257.921946869
+DATADG/rac/datafile/undotbs1.258.921946869
+DATADG/rac/datafile/users.259.921946869
+DATADG/rac/datafile/undotbs2.267.921947133
控制文件
SQL> desc v$controlfile;
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
+DATADG/rac/controlfile/current.261.921946973
+DATADG/rac/controlfile/current.260.921946973
临时表空间文件
SQL> desc dba_temp_files;
SQL> select file_name from dba_temp_files;
FILE_NAME
--------------------------------------------------------------------------------
+DATADG/rac/tempfile/temp.266.921947005
SQL>
归档日志文件
SQL> select name from v$archived_log;
NAME
--------------------------------------------------------------------------------
+DATADG/rac/archivelog/2016_09_07/thread_2_seq_1.273.921947361
+DATADG/rac/archivelog/2016_09_08/thread_1_seq_5.297.922014189
+DATADG/rac/archivelog/2016_09_08/thread_1_seq_6.298.922014197
+DATADG/rac/archivelog/2016_09_08/thread_1_seq_7.299.922014197
+DATADG/rac/archivelog/2016_09_08/thread_2_seq_2.300.922014203
+DATADG/rac/archivelog/2016_09_08/thread_2_seq_3.301.922014719
+DATADG/rac/archivelog/2016_09_08/thread_1_seq_8.302.922024923
+DATADG/rac/archivelog/2016_09_08/thread_1_seq_9.303.922024925
+DATADG/rac/archivelog/2016_09_08/thread_2_seq_4.304.922027075
SQL> show parameter recovery
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string +DATADG
db_recovery_file_dest_size big integer 4407M
recovery_parallelism integer 0
Steps To Do
1、修改initRAC1.ora和initRAC2.ora
修改控制文件路径,以及文件规定的所在磁盘组的路径
*.control_files=’+EXTDG/rac/controlfile/control01.dbf’,’+EXTDG/rac/controlfile/control02.dbf’
*.db_create_file_dest=’+EXTDG’
*.db_recovery_file_dest=’+EXTDG’
2、asmcmd cp文件到指定的EXTDG磁盘组
mkdir +EXTDG/rac
mkdir +EXTDG/rac/ARCHIVELOG/
mkdir +EXTDG/rac/CONTROLFILE/
mkdir +EXTDG/rac/DATAFILE/
mkdir +EXTDG/rac/ONLINELOG/
mkdir +EXTDG/rac/PARAMETERFILE/
mkdir +EXTDG/rac/TEMPFILE/
cp命令失败,不通复制带有number/incarnation文件名的文件,这个需要重新命名
所以,只有对所有使用number/incarnation的文件进程重新命令
ASMCMD [+datadg/rac/archivelog/2016_09_08] > cp * +extdg/rac/archivelog/20160908
copying +datadg/rac/archivelog/2016_09_08/thread_1_seq_5.297.922014189 -> +extdg/rac/archivelog/20160908/thread_1_seq_5.297.922014189
ASMCMD-8016: copy source ‘+datadg/rac/archivelog/2016_09_08/thread_1_seq_5.297.922014189’ and target ‘+extdg/rac/archivelog/20160908/thread_1_seq_5.297.922014189’ failed
ORA-15056: additional error message
ORA-15046: ASM file name ‘+extdg/rac/archivelog/20160908/thread_1_seq_5.297.922014189’ is not in single-file creation form
ORA-06512: at “SYS.X$DBMS_DISKGROUP”, line 415
ORA-06512: at line 3 (DBD ERROR: OCIStmtExecute
Cause and solution
The cp command failed because the ASM file name was not in a form that can be used to create an single file.File name should not contain the file number/incarnation
控制文件:
cp +DATADG/rac/controlfile/current.261.921946973 +EXTDG/rac/controlfile/control01.dbf
cp +DATADG/rac/controlfile/current.260.921946973 +EXTDG/rac/controlfile/control02.dbf
数据文件:
cp +DATADG/rac/datafile/system.256.921946869 +EXTDG/rac/datafile/system01.dbf
cp +DATADG/rac/datafile/sysaux.257.921946869 +EXTDG/rac/datafile/sysaux01.dbf
cp +DATADG/rac/datafile/undotbs1.258.921946869 +EXTDG/rac/datafile/undotbs1.dbf
cp +DATADG/rac/datafile/users.259.921946869 +EXTDG/rac/datafile/users01.dbf
cp +DATADG/rac/datafile/undotbs2.267.921947133 +EXTDG/rac/datafile/undotbs2.dbf
临时数据文件
cp +DATADG/rac/tempfile/temp.266.921947005 +EXTDG/rac/tempfile/temp01.dbf
online redolog文件
+datadg/rac/onlinelog
cp +datadg/rac/onlinelog/group_1.262.921946975 +EXTDG/rac/onlinelog/group_1a.dbf
cp +datadg/rac/onlinelog/group_1.263.921946977 +EXTDG/rac/onlinelog/group_1b.dbf
cp +datadg/rac/onlinelog/group_2.264.921946983 +EXTDG/rac/onlinelog/group_2a.dbf
cp +datadg/rac/onlinelog/group_2.265.921946985 +EXTDG/rac/onlinelog/group_2b.dbf
cp +datadg/rac/onlinelog/group_3.268.921947331 +EXTDG/rac/onlinelog/group_3a.dbf
cp +datadg/rac/onlinelog/group_3.269.921947337 +EXTDG/rac/onlinelog/group_3b.dbf
cp +datadg/rac/onlinelog/group_4.270.921947345 +EXTDG/rac/onlinelog/group_4a.dbf
cp +datadg/rac/onlinelog/group_4.271.921947349 +EXTDG/rac/onlinelog/group_4b.dbf
归档日志文件:
在保证停机之前进行多个switch,并且immediate方式关闭的,可以不进行归档转移
注:
online redo log的迁移需要使用alter datafile rename的操作,如此可正常进行冷备份,整库迁移
online redolog无法进行迁移,所以需要新建数据库online redolog,而数据库则需要使用open resetlogs方式打开了
alter database rename file ‘/u01/oradata/tydb/redo03.log’,’/u01/oradata/tydb/redo02.log’,’/u01/oradata/tydb/redo01.log’ to ‘/u01/oradata/redo03.log’,’/u01/oradata/redo02.log’,’/u01/oradata/redo01.log’;
查看online redo log信息
select group#,type,member from v$logfile;
3、启动到mount状态
su - oracle
export ORACLE_SID=RAC1
sqlplus / as sysdba
startup mount;
4、rename file路径
rename datafile(数据文件)
alter database rename file '+DATADG/rac/datafile/system.256.921946869' to '+EXTDG/rac/datafile/system01.dbf';
alter database rename file '+DATADG/rac/datafile/sysaux.257.921946869' to '+EXTDG/rac/datafile/sysaux01.dbf';
alter database rename file '+DATADG/rac/datafile/undotbs1.258.921946869' to '+EXTDG/rac/datafile/undotbs1.dbf';
alter database rename file '+DATADG/rac/datafile/users.259.921946869' to '+EXTDG/rac/datafile/users01.dbf';
alter database rename file '+DATADG/rac/datafile/undotbs2.267.921947133' to '+EXTDG/rac/datafile/undotbs2.dbf';
rename online redolog(联机重做文件)
alter database rename file '+datadg/rac/onlinelog/group_1.262.921946975' to '+EXTDG/rac/onlinelog/group_1a.dbf';
alter database rename file '+datadg/rac/onlinelog/group_1.263.921946977' to '+EXTDG/rac/onlinelog/group_1b.dbf';
alter database rename file '+datadg/rac/onlinelog/group_2.264.921946983' to '+EXTDG/rac/onlinelog/group_2a.dbf';
alter database rename file '+datadg/rac/onlinelog/group_2.265.921946985' to '+EXTDG/rac/onlinelog/group_2b.dbf';
alter database rename file '+datadg/rac/onlinelog/group_3.268.921947331' to '+EXTDG/rac/onlinelog/group_3a.dbf';
alter database rename file '+datadg/rac/onlinelog/group_3.269.921947337' to '+EXTDG/rac/onlinelog/group_3b.dbf';
alter database rename file '+datadg/rac/onlinelog/group_4.270.921947345' to '+EXTDG/rac/onlinelog/group_4a.dbf';
alter database rename file '+datadg/rac/onlinelog/group_4.271.921947349' to '+EXTDG/rac/onlinelog/group_4b.dbf';
rename tempfile(临时文件,注,这一部分也可以不进行rename,而tempfile可以通过重新创建来节省时间)
alter database rename file '+DATADG/rac/tempfile/temp.266.921947005' to '+EXTDG/rac/tempfile/temp01.dbf';
6、open正常open数据库
alter database open
查看归档文件路径
show parameter log_archive_
archive log list
归档日志文件存放到对应的目录,对于目archived log 路径改变,使用rman crosscheck等校验,然后进行catalog start with 重新加入到crontrolfile的注册信息里
crosscheck archivelog all
delete expired archivelog
catalog start with ‘+EXTDG/rac/archivelog/’
node2:
sqlplus / as sysdba
startup pfile=initRAC2.ora
create spfile from pfile;
create pfile from spfile;
至此,使用停机窗口,采用冷迁移方式完成。