背景介绍
由于机房服务器变更,需要将 Oracle 迁移到一台新服务器上去。
以下是环境说明:
新服务器上安装和配置 Oracle
在新服务器(192.168.1.18)上安装了Oracle,为了保险,主机名、数据库实例名、安装目录都和原数据库保持一致。具体安装方法可参考:centos 6.5下安装oracle/197770.html">oracle/40223.html">oracle 11gR2与Oracle自动启动的配置
查询需要拷贝的文件
sqlplus / as sysdba
SQL> show parameter pfileNAME TYPE VALUE------------------------------------ ----------- ------------------------------spfile string /u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileorcl.oraSQL> show parameter controlNAME TYPE VALUE------------------------------------ ----------- ------------------------------control_file_record_keep_time integer 7control_files string /u01/app/oracle/oradata/orcl/control01.ctl, /u01/app/oracle/recovery_area/orcl/control02.ctlcontrol_management_pack_access string DIAGNOSTIC+TUNINGSQL> 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 NOSQL> 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.dbfSQL> 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 oracle@192.168.1.18:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileorcl.orascp /u01/app/oracle/oradata/orcl/control01.ctl oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/control01.ctlscp /u01/app/oracle/recovery_area/orcl/control02.ctl oracle@192.168.1.18:/u01/app/oracle/recovery_area/orcl/control02.ctlscp /u01/app/oracle/oradata/orcl/redo03.log oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/redo03.logscp /u01/app/oracle/oradata/orcl/redo02.log oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/redo02.logscp /u01/app/oracle/oradata/orcl/redo01.log oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/redo01.logscp /u01/app/oracle/oradata/orcl/system01.dbf oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/system01.dbfscp /u01/app/oracle/oradata/orcl/sysaux01.dbf oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/sysaux01.dbfscp /u01/app/oracle/oradata/orcl/undotbs01.dbf oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/undotbs01.dbfscp /u01/app/oracle/oradata/orcl/users01.dbf oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/users01.dbfscp /u01/app/oracle/oradata/orcl/users02.dbf oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/users02.dbfscp /u01/app/oracle/oradata/orcl/users03.dbf oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/users03.dbfscp /u01/app/oracle/oradata/orcl/temp01.dbf oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/temp01.dbf
等待拷贝完成
尝试启动新数据库
dba 登录进行启动数据库
[oracle@oracle ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on Thu Sep 17 09:26:11 2015Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to an idle instance.SQL> startupORACLE instance started.Total System Global Area 6747725824 bytesFixed Size 2213976 bytesVariable Size 5100275624 bytesDatabase Buffers 1610612736 bytesRedo Buffers 34623488 bytesDatabase mounted.Database opened.
注意最后一句,到这里就启动成功了。这次很顺利,没有出现意外。也可以通过以下语句检测数据库的状态:
SQL> select status from v$instance;STATUS------------OPEN
如果 Database mounted
成功后报错,也就是数据库最终不是 open 状态,只是 mounted 状态, 可以尝试恢复数据库。
recover database;
完成后,再打开数据库,一般可以成功。
alter database open;
验证两个库的数据
根据自己的实际情况进行验证, 这里不再赘述.
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。
新闻热点
疑难解答