ITPub博客

首页 > Linux操作系统 > Linux操作系统 > EXP,EXPDP数据导入本地性能测试

EXP,EXPDP数据导入本地性能测试

原创 Linux操作系统 作者:lygle 时间:2013-04-06 11:56:18 0 删除 编辑

     大家都知道,Oracle数据库有两种比较方便的导出导入工具,那就是exp/imp和expdp/impdp。熟悉此工具的人也会了解到,exp/imp的使用 (服务器端和客户端都可以执行,并且备份文件可以在客户端产生);expdp/impdp的使用 (服务器端和客户端都可以执行,备份文件只能存在服务器里面)。

         但鉴于导出导入工具的特点,我们就想能否通过expdp将远端数据库数据导入到本地库中呢?当然可以!下面我们就一起来做一个测试吧。


测试说明:

目的:将远端数据库服务器(IP为65)的数据导入到本地(IP为67)dmp文件中

其中用到服务器(65)一个用户(user_exp)的一张表做测试(t_exp)

Create tablespace tbs_exp datafile ‘D:\tbs_exp.dbf’ size 10240m autoextend off;

Create user user_exp identified by user_exp default tablespace tbs_exp;

Grant connect,resource,unlimited tablespace to user_exp;

Conn user_exp/user_exp

create table t_exp as

select * from user_tablespaces;


declare

begin

  for i in 1 .. 10000000 loop

    insert into t_exp

      (tablespace_name, block_size, initial_extent,MIN_EXTENTS )

    values

      ('tablespace_name',0,0,i);

  end loop;

  commit;

end;

/

1.EXP工具数据导入本地步骤
直接通过以下代码将服务器数据导入到本地:

exp user_exp/user_exp@orcl_65 file=d:\exp_01.dmp log=d:\exp_01.log tables=(t_exp)

2.EXPDP工具数据导入本地步骤
第一步:本地建立导出用户

Create user db_exp identified by db_exp;

Grant connect,resource,create database link to db_exp;

第二步:本地创建directory,并授权导出用户使用

在操作系统上创建direxp目录

create or replace directory DIR_EXP as 'D:\direxp';

grant read,write on directory DIR_EXP to db_exp;

第三步:,并创建db link 链接

-- Create database link

create database link to_exp_65

  connect to user_exp identified by user_exp

  using '(DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.48.1.65)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SID = orcl)

    )

  )';

Select 1 from dual@to_exp_65;

第四步:导出代码

         expdp db_exp/db_exp@orcl_67 directory=DIR_EXP dumpfile=expdp_01.dmp logfile=expdp_01.log tables=(t_exp) network_link=to_exp_65


其他备注:

Db_exp 本地用户,用来连接远端数据库服务器

Dir_exp 本地db_exp用户下 的 directory 用户本地指定expdp写入目录,这里是D盘direxp文件夹

To_exp_65 本地db_exp用户下的 db link ,用来连接远端数据库服务器


3.EXP,EXPDP工具数据导入本地性能对比
性能测试结果:

Exp导出过程如下:


C:\Documents and Settings\Administrator>prompt $P$G$T$G

C:\Documents and Settings\Administrator>16:10:55.37>

C:\Documents and Settings\Administrator>16:11:05.92>exp user_exp/user_exp@orcl_6

5 file=d:\exp_01.dmp log=d:\exp_01.log tables=(t_exp)

Export: Release 10.2.0.1.0 - Production on 星期三 10月 12 16:11:07 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集

服务器使用 AL32UTF8 字符集 (可能的字符集转换)

即将导出指定的表通过常规路径...

. . 正在导出表                           T_EXP导出了    10000007 行

成功终止导出, 没有出现警告。

C:\Documents and Settings\Administrator>16:17:51.04>

用时:6分钟46秒


Expdp导出过程如下:

C:\Documents and Settings\Administrator>16:22:15.25>expdp db_exp/db_exp@orcl_67

directory=DIR_EXP dumpfile=expdp_01.dmp logfile=expdp_01.log tables=(t_exp) netw

ork_link=to_exp_65

Export: Release 10.2.0.1.0 - Production on 星期三, 12 10月, 2011 16:22:16

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

启动 "DB_EXP"."SYS_EXPORT_TABLE_01":  db_exp/********@orcl_67 directory=DIR_EXP

dumpfile=expdp_01.dmp logfile=expdp_01.log tables=(t_exp) network_link=to_exp_65

正在使用 BLOCKS 方法进行估计...

处理对象类型 TABLE_EXPORT/TABLE/TABLE_DATA

使用 BLOCKS 方法的总估计: 336 MB

处理对象类型 TABLE_EXPORT/TABLE/TABLE

. . 导出了 "USER_EXP"."T_EXP"                          285.8 MB 10000007 行

已成功加载/卸载了主表 "DB_EXP"."SYS_EXPORT_TABLE_01"

******************************************************************************

DB_EXP.SYS_EXPORT_TABLE_01 的转储文件集为:

  D:\DIREXP\EXPDP_01.DMP

作业 "DB_EXP"."SYS_EXPORT_TABLE_01" 已于 16:23:35 成功完成

C:\Documents and Settings\Administrator>16:23:36.46>

用时:1分钟21秒


另:Expdp导入到远程数据库服务端 所耗时间如下:

C:\Documents and Settings\Administrator>16:27:40.92>expdp user_exp/user_exp@orcl

_65 directory=DATA_FILE_DIR dumpfile=expdp_02.dmp logfile=expdp_02.log

Export: Release 10.2.0.1.0 - Production on 星期三, 12 10月, 2011 16:27:41

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

启动 "USER_EXP"."SYS_EXPORT_SCHEMA_01":  user_exp/********@orcl_65 directory=DAT

A_FILE_DIR dumpfile=expdp_02.dmp logfile=expdp_02.log

正在使用 BLOCKS 方法进行估计...

处理对象类型 SCHEMA_EXPORT/TABLE/TABLE_DATA

使用 BLOCKS 方法的总估计: 336 MB

处理对象类型 SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA

处理对象类型 SCHEMA_EXPORT/TABLE/TABLE

处理对象类型 SCHEMA_EXPORT/TABLE/INDEX/INDEX

处理对象类型 SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT

处理对象类型 SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

处理对象类型 SCHEMA_EXPORT/TABLE/COMMENT

. . 导出了 "USER_EXP"."T_EXP"                          285.9 MB 10000007 行

已成功加载/卸载了主表 "USER_EXP"."SYS_EXPORT_SCHEMA_01"

******************************************************************************

USER_EXP.SYS_EXPORT_SCHEMA_01 的转储文件集为:

  E:\ORACLE\PRODUCT\10.2.0\DB_1\DEMO\SCHEMA\SALES_HISTORY\EXPDP_02.DMP

作业 "USER_EXP"."SYS_EXPORT_SCHEMA_01" 已于 16:24:52 成功完成

C:\Documents and Settings\Administrator>16:27:59.70>

用时:0分钟19秒


可见,从远端服务器导数据到本地,使用数据泵也是可以完成的,同时效率还是远远高于普通的exp导出。

 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28673746/viewspace-757817/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-02-27

  • 博文量
    129
  • 访问量
    408524