背景介紹
由於機房服務器變更,需要將 Oracle 遷移到一台新服務器上去。
以下是環境說明:
新服務器上安裝和配置 Oracle
在新服務器(192.168.1.18)上安裝了Oracle,為了保險,主機名、數據庫實例名、安裝目錄都和原數據庫保持一致。具體安裝方法可參考:centos 6.5下安裝oracle 11gR2與Oracle自動啟動的配置
查詢需要拷貝的文件
sqlplus / as sysdba
SQL> show parameter pfile NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ spfile string /u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileorcl.ora SQL> show parameter control NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ control_file_record_keep_time integer 7 control_files string /u01/app/oracle/oradata/orcl/control01.ctl, /u01/app/oracle/recovery_area/orcl/control02.ctl control_management_pack_access string DIAGNOSTIC+TUNING SQL> select * from v$logfile; GROUP# STATUS TYPE MEMBER IS_RECOVERY_DEST_FILE ---------- ------- ------- -------------------------------------------------------------------------------- --------------------- 3 ONLINE /u01/app/oracle/oradata/orcl/redo03.log NO 2 ONLINE /u01/app/oracle/oradata/orcl/redo02.log NO 1 ONLINE /u01/app/oracle/oradata/orcl/redo01.log NO SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- /u01/app/oracle/oradata/orcl/system01.dbf /u01/app/oracle/oradata/orcl/sysaux01.dbf /u01/app/oracle/oradata/orcl/undotbs01.dbf /u01/app/oracle/oradata/orcl/users01.dbf /u01/app/oracle/oradata/orcl/users02.dbf SQL> select name from v$tempfile; NAME -------------------------------------------------------------------------------- /u01/app/oracle/oradata/orcl/temp01.dbf
根據以上查詢結果,發現有以下文件需要拷貝:
/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileorcl.ora /u01/app/oracle/oradata/orcl/control01.ctl /u01/app/oracle/recovery_area/orcl/control02.ctl /u01/app/oracle/oradata/orcl/redo03.log /u01/app/oracle/oradata/orcl/redo02.log /u01/app/oracle/oradata/orcl/redo01.log /u01/app/oracle/oradata/orcl/system01.dbf /u01/app/oracle/oradata/orcl/sysaux01.dbf /u01/app/oracle/oradata/orcl/undotbs01.dbf /u01/app/oracle/oradata/orcl/users01.dbf /u01/app/oracle/oradata/orcl/users02.dbf /u01/app/oracle/oradata/orcl/users03.dbf /u01/app/oracle/oradata/orcl/temp01.dbf
停掉原數據庫與新數據庫
service oracle stop
使用scp拷貝文件到新服務器
scp /u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileorcl.ora [email protected]:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileorcl.ora scp /u01/app/oracle/oradata/orcl/control01.ctl [email protected]:/u01/app/oracle/oradata/orcl/control01.ctl scp /u01/app/oracle/recovery_area/orcl/control02.ctl [email protected]:/u01/app/oracle/recovery_area/orcl/control02.ctl scp /u01/app/oracle/oradata/orcl/redo03.log [email protected]:/u01/app/oracle/oradata/orcl/redo03.log scp /u01/app/oracle/oradata/orcl/redo02.log [email protected]:/u01/app/oracle/oradata/orcl/redo02.log scp /u01/app/oracle/oradata/orcl/redo01.log [email protected]:/u01/app/oracle/oradata/orcl/redo01.log scp /u01/app/oracle/oradata/orcl/system01.dbf [email protected]:/u01/app/oracle/oradata/orcl/system01.dbf scp /u01/app/oracle/oradata/orcl/sysaux01.dbf [email protected]:/u01/app/oracle/oradata/orcl/sysaux01.dbf scp /u01/app/oracle/oradata/orcl/undotbs01.dbf [email protected]:/u01/app/oracle/oradata/orcl/undotbs01.dbf scp /u01/app/oracle/oradata/orcl/users01.dbf [email protected]:/u01/app/oracle/oradata/orcl/users01.dbf scp /u01/app/oracle/oradata/orcl/users02.dbf [email protected]:/u01/app/oracle/oradata/orcl/users02.dbf scp /u01/app/oracle/oradata/orcl/users03.dbf [email protected]:/u01/app/oracle/oradata/orcl/users03.dbf scp /u01/app/oracle/oradata/orcl/temp01.dbf [email protected]:/u01/app/oracle/oradata/orcl/temp01.dbf
等待拷貝完成
嘗試啟動新數據庫
dba 登錄進行啟動數據庫
[oracle@oracle ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Thu Sep 17 09:26:11 2015 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to an idle instance. SQL> startup ORACLE instance started. Total System Global Area 6747725824 bytes Fixed Size 2213976 bytes Variable Size 5100275624 bytes Database Buffers 1610612736 bytes Redo Buffers 34623488 bytes Database mounted. Database opened.
注意最後一句,到這裡就啟動成功了。這次很順利,沒有出現意外。也可以通過以下語句檢測數據庫的狀態:
SQL> select status from v$instance; STATUS ------------ OPEN
如果 Database mounted
成功後報錯,也就是數據庫最終不是 open 狀態,只是 mounted 狀態, 可以嘗試恢復數據庫。
recover database;
完成後,再打開數據庫,一般可以成功。
alter database open;
驗證兩個庫的數據
根據自己的實際情況進行驗證, 這裡不再贅述.
總結
以上就是這篇文章的全部內容了,希望本文的內容對大家學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流。