阅读量:0
oracle使用backup as copy方式迁移数据文件
1 基础环境
--确认数据文件路径 set line 200 col name for a75 select file#,name from v$datafile FILE# NAME ---------- --------------------------------------------------------------------------- 1 /u01/app/oracle/oradata/ORCL/system01.dbf 3 /u01/app/oracle/oradata/ORCL/sysaux01.dbf 4 /u01/app/oracle/oradata/ORCL/undotbs01.dbf 5 /u01/app/oracle/oradata/ORCL/test.dbf 7 /u01/app/oracle/oradata/ORCL/users01.dbf --目标路径(确认目标路径的所属) /oradata/ORCL [root@test ~]# ll /oradata/ total 0 drwxrwxr-x 2 oracle oinstall 6 Jul 25 02:37 ORCL
2 重新起库到mount状态
SQL> shu immediate SQL> startup mount;
3 backup as copy 方式改路径
rman target / backup as copy datafile 1 format '/oradata/ORCL/system01.dbf'; backup as copy datafile 3 format '/oradata/ORCL/sysaux01.dbf'; backup as copy datafile 4 format '/oradata/ORCL/undotbs01.dbf'; backup as copy datafile 5 format '/oradata/ORCL/test.dbf'; backup as copy datafile 7 format '/oradata/ORCL/users01.dbf'; switch datafile 1 to copy; switch datafile 3 to copy; switch datafile 4 to copy; switch datafile 5 to copy; switch datafile 7 to copy;
4 确认文件路径是否是目标路径
SQL> set line 200 SQL> col name for a75 SQL> select file#,name from v$datafile; FILE# NAME ---------- --------------------------------------------------------------------------- 1 /oradata/ORCL/system01.dbf 3 /oradata/ORCL/sysaux01.dbf 4 /oradata/ORCL/undotbs01.dbf 5 /oradata/ORCL/test.dbf 7 /oradata/ORCL/users01.dbf [oracle@test ~]$ cd /oradata/ORCL/ [oracle@test ORCL]$ ll total 3986472 -rw-r----- 1 oracle oinstall 618668032 Jul 25 02:47 sysaux01.dbf -rw-r----- 1 oracle oinstall 954212352 Jul 25 02:47 system01.dbf -rw-r----- 1 oracle oinstall 2147491840 Jul 25 02:47 test.dbf -rw-r----- 1 oracle oinstall 356524032 Jul 25 02:47 undotbs01.dbf -rw-r----- 1 oracle oinstall 5251072 Jul 25 02:47 users01.dbf
5 起库到open状态
alter database open; select open_mode,database_role from v$database;