【Oracle】How to Rename or Move Datafiles and Logfiles 之一
在做搭建第二備庫的時候用到了資料檔案的遷移,當時選擇了 在mount狀態下,offine 資料檔案然後在進行rename 的過程,這裡直接進行了,當然可以參考MOS 文件 How to Rename or Move Datafiles and Logfiles [ID 115424.1]
一在資料庫shutdown 模式 遷移資料檔案和日誌檔案
1 檢視檔案位置
SYS@yangdb-rac3> select file_name from dba_data_files
2 union
3 select file_name from dba_temp_files;
FILE_NAME
--------------------------------------------------------------------------------
/opt/oracle/oradata/yangdb/example01.dbf
/opt/oracle/oradata/yangdb/sysaux01.dbf
/opt/oracle/oradata/yangdb/system01.dbf
/opt/oracle/oradata/yangdb/temp01.dbf
/opt/oracle/oradata/yangdb/undotbs01.dbf
/opt/oracle/oradata/yangdb/users01.dbf
6 rows selected.
SYS@yangdb-rac3> select member from v$logfile;
MEMBER
-------------------------------------------------------------------------
/opt/oracle/oradata/yangdb/redo03.log
/opt/oracle/oradata/yangdb/redo02.log
/opt/oracle/oradata/yangdb/redo01.log
SYS@yangdb-rac3> col name for a50
SYS@yangdb-rac3> select name ,status ,enabled from v$datafile;
NAME STATUS ENABLED
-------------------------------------------------- ------- ----------
/opt/oracle/oradata/yangdb/system01.dbf SYSTEM READ WRITE
/opt/oracle/oradata/yangdb/sysaux01.dbf ONLINE READ WRITE
/opt/oracle/oradata/yangdb/undotbs01.dbf ONLINE READ WRITE
/opt/oracle/oradata/yangdb/users01.dbf ONLINE READ WRITE
/opt/oracle/oradata/yangdb/example01.dbf ONLINE READ WRITE
2 因為要移動整個資料庫的檔案,所以要修改引數檔案中的controfile的引數
SYS@yangdb-rac3> create pfile='/tmp/inityangdb.ora' from spfile;
File created.
SYS@yangdb-rac3> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
3 移動所有的資料庫檔案到新的位置
oracle@rac3:/opt/oracle/oradata/yangdb>ls
control01.ctl example01.dbf redo01.log redo02.log redo03.log sysaux01.dbf system01.dbf temp01.dbf undotbs01.dbf users01.dbf
oracle@rac3:/opt/oracle/oradata/yangdb>mv * ../yangdb_test/
oracle@rac3:/opt/oracle/oradata/yangdb>ls
oracle@rac3:/opt/oracle/oradata/yangdb>cd ../yangdb_test/
oracle@rac3:/opt/oracle/oradata/yangdb_test>ls
control01.ctl example01.dbf redo01.log redo02.log redo03.log sysaux01.dbf system01.dbf temp01.dbf undotbs01.dbf users01.dbf
4 修改引數檔案pfile
*.control_files='/opt/oracle/oradata/yangdb_test/control01.ctl','/opt/oracle/oradata/yangdb_test/control02.ctl','/opt/oracle/oradata/yangdb_test/control03.ctl'
5 把老的spfile檔案mv到別的地方或者刪除,建立新的spfile
SYS@yangdb-rac3> create spfile from pfile='/tmp/inityangdb.ora';
File created.
SYS@yangdb-rac3> startup mount
ORACLE instance started.
Total System Global Area 1653518336 bytes
Fixed Size 2213896 bytes
Variable Size 956303352 bytes
Database Buffers 687865856 bytes
Redo Buffers 7135232 bytes
Database mounted.
確認一下檔案位置:(可以省略)
SYS@yangdb-rac3> col member for a50
SYS@yangdb-rac3> select member from v$logfile;
MEMBER
--------------------------------------------------
/opt/oracle/oradata/yangdb/redo03.log
/opt/oracle/oradata/yangdb/redo02.log
/opt/oracle/oradata/yangdb/redo01.log
SYS@yangdb-rac3> select name ,status ,enabled from v$datafile;
NAME STATUS ENABLED
-------------------------------------------------- ------- ----------
/opt/oracle/oradata/yangdb/system01.dbf SYSTEM READ WRITE
/opt/oracle/oradata/yangdb/sysaux01.dbf ONLINE READ WRITE
/opt/oracle/oradata/yangdb/undotbs01.dbf ONLINE READ WRITE
/opt/oracle/oradata/yangdb/users01.dbf ONLINE READ WRITE
/opt/oracle/oradata/yangdb/example01.dbf ONLINE READ WRITE
SYS@yangdb-rac3>select name from v$controlfile;
NAME
--------------------------------------------------
/opt/oracle/oradata/yangdb_test/control01.ctl
/opt/oracle/oradata/yangdb_test/control02.ctl
/opt/oracle/oradata/yangdb_test/control03.ctl
6 修改資料檔案和日誌檔案的位置:
SYS@yangdb-rac3> alter database rename file '/opt/oracle/oradata/yangdb/example01.dbf' to '/opt/oracle/oradata/yangdb_test/example01.dbf';
Database altered.
SYS@yangdb-rac3> alter database rename file '/opt/oracle/oradata/yangdb/sysaux01.dbf' to '/opt/oracle/oradata/yangdb_test/sysaux01.dbf';
Database altered.
SYS@yangdb-rac3> alter database rename file '/opt/oracle/oradata/yangdb/system01.dbf' to '/opt/oracle/oradata/yangdb_test/system01.dbf';
Database altered.
SYS@yangdb-rac3> alter database rename file '/opt/oracle/oradata/yangdb/temp01.dbf' to '/opt/oracle/oradata/yangdb_test/temp01.dbf';
Database altered.
SYS@yangdb-rac3> alter database rename file '/opt/oracle/oradata/yangdb/undotbs01.dbf' to '/opt/oracle/oradata/yangdb_test/undotbs01.dbf';
Database altered.
SYS@yangdb-rac3> alter database rename file '/opt/oracle/oradata/yangdb/users01.dbf' to '/opt/oracle/oradata/yangdb_test/users01.dbf';
Database altered.
SYS@yangdb-rac3> col member for a50
SYS@yangdb-rac3> select name ,status ,enabled from v$datafile;
NAME STATUS ENABLED
-------------------------------------------------- ------- ----------
/opt/oracle/oradata/yangdb_test/system01.dbf SYSTEM READ WRITE
/opt/oracle/oradata/yangdb_test/sysaux01.dbf ONLINE READ WRITE
/opt/oracle/oradata/yangdb_test/undotbs01.dbf ONLINE READ WRITE
/opt/oracle/oradata/yangdb_test/users01.dbf ONLINE READ WRITE
/opt/oracle/oradata/yangdb_test/example01.dbf ONLINE READ WRITE
7 修改redo 日誌檔案的位置!
SYS@yangdb-rac3>
SYS@yangdb-rac3> alter database rename file '/opt/oracle/oradata/yangdb/redo03.log' to '/opt/oracle/oradata/yangdb_test/redo03.log';
Database altered.
SYS@yangdb-rac3> alter database rename file '/opt/oracle/oradata/yangdb/redo02.log' to '/opt/oracle/oradata/yangdb_test/redo02.log';
Database altered.
SYS@yangdb-rac3> alter database rename file '/opt/oracle/oradata/yangdb/redo01.log' to '/opt/oracle/oradata/yangdb_test/redo01.log';
Database altered.
SYS@yangdb-rac3> alter database open;
Database altered.
開啟資料庫進行驗證:
SYS@yangdb-rac3> col member for a50
SYS@yangdb-rac3> select member from v$logfile;
MEMBER
--------------------------------------------------
/opt/oracle/oradata/yangdb_test/redo03.log
/opt/oracle/oradata/yangdb_test/redo02.log
/opt/oracle/oradata/yangdb_test/redo01.log
SYS@yangdb-rac3> select name ,status ,enabled from v$datafile;
NAME STATUS ENABLED
-------------------------------------------------- ------- ----------
/opt/oracle/oradata/yangdb_test/system01.dbf SYSTEM READ WRITE
/opt/oracle/oradata/yangdb_test/sysaux01.dbf ONLINE READ WRITE
/opt/oracle/oradata/yangdb_test/undotbs01.dbf ONLINE READ WRITE
/opt/oracle/oradata/yangdb_test/users01.dbf ONLINE READ WRITE
/opt/oracle/oradata/yangdb_test/example01.dbf ONLINE READ WRITE
SYS@yangdb-rac3> select name from v$controlfile;
NAME
--------------------------------------------------
/opt/oracle/oradata/yangdb_test/control01.ctl
/opt/oracle/oradata/yangdb_test/control02.ctl
/opt/oracle/oradata/yangdb_test/control03.ctl
至此 成功遷移,僅僅是做測試用的,對於生產環境而言,shutdown 資料庫本身對應用必定有影響。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22664653/viewspace-708991/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【Oracle】How to Rename or Move Datafiles and Logfiles 之二Oracle
- Move_or_Rename_the_Tempfile_in_OracleOracle
- How To Move Datafiles On AIX Using Raw Logical Volumes To A New Location?AI
- How to rename an Oracle stored procedureOracle
- How to Rename Tablespace In Oracle10gOracle
- How does one rename a database?Database
- How to Rename a Server That Is Not a Data Store ServerServer
- How to move progress database to different OSDatabase
- How To Move The DB Audit Trails To A New TablespaceAI
- How to Move or Copy a Tablespace to Another Database (61)Database
- how to move a MediaWiki wiki from one server to anotherServer
- Rename or Move a datafile In Oracle 19c RAC-20220117Oracle
- How to move ASM database files from one diskgroup to anotherASMDatabase
- How to move Oracle Spatial objects from SYSAUX tablespace to a user defined tablespace [ID 1119758.1OracleObjectUX
- How to Rename Database/Change DB_NAME or ORACLE_SID/Instance Name-15390.1DatabaseOracle
- How to Move/Recreate GI Management Repository to Different Shared Storage
- How to move ASM spfile to a different disk group [ID 1082943.1]ASM
- Oracle的move操作Oracle
- move oracle 10 directoryOracle
- Rename db_name for OracleOracle
- OMF (Oracle Managed Files) Usage for Datafiles [ID 137482.1]Oracle
- ORACLE MOVE表空間Oracle
- Overview of Datafiles (62)View
- How to Move a Database Using Transportable Tablespaces (文件 ID 1493809.1)Database
- oracle 線上修改online redo logfiles size 大小Oracle
- oracle 線上rename資料檔案Oracle
- oracle rename 的連帶問題Oracle
- Rename Tablespace in Oracle database 10gOracleDatabase
- oracle 分割槽表move和包含分割槽表的lob moveOracle
- How to Move Tablespaces Across Platforms Using Transportable Tablespaces With RMAN [ID 371556.1]ROSPlatform
- How Oracle Works!Oracle
- How to Study OracleOracle
- [轉移]ORACLE MOVE 表空間Oracle
- [Oracle] Shrink space & Table move比較Oracle
- alter system check datafiles 命令
- How to enable trace in OracleOracle
- In Oracle,How to use dumpOracle
- An Example of How Oracle WorksOracle