EXP,EXPDP資料匯入本地效能測試

lygle發表於2013-04-06

     大家都知道,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部落格 ” ,連結:http://blog.itpub.net/28673746/viewspace-757817/,如需轉載,請註明出處,否則將追究法律責任。

相關文章