oracle migrate data files

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/leo__1990/article/details/91488766

1. Shut down the database

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. migrate data files to a specified location

[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. Start the database to mount state, 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. Open the database

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.

I made a wrong operation during the experiment

I have finished migration of data files, and made a rename operation, then the control file could not find the original data file reported the following errors:

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

Solution:

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.

Guess you like

Origin blog.csdn.net/leo__1990/article/details/91488766