一步一步教你更换 Oracle 11g RAC 共享存储

前端之家收集整理的这篇文章主要介绍了一步一步教你更换 Oracle 11g RAC 共享存储前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

该环境为本人测试环境,生产环境该方案仍可使用。

一、服务器上添加新存储,根据原来的裸设备绑定方式对裸盘进行绑定。

  1. KERNEL=="sd*",PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="1ATA_VBox_HARDDISK_VB74b34d9d-2af737fa",NAME="newasm-diskb",OWNER="grid",GROUP="asmadmin",MODE="0660"
这里使用的是scsi_id进行绑定的,因此新加的盘也使用该方法

验证新存储绑定状态:

  1. [root@hadoop01 rules.d]# ll /dev/new*
  2. brw-rw----. 1 grid asmadmin 8,32 Jul 26 11:32 /dev/newasm-diskb
老存储绑定状态:

  1. [root@hadoop01 rules.d]# ll /dev/asm*
  2. brw-rw----. 1 grid asmadmin 8,16 Jul 26 11:34 /dev/asm-diskb

二、grid用户asmca创建磁盘组

newdata为新增的磁盘组。

三、迁移spfile&控制文件

3.1 srvctl stop database -d orcl关闭数据库

3.2 添加控制文件到相应路径

先nomount数据库

  1. sql> startup nomount;
  2. ORACLE instance started.
  3.  
  4. Total System Global Area 1603411968 bytes
  5. Fixed Size 2228784 bytes
  6. Variable Size 1090522576 bytes
  7. Database Buffers 503316480 bytes
  8. Redo Buffers 7344128 bytes


然后:

  1. [oracle@hadoop01 ~]$ rman target /
  2.  
  3. Recovery Manager: Release 11.2.0.3.0 - Production on Tue Jul 26 17:15:43 2016
  4.  
  5. Copyright (c) 1982,2011,Oracle and/or its affiliates. All rights reserved.
  6.  
  7. connected to target database: ORCL (not mounted)
  8.  
  9. RMAN> restore controlfile to '+NEWDATA' from '+data/orcl/controlfile/Current.260.918213121';
  10.  
  11. Starting restore at 26-JUL-16
  12. using target database control file instead of recovery catalog
  13. allocated channel: ORA_DISK_1
  14. channel ORA_DISK_1: SID=36 instance=orcl1 device type=DISK
  15.  
  16. channel ORA_DISK_1: copied control file copy
  17. Finished restore at 26-JUL-16
  18.  
  19. RMAN> restore controlfile to '+NEWDATA' from '+data/orcl/controlfile/Current.260.918213121';
  20.  
  21. Starting restore at 26-JUL-16
  22. using channel ORA_DISK_1
  23.  
  24. channel ORA_DISK_1: copied control file copy
  25. Finished restore at 26-JUL-16

3.3 创建pfile,并修改其部分内容

  1. sql> create pfile='/home/oracle/initorcl.ora' from spfile;
  2.  
  3. File created.

修改控制文件位置:

*.control_files='+DATA/orcl/controlfile/current.261.918213119','+DATA/orcl/controlfile/current.260.918213121'

修改创建数据文件默认位置:

*.db_create_file_dest='+DATA'

修改快速回复区路径:

*.db_recovery_file_dest='+DATA'

如仍存在包含老磁盘组的参数一并修改掉。

修改完成的结果如下:

  1. orcl1.__db_cache_size=503316480
  2. orcl2.__db_cache_size=587202560
  3. orcl1.__java_pool_size=16777216
  4. orcl2.__java_pool_size=16777216
  5. orcl1.__large_pool_size=16777216
  6. orcl2.__large_pool_size=16777216
  7. orcl1.__pga_aggregate_target=654311424
  8. orcl2.__pga_aggregate_target=654311424
  9. orcl1.__sga_target=956301312
  10. orcl2.__sga_target=956301312
  11. orcl1.__shared_io_pool_size=0
  12. orcl2.__shared_io_pool_size=0
  13. orcl1.__shared_pool_size=369098752
  14. orcl2.__shared_pool_size=318767104
  15. orcl1.__streams_pool_size=33554432
  16. orcl2.__streams_pool_size=0
  17. *.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
  18. *.audit_trail='db'
  19. *.cluster_database=true
  20. *.compatible='11.2.0.0.0'
  21. *.control_files='+newdata/orcl/controlfile/current.256.918234967','+newdata/orcl/controlfile/current.257.918234949'
  22. *.db_block_size=8192
  23. *.db_create_file_dest='+NEWDATA'
  24. *.db_domain=''
  25. *.db_name='orcl'
  26. *.db_recovery_file_dest='+NEWDATA'
  27. *.db_recovery_file_dest_size=104856551424
  28. *.diagnostic_dest='/u01/app/oracle'
  29. *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
  30. orcl1.instance_number=1
  31. orcl2.instance_number=2
  32. *.log_archive_format='%t_%s_%r.dbf'
  33. *.memory_target=1605369856
  34. *.open_cursors=300
  35. *.processes=150
  36. *.remote_listener='hadoop-cluster:1521'
  37. *.remote_login_passwordfile='exclusive'
  38. orcl2.thread=2
  39. orcl1.thread=1
  40. orcl1.undo_tablespace='UNDOTBS1'
  41. orcl2.undo_tablespace='UNDOTBS2'


3.4 在rac中的一个节点(此处用一号结点)指定pfile启动数据库到mount状态以验证pfile正确定,创建spfile。

sql> startup force mount pfile='/home/oracle/initorcl.ora';
ORACLE instance started.

Total System Global Area 1603411968 bytes
Fixed Size 2228784 bytes
Variable Size 1090522576 bytes
Database Buffers 503316480 bytes
Redo Buffers 7344128 bytes
Database mounted.

mount成功,创建spfile

  1. sql> create spfile='+newdata/orcl/spfileorcl.ora' from pfile='/home/oracle/initorcl.ora';
  2.  
  3. File created.

3.5 srvctl修改数据库参数文件位置。

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

3.6 关闭数据库用新的spfile以及controlfile启动一遍,验证正确性。

  1. [oracle@hadoop01 ~]$ srvctl start database -d orcl
  2. [oracle@hadoop01 ~]$
  3. [oracle@hadoop01 ~]$ sqlplus / as sysdba
  4.  
  5. sql*Plus: Release 11.2.0.3.0 Production on Tue Jul 26 17:29:22 2016
  6.  
  7. Copyright (c) 1982,Oracle. All rights reserved.
  8.  
  9.  
  10. Connected to:
  11. Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
  12. With the Partitioning,Real Application Clusters,Automatic Storage Management,OLAP,Data Mining and Real Application Testing options
  13.  
  14. sql> show parameter spfile
  15.  
  16. NAME TYPE VALUE
  17. ------------------------------------ ----------- ------------------------------
  18. spfile string +NEWDATA/orcl/spfileorcl.ora
  19. sql> show parameter control
  20.  
  21. NAME TYPE VALUE
  22. ------------------------------------ ----------- ------------------------------
  23. control_file_record_keep_time integer 7
  24. control_files string +NEWDATA/orcl/controlfile/curr
  25. ent.256.918234967,+NEWDATA/or
  26. cl/controlfile/current.257.918
  27. 234949

四、迁移数据文件

保证数据库处于归档模式。rman进行backup as copy 操作

  1. [oracle@hadoop01 ~]$ rman target /
  2.  
  3. Recovery Manager: Release 11.2.0.3.0 - Production on Tue Jul 26 17:32:21 2016
  4.  
  5. Copyright (c) 1982,Oracle and/or its affiliates. All rights reserved.
  6.  
  7. connected to target database: ORCL (DBID=1445993855)
  8.  
  9. RMAN> backup as copy database format '+NEWDATA';
  10.  
  11. Starting backup at 26-JUL-16
  12. using target database control file instead of recovery catalog
  13. allocated channel: ORA_DISK_1
  14. channel ORA_DISK_1: SID=53 instance=orcl1 device type=DISK
  15. channel ORA_DISK_1: starting datafile copy
  16. input datafile file number=00001 name=+DATA/orcl/datafile/system.256.918213045
  17. output file name=+NEWDATA/orcl/datafile/system.260.918235957 tag=TAG20160726T173235 RECID=2 STAMP=918235979
  18. channel ORA_DISK_1: datafile copy complete,elapsed time: 00:00:25
  19. channel ORA_DISK_1: starting datafile copy
  20. input datafile file number=00002 name=+DATA/orcl/datafile/sysaux.257.918213045
  21. output file name=+NEWDATA/orcl/datafile/sysaux.261.918235981 tag=TAG20160726T173235 RECID=3 STAMP=918236002
  22. channel ORA_DISK_1: datafile copy complete,elapsed time: 00:00:25
  23. channel ORA_DISK_1: starting datafile copy
  24. input datafile file number=00005 name=+DATA/orcl/datafile/example.267.918213155
  25. output file name=+NEWDATA/orcl/datafile/example.262.918236007 tag=TAG20160726T173235 RECID=4 STAMP=918236019
  26. channel ORA_DISK_1: datafile copy complete,elapsed time: 00:00:15
  27. channel ORA_DISK_1: starting datafile copy
  28. input datafile file number=00003 name=+DATA/orcl/datafile/undotbs1.258.918213045
  29. output file name=+NEWDATA/orcl/datafile/undotbs1.263.918236023 tag=TAG20160726T173235 RECID=5 STAMP=918236026
  30. channel ORA_DISK_1: datafile copy complete,elapsed time: 00:00:07
  31. channel ORA_DISK_1: starting datafile copy
  32. input datafile file number=00006 name=+DATA/orcl/datafile/undotbs2.268.918213341
  33. output file name=+NEWDATA/orcl/datafile/undotbs2.264.918236029 tag=TAG20160726T173235 RECID=6 STAMP=918236030
  34. channel ORA_DISK_1: datafile copy complete,elapsed time: 00:00:03
  35. channel ORA_DISK_1: starting datafile copy
  36. copying current control file
  37. output file name=+NEWDATA/orcl/controlfile/backup.265.918236033 tag=TAG20160726T173235 RECID=7 STAMP=918236034
  38. channel ORA_DISK_1: datafile copy complete,elapsed time: 00:00:03
  39. channel ORA_DISK_1: starting datafile copy
  40. input datafile file number=00004 name=+DATA/orcl/datafile/users.259.918213045
  41. output file name=+NEWDATA/orcl/datafile/users.266.918236035 tag=TAG20160726T173235 RECID=8 STAMP=918236035
  42. channel ORA_DISK_1: datafile copy complete,elapsed time: 00:00:01
  43. channel ORA_DISK_1: starting full datafile backup set
  44. channel ORA_DISK_1: specifying datafile(s) in backup set
  45. including current SPFILE in backup set
  46. channel ORA_DISK_1: starting piece 1 at 26-JUL-16
  47. channel ORA_DISK_1: finished piece 1 at 26-JUL-16
  48. piece handle=+NEWDATA/orcl/backupset/2016_07_26/nnsnf0_tag20160726t173235_0.267.918236037 tag=TAG20160726T173235 comment=NONE
  49. channel ORA_DISK_1: backup set complete,elapsed time: 00:00:01
  50. Finished backup at 26-JUL-16
  51.  
srvctl stop database -d orcl -o immediate

  1. [oracle@hadoop01 ~]$ srvctl stop database -d orcl -o immediate
  2. [oracle@hadoop01 ~]$ sqlplus / as sysdba
  3.  
  4. sql*Plus: Release 11.2.0.3.0 Production on Tue Jul 26 17:35:54 2016
  5.  
  6. Copyright (c) 1982,Oracle. All rights reserved.
  7.  
  8. Connected to an idle instance.
  9.  
  10. sql> startup mount
  11. ORACLE instance started.
  12.  
  13. Total System Global Area 1603411968 bytes
  14. Fixed Size 2228784 bytes
  15. Variable Size 1090522576 bytes
  16. Database Buffers 503316480 bytes
  17. Redo Buffers 7344128 bytes
  18. Database mounted.
  19. sql> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
  20. With the Partitioning,Data Mining and Real Application Testing options
  21. [oracle@hadoop01 ~]$ rman target /
  22.  
  23. Recovery Manager: Release 11.2.0.3.0 - Production on Tue Jul 26 17:36:28 2016
  24.  
  25. Copyright (c) 1982,Oracle and/or its affiliates. All rights reserved.
  26.  
  27. connected to target database: ORCL (DBID=1445993855,not open)
  28.  
  29. RMAN> switch database to copy;
  30.  
  31. using target database control file instead of recovery catalog
  32. datafile 1 switched to datafile copy "+NEWDATA/orcl/datafile/system.260.918235957"
  33. datafile 2 switched to datafile copy "+NEWDATA/orcl/datafile/sysaux.261.918235981"
  34. datafile 3 switched to datafile copy "+NEWDATA/orcl/datafile/undotbs1.263.918236023"
  35. datafile 4 switched to datafile copy "+NEWDATA/orcl/datafile/users.266.918236035"
  36. datafile 5 switched to datafile copy "+NEWDATA/orcl/datafile/example.262.918236007"
  37. datafile 6 switched to datafile copy "+NEWDATA/orcl/datafile/undotbs2.264.918236029"
  38.  
  39. RMAN>

switch完成后一定要recover一下

  1. [oracle@hadoop01 ~]$ rman target /
  2.  
  3. Recovery Manager: Release 11.2.0.3.0 - Production on Tue Jul 26 17:40:51 2016
  4.  
  5. Copyright (c) 1982,not open)
  6.  
  7. RMAN> recover database;
  8.  
  9. Starting recover at 26-JUL-16
  10. using target database control file instead of recovery catalog
  11. allocated channel: ORA_DISK_1
  12. channel ORA_DISK_1: SID=35 instance=orcl1 device type=DISK
  13.  
  14. starting media recovery
  15. media recovery complete,elapsed time: 00:00:02
  16.  
  17. Finished recover at 26-JUL-16
  18.  
  19. RMAN> exit
  20.  
  21.  
  22. Recovery Manager complete.

然后srvctl方式启动数据库

[oracle@hadoop01 ~]$ srvctl start database -d orcl

五、迁移临时文件

查看临时表空间

  1. select * from dba_tablespaces where contents = 'TEMPORARY';


查看临时文件

  1. select * from V$TEMPFILE;


为临时表空间添加临时文件

  1. sql> alter tablespace temp add tempfile size 18M;
  2.  
  3. Tablespace altered.
  4.  
由于db_create_file_dest参数设置为+newdata,所以新临时文件自动创建在newdata磁盘组上

删除老存储上的临时文件

  1. [oracle@hadoop01 ~]$ sqlplus / as sysdba
  2.  
  3. sql*Plus: Release 11.2.0.3.0 Production on Tue Jul 26 17:50:16 2016
  4.  
  5. Copyright (c) 1982,Data Mining and Real Application Testing options
  6.  
  7. sql> alter tablespace temp add tempfile size 18M;
  8.  
  9. Tablespace altered.
  10.  
  11. sql> ALTER DATABASE TEMPFILE '+DATA/orcl/tempfile/temp.266.918213143' DROP INCLUDING DATAFILES;
  12.  
  13. Database altered.

六、迁移online redo log

  1. ALTER DATABASE ADD LOGFILE THREAD 1 GROUP 5 SIZE 50M;
  2.  
  3. ALTER DATABASE ADD LOGFILE THREAD 1 GROUP 6 SIZE 50M;
  4.  
  5. ALTER DATABASE ADD LOGFILE THREAD 2 GROUP 7 SIZE 50M;
  6.  
  7. ALTER DATABASE ADD LOGFILE THREAD 2 GROUP 8 SIZE 50M;
  8.  
  9. ALTER DATABASE DROP LOGFILE GROUP 1;
  10.  
  11. ALTER DATABASE DROP LOGFILE GROUP 2;
  12.  
  13. ALTER DATABASE DROP LOGFILE GROUP 3;
  14.  
  15. ALTER DATABASE DROP LOGFILE GROUP 4;

遇到在线日志或未回档的日志采用如下命令:

alter system switch logfile;

alter system checkpoint;

七、迁移OCR&voting disk&ASM spfile

  1. [root@hadoop01 ~]# crsctl query css votedisk
  2. ## STATE File Universal Id File Name Disk group
  3. -- ----- ----------------- --------- ---------
  4. 1. ONLINE 4b1a5effbe514f46bfd6a45c20c06935 (/dev/asm-diskb) [DATA]
  5. Located 1 voting disk(s).
  6. [root@hadoop01 ~]# crsctl replace votedisk +newdata
  7. Successful addition of voting disk 350eddf550034f2bbfb890dd05d80ed0.
  8. Successful deletion of voting disk 4b1a5effbe514f46bfd6a45c20c06935.
  9. Successfully replaced voting disk group with +newdata.
  10. CRS-4266: Voting file(s) successfully replaced
  11. [root@hadoop01 ~]# crsctl query css votedisk
  12. ## STATE File Universal Id File Name Disk group
  13. -- ----- ----------------- --------- ---------
  14. 1. ONLINE 350eddf550034f2bbfb890dd05d80ed0 (/dev/newasm-diskb) [NEWDATA]
  15. Located 1 voting disk(s).

voting disk 迁移完成。

  1. [root@hadoop01 ~]# ocrcheck
  2. Status of Oracle Cluster Registry is as follows :
  3. Version : 3
  4. Total space (kbytes) : 262120
  5. Used space (kbytes) : 2864
  6. Available space (kbytes) : 259256
  7. ID : 1844481808
  8. Device/File Name : +DATA
  9. Device/File integrity check succeeded
  10.  
  11. Device/File not configured
  12.  
  13. Device/File not configured
  14.  
  15. Device/File not configured
  16.  
  17. Device/File not configured
  18.  
  19. Cluster registry integrity check succeeded
  20.  
  21. Logical corruption check succeeded
  22.  
  23. [root@hadoop01 ~]# ocrconfig -add +newdata
  24. [root@hadoop01 ~]# ocrconfig -delete +data
  25. [root@hadoop01 ~]# ocrcheck
  26. Status of Oracle Cluster Registry is as follows :
  27. Version : 3
  28. Total space (kbytes) : 262120
  29. Used space (kbytes) : 2864
  30. Available space (kbytes) : 259256
  31. ID : 1844481808
  32. Device/File Name : +newdata
  33. Device/File integrity check succeeded
  34.  
  35. Device/File not configured
  36.  
  37. Device/File not configured
  38.  
  39. Device/File not configured
  40.  
  41. Device/File not configured
  42.  
  43. Cluster registry integrity check succeeded
  44.  
  45. Logical corruption check succeeded
  46.  
  47.  
OCR迁移完成。

如遇到CRS-4602,CRS-1638 错误,传送门-->http://blog.csdn.net/u011478909/article/details/51972303

  1. sql> create pfile='/tmp/pfile.asm' from spfile;
  2.  
  3. File created.
  4.  
  5. sql> create spfile='+NEWDATA' from pfile='/tmp/pfile.asm';
  6.  
  7. File created.

八、卸载老磁盘组

asmca dismount +data磁盘组 然后将其drop


至此,oracle rac存储更换完成。

猜你在找的Oracle相关文章