欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Oracle 11g R2 RAC with ASM存储迁移--Rman copy&ASM Rebalance(一)

程序员文章站 2023-11-14 14:47:16
ASM GROUP-Rman copy迁移 0x00--环境介绍 VMware版本:VMware12pro 主机操作系统:RHEL6.5_64 共享存储使用VMWARE创建共享磁盘文件 数据库版本:Oracle11gR2 11.2.0.4.0_RAC Oracle数据库文件部署在ASM磁盘组上,需要 ......

ASM GROUP-Rman copy迁移

0x00--环境介绍

VMware版本:VMware12pro

主机操作系统:RHEL6.5_64

共享存储使用VMWARE创建共享磁盘文件

数据库版本:Oracle11gR2 11.2.0.4.0_RAC

Oracle数据库文件部署在ASM磁盘组上,需要在不停机或者尽量短的停机时间完成存储迁移。由于只是设计存储更换,无需借助第三方工具。采取迁移ASM DISKGROUP的方式完成迁移。模拟现实环境中,ASM磁盘组存放在存储设备上,模拟由于设备升级、存储虚拟化整合或者存储设备淘汰,需要进行存储更换。

首先使用新建ASM GROUP,使用rman copy替换旧有的存储ASM group,然后再采取ASM Rebalance进行在线迁移回来。两种方法

0x01--迁移步骤

数据为重,首先应该有完整可恢复的数据备份,确保数据的安全性。再进行迁移。迁移前首先收集数据库现有的信息。

1)      划分asm disk,并检查或更改UDEV配置文件,使得新存储的asm disk对ASM实例可识别。

2)      备份OCR、Voting Disk、ASM disk header和数据库。

3)      创建新的DISKGROUP

4)      迁移OCR和Vote Disks到新磁盘组(ASM diskgroup)

5)      迁移ASM Spfile到新磁盘组(ASM diskgroup)

6)      迁移数据库相关文件至新磁盘组(ASM diskgroup)

7)      在线修改数据库参数文件(归档路径、闪回等)

8)      删除旧磁盘组

9)      观察期。

10)   执行数据库备份

0x02--新存储划分空间

模拟环境中,是用VMware创建共享磁盘文件实现新存储划分。新创建3个10G新共享存储磁盘,ndata1,ndata2,ndata3用于存放数据文件,新建3个1GB共享存储磁盘,nocr1,nocr2,nocr3,用于存放OCR与VOTE信息,将原存储上的数据全部迁移过来。

 1 C:\Windows\system32>cd c:\VM\VM12
 2  
 3 c:\VM\VM12>vmware-vdiskmanager.exe -c -s 10240Mb -a lsilogic -t 2 C:\VM\VM12\sharedisk\ndata1.vmdk
 4 Creating disk 'C:\VM\VM12\sharedisk\ndata1.vmdk'
 5   Create: 100% done.
 6 Virtual disk creation successful.
 7  
 8 c:\VM\VM12>vmware-vdiskmanager.exe -c -s 10240Mb -a lsilogic -t 2 C:\VM\VM12\sharedisk\ndata2.vmdk
 9 Creating disk 'C:\VM\VM12\sharedisk\ndata2.vmdk'
10   Create: 100% done.
11 Virtual disk creation successful.
12  
13 c:\VM\VM12>vmware-vdiskmanager.exe -c -s 10240Mb -a lsilogic -t 2 C:\VM\VM12\sharedisk\ndata3.vmdk
14 Creating disk 'C:\VM\VM12\sharedisk\ndata3.vmdk'
15   Create: 100% done.
16 Virtual disk creation successful.
17  
18 c:\VM\VM12>vmware-vdiskmanager.exe -c -s 1024Mb -a lsilogic -t 2 C:\VM\VM12\sharedisk\nocr1.vmdk
19 Creating disk 'C:\VM\VM12\sharedisk\nocr1.vmdk'
20   Create: 100% done.
21 Virtual disk creation successful.
22  
23 c:\VM\VM12>vmware-vdiskmanager.exe -c -s 1024Mb -a lsilogic -t 2 C:\VM\VM12\sharedisk\nocr2.vmdk
24 Creating disk 'C:\VM\VM12\sharedisk\nocr2.vmdk'
25   Create: 100% done.
26 Virtual disk creation successful.
27  
28 c:\VM\VM12>vmware-vdiskmanager.exe -c -s 1024Mb -a lsilogic -t 2 C:\VM\VM12\sharedisk\nocr3.vmdk
29 Creating disk 'C:\VM\VM12\sharedisk\nocr3.vmdk'
30   Create: 100% done.
31 Virtual disk creation successful.

0x03--虚拟机添加磁盘

Oracle 11g R2 RAC with ASM存储迁移--Rman copy&ASM Rebalance(一)

Oracle 11g R2 RAC with ASM存储迁移--Rman copy&ASM Rebalance(一)

选择独立模式,保留现有格式,磁盘设置,高级设置中,修改虚拟设备节点,与本地磁盘不在同一总线上。在两节点都添加6块新盘。

Oracle 11g R2 RAC with ASM存储迁移--Rman copy&ASM Rebalance(一)

 

   

Oracle 11g R2 RAC with ASM存储迁移--Rman copy&ASM Rebalance(一)

 

 Oracle 11g R2 RAC with ASM存储迁移--Rman copy&ASM Rebalance(一)

Oracle 11g R2 RAC with ASM存储迁移--Rman copy&ASM Rebalance(一)

主机端识别新划盘:分别是sdh、sdi、sdj,三块10GB的磁盘,sdk,sdl,sdm,为3块1GB的磁盘。

Oracle 11g R2 RAC with ASM存储迁移--Rman copy&ASM Rebalance(一)

Oracle 11g R2 RAC with ASM存储迁移--Rman copy&ASM Rebalance(一)

0x04--Create New ASM diskgroup创建ASM DISKGROUP

查看当前ASM磁盘组信息

 1 ASMCMD> lsdg
 2 State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
 3 MOUNTED  NORMAL  N         512   4096  1048576     23529    18226            10236            3995              0             Y  DATA/
 4 MOUNTED  EXTERN  N         512   4096  1048576     10236     9709                0            9709              0             N  ORADATA1/
 5 ASMCMD>
 6  
 7 [grid@myrac1 ~]$ sqlplus / as sysasm
 8  
 9 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 05:22:17 2017
10  
11 Copyright (c) 1982, 2013, Oracle.  All rights reserved.
12  
13  
14 Connected to:
15 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
16 With the Real Application Clusters and Automatic Storage Management options
17  
18 SQL> select instance_name from v$instance;
19  
20 INSTANCE_NAME
21 ----------------
22 +ASM1
23  
24 SQL> col name for a10
25 SQL> set linesize 150
26 SQL> select NAME, ALLOCATION_UNIT_SIZE, STATE, TOTAL_MB, FREE_MB USABLE_FILE_MB from gv$asm_diskgroup;
27  
28 NAME        ALLOCATION_UNIT_SIZE STATE         TOTAL_MB USABLE_FILE_MB
29 ---------- -------------------- ----------- ---------- --------------
30 DATA                   1048576 MOUNTED     23529           18234
31 ORADATA1           1048576 MOUNTED     10236           9709
32 DATA                   1048576 MOUNTED     23529           18234
33 ORADATA1           1048576 MOUNTED     10236           9709
34  
35 SQL> select failgroup, name from v$asm_disk where group_number=(select group_number from v$asm_diskgroup where name = 'DATA');
36  
37 FAILGROUP                 NAME
38 ------------------------------ ----------
39 DATA2                         DATA2
40 DATA3                         DATA3
41 OCR1                          OCR1
42 OCR2                          OCR2
43 OCR3                          OCR3
44  
45  
46 SQL> select NAME,PATH,total_mb,free_mb from v$asm_disk;
47 NAME        PATH            TOTAL_MB   FREE_MB
48 ---------- --------------- ---------- ----------
49 DATA1       ORCL:DATA1          10236         9709
50 DATA2       ORCL:DATA2          10236         8180
51 DATA3       ORCL:DATA3          10236         8200
52 OCR1        ORCL:OCR1            1019          612
53 OCR2        ORCL:OCR2            1019          618
54 OCR3        ORCL:OCR3            1019          616
55  
56 6 rows selected.
57  
58 SQL>

fdisk 对新划磁盘进行分区,创建ASM磁盘

 1 [root@myrac2 ~]# oracleasm listdisks
 2 DATA1
 3 DATA2
 4 DATA3
 5 OCR1
 6 OCR2
 7 OCR3
 8 [root@myrac2 ~]# oracleasm createdisk NDATA1 /dev/sdh1
 9 Writing disk header: done
10 Instantiating disk: done
11 [root@myrac2 ~]# oracleasm createdisk NDATA2 /dev/sdi1
12 Writing disk header: done
13 Instantiating disk: done
14 [root@myrac2 ~]# oracleasm createdisk NDATA3 /dev/sdj1
15 Writing disk header: done
16 Instantiating disk: done
17 [root@myrac2 ~]# oracleasm createdisk NOCR1 /dev/sdk1
18 Writing disk header: done
19 Instantiating disk: done
20 [root@myrac2 ~]# oracleasm createdisk NOCR2 /dev/sdl1
21 Writing disk header: done
22 Instantiating disk: done
23 [root@myrac2 ~]# oracleasm createdisk NOCR3 /dev/sdm1
24 Writing disk header: done
25 Instantiating disk: done
26 [root@myrac2 ~]# oracleasm listdisks
27 DATA1
28 DATA2
29 DATA3
30 NDATA1
31 NDATA2
32 NDATA3
33 NOCR1
34 NOCR2
35 NOCR3
36 OCR1
37 OCR2
38 OCR3
39 [root@myrac2 ~]#
40  
41 [root@myrac1 ~]# oracleasm scandisks
42 Reloading disk partitions: done
43 Cleaning any stale ASM disks...
44 Scanning system for ASM disks...
45 Instantiating disk "NDATA1"
46 Instantiating disk "NDATA2"
47 Instantiating disk "NDATA3"
48 Instantiating disk "NOCR1"
49 Instantiating disk "NOCR2"
50 Instantiating disk "NOCR3"
51 [root@myrac1 ~]# oracleasm listdisks
52 DATA1
53 DATA2
54 DATA3
55 NDATA1
56 NDATA2
57 NDATA3
58 NOCR1
59 NOCR2
60 NOCR3
61 OCR1
62 OCR2
63 OCR3
64 [root@myrac1 ~]#

0x05--ASMCA创建新的ASM GROUP

Oracle 11g R2 RAC with ASM存储迁移--Rman copy&ASM Rebalance(一)

Oracle 11g R2 RAC with ASM存储迁移--Rman copy&ASM Rebalance(一)

Oracle 11g R2 RAC with ASM存储迁移--Rman copy&ASM Rebalance(一)

 1 SQL> CREATE DISKGROUP NDATA EXTERNAL REDUNDANCY  DISK ' /dev/oracleasm/disks/NDATA1' ' /dev/oracleasm/disks/NDATA2 SIZE 10240M  ATTRIBUTE 'compatible.asm'='11.2.0.0.
 2 0','au_size'='1M' /* ASMCA */
 3 SQL> CREATE DISKGROUP FRA2 EXTERNAL REDUNDANCY  DISK '/dev/asm-diskl' SIZE 5120M  ATTRIBUTE 'compatible.asm'='11.2.0.0.0'
 4 ,'au_size'='1M' /* ASMCA */
 5  
 6 [grid@myrac1 ~]$ sqlplus / as sysasm
 7  
 8 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 06:41:11 2017
 9  
10 Copyright (c) 1982, 2013, Oracle.  All rights reserved.
11  
12  
13 Connected to:
14 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
15 With the Real Application Clusters and Automatic Storage Management options
16  
17 SQL> select name,state from v$asm_diskgroup;
18  
19 NAME                          STATE
20 ------------------------------ -----------
21 DATA                          MOUNTED
22 ORADATA1                  MOUNTED
23 NDATA                       MOUNTED
24 NOCR                         MOUNTED
25  
26 SQL>

0x06--Moving OCR&VOTE DISK to new ASM diskgroup 迁移OCR和Vote Disks到新磁盘组

 1 [grid@myrac1 ~]$ ocrcheck
 2 Status of Oracle Cluster Registry is as follows :
 3         Version                  :          3
 4         Total space (kbytes)     :     262120
 5         Used space (kbytes)      :       3152
 6         Available space (kbytes) :     258968
 7         ID                       :  943942235
 8         Device/File Name         :  +ORADATA1
 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 bypassed due to non-privileged user

添加OCR磁盘组

 1 [root@myrac1 dev]# ocrconfig -add +NOCR
 2 [root@myrac1 dev]# ocrcheck
 3 Status of Oracle Cluster Registry is as follows :
 4         Version                  :          3
 5         Total space (kbytes)     :     262120
 6         Used space (kbytes)      :       3152
 7         Available space (kbytes) :     258968
 8         ID                       :  943942235
 9         Device/File Name         :  +ORADATA1
10                                     Device/File integrity check succeeded
11         Device/File Name         :      +NOCR
12                                     Device/File integrity check succeeded
13  
14                                     Device/File not configured
15  
16                                     Device/File not configured
17  
18                                     Device/File not configured
19  
20         Cluster registry integrity check succeeded
21  
22         Logical corruption check succeeded
23  
24 [root@myrac1 dev]#

删除旧OCR磁盘组

 1 [root@myrac1 ~]# ocrconfig -delete +ORADATA1
 2 [root@myrac1 ~]# ocrcheck
 3 Status of Oracle Cluster Registry is as follows :
 4         Version                  :          3
 5         Total space (kbytes)     :     262120
 6         Used space (kbytes)      :       3152
 7         Available space (kbytes) :     258968
 8         ID                       :  943942235
 9         Device/File Name         :      +NOCR
10                                     Device/File integrity check succeeded
11  
12                                     Device/File not configured
13  
14                                     Device/File not configured
15  
16                                     Device/File not configured
17  
18                                     Device/File not configured
19  
20         Cluster registry integrity check succeeded
21  
22         Logical corruption check succeeded
23  
24 [root@myrac1 ~]#

查看votedisks信息,迁移至新磁盘组

 1 [root@myrac1 ~]# crsctl query css votedisk
 2 ##  STATE    File Universal Id                File Name Disk group
 3 --  -----    -----------------                --------- ---------
 4  1. ONLINE   30f8194c62ee4f94bf0da8c5cdd174b6 (ORCL:OCR1) [DATA]
 5  2. ONLINE   866e0b01fabc4f29bf3935f9c02bfaea (ORCL:OCR2) [DATA]
 6  3. ONLINE   78a869e1fa844f65bf5b2b05cc93bb27 (ORCL:OCR3) [DATA]
 7 Located 3 voting disk(s).
 8 [root@myrac1 ~]#
 9 [root@myrac1 ~]#
10 [root@myrac1 ~]# crsctl replace votedisk +NOCR
11 Successful addition of voting disk 89681e4b76bf4f0fbf09e8d5879af2d4.
12 Successful deletion of voting disk 30f8194c62ee4f94bf0da8c5cdd174b6.
13 Successful deletion of voting disk 866e0b01fabc4f29bf3935f9c02bfaea.
14 Successful deletion of voting disk 78a869e1fa844f65bf5b2b05cc93bb27.
15 Successfully replaced voting disk group with +NOCR.
16 CRS-4266: Voting file(s) successfully replaced
17 [root@myrac1 ~]# crsctl query css votedisk
18 ##  STATE    File Universal Id                File Name Disk group
19 --  -----    -----------------                --------- ---------
20  1. ONLINE   89681e4b76bf4f0fbf09e8d5879af2d4 (ORCL:NOCR1) [NOCR]
21 Located 1 voting disk(s).
22 [root@myrac1 ~]#

0x07--Moving server side ASM SPfile to new ASM diskgroup

 1 [grid@myrac1 ~]$ sqlplus / as sysasm
 2  
 3 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 06:51:27 2017
 4  
 5 Copyright (c) 1982, 2013, Oracle.  All rights reserved.
 6  
 7  
 8 Connected to:
 9 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
10 With the Real Application Clusters and Automatic Storage Management options
11  
12 SQL> show parameter spfile
13  
14 NAME                               TYPE     VALUE
15 ------------------------------------ ----------- ------------------------------
16 spfile                                string    +ORADATA1/myrac-cluster/asmpar
17                                            ameterfile/asmspfile.ora
18 SQL> exit
19 Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
20 With the Real Application Clusters and Automatic Storage Management options
21 [grid@myrac1 ~]$ asmcmd
22 ASMCMD> spget
23 +ORADATA1/myrac-cluster/asmparameterfile/asmspfile.ora
24 ASMCMD> exit
25 [grid@myrac1 ~]$ sqlplus / as sysasm
26  
27 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 06:52:24 2017
28  
29 Copyright (c) 1982, 2013, Oracle.  All rights reserved.
30  
31  
32 Connected to:
33 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
34 With the Real Application Clusters and Automatic Storage Management options
35 SQL> create pfile='/tmp/asm_pfile.ora' from spfile;
36  
37 File created.
38  
39 SQL> create spfile='+NOCR' from pfile='/tmp/asm_pfile.ora';
40  
41 File created.
42  
43 SQL>

查看ASM日志信息

1 Thu Feb 09 06:54:35 2017
2 NOTE: updated gpnp profile ASM diskstring:
3 NOTE: updated gpnp profile ASM SPFILE to +NOCR/myrac-cluster/asmparameterfile/registry.253.935477673
4 [grid@myrac1 ~]$ asmcmd
5 ASMCMD> spget
6 +NOCR/myrac-cluster/asmparameterfile/registry.253.935477673
7 ASMCMD>

0x08--Moving database related files to new ASM diskgroup

迁移控制文件

 1 [oracle@myrac1 ~]$ sqlplus / as sysdba
 2  
 3 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 07:00:06 2017
 4  
 5 Copyright (c) 1982, 2013, Oracle.  All rights reserved.
 6  
 7  
 8 Connected to:
 9 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
10 With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
11 Data Mining and Real Application Testing options
12  
13 SQL> show parameter control
14  
15 NAME                               TYPE     VALUE
16 ------------------------------------ ----------- ------------------------------
17 control_file_record_keep_time          integer  7
18 control_files                      string    +DATA/myrac/controlfile/curren
19                                            t.256.935374197
20 control_management_pack_access          string    DIAGNOSTIC+TUNING
21 SQL> alter system set control_files='+NDATA' scope=spfile sid='*';
22  
23 System altered.
24  
25 SQL> show parameter control
26  
27 NAME                               TYPE     VALUE
28 ------------------------------------ ----------- ------------------------------
29 control_file_record_keep_time          integer  7
30 control_files                      string    +DATA/myrac/controlfile/curren
31                                            t.256.935374197
32 control_management_pack_access          string    DIAGNOSTIC+TUNING
33 SQL>

关闭数据库

1 [oracle@myrac1 ~]$ srvctl stop database -d myrac
2 [oracle@myrac1 ~]$

启动实例1到nomount状态

1 [oracle@myrac1 ~]$ srvctl start instance -d myrac -i myrac1 -o nomount
2 [oracle@myrac1 ~]$

RMAN Restore

 1 [oracle@myrac1 ~]$ rman target /
 2  
 3 Recovery Manager: Release 11.2.0.4.0 - Production on Thu Feb 9 07:20:16 2017
 4  
 5 Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
 6  
 7 connected to target database: MYRAC (not mounted)
 8  
 9 RMAN> restore controlfile from '+DATA/myrac/controlfile/current.256.935374197';
10 Starting restore at 09-FEB-17
11 using target database control file instead of recovery catalog
12 allocated channel: ORA_DISK_1
13 channel ORA_DISK_1: SID=34 instance=myrac1 device type=DISK
14  
15 channel ORA_DISK_1: copied control file copy
16 output file name=+NDATA/myrac/controlfile/current.257.935479241
17 Finished restore at 09-FEB-17
18  
19 RMAN>

完成迁移

 1 [oracle@myrac1 ~]$ sqlplus / as sysdba
 2  
 3 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 07:22:11 2017
 4  
 5 Copyright (c) 1982, 2013, Oracle.  All rights reserved.
 6  
 7  
 8 Connected to:
 9 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
10 With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
11 Data Mining and Real Application Testing options
12  
13 SQL> alter database mount;
14  
15 Database altered.
16  
17 SQL> alter database open;   
18  
19 Database altered.
20 SQL> show parameter control
21  
22 NAME                               TYPE     VALUE
23 ------------------------------------ ----------- ------------------------------
24 control_file_record_keep_time          integer  7
25 control_files                      string    +NDATA/myrac/controlfile/curre
26                                            nt.257.935479241
27 control_management_pack_access          string    DIAGNOSTIC+TUNING
28 SQL>

0x09--Moving SPfile to new ASM diskgroup

查看参数文件

 1 SQL> show parameter spfile
 2  
 3 NAME                               TYPE     VALUE
 4 ------------------------------------ ----------- ------------------------------
 5 spfile                                string    +ORADATA1/myrac/spfilemyrac.or
 6                                            a
 7 SQL> create pfile='/tmp/pfile_db.ora' from spfile;
 8  
 9 File created.
10  
11 SQL> create spfile='+NDATA' from pfile='/tmp/pfile_db.ora';
12  
13 File created.
14  
15 SQL>

ASMCMD移动SPFILE文件位置

 1 [grid@myrac1 trace]$ asmcmd
 2 ASMCMD> spget
 3 +NOCR/myrac-cluster/asmparameterfile/registry.253.935477673
 4 ASMCMD> ls
 5 DATA/
 6 NDATA/
 7 NOCR/
 8 ORADATA1/
 9 ASMCMD> cd ndata
10 ASMCMD> ls
11 MYRAC/
12 ASMCMD> cd myrac
13 ASMCMD> ls
14 CONTROLFILE/
15 PARAMETERFILE/
16 ASMCMD> cd parameterfile
17 ASMCMD> ls
18 spfile.258.935480051
19 ASMCMD>  mkalias +NDATA/myrac/parameterfile/spfile.258.935480051 +NDATA/myrac/spfilemyrac.ora
20 ASMCMD> ls -l
21 Type           Redund  Striped  Time             Sys  Name
22                                                  Y    CONTROLFILE/
23                                                  Y    PARAMETERFILE/
24                                                  N    spfilemyrac.ora => +NDATA/MYRAC/PARAMETERFILE/spfile.258.935480051
25 ASMCMD>

编辑spfile

 1 [oracle@myrac1 dbs]$ cat initmyrac1.ora
 2 SPFILE='+ORADATA1/myrac/spfilemyrac.ora'         # line added by Agent
 3 [oracle@myrac1 dbs]$ vim initmyrac1.ora
 4 [oracle@myrac1 dbs]$ cat initmyrac1.ora
 5 SPFILE='+NDATA/myrac/spfilemyrac.ora'         # line added by Agent
 6 [oracle@myrac1 dbs]$
 7  
 8 [oracle@myrac2 dbs]$ cat initmyrac2.ora
 9 SPFILE='+ORADATA1/myrac/spfilemyrac.ora'         # line added by Agent
10 [oracle@myrac2 dbs]$ vim initmyrac2.ora
11 [oracle@myrac2 dbs]$ cat initmyrac2.ora
12 SPFILE='+NDATA/myrac/spfilemyrac.ora'         # line added by Agent
13 [oracle@myrac2 dbs]$

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

 1 [oracle@myrac1 dbs]$ srvctl modify database -d myrac -p +NDATA/MYRAC/spfilemyrac.ora
 2 [oracle@myrac1 dbs]$ srvctl config database -d myrac
 3 Database unique name: myrac
 4 Database name: myrac
 5 Oracle home: /u01/app/oracle/product/11.2/db_1
 6 Oracle user: oracle
 7 Spfile: +NDATA/MYRAC/spfilemyrac.ora
 8 Domain: weidong.zhang
 9 Start options: open
10 Stop options: immediate
11 Database role: PRIMARY
12 Management policy: AUTOMATIC
13 Server pools: myrac
14 Database instances: myrac1,myrac2
15 Disk Groups: ORADATA1,DATA,NDATA
16 Mount point paths:
17 Services:
18 Type: RAC
19 Database is administrator managed

用新的spfile以及controlfile启动,验证正确性

 1 [oracle@myrac1 ~]$ srvctl start database -d myrac
 2 [oracle@myrac1 dbs]$ sqlplus / as sysdba
 3  
 4 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 08:36:24 2017
 5  
 6 Copyright (c) 1982, 2013, Oracle.  All rights reserved.
 7  
 8  
 9 Connected to:
10 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
11 With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
12 Data Mining and Real Application Testing options
13  
14 SQL> show parameter spfile
15  
16 NAME                               TYPE     VALUE
17 ------------------------------------ ----------- ------------------------------
18 spfile                                string    +NDATA/myrac/spfilemyrac.ora
19 SQL>
20 SQL> show parameter control
21  
22 NAME                               TYPE     VALUE
23 ------------------------------------ ----------- ------------------------------
24 control_file_record_keep_time          integer  7
25 control_files                     string    +NDATA/myrac/controlfile/curre
26                                            nt.257.935479241
27 control_management_pack_access          string    DIAGNOSTIC+TUNING
28 SQL>

0x0A--Moving data files to new ASM diskgroup

 1 SQL> archive log list;
 2 Database log mode             Archive Mode
 3 Automatic archival        Enabled
 4 Archive destination              +DATA
 5 Oldest online log sequence     35
 6 Next log sequence to archive   36
 7 Current log sequence          36
 8  
 9 [oracle@myrac1 dbs]$ rman target /
10  
11 Recovery Manager: Release 11.2.0.4.0 - Production on Thu Feb 9 08:41:47 2017
12  
13 Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
14  
15 connected to target database: MYRAC (DBID=42893065)
16  
17 RMAN> backup as copy database format '+NDATA';
18  
19 Starting backup at 09-FEB-17
20 using target database control file instead of recovery catalog
21 allocated channel: ORA_DISK_1
22 channel ORA_DISK_1: SID=56 instance=myrac1 device type=DISK
23 channel ORA_DISK_1: starting datafile copy
24 input datafile file number=00001 name=+DATA/myrac/datafile/system.261.935388681
25 output file name=+NDATA/myrac/datafile/system.259.935484205 tag=TAG20170209T084324 RECID=16 STAMP=935484210
26 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
27 channel ORA_DISK_1: starting datafile copy
28 input datafile file number=00002 name=+DATA/myrac/datafile/sysaux.264.935388699
29 output file name=+NDATA/myrac/datafile/sysaux.260.935484213 tag=TAG20170209T084324 RECID=17 STAMP=935484218
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/myrac/datafile/test_temp_tablespace.268.935388711
33 output file name=+NDATA/myrac/datafile/test_temp_tablespace.261.935484219 tag=TAG20170209T084324 RECID=18 STAMP=935484222
34 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
35 channel ORA_DISK_1: starting datafile copy
36 input datafile file number=00003 name=+DATA/myrac/datafile/undotbs1.265.935388707
37 output file name=+NDATA/myrac/datafile/undotbs1.262.935484223 tag=TAG20170209T084324 RECID=19 STAMP=935484223
38 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
39 channel ORA_DISK_1: starting datafile copy
40 input datafile file number=00005 name=+DATA/myrac/datafile/undotbs2.267.935388709
41 output file name=+NDATA/myrac/datafile/undotbs2.263.935484225 tag=TAG20170209T084324 RECID=20 STAMP=935484224
42 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
43 channel ORA_DISK_1: starting datafile copy
44 copying current control file
45 output file name=+NDATA/myrac/controlfile/backup.264.935484227 tag=TAG20170209T084324 RECID=21 STAMP=935484229
46 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
47 channel ORA_DISK_1: starting datafile copy
48 input datafile file number=00004 name=+DATA/myrac/datafile/users.266.935388709
49 output file name=+NDATA/myrac/datafile/users.265.935484231 tag=TAG20170209T084324 RECID=22 STAMP=935484231
50 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:04
51 channel ORA_DISK_1: starting full datafile backup set
52 channel ORA_DISK_1: specifying datafile(s) in backup set
53 including current SPFILE in backup set
54 channel ORA_DISK_1: starting piece 1 at 09-FEB-17
55 channel ORA_DISK_1: finished piece 1 at 09-FEB-17
56 piece handle=+NDATA/myrac/backupset/2017_02_09/nnsnf0_tag20170209t084324_0.266.935484233 tag=TAG20170209T084324 comment=NONE
57 channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
58 Finished backup at 09-FEB-17
59  
60 ==================================

 

 1 [oracle@myrac1 ~]$ srvctl stop database -d myrac -o immediate
 2 [oracle@myrac1 ~]$ sqlplus / as sysdba
 3  
 4 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 08:47:32 2017
 5  
 6 Copyright (c) 1982, 2013, 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 1653518336 bytes
14 Fixed Size                  2253784 bytes
15 Variable Size         1493175336 bytes
16 Database Buffers     150994944 bytes
17 Redo Buffers             7094272 bytes
18 Database mounted.
19 SQL>
20 ===============================================
21 [oracle@myrac1 dbs]$ rman target /
22  
23 Recovery Manager: Release 11.2.0.4.0 - Production on Thu Feb 9 08:48:39 2017
24  
25 Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
26  
27 connected to target database: MYRAC (DBID=42893065, 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 "+NDATA/myrac/datafile/system.259.935484205"
33 datafile 2 switched to datafile copy "+NDATA/myrac/datafile/sysaux.260.935484213"
34 datafile 3 switched to datafile copy "+NDATA/myrac/datafile/undotbs1.262.935484223"
35 datafile 4 switched to datafile copy "+NDATA/myrac/datafile/users.265.935484231"
36 datafile 5 switched to datafile copy "+NDATA/myrac/datafile/undotbs2.263.935484225"
37 datafile 6 switched to datafile copy "+NDATA/myrac/datafile/test_temp_tablespace.261.935484219"
38  
39 RMAN> recover database;
40  
41 Starting recover at 09-FEB-17
42 allocated channel: ORA_DISK_1
43 channel ORA_DISK_1: SID=37 instance=myrac1 device type=DISK
44  
45 starting media recovery
46 media recovery complete, elapsed time: 00:00:01
47  
48 Finished recover at 09-FEB-17
49  
50 RMAN>

启动数据库

 1 [oracle@myrac1 ~]$ srvctl stop database -d myrac
 2 [oracle@myrac1 ~]$ srvctl start database -d myrac
 3 [oracle@myrac1 dbs]$ sqlplus / as sysdba
 4  
 5 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 08:57:56 2017
 6  
 7 Copyright (c) 1982, 2013, Oracle.  All rights reserved.
 8  
 9  
10 Connected to:
11 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
12 With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
13 Data Mining and Real Application Testing options
14  
15 SQL>
16 SQL> SQL> select file_name from dba_data_files;
17  
18 FILE_NAME
19 --------------------------------------------------------------------------------
20 +NDATA/myrac/datafile/users.265.935484231
21 +NDATA/myrac/datafile/undotbs1.262.935484223
22 +NDATA/myrac/datafile/sysaux.260.935484213
23 +NDATA/myrac/datafile/system.259.935484205
24 +NDATA/myrac/datafile/undotbs2.263.935484225
25 +NDATA/myrac/datafile/test_temp_tablespace.261.935484219
26  
27 6 rows selected.
28  
29 SQL>

0x0B--Moving temp files to new ASM diskgroup

1 SQL>  select file_name from dba_temp_files;   
2  
3 FILE_NAME
4 --------------------------------------------------------------------------------
5 +DATA/myrac/tempfile/temp.258.935389865
6  
7 SQL>

修改db_create_file_dest参数

 

 1 SQL> show parameter db_c
 2  
 3 NAME                               TYPE     VALUE
 4 ------------------------------------ ----------- ------------------------------
 5 db_cache_advice              string    ON
 6 db_cache_size                          big integer 0
 7 db_create_file_dest                   string    +DATA
 8 db_create_online_log_dest_1            string
 9 db_create_online_log_dest_2            string
10 db_create_online_log_dest_3            string
11 db_create_online_log_dest_4            string
12 db_create_online_log_dest_5            string
13 SQL> alter system set db_create_file_dest = '+NDATA';
14  
15 System altered.
16  
17 SQL> show parameter db_c
18  
19 NAME                               TYPE     VALUE
20 ------------------------------------ ----------- ------------------------------
21 db_cache_advice              string    ON
22 db_cache_size                          big integer 0
23 db_create_file_dest                   string    +NDATA
24 db_create_online_log_dest_1            string
25 db_create_online_log_dest_2            string
26 db_create_online_log_dest_3            string
27 db_create_online_log_dest_4            string
28 db_create_online_log_dest_5            string
29 SQL>

增加临时文件

 1 ##由于已经设置了 db_create_file_dest参数,创建时会直接在NDATA上
 2 SQL> select file_name from dba_temp_files;
 3  
 4 FILE_NAME
 5 --------------------------------------------------------------------------------
 6 +DATA/myrac/tempfile/temp.258.935389865
 7  
 8 SQL> alter tablespace temp add tempfile; 
 9  
10 Tablespace altered.
11  
12 SQL> select file_name from dba_temp_files;
13  
14 FILE_NAME
15 --------------------------------------------------------------------------------
16 +NDATA/myrac/tempfile/temp.267.935485927
17 +DATA/myrac/tempfile/temp.258.935389865

删除原有临时文件

 1 SQL> alter tablespace temp drop tempfile '+DATA/myrac/tempfile/temp.258.935389865';
 2  
 3 Tablespace altered.
 4  
 5 SQL> select file_name from dba_temp_files;
 6  
 7 FILE_NAME
 8 --------------------------------------------------------------------------------
 9 +NDATA/myrac/tempfile/temp.267.935485927
10  
11 SQL>

0x0C--Moving online redo log files to new ASM diskgroup

SQL> select group#,member from v$logfile;
 
    GROUP# MEMBER
---------- ---------------------------------------------
        1 +DATA/myrac/onlinelog/group_1.269.935390433
        2 +DATA/myrac/onlinelog/group_2.270.935390443
        3 +DATA/myrac/onlinelog/group_3.271.935390447
        4 +DATA/myrac/onlinelog/group_4.272.935390453
        1 +DATA/myrac/onlinelog/group_1.273.935390965
        2 +DATA/myrac/onlinelog/group_2.274.935390973
        3 +DATA/myrac/onlinelog/group_3.275.935390977
        4 +DATA/myrac/onlinelog/group_4.276.935390983
 
8 rows selected.

将新磁盘组添加进logfile日志组

 1 SQL> alter database add logfile member '+NDATA' ,'+NDATA' to group 1;
 2  
 3 Database altered.
 4  
 5 SQL> alter database add logfile member '+NDATA' ,'+NDATA' to group 2;
 6  
 7 Database altered.
 8  
 9 SQL> alter database add logfile member '+NDATA' ,'+NDATA' to group 3;
10  
11 Database altered.
12  
13 SQL> alter database add logfile member '+NDATA' ,'+NDATA' to group 4;
14  
15 Database altered.
16  
17 SQL> alter database add logfile member '+NDATA' ,'+NDATA' to group 5;
18  
19 Database altered.

删除原日志成员(注:切换为非当前日志进行删除)

依次删除原日志组成员

1 SQL>alter database drop logfile member '+DATA/myrac/onlinelog/group_3.275.935390977';

若无法删除,可进行手动日志切换

1 alter system switch logfile;
2 alter system checkpoint;
 1 SQL> select log.group#,log.status,logfile.member from v$log log, v$logfile logfile where log.group#=logfile.group# order by group#;
 2  
 3     GROUP# STATUS      MEMBER
 4 ---------- ---------------- ---------------------------------------------
 5         1 INACTIVE      +NDATA/myrac/onlinelog/group_1.277.935488433
 6         1 INACTIVE      +NDATA/myrac/onlinelog/group_1.278.935489653
 7         2 CURRENT      +NDATA/myrac/onlinelog/group_2.269.935487101
 8         2 CURRENT      +NDATA/myrac/onlinelog/group_2.273.935487191
 9         3 INACTIVE      +NDATA/myrac/onlinelog/group_3.270.935487107
10         3 INACTIVE      +NDATA/myrac/onlinelog/group_3.274.935487197
11         4 CURRENT      +NDATA/myrac/onlinelog/group_4.271.935487115
12         4 CURRENT      +NDATA/myrac/onlinelog/group_4.275.935487203
13         5 INACTIVE      +NDATA/myrac/onlinelog/group_5.276.935487665
14         5 INACTIVE      +NDATA/myrac/onlinelog/group_5.272.935490035

0x0D--修改闪回区,归档路径

1 SQL> show parameter recover
2  
3 NAME                               TYPE     VALUE
4 ------------------------------------ ----------- ------------------------------
5 db_recovery_file_dest               string    +DATA
6 db_recovery_file_dest_size        big integer 4407M
7 db_unrecoverable_scn_tracking       boolean       TRUE
8 recovery_parallelism                 integer  0
9 SQL>
1 SQL>
2 SQL> alter system set db_recovery_file_dest='+NDATA';
3 System altered.
4  
 1 SQL> show parameter recover
 2  
 3 NAME                               TYPE     VALUE
 4 ------------------------------------ ----------- ------------------------------
 5 db_recovery_file_dest               string    +NDATA
 6 db_recovery_file_dest_size        big integer 4407M
 7 db_unrecoverable_scn_tracking       boolean       TRUE
 8 recovery_parallelism                 integer  0
 9 SQL> archive log list
10 Database log mode             Archive Mode
11 Automatic archival        Enabled
12 Archive destination              +DATA
13 Oldest online log sequence     50
14 Next log sequence to archive   51
15 Current log sequence          51
1 SQL> alter system set log_archive_dest_1='location=+NDATA';
2  
3 System altered.
1 SQL> archive log list
2 Database log mode             Archive Mode
3 Automatic archival        Enabled
4 Archive destination              +NDATA
5 Oldest online log sequence     50
6 Next log sequence to archive   51
7 Current log sequence          51
8 SQL>

0x0E--Dropping old disk groups,删除旧磁盘组

 1 [grid@myrac1 ~]$ sqlplus / as sysasm
 2  
 3 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 10:45:50 2017
 4  
 5 Copyright (c) 1982, 2013, Oracle.  All rights reserved.
 6  
 7  
 8 Connected to:
 9 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
10 With the Real Application Clusters and Automatic Storage Management options
11  
12 SQL> alter diskgroup data dismount;
13  
14 Diskgroup altered.
15  
16 SQL> alter diskgroup oradata1 dismount;
17  
18 Diskgroup altered.
19  
20 [grid@myrac2 ~]$ sqlplus / as sysasm
21  
22 SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 9 10:51:39 2017
23  
24 Copyright (c) 1982, 2013, Oracle.  All rights reserved.
25  
26  
27 Connected to:
28 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
29 With the Real Application Clusters and Automatic Storage Management options
30  
31 SQL> alter diskgroup data dismount;
32  
33 Diskgroup altered.
34  
35 SQL>  alter diskgroup oradata1 dismount;
36  
37 Diskgroup altered.
38  
39 SQL>
40  
41 SQL> drop diskgroup data including contents;
42 drop diskgroup data including contents
43 *
44 ERROR at line 1:
45 ORA-15039: diskgroup not dropped
46 ORA-15001: diskgroup "DATA" does not exist or is not mounted
47 SQL> drop diskgroup data force including contents;
48 drop diskgroup data force including contents
49 *
50 ERROR at line 1:
51 ORA-15039: diskgroup not dropped
52 ORA-15073: diskgroup DATA is mounted by another ASM instance
53  
54  
55 SQL> drop diskgroup data force including contents;
56  
57 Diskgroup dropped.
58  
59 SQL> drop diskgroup oradata1 force including contents;
60  
61 Diskgroup dropped.
62  
63 SQL>

 

Remove the disks from OCR

1 [root@myrac1 ~]# srvctl remove diskgroup -g DATA
2 PRCA-1002 : Failed to remove CRS resource ora.DATA.dg for ASM Disk Group DATA
3 PRCR-1028 : Failed to remove resource ora.DATA.dg
4 PRCR-1072 : Failed to unregister resource ora.DATA.dg
5 CRS-0222: Resource 'ora.DATA.dg' has dependency error.
6 [root@myrac1 ~]# srvctl modify database -d myrac -a "NDATA,NOCR"
7 [root@myrac1 ~]# srvctl remove diskgroup -g DATA
8 [root@myrac1 ~]# srvctl remove diskgroup -g ORADATA1

至此已经全部完成存储迁移。其中需要多次重启数据库,有少量停机时间,做好数据备份。

---本文首发于本人的

0x0F--ASM rebalance迁移详见下篇随笔