使用switch copy命令对普通文件和ASM文件的相互迁移
2018-03-20 14:54
302 查看
创建测试用的表空间及数据SYS@racdb3>create tablespace test_tbs datafile '/u01/app/oracle/test_tbs01.dbf' size 10M ;
Tablespace created.
SYS@racdb3>create table test_tbs_t1 (id number) tablespace test_tbs;
Table created.
SYS@racdb3>insert into test_tbs_t1 values(1);
1 row created.
SYS@racdb3>commit;
Commit complete.
SYS@racdb3>进行备份backup as copy tablespace test_tbs format '+DATA';
[oracle@host03 ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Tue Mar 20 14:36:04 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: RACDB (DBID=960841425)
RMAN> backup as copy tablespace test_tbs format '+DATA';
Starting backup at 20-MAR-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=67 instance=racdb3 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00008 name=/u01/app/oracle/test_tbs01.dbf
output file name=+DATA/racdb/datafile/test_tbs.701.971274979 tag=TAG20180320T143618 RECID=3 STAMP=971274979
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 20-MAR-18
Starting Control File and SPFILE Autobackup at 20-MAR-18
piece handle=/home/oracle/control_c-960841425-20180320-00 comment=NONE
Finished Control File and SPFILE Autobackup at 20-MAR-18表空间offlinealter tablespace test_tbs offline;
SYS@racdb3>alter tablespace test_tbs offline;
进行切换,并查看状态switch tablespace test_tbs to copy;
RMAN> switch tablespace test_tbs to copy;
datafile 8 switched to datafile copy "+DATA/racdb/datafile/test_tbs.701.971274979"
SYS@racdb3>recover tablespace test_tbs;
Media recovery complete.
SYS@racdb3>alter tablespace test_tbs online;
Tablespace altered.
SYS@racdb3>
SYS@racdb3>select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
+DATA/racdb/undotbs01.dbf
+DATA/racdb/users01.dbf
+DATA/racdb/sysaux01.dbf
+DATA/racdb/system01.dbf
+DATA/racdb/example01.dbf
+DATA/racdb/undotbs02.dbf
+DATA/racdb/datafile/abc.448.966705497
+DATA/racdb/datafile/test_tbs.701.971274979
8 rows selected.
SYS@racdb3>select * from test_tbs_t1;
ID
----------
1
SYS@racdb3>下面测试,将ASM上的数据文件,迁移到普通路径上
创建测试数据create tablespace asm_tbs datafile '+DATA' size 10M;
create table asm_t1(id number) tablespace asm_tbs;
insert into asm_t1 values(2);
commit;
SYS@racdb3>create tablespace asm_tbs datafile '+DATA' size 10M;
Tablespace created.
SYS@racdb3>create table asm_t1(id number) tablespace asm_tbs;
Table created.
SYS@racdb3>insert into asm_t1 values(2);
1 row created.
SYS@racdb3>commit;
Commit complete.
SYS@racdb3>步骤如下:backup as copy tablespace asm_tbs format '/u01/app/oracle/asm_tbs.dbf' ;
alter tablespace asm_tbs offline;
switch tablespace asm_tbs to copy;
recover tablespace asm_tbs;
alter tablespace asm_tbs online;过程RMAN> backup as copy tablespace asm_tbs format '/u01/app/oracle/asm_tbs.dbf' ;
Starting backup at 20-MAR-18
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00009 name=+DATA/racdb/datafile/asm_tbs.702.971275499
output file name=/u01/app/oracle/asm_tbs.dbf tag=TAG20180320T144539 RECID=5 STAMP=971275541
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 20-MAR-18
Starting Control File and SPFILE Autobackup at 20-MAR-18
piece handle=/home/oracle/control_c-960841425-20180320-01 comment=NONE
Finished Control File and SPFILE Autobackup at 20-MAR-18
RMAN>
RMAN> sql 'alter tablespace asm_tbs offline';
sql statement: alter tablespace asm_tbs offline
RMAN> switch tablespace asm_tbs to copy;
datafile 9 switched to datafile copy "/u01/app/oracle/asm_tbs.dbf"
RMAN> recover tablespace asm_tbs;
Starting recover at 20-MAR-18
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 20-MAR-18
RMAN> sql 'alter tablespace asm_tbs online';
sql statement: alter tablespace asm_tbs online
RMAN>
SYS@racdb3>select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
+DATA/racdb/undotbs01.dbf
+DATA/racdb/users01.dbf
+DATA/racdb/sysaux01.dbf
+DATA/racdb/system01.dbf
+DATA/racdb/example01.dbf
+DATA/racdb/undotbs02.dbf
+DATA/racdb/datafile/abc.448.966705497
+DATA/racdb/datafile/test_tbs.701.971274979
/u01/app/oracle/asm_tbs.dbf
9 rows selected.
SYS@racdb3>
SYS@racdb3>select * from asm_t1;
ID
----------
2
SYS@racdb3>
end
Tablespace created.
SYS@racdb3>create table test_tbs_t1 (id number) tablespace test_tbs;
Table created.
SYS@racdb3>insert into test_tbs_t1 values(1);
1 row created.
SYS@racdb3>commit;
Commit complete.
SYS@racdb3>进行备份backup as copy tablespace test_tbs format '+DATA';
[oracle@host03 ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Tue Mar 20 14:36:04 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: RACDB (DBID=960841425)
RMAN> backup as copy tablespace test_tbs format '+DATA';
Starting backup at 20-MAR-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=67 instance=racdb3 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00008 name=/u01/app/oracle/test_tbs01.dbf
output file name=+DATA/racdb/datafile/test_tbs.701.971274979 tag=TAG20180320T143618 RECID=3 STAMP=971274979
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 20-MAR-18
Starting Control File and SPFILE Autobackup at 20-MAR-18
piece handle=/home/oracle/control_c-960841425-20180320-00 comment=NONE
Finished Control File and SPFILE Autobackup at 20-MAR-18表空间offlinealter tablespace test_tbs offline;
SYS@racdb3>alter tablespace test_tbs offline;
进行切换,并查看状态switch tablespace test_tbs to copy;
RMAN> switch tablespace test_tbs to copy;
datafile 8 switched to datafile copy "+DATA/racdb/datafile/test_tbs.701.971274979"
SYS@racdb3>recover tablespace test_tbs;
Media recovery complete.
SYS@racdb3>alter tablespace test_tbs online;
Tablespace altered.
SYS@racdb3>
SYS@racdb3>select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
+DATA/racdb/undotbs01.dbf
+DATA/racdb/users01.dbf
+DATA/racdb/sysaux01.dbf
+DATA/racdb/system01.dbf
+DATA/racdb/example01.dbf
+DATA/racdb/undotbs02.dbf
+DATA/racdb/datafile/abc.448.966705497
+DATA/racdb/datafile/test_tbs.701.971274979
8 rows selected.
SYS@racdb3>select * from test_tbs_t1;
ID
----------
1
SYS@racdb3>下面测试,将ASM上的数据文件,迁移到普通路径上
创建测试数据create tablespace asm_tbs datafile '+DATA' size 10M;
create table asm_t1(id number) tablespace asm_tbs;
insert into asm_t1 values(2);
commit;
SYS@racdb3>create tablespace asm_tbs datafile '+DATA' size 10M;
Tablespace created.
SYS@racdb3>create table asm_t1(id number) tablespace asm_tbs;
Table created.
SYS@racdb3>insert into asm_t1 values(2);
1 row created.
SYS@racdb3>commit;
Commit complete.
SYS@racdb3>步骤如下:backup as copy tablespace asm_tbs format '/u01/app/oracle/asm_tbs.dbf' ;
alter tablespace asm_tbs offline;
switch tablespace asm_tbs to copy;
recover tablespace asm_tbs;
alter tablespace asm_tbs online;过程RMAN> backup as copy tablespace asm_tbs format '/u01/app/oracle/asm_tbs.dbf' ;
Starting backup at 20-MAR-18
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00009 name=+DATA/racdb/datafile/asm_tbs.702.971275499
output file name=/u01/app/oracle/asm_tbs.dbf tag=TAG20180320T144539 RECID=5 STAMP=971275541
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 20-MAR-18
Starting Control File and SPFILE Autobackup at 20-MAR-18
piece handle=/home/oracle/control_c-960841425-20180320-01 comment=NONE
Finished Control File and SPFILE Autobackup at 20-MAR-18
RMAN>
RMAN> sql 'alter tablespace asm_tbs offline';
sql statement: alter tablespace asm_tbs offline
RMAN> switch tablespace asm_tbs to copy;
datafile 9 switched to datafile copy "/u01/app/oracle/asm_tbs.dbf"
RMAN> recover tablespace asm_tbs;
Starting recover at 20-MAR-18
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 20-MAR-18
RMAN> sql 'alter tablespace asm_tbs online';
sql statement: alter tablespace asm_tbs online
RMAN>
SYS@racdb3>select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
+DATA/racdb/undotbs01.dbf
+DATA/racdb/users01.dbf
+DATA/racdb/sysaux01.dbf
+DATA/racdb/system01.dbf
+DATA/racdb/example01.dbf
+DATA/racdb/undotbs02.dbf
+DATA/racdb/datafile/abc.448.966705497
+DATA/racdb/datafile/test_tbs.701.971274979
/u01/app/oracle/asm_tbs.dbf
9 rows selected.
SYS@racdb3>
SYS@racdb3>select * from asm_t1;
ID
----------
2
SYS@racdb3>
end
相关文章推荐
- Oracle 11g单实例使用asm,并测试数据文件的迁移到其他磁盘组
- 将数据库从普通文件系统迁移到ASM中
- 使用RMAN迁移文件系统数据库到ASM
- 普通文件迁移ASM
- 【翻译自mos文章】 使用asmcmd cp命令 把datafile从文件系统移动(move)到asm磁盘组中--针对11gR2
- 使用asmcmdcp命令把datafile从文件系统移动(move)到asm磁盘组中 针对11gR2
- 使用rman迁移数据文件操作步骤(RAC-ASM环境)
- 使用普通文件创建ASM实例
- 使用RMAN迁移文件系统数据库到ASM
- 普通文件迁移到ASM
- Linux 普通用户拿到root权限及使用szrz命令上传下载文件
- Linux系统使用普通命令删除不掉的文件处理方法
- 使用asmcmdcp命令把datafile从文件系统移动(move)到asm磁盘组中 针对11gR2
- 使用RMAN迁移文件系统数据库到ASM
- Xamarin中使用EF Core 2.0应该如何使用数据迁移命令生成迁移文件
- 使用RMAN迁移文件系统数据库到ASM
- 普通用户使用的命令-文件和目录管理类命令基本用法介绍
- 使用DBMS_FILE_TRANSFER迁移ASM中的表空间和数据文件
- 将数据库从普通文件系统迁移到ASM中
- 使用RMAN迁移文件系统数据库到ASM