oracle 迁移数据文件

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/leo__1990/article/details/91488766

1.关闭数据库

oracle@mumuso ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Fri Sep 9 10:21:34 2016

Copyright (c) 1982, 2013, Oracle.  All rights reserved.
SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area 3206946816 bytes
Fixed Size            2280384 bytes
Variable Size         1677722688 bytes
Database Buffers     1518338048 bytes
Redo Buffers            8605696 bytes
Database mounted.
Database opened.

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

2.将数据文件迁移到指定位置

[oracle@mumuso oradata]$ cp NEANDS.dbf /u01/app/oracle/oradata/orcl/NEANDS.dbf
[oracle@mumuso oradata]$ cp TS_FAIR.dbf /u01/app/oracle/oradata/orcl/TS_FAIR.dbf

3.将数据库启动到mount状态,rename datafile

SQL> startup mount
ORACLE instance started.
Total System Global Area 3206946816 bytes
Fixed Size            2280384 bytes
Variable Size         1677722688 bytes
Database Buffers     1518338048 bytes
Redo Buffers            8605696 bytes
Database mounted.
SQL> alter database rename file '/u01/app/oracle/oradata/NEANDS.dbf'  to '/u01/app/oracle/oradata/orcl/NEANDS.dbf'; 
Database altered.
SQL> alter database rename file '/u01/app/oracle/oradata/TS_FAIR.dbf'  to '/u01/app/oracle/oradata/orcl/TS_FAIR.dbf'; 
Database altered.

4.打开数据库

SQL> alter database open;
Database altered.
SQL> select file#,name,status from v$datafile;

     FILE# NAME                                                 STATUS
---------- ---------------------------------------------------------------------------------------------------- -------
     1 /u01/app/oracle/oradata/orcl/system01.dbf                                SYSTEM
     2 /u01/app/oracle/oradata/orcl/sysaux01.dbf                                ONLINE
     3 /u01/app/oracle/oradata/orcl/undotbs01.dbf                                ONLINE
     4 /u01/app/oracle/oradata/orcl/users01.dbf                                ONLINE
     5 /u01/app/oracle/oradata/orcl/NEANDS.dbf                                ONLINE
     6 /u01/app/oracle/oradata/orcl/TS_FAIR.dbf                                ONLINE

6 rows selected.

在实验过程中做了错误的操作

我已经迁移完数据文件,又做了rename操作,此时控制文件已经找不到原来的数据文件报如下错误:

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down. " - rest of line ignored.
SQL> alter database rename file '/u01/app/oracle/oradata/NEANDS.dbf'  to '/u01/app/oracle/oradata/orcl/NEANDS.dbf'; 
alter database rename file '/u01/app/oracle/oradata/NEANDS.dbf'  to '/u01/app/oracle/oradata/orcl/NEANDS.dbf'
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 3342
Session ID: 3394 Serial number: 5

解决办法:

SQL> alter database recover datafile '/u01/app/oracle/oradata/orcl/NEANDS.dbf';
Database altered.
SQL>   alter database recover datafile '/u01/app/oracle/oradata/orcl/TS_FAIR.dbf';
Database altered.
SQL> alter database open;
Database altered.

猜你喜欢

转载自blog.csdn.net/leo__1990/article/details/91488766