本篇内容介绍了“rman换磁盘迁移的方法是什么”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情...
本篇内容介绍了“rman换磁盘迁移的方法是什么”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
I先迁移数据文件
1 准备
新插一块盘,并且格式化 ,mount上
/dev/sdc/
mkfs.ext4 /dev/sdc/
mkdir /home/oracle/cs
mount /dev/sdc /home/oracle/cs
vi /etc/fstab --永久挂载
df -h
2 copy数据文件移动到新设备cs上
i)先查看当前库数据文件位置
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/ooradata/test1/system01.dbf
/ooradata/test1/sysaux01.dbf
/ooradata/test1/undotbs01.dbf
/ooradata/test1/users01.dbf
ii)复制到新的路径 copy ... to
rman target/
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
copy datafile'/ooradata/test1/system01.dbf'to'/home/oracle/cs/system01.dbf';
copy datafile'/ooradata/test1/sysaux01.dbf'to'/home/oracle/cs/sysaux01.dbf';
copy datafile'/ooradata/test1/undotbs01.dbf'to'/home/oracle/cs/undotbs01.dbf';
copy datafile'/ooradata/test1/users01.dbf'to'/home/oracle/cs/users01.dbf';
}
注:复制前,可以先切归 alter system archive log current;
iii)验证
[oracle@jcy1 oradata]$ cd /home/oracle/cs
[oracle@jcy1 cs]$ ll
total 1295400
-rw-r----- 1 oracle dba 513810432 Feb 2 07:50 sysaux01.dbf
-rw-r----- 1 oracle dba 775954432 Feb 2 07:50 system01.dbf
-rw-r----- 1 oracle dba 31465472 Feb 2 07:50 undotbs01.dbf
-rw-r----- 1 oracle dba 5251072 Feb 2 07:50 users01.dbf
II 迁移控制文件
1 先查看控制文件位置
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/ooradata/test1/control01.ctl
/u01/app/oracle/fast_recovery_area/test1/control02.ctl
2 copy到新位置
RMAN> copy current controlfile to '/home/oracle/cs/control01.ctl';
注:这里不需要制定原位置,02.ctl我们就不做改动。控制文件为了安全,一般要分别放在3个不同的磁盘上,咱们这里仅为做实验
i)验证
[oracle@jcy1 oradata]$ cd /home/oracle/cs
[oracle@jcy1 cs]$ ls -l control01.ctl
-rw-r----- 1 oracle dba 9748480 Feb 2 08:08 control01.ctl
ii)因为控制文件移动了位置,需要在参数文件里修改控制文件位置
SQL> create pfile='/home/oracle/cs/a.txt' from spfile;
File created.
SQL> !vi /home/oracle/cs/a.txt
修改值control_files
*.control_files='/home/oracle/cs/control01.ctl','/u01/app/oracle/fast_recovery_area/test1/control02.ctl'
关库
SQL> shutdown immediate
创建spfile
SQL> create spfile from pfile='/home/oracle/cs/a.txt';
File created.
启动
SQL> startup nomount;
SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-00214: control file
'/u01/app/oracle/fast_recovery_area/test1/control02.ctl' version 724
inconsistent with file '/home/oracle/cs/control01.ctl' version 717
解决方法:把第二个控制文件删除,后期咱们再添加
SQL> create pfile ='/home/oracle/cs/b.txt' from spfile; --新的b.txt文件
File created.
SQL> !vi /home/oracle/cs/b.txt
修改值control_files
*.control_files='/home/oracle/cs/control01.ctl'
关库
SQL> shutdown immediate
创建psfile
SQL> create spfile from pfile='/home/oracle/cs/b.txt';
SQL> startup nomount;
SQL> alter database mount;
正常
iii)查看启动的是哪个控制文件
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/home/oracle/cs/control01.ctl
注:如果还是没有改过来,需要制定一下,我这里是没有遇到哈,
RMAN>switch database to copy;
3 恢复数据文件
RMAN> recover database;
III 迁移日志文件
1 查看日志文件位置
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/ooradata/test1/redo03.log
/ooradata/test1/redo02.log
/ooradata/test1/redo01.log
2 copy到新位置
SQL> alter database rename file '/ooradata/test1/redo03.log' to '/home/oracle/cs/redo03.log';
Database altered.
SQL> alter database rename file '/ooradata/test1/redo02.log' to '/home/oracle/cs/redo02.log';
Database altered.
SQL> alter database rename file '/ooradata/test1/redo01.log' to '/home/oracle/cs/redo01.log';
Database altered.
验证一下
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/home/oracle/cs/redo03.log
/home/oracle/cs/redo02.log
/home/oracle/cs/redo01.log
3 这时候就可以open数据库了,一定一定要迁移完数据、控制、日志文件后再open
SQL> alter database open RESETLOGS;
Database altered.
IIII 迁移临时文件
1 查看临时文件位置
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
/ooradata/test1/temp01.dbf
2 更改临时文件位置
i)思路:先添加一个临时文件,再把之前的删除
SQL> alter tablespace temp add tempfile '/home/oracle/cs/temp01.dbf' size 100m;
Tablespace altered.
ii)删除
SQL> alter database tempfile '/ooradata/test1/temp01.dbf' drop;
alter database tempfile '/ooradata/test1/temp01.dbf' drop
*
ERROR at line 1:
ORA-25152: TEMPFILE cannot be dropped at this time
--正在使用,可以重启后在删除
SQL> shutdown immediate
SQL>startup
SQL> alter database tempfile '/ooradata/test1/temp01.dbf' drop;
Database altered.
iii)验证
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
/home/oracle/cs/temp01.dbf
“rman换磁盘迁移的方法是什么”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注捷杰建站网站,小编将为大家输出更多高质量的实用文章!