search
HomeDatabaseMysql Tutorialoracle 11g R2 单实例 ASM 数据库数据磁盘组迁移

oracle 11g R2 单实例 ASM 数据库数据磁盘组迁移 在使用ASM作为数据库存储的时候,可能往往我们会因为某些原因,会考虑将数据的存储数据迁移到一个新的磁盘组。 例如:创建数据库的时候,数据存储在一个External redundancy 的磁盘组,没有冗余镜像。后期我

oracle 11g R2 单实例 ASM 数据库数据磁盘组迁移

     在使用ASM作为数据库存储的时候,可能往往我们会因为某些原因,会考虑将数据的存储数据迁移到一个新的磁盘组。

例如:创建数据库的时候,数据存储在一个External redundancy 的磁盘组,没有冗余镜像。后期我们会考虑将数据库数据迁移到一个Normal redundancy 或者 High redundancy的磁盘组。

测试环境:

主机环境

SQL> host lsb_release -a
LSB Version:    :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: EnterpriseEnterpriseServer
Description:    Enterprise Linux Enterprise Linux Server release 5.7 (Carthage)
Release:        5.7
Codename:       Carthage

数据库版本:

SQL> select instance_name,version from v$instance;

INSTANCE_NAME    VERSION
---------------- -----------------
ORCL             11.2.0.3.0
##单实例


ASM版本

SQL> select instance_name,version from v$instance;

INSTANCE_NAME    VERSION
---------------- -----------------
+ASM             11.2.0.3.0


ASM磁盘组共三个

SQL> select name from v$asm_diskgroup;

NAME
------------------------------
BACKUP
SYSTEMDG
DATA

目前数据数据存储于 SYSTEMDG ,包括(数据文件,临时文件,undo文件,redo文件、控制文件、参数文件) 本测试将数据迁移至DATA磁盘组,BACKUP磁盘组为备份dest。环境交代完毕!

需要迁移的文件:数据文件,临时文件,undo文件,redo文件、控制文件、参数文件

迁移前,先记下数据库的DBID


开始迁移


#首先,consistent 关闭数据库

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

#将数据库启动至mount状态
SQL> startup mount;
ORACLE instance started.

Total System Global Area  542814208 bytes
Fixed Size                  2230152 bytes
Variable Size             180357240 bytes
Database Buffers          352321536 bytes
Redo Buffers                7905280 bytes
Database mounted.


#启动rman工具,将数据库镜像备份至DATA磁盘组
RMAN> backup as copy database format '+DATA';

Starting backup at 28-OCT-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=137 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=16 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=+SYSTEMDG/orcl/datafile/system.261.829928875
channel ORA_DISK_2: starting datafile copy
input datafile file number=00002 name=+SYSTEMDG/orcl/datafile/sysaux.262.829928875
output file name=+DATA/orcl/datafile/system.257.830041439 tag=TAG20131028T230354 RECID=23 STAMP=830041580
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:02:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=+SYSTEMDG/orcl/datafile/undotbs1.263.829929061
output file name=+DATA/orcl/datafile/sysaux.256.830041437 tag=TAG20131028T230354 RECID=22 STAMP=830041580
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:02:26
channel ORA_DISK_2: starting datafile copy
input datafile file number=00005 name=+SYSTEMDG/orcl/datafile/users01.264.829929061
output file name=+DATA/orcl/datafile/undotbs1.258.830041581 tag=TAG20131028T230354 RECID=25 STAMP=830041611
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=+SYSTEMDG/orcl/datafile/users.265.829929107
output file name=+DATA/orcl/datafile/users01.259.830041581 tag=TAG20131028T230354 RECID=24 STAMP=830041611
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:35
output file name=+DATA/orcl/datafile/users.260.830041617 tag=TAG20131028T230354 RECID=26 STAMP=830041617
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 28-OCT-13

Starting Control File and SPFILE Autobackup at 28-OCT-13
piece handle=+BACKUP/orcl/autobackup/2013_10_28/s_830041354.262.830041621 comment=NONE
Finished Control File and SPFILE Autobackup at 28-OCT-13

#完成copy

#查看当前控制文件value,并修改为希望的值

SQL> show parameter control_files

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_files                        string      +SYSTEMDG/orcl/control01.ctl,
                                                 +BACKUP/orcl/controlfile/curre
                                                 nt.256.829519259
                                                 
SQL> alter system set control_files='+DATA','+BACKUP/orcl/controlfile/current.256.829519259' scope=spfile;

System altered.


#关闭数据库,让修改的control_files参数生效
SQL> shutdown immediate;
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.         

#将数据库启动至nomount阶段

SQL> startup nomount;
ORACLE instance started.

Total System Global Area  542814208 bytes
Fixed Size                  2230152 bytes
Variable Size             180357240 bytes
Database Buffers          352321536 bytes
Redo Buffers                7905280 bytes

#打开RMAN工具,通过设置dbid的方式,恢复控制文件,此时,数据库会根据control_files设置的值,将控制文件恢复到指定的位置。

[oracle@linusfay-up ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Mon Oct 28 23:56:54 2013

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

connected to target database: ORCL (not mounted)

RMAN> set dbid=1357299984

executing command: SET DBID


#从自动备份中恢复控制文件
RMAN> restore controlfile from autobackup;

Starting restore at 28-OCT-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=136 device type=DISK

recovery area destination: +BACKUP
database name (or database unique name) used for search: ORCL
channel ORA_DISK_1: AUTOBACKUP +backup/ORCL/AUTOBACKUP/2013_10_28/s_830041354.262.830041621 found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20131028
channel ORA_DISK_1: restoring control file from AUTOBACKUP +backup/ORCL/AUTOBACKUP/2013_10_28/s_830041354.262.830041621
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=+DATA/orcl/controlfile/current.261.830042181
output file name=+BACKUP/orcl/controlfile/current.256.829519259
Finished restore at 28-OCT-13

#控制文件恢复成功,将数据库启动至mount阶段
RMAN> alter database mount;

#查看之前备份的数据库镜像
RMAN> list copy of database;

List of Datafile Copies
=======================

Key     File S Completion Time Ckp SCN    Ckp Time       
------- ---- - --------------- ---------- ---------------
23      1    A 28-OCT-13       1087234    28-OCT-13      
        Name: +DATA/orcl/datafile/system.257.830041439
        Tag: TAG20131028T230354

22      2    A 28-OCT-13       1087234    28-OCT-13      
        Name: +DATA/orcl/datafile/sysaux.256.830041437
        Tag: TAG20131028T230354

25      3    A 28-OCT-13       1087234    28-OCT-13      
        Name: +DATA/orcl/datafile/undotbs1.258.830041581
        Tag: TAG20131028T230354

26      4    A 28-OCT-13       1087234    28-OCT-13      
        Name: +DATA/orcl/datafile/users.260.830041617
        Tag: TAG20131028T230354

24      5    A 28-OCT-13       1087234    28-OCT-13      
        Name: +DATA/orcl/datafile/users01.259.830041581
        Tag: TAG20131028T230354
database mounted
released channel: ORA_DISK_1             


#将数据库switch至database copy
RMAN> switch database to copy;

Starting implicit crosscheck backup at 28-OCT-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=136 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=16 device type=DISK
Crosschecked 5 objects
Finished implicit crosscheck backup at 28-OCT-13

Starting implicit crosscheck copy at 28-OCT-13
using channel ORA_DISK_1
using channel ORA_DISK_2
Crosschecked 5 objects
Finished implicit crosscheck copy at 28-OCT-13

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: +backup/ORCL/AUTOBACKUP/2013_10_28/s_830041354.262.830041621
File Name: +backup/ORCL/AUTOBACKUP/2013_10_27/s_829931410.271.829931413
File Name: +backup/ORCL/AUTOBACKUP/2013_10_27/s_829920770.278.829920963
File Name: +backup/ORCL/AUTOBACKUP/2013_10_27/s_829920770.276.829921283

datafile 1 switched to datafile copy "+DATA/orcl/datafile/system.257.830041439"
datafile 2 switched to datafile copy "+DATA/orcl/datafile/sysaux.256.830041437"
datafile 3 switched to datafile copy "+DATA/orcl/datafile/undotbs1.258.830041581"
datafile 4 switched to datafile copy "+DATA/orcl/datafile/users.260.830041617"
datafile 5 switched to datafile copy "+DATA/orcl/datafile/users01.259.830041581"    


#ok,完成数据文件的switch

#恢复数据库

RMAN> recover database;

#完成恢复,以resetlogs方式打开数据库。

RMAN> alter database open resetlogs;

database opened

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DATA/orcl/datafile/system.257.830041439
+DATA/orcl/datafile/sysaux.256.830041437
+DATA/orcl/datafile/undotbs1.258.830041581
+DATA/orcl/datafile/users.260.830041617
+DATA/orcl/datafile/users01.259.830041581

#数据库打开成功,接下里就是迁移 tempfile,redo lofile,修改 数据库db_create_file_dest=+DATA

SQL> create temporary tablespace temp tempfile '+DATA';

Tablespace created.


SQL> select file_name from dba_temp_files;

FILE_NAME
--------------------------------------------------------------------------------
+SYSTEMDG/orcl/tempfile/temp1.267.830034603
+DATA/orcl/tempfile/temp.262.830042531

#修改默认临时表空间,并删除废弃的临时表空间以及数据文件
SQL> alter database default temporary tablespace temp;

Database altered.

SQL> drop tablespace temp1 including contents and datafiles;

Tablespace dropped.


SQL> show parameter control_files

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_files                        string      +DATA/orcl/controlfile/current
                                                 .261.830042181, +BACKUP/orcl/c
                                                 ontrolfile/current.256.8295192
                                                 59

#修改db_create_file_dest
SQL> show parameter db_create_file_dest

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest                  string      +SYSTEMDG


SQL> alter system set db_create_file_dest='+DATA' scope=spfile;

System altered.                         

#重启数据库,让参数生效
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE instance started.

Total System Global Area  542814208 bytes
Fixed Size                  2230152 bytes
Variable Size             180357240 bytes
Database Buffers          352321536 bytes
Redo Buffers                7905280 bytes
Database mounted.
Database opened.                

#最后 迁移redo logfile  采用 新加成员 删除废弃成员的方式来迁移
SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
+BACKUP/orcl/onlinelog/group_1.257.829519279
+SYSTEMDG/orcl/onlinelog/group_1.268.830035813
+BACKUP/orcl/onlinelog/group_2.258.829519305
+SYSTEMDG/orcl/onlinelog/group_2.269.830035825
+BACKUP/orcl/onlinelog/group_3.259.829519331
+SYSTEMDG/orcl/onlinelog/group_3.270.830035835

6 rows selected.       


SQL> alter database add logfile member '+DATA' to group 1;

Database altered.

SQL> alter database add logfile member '+DATA' to group 2;

Database altered.

SQL> alter database add logfile member '+DATA' to group 3;

Database altered.


SQL> alter system switch logfile;

System altered.

SQL> alter system checkpoint;

System altered.

SQL> alter database drop  logfile member '+SYSTEMDG/orcl/onlinelog/group_1.268.830035813';

Database altered.

#迁移参数文件
SQL> create pfile='$ORACLE_HOME/dbs/init_orcl.ora' from spfile;

File created.

SQL> shutdown  immediate;
ASM diskgroups dismounted
ASM instance shutdown
SQL> startup pfile='$ORACLE_HOME/dbs/init_orcl.ora';
ASM instance started

Total System Global Area  283930624 bytes
Fixed Size                  2227664 bytes
Variable Size             256537136 bytes
ASM Cache                  25165824 bytes
ASM diskgroups mounted

SQL> create spfile ='+DATA' from pfile='$ORACLE_HOME/dbs/init_orcl.ora';

File created.

SQL> show parameter pfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +DATA/asm/asmparameterfile/reg
                                                 istry.253.830084811


#迁移redo logfile的时候,删除的时候,可能会因为是current  或者active状态无法删除,此时可根据实际情况
#使用 alter system switch logfile  或者 alter system checkpoint 来改变日志组的状态来达到删除的目的。

#至此,数据库存储从SYSTEMDG DISKGROUP 迁移到 DATA磁盘组完成

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What are the differences in syntax between MySQL and other SQL dialects?What are the differences in syntax between MySQL and other SQL dialects?Apr 27, 2025 am 12:26 AM

MySQLdiffersfromotherSQLdialectsinsyntaxforLIMIT,auto-increment,stringcomparison,subqueries,andperformanceanalysis.1)MySQLusesLIMIT,whileSQLServerusesTOPandOracleusesROWNUM.2)MySQL'sAUTO_INCREMENTcontrastswithPostgreSQL'sSERIALandOracle'ssequenceandt

What is MySQL partitioning?What is MySQL partitioning?Apr 27, 2025 am 12:23 AM

MySQL partitioning improves performance and simplifies maintenance. 1) Divide large tables into small pieces by specific criteria (such as date ranges), 2) physically divide data into independent files, 3) MySQL can focus on related partitions when querying, 4) Query optimizer can skip unrelated partitions, 5) Choosing the right partition strategy and maintaining it regularly is key.

How do you grant and revoke privileges in MySQL?How do you grant and revoke privileges in MySQL?Apr 27, 2025 am 12:21 AM

How to grant and revoke permissions in MySQL? 1. Use the GRANT statement to grant permissions, such as GRANTALLPRIVILEGESONdatabase_name.TO'username'@'host'; 2. Use the REVOKE statement to revoke permissions, such as REVOKEALLPRIVILEGESONdatabase_name.FROM'username'@'host' to ensure timely communication of permission changes.

Explain the differences between InnoDB and MyISAM storage engines.Explain the differences between InnoDB and MyISAM storage engines.Apr 27, 2025 am 12:20 AM

InnoDB is suitable for applications that require transaction support and high concurrency, while MyISAM is suitable for applications that require more reads and less writes. 1.InnoDB supports transaction and bank-level locks, suitable for e-commerce and banking systems. 2.MyISAM provides fast read and indexing, suitable for blogging and content management systems.

What are the different types of JOINs in MySQL?What are the different types of JOINs in MySQL?Apr 27, 2025 am 12:13 AM

There are four main JOIN types in MySQL: INNERJOIN, LEFTJOIN, RIGHTJOIN and FULLOUTERJOIN. 1.INNERJOIN returns all rows in the two tables that meet the JOIN conditions. 2.LEFTJOIN returns all rows in the left table, even if there are no matching rows in the right table. 3. RIGHTJOIN is contrary to LEFTJOIN and returns all rows in the right table. 4.FULLOUTERJOIN returns all rows in the two tables that meet or do not meet JOIN conditions.

What are the different storage engines available in MySQL?What are the different storage engines available in MySQL?Apr 26, 2025 am 12:27 AM

MySQLoffersvariousstorageengines,eachsuitedfordifferentusecases:1)InnoDBisidealforapplicationsneedingACIDcomplianceandhighconcurrency,supportingtransactionsandforeignkeys.2)MyISAMisbestforread-heavyworkloads,lackingtransactionsupport.3)Memoryengineis

What are some common security vulnerabilities in MySQL?What are some common security vulnerabilities in MySQL?Apr 26, 2025 am 12:27 AM

Common security vulnerabilities in MySQL include SQL injection, weak passwords, improper permission configuration, and unupdated software. 1. SQL injection can be prevented by using preprocessing statements. 2. Weak passwords can be avoided by forcibly using strong password strategies. 3. Improper permission configuration can be resolved through regular review and adjustment of user permissions. 4. Unupdated software can be patched by regularly checking and updating the MySQL version.

How can you identify slow queries in MySQL?How can you identify slow queries in MySQL?Apr 26, 2025 am 12:15 AM

Identifying slow queries in MySQL can be achieved by enabling slow query logs and setting thresholds. 1. Enable slow query logs and set thresholds. 2. View and analyze slow query log files, and use tools such as mysqldumpslow or pt-query-digest for in-depth analysis. 3. Optimizing slow queries can be achieved through index optimization, query rewriting and avoiding the use of SELECT*.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software