背景介绍
由于机房服务器变更,需要将 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 oracle@192.168.1.18:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileorcl.ora scp /u01/app/oracle/oradata/orcl/control01.ctl oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/control01.ctl scp /u01/app/oracle/recovery_area/orcl/control02.ctl oracle@192.168.1.18:/u01/app/oracle/recovery_area/orcl/control02.ctl scp /u01/app/oracle/oradata/orcl/redo03.log oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/redo03.log scp /u01/app/oracle/oradata/orcl/redo02.log oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/redo02.log scp /u01/app/oracle/oradata/orcl/redo01.log oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/redo01.log scp /u01/app/oracle/oradata/orcl/system01.dbf oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/system01.dbf scp /u01/app/oracle/oradata/orcl/sysaux01.dbf oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/sysaux01.dbf scp /u01/app/oracle/oradata/orcl/undotbs01.dbf oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/undotbs01.dbf scp /u01/app/oracle/oradata/orcl/users01.dbf oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/users01.dbf scp /u01/app/oracle/oradata/orcl/users02.dbf oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/users02.dbf scp /u01/app/oracle/oradata/orcl/users03.dbf oracle@192.168.1.18:/u01/app/oracle/oradata/orcl/users03.dbf scp /u01/app/oracle/oradata/orcl/temp01.dbf oracle@192.168.1.18:/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;
验证两个库的数据
根据自己的实际情况进行验证, 这里不再赘述.
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:notice#nhooo.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。