从本节开始,将介绍下如何将单实例数据库迁移到rac环境。在生产环境中,随着业务和数据量的加大,这种需求和场景不可避免,一般来讲主要由以下四种方法实现迁移过程!
1:使用expdp/impdp数据泵导出导入,或者使用传统的exp/imp导入导出,后者效率低下;
2: 使用在线表空间迁移技术快速导出导入,前提是数据库的字符集要一致;
3:使用rman的备份进行异机恢复
4: 对单实例数据库构建基于rac的物理备库,进而切换备库为主库,这是生产环境中最为推荐的做法
本节中介绍使用expdp/impdp数据泵导出导入的方式实现迁移!
环境介绍:
数据库的版本均为10.2.0.5
操作系统的版本单实例数据库(源库)为rhel5.4 64 bit
rac(目标数据库)为ceontos4.8 64bit
一:查看源库的版本和表空间情况,同时在源库上建新的表空间和用户,插入数据,建立索引,创建目录对象,使用expdp到出用户的schema等
SQL> select * from v$version; BANNER SQL> show parameter compat; NAME TYPE VALUE
TABLESPACE_NAME FILE_NAME SQL> create tablespace exp_rac datafile SQL> create tablespace exp_rac_index datafile SQL> select tablespace_name,file_name from dba_data_files; TABLESPACE_NAME FILE_NAME
SQL> grant connect,resource to test1; SQL> create table test1.source as select * from dba_source; SQL> insert into test1.source select * from test1.source; SQL> / SQL> / SQL> commit; SQL> analyze table test1.source compute statistics; SQL> select count(*) from test1.source; COUNT(*) SQL> select sum(bytes/(1024*1024)) MB from dba_extents MB [oracle@server49 orcl]$ ll -h exp_rac01.dbf SQL> create index test1.i_source SQL> select table_name,tablespace_name from dba_indexes TABLE_NAME TABLESPACE_NAME SQL> grant read,write on directory expdp_dir to test1; SQL> !mkdir -p /home/oracle/expdp_dir [oracle@server49 ~]$ expdp test1/oracle directory=expdp_dir dumpfile=source.dmp logfile=source.log schemas=test1 Export: Release 10.2.0.5.0 - 64bit Production on Sunday, 01 January, 2012 19:38:30 Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
|
二:复制expdp导出的相关文件到目标库上,同时在目标库上创建相应的用户和表空间以及目录对象等
[oracle@rac1 ~]$ sqlplus sys/123456@racdb as sysdba Connected to: SQL> select file_name,tablespace_name from dba_data_files; FILE_NAME TABLESPACE_NAME SQL> create user test1 identified by oracle SQL> grant connect,resource to test1; SQL> create directory expdp_dir as '/home/oracle/expdp_dir'; SQL> grant read,write on directory expdp_dir to test1; SQL> create tablespace exp_rac datafile size 500M; SQL> create tablespace exp_rac_index datafile size 500M; |
三:在目标数据库上使用impdp导入数据
[oracle@rac1 ~]$ impdp test1/oracle directory=expdp_dir dumpfile=source.dmp logfile=source.log schemas=test1 Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production logfile=source.log schemas=test1 |
四:测试结果
[oracle@rac1 ~]$ sqlplus sys/123456@racdb as sysdba Connected to: SQL> select count(*) from test1.source; COUNT(*) SQL> col table_name format a20 TABLE_NAME TABLESPACE_NAME
---------- 56 本文转自斩月博客51CTO博客,原文链接http://blog.51cto.com/ylw6006/757510如需转载请自行联系原作者 ylw6006 |