Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3386120
  • 博文数量: 631
  • 博客积分: 10716
  • 博客等级: 上将
  • 技术积分: 8397
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-01 22:35
文章分类

全部博文(631)

文章存档

2020年(2)

2019年(22)

2018年(4)

2017年(37)

2016年(22)

2015年(1)

2013年(12)

2012年(20)

2011年(19)

2010年(20)

2009年(282)

2008年(190)

分类: Oracle

2017-01-11 18:18:06


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


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


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进行绑定的,因此新加的盘也使用该方法。


验证新存储绑定状态:


[root@hadoop01 rules.d]# ll /dev/new*


brw-rw----. 1 grid asmadmin 8, 32 Jul 26 11:32 /dev/newasm-diskb


老存储绑定状态:


[root@hadoop01 rules.d]# ll /dev/asm*


brw-rw----. 1 grid asmadmin 8, 16 Jul 26 11:34 /dev/asm-diskb


二、grid用户asmca创建磁盘组


http://img.blog.csdn.net/20160726114112221?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center


newdata为新增的磁盘组。


三、迁移spfile&控制文件


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


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


nomount数据库:


SQL> startup nomount;


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




然后:


[oracle@hadoop01 ~]$ rman target /


 


Recovery Manager: Release 11.2.0.3.0 - Production on Tue Jul 26 17:15:43 2016


 


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


 


connected to target database: ORCL (not mounted)


 


RMAN>  restore controlfile to '+NEWDATA' from '+data/orcl/controlfile/Current.260.918213121';


 


Starting restore at 26-JUL-16


using target database control file instead of recovery catalog


allocated channel: ORA_DISK_1


channel ORA_DISK_1: SID=36 instance=orcl1 device type=DISK


 


channel ORA_DISK_1: copied control file copy


Finished restore at 26-JUL-16


 


RMAN> restore controlfile to '+NEWDATA' from '+data/orcl/controlfile/Current.260.918213121';


 


Starting restore at 26-JUL-16


using channel ORA_DISK_1


 


channel ORA_DISK_1: copied control file copy


Finished restore at 26-JUL-16


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


SQL> create pfile='/home/oracle/initorcl.ora' from spfile;


 


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'


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


修改完成的结果如下:


orcl1.__db_cache_size=503316480


orcl2.__db_cache_size=587202560


orcl1.__java_pool_size=16777216


orcl2.__java_pool_size=16777216


orcl1.__large_pool_size=16777216


orcl2.__large_pool_size=16777216


orcl1.__pga_aggregate_target=654311424


orcl2.__pga_aggregate_target=654311424


orcl1.__sga_target=956301312


orcl2.__sga_target=956301312


orcl1.__shared_io_pool_size=0


orcl2.__shared_io_pool_size=0


orcl1.__shared_pool_size=369098752


orcl2.__shared_pool_size=318767104


orcl1.__streams_pool_size=33554432


orcl2.__streams_pool_size=0


*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'


*.audit_trail='db'


*.cluster_database=true


*.compatible='11.2.0.0.0'


*.control_files='+newdata/orcl/controlfile/current.256.918234967','+newdata/orcl/controlfile/current.257.918234949'


*.db_block_size=8192


*.db_create_file_dest='+NEWDATA'


*.db_domain=''


*.db_name='orcl'


*.db_recovery_file_dest='+NEWDATA'


*.db_recovery_file_dest_size=104856551424


*.diagnostic_dest='/u01/app/oracle'


*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'


orcl1.instance_number=1


orcl2.instance_number=2


*.log_archive_format='%t_%s_%r.dbf'


*.memory_target=1605369856


*.open_cursors=300


*.processes=150


*.remote_listener='hadoop-cluster:1521'


*.remote_login_passwordfile='exclusive'


orcl2.thread=2


orcl1.thread=1


orcl1.undo_tablespace='UNDOTBS1'


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


SQL> create spfile='+newdata/orcl/spfileorcl.ora' from pfile='/home/oracle/initorcl.ora';


 


File created.


 


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


[oracle@hadoop01 ~]$ srvctl modify database -d orcl -p +newdata/orcl/spfileorcl.ora


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


Database unique name: orcl


Database name: orcl


Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1


Oracle user: oracle


Spfile: +newdata/orcl/spfileorcl.ora


Domain:


Start options: open


Stop options: immediate


Database role: PRIMARY


Management policy: AUTOMATIC


Server pools: orcl


Database instances: orcl1,orcl2


Disk Groups: DATA,NEWDATA


Mount point paths:


Services:


Type: RAC


Database is administrator managed


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


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


[oracle@hadoop01 ~]$


[oracle@hadoop01 ~]$ sqlplus / as sysdba


 


SQL*Plus: Release 11.2.0.3.0 Production on Tue Jul 26 17:29:22 2016


 


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


 


 


Connected to:


Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production


With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,


Data Mining and Real Application Testing options


 


SQL> show parameter spfile


 


NAME                                TYPE      VALUE


------------------------------------ ----------- ------------------------------


spfile                              string    +NEWDATA/orcl/spfileorcl.ora


SQL> show parameter control


 


NAME                                TYPE      VALUE


------------------------------------ ----------- ------------------------------


control_file_record_keep_time       integer   7


control_files                       string    +NEWDATA/orcl/controlfile/curr


                                               ent.256.918234967, +NEWDATA/or


                                               cl/controlfile/current.257.918


                                               234949


 


四、迁移数据文件


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


[oracle@hadoop01 ~]$ rman target /


 


Recovery Manager: Release 11.2.0.3.0 - Production on Tue Jul 26 17:32:21 2016


 


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


 


connected to target database: ORCL (DBID=1445993855)


 


RMAN> backup as copy database format '+NEWDATA';


 


Starting backup at 26-JUL-16


using target database control file instead of recovery catalog


allocated channel: ORA_DISK_1


channel ORA_DISK_1: SID=53 instance=orcl1 device type=DISK


channel ORA_DISK_1: starting datafile copy


input datafile file number=00001 name=+DATA/orcl/datafile/system.256.918213045


output file name=+NEWDATA/orcl/datafile/system.260.918235957 tag=TAG20160726T173235 RECID=2 STAMP=918235979


channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25


channel ORA_DISK_1: starting datafile copy


input datafile file number=00002 name=+DATA/orcl/datafile/sysaux.257.918213045


output file name=+NEWDATA/orcl/datafile/sysaux.261.918235981 tag=TAG20160726T173235 RECID=3 STAMP=918236002


channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25


channel ORA_DISK_1: starting datafile copy


input datafile file number=00005 name=+DATA/orcl/datafile/example.267.918213155


output file name=+NEWDATA/orcl/datafile/example.262.918236007 tag=TAG20160726T173235 RECID=4 STAMP=918236019


channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15


channel ORA_DISK_1: starting datafile copy


input datafile file number=00003 name=+DATA/orcl/datafile/undotbs1.258.918213045


output file name=+NEWDATA/orcl/datafile/undotbs1.263.918236023 tag=TAG20160726T173235 RECID=5 STAMP=918236026


channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07


channel ORA_DISK_1: starting datafile copy


input datafile file number=00006 name=+DATA/orcl/datafile/undotbs2.268.918213341


output file name=+NEWDATA/orcl/datafile/undotbs2.264.918236029 tag=TAG20160726T173235 RECID=6 STAMP=918236030


channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03


channel ORA_DISK_1: starting datafile copy


copying current control file


output file name=+NEWDATA/orcl/controlfile/backup.265.918236033 tag=TAG20160726T173235 RECID=7 STAMP=918236034


channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03


channel ORA_DISK_1: starting datafile copy


input datafile file number=00004 name=+DATA/orcl/datafile/users.259.918213045


output file name=+NEWDATA/orcl/datafile/users.266.918236035 tag=TAG20160726T173235 RECID=8 STAMP=918236035


channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01


channel ORA_DISK_1: starting full datafile backup set


channel ORA_DISK_1: specifying datafile(s) in backup set


including current SPFILE in backup set


channel ORA_DISK_1: starting piece 1 at 26-JUL-16


channel ORA_DISK_1: finished piece 1 at 26-JUL-16


piece handle=+NEWDATA/orcl/backupset/2016_07_26/nnsnf0_tag20160726t173235_0.267.918236037 tag=TAG20160726T173235 comment=NONE


channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01


Finished backup at 26-JUL-16


 


srvctl stop database -d orcl -o immediate


[oracle@hadoop01 ~]$ srvctl stop database -d orcl -o immediate


[oracle@hadoop01 ~]$ sqlplus / as sysdba


 


SQL*Plus: Release 11.2.0.3.0 Production on Tue Jul 26 17:35:54 2016


 


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


 


Connected to an idle instance.


 


SQL> startup mount


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.


SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production


With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,


Data Mining and Real Application Testing options


[oracle@hadoop01 ~]$ rman target /


 


Recovery Manager: Release 11.2.0.3.0 - Production on Tue Jul 26 17:36:28 2016


 


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


 


connected to target database: ORCL (DBID=1445993855, not open)


 


RMAN> switch database to copy;


 


using target database control file instead of recovery catalog


datafile 1 switched to datafile copy "+NEWDATA/orcl/datafile/system.260.918235957"


datafile 2 switched to datafile copy "+NEWDATA/orcl/datafile/sysaux.261.918235981"


datafile 3 switched to datafile copy "+NEWDATA/orcl/datafile/undotbs1.263.918236023"


datafile 4 switched to datafile copy "+NEWDATA/orcl/datafile/users.266.918236035"


datafile 5 switched to datafile copy "+NEWDATA/orcl/datafile/example.262.918236007"


datafile 6 switched to datafile copy "+NEWDATA/orcl/datafile/undotbs2.264.918236029"


 


RMAN>


switch完成后一定要recover一下


[oracle@hadoop01 ~]$ rman target /


 


Recovery Manager: Release 11.2.0.3.0 - Production on Tue Jul 26 17:40:51 2016


 


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


 


connected to target database: ORCL (DBID=1445993855, not open)


 


RMAN> recover database;


 


Starting recover at 26-JUL-16


using target database control file instead of recovery catalog


allocated channel: ORA_DISK_1


channel ORA_DISK_1: SID=35 instance=orcl1 device type=DISK


 


starting media recovery


media recovery complete, elapsed time: 00:00:02


 


Finished recover at 26-JUL-16


 


RMAN> exit


 


 


Recovery Manager complete.


 


然后srvctl方式启动数据库。


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


五、迁移临时文件


查看临时表空间


select * from dba_tablespaces where contents = 'TEMPORARY';


 


查看临时文件


select * from V$TEMPFILE;


 


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


SQL> alter tablespace temp add tempfile size 18M;


 


Tablespace altered.


 


由于db_create_file_dest参数设置为+newdata,所以新临时文件会自动创建在newdata磁盘组上


删除老存储上的临时文件。


[oracle@hadoop01 ~]$ sqlplus / as sysdba


 


SQL*Plus: Release 11.2.0.3.0 Production on Tue Jul 26 17:50:16 2016


 


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


 


 


Connected to:


Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production


With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,


Data Mining and Real Application Testing options


 


SQL> alter tablespace temp add tempfile size 18M;


 


Tablespace altered.


 


SQL> ALTER DATABASE TEMPFILE '+DATA/orcl/tempfile/temp.266.918213143' DROP INCLUDING DATAFILES;


 


Database altered.


 


六、迁移online redo log


ALTER DATABASE ADD LOGFILE THREAD 1 GROUP 5 SIZE 50M;


 


ALTER DATABASE ADD LOGFILE THREAD 1 GROUP 6 SIZE 50M;


 


ALTER DATABASE ADD LOGFILE THREAD 2 GROUP 7 SIZE 50M;


 


ALTER DATABASE ADD LOGFILE THREAD 2 GROUP 8 SIZE 50M;


 


ALTER DATABASE DROP LOGFILE GROUP 1;


 


ALTER DATABASE DROP LOGFILE GROUP 2;


 


ALTER DATABASE DROP LOGFILE GROUP 3;


 


ALTER DATABASE DROP LOGFILE GROUP 4;



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


alter system switch logfile;


alter system checkpoint;


七、迁移OCR&voting disk&ASM spfile


[root@hadoop01 ~]# crsctl query css votedisk


##  STATE    File Universal Id                File Name Disk group


--  -----    -----------------                --------- ---------


 1. ONLINE   4b1a5effbe514f46bfd6a45c20c06935 (/dev/asm-diskb) [DATA]


Located 1 voting disk(s).


[root@hadoop01 ~]# crsctl replace votedisk +newdata


Successful addition of voting disk 350eddf550034f2bbfb890dd05d80ed0.


Successful deletion of voting disk 4b1a5effbe514f46bfd6a45c20c06935.


Successfully replaced voting disk group with +newdata.


CRS-4266: Voting file(s) successfully replaced


[root@hadoop01 ~]# crsctl query css votedisk


##  STATE    File Universal Id                File Name Disk group


--  -----    -----------------                --------- ---------


 1. ONLINE   350eddf550034f2bbfb890dd05d80ed0 (/dev/newasm-diskb) [NEWDATA]


Located 1 voting disk(s).



voting disk
迁移完成。


[root@hadoop01 ~]# ocrcheck


Status of Oracle Cluster Registry is as follows :


     Version                  :          3


     Total space (kbytes)     :     262120


     Used space (kbytes)      :       2864


     Available space (kbytes) :     259256


     ID                       : 1844481808


     Device/File Name         :      +DATA


                                    Device/File integrity check succeeded


 


                                    Device/File not configured


 


                                    Device/File not configured


 


                                    Device/File not configured


 


                                    Device/File not configured


 


     Cluster registry integrity check succeeded


 


     Logical corruption check succeeded


 


[root@hadoop01 ~]# ocrconfig -add +newdata


[root@hadoop01 ~]# ocrconfig -delete +data


[root@hadoop01 ~]# ocrcheck


Status of Oracle Cluster Registry is as follows :


     Version                  :          3


     Total space (kbytes)     :     262120


     Used space (kbytes)      :       2864


     Available space (kbytes) :     259256


     ID                       : 1844481808


     Device/File Name         :   +newdata


                                    Device/File integrity check succeeded


 


                                    Device/File not configured


 


                                    Device/File not configured


 


                                    Device/File not configured


 


                                    Device/File not configured


 


     Cluster registry integrity check succeeded


 


     Logical corruption check succeeded


 


 


OCR迁移完成。


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


SQL> create pfile='/tmp/pfile.asm' from spfile;


 


File created.


 


SQL>  create spfile='+NEWDATA' from pfile='/tmp/pfile.asm';


 


File created.


 


八、卸载老磁盘组


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


http://img.blog.csdn.net/20160726182257694?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center


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


 


 


 


 


 


 


 




阅读(1940) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~