通過dblink使用expdp能不能匯出9i庫的資料?,dblinkexpdp

來源:互聯網
上載者:User

通過dblink使用expdp能不能匯出9i庫的資料?,dblinkexpdp

expdp/impdp是10g推出的匯入匯出工具,9i下是沒有該工具的,有人提議用10g的expdp,通過dblink匯出9i的資料,乍一聽感覺是那麼回事,但究竟行不行,咱們實驗說明。


1. 登入到一台10g/11g的伺服器,首先建立串連到9i庫TEST的一個連結tlink:

SQL> create database link tlink connect to test identified by test using 'TEST';Database link created.


2. 編輯expdp匯出的設定檔:

userid=user/pwd- expdp使用的本機資料庫使用者directory=expdp_dir- directory路徑dumpfile=testtkt.dumplogfile=testtkt.logtables=test.t_r- 要匯出的9i庫表t_rnetwork_link=tlink- 連結到的9i庫dblink


3. 執行expdp:

[oracle11g@Node1 expdp_dir]$ expdp parfile=tlink.parExport: Release 11.2.0.1.0 - Production on Mon May 18 13:35:57 2015Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsORA-39006: internal errorORA-39065: unexpected master process exception in DISPATCHORA-00904: "SYS"."KUPM$MCP"."GET_ENDIANNESS": invalid identifierORA-39097: Data Pump job encountered unexpected error -904
提示一系列ORA錯誤。

expdp不像exp,他是將匯出轉變成一個Oracle內部的job任務,有一點可以證明,就是使用exp匯出時用ctrl+c中斷,此時匯出過程整體中斷,如果使用expdp匯出時用ctrl+c中斷,此時匯出過程並未中斷,因為其已經轉變為Oracle的一個任務,和用戶端無關,退出互動模式後,會進入export的命令列模式,有status、start、stop等命令可以用。

從上面的報錯可以看到ORA-00904: "SYS"."KUPM$MCP"."GET_ENDIANNESS": invalid identifier,關於904的錯誤描述:

[oracle11g@Node1 expdp_dir]$ oerr ora 90400904, 00000, "%s: invalid identifier"// *Cause:// *Action:
說明是找不到對應的標識符,再看看SYS.KUPM$MCP大概是什麼:

SQL> desc sys.KUPM$MCP;PROCEDURE CLOSE_JOBFUNCTION DISPATCH RETURNS KUPC$_MESSAGE Argument Name                  Type                    In/Out Default? ------------------------------ ----------------------- ------ -------- REQUEST                        KUPC$_MESSAGE           INPROCEDURE FILE_LOG_MESSAGE Argument Name                  Type                    In/Out Default? ------------------------------ ----------------------- ------ -------- ERRCODE                        NUMBER                  IN PARAMETER1                     VARCHAR2                IN     DEFAULT PARAMETER2                     VARCHAR2                IN     DEFAULT PARAMETER3                     VARCHAR2                IN     DEFAULT PARAMETER4                     VARCHAR2                IN     DEFAULT PARAMETER5                     VARCHAR2                IN     DEFAULT PARAMETER6                     VARCHAR2                IN     DEFAULT PARAMETER7                     VARCHAR2                IN     DEFAULT PARAMETER8                     VARCHAR2                IN     DEFAULTPROCEDURE FILE_TO_WORKER Argument Name                  Type                    In/Out Default? ------------------------------ ----------------------- ------ -------- MESSAGE                        KUPC$_MESSAGE           INFUNCTION GET_ENDIANNESS RETURNS NUMBERPROCEDURE MAIN Argument Name                  Type                    In/Out Default? ------------------------------ ----------------------- ------ -------- JOB_NAME                       VARCHAR2                IN JOB_OWNER                      VARCHAR2                IN RESTART_JOB                    BINARY_INTEGER          IN DEBUG_INFO                     BINARY_INTEGER          INPROCEDURE MAINLOOPPROCEDURE SET_DEBUG Argument Name                  Type                    In/Out Default? ------------------------------ ----------------------- ------ -------- DEBUG_FLAGS                    BINARY_INTEGER          INFUNCTION VALIDATE_EXPRESSION RETURNS NUMBER Argument Name                  Type                    In/Out Default? ------------------------------ ----------------------- ------ -------- EXPR_VALUE                     VARCHAR2                IN
其實他包含了若干函數,GET_ENDIANNESS是其中一個(從名稱上看,貌似是獲得“大小端資訊”),顯然是沒找到對應函數,忘了從什麼地方看到過關於這個函數的描述(如果哪位高人記得,可以回複下),他在9i中是不存在的,可以證明expdp匯出過程是需要調用這個函數的,但這個函數在9i中是沒有定義的,因此9i下是不能使用expdp。


4. 我們接著看dblink匯出10g以上版本的庫

SQL> create database link ldplink connect to puser identified by puser_pwd using 'link_10g';Database link created.

5. 編輯expdp設定檔:
[oracle11g@Node1 expdp_dir]$ vi link_10g.par
userid=user/pwd
directory=expdp_dirdumpfile=link_10g.dumplogfile=link_10g.logtables=puser.l_rnetwork_link=link_10g


6. 執行expdp:

[oracle11g@Node1 expdp_dir]$ expdp parfile=link_10g.par Export: Release 11.2.0.1.0 - Production on Mon May 18 13:40:45 2015Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsORA-31631: privileges are requiredORA-39149: cannot link privileged user to non-privileged user

這回又提示ORA-31631和ORA-39149兩個錯誤。

[oracle11g@Node1 expdp_dir]$ oerr ora 3163131631, 00000, "privileges are required" // *Cause:  The necessary privileges are not available for operations such//          as: restarting a job on behalf of another owner, using a device//          as a member of the dump file set, or ommiting a directory//          object associated with any of the various output files.  //          Refer to any following error messages for additional information.// *Action: Select a different job to restart, try a different operation, or//          contact a database administrator to acquire the needed privileges.

提示是缺少許可權。

[oracle11g@Node1 expdp_dir]$ oerr ora 3914939149, 00000, "cannot link privileged user to non-privileged user"// *Cause:  A Data Pump job initiated be a user with //          EXPORT_FULL_DATABASE/IMPORT_FULL_DATABASE roles specified a//          network link that did not correspond to a user with//          equivalent roles on the remote database.// *Action: Specify a network link that maps users to identically privileged //          users in the remote database.
這個錯誤提示的更加明確,提示使用dblink並且具有EXPORT_FULL_DATABASE/IMPORT_FULL_DATABASE角色的執行使用者,對應遠端的使用者並沒有相應的角色許可權。有點繞,簡單講,就是我這裡使用expdp的資料庫使用者user,是有DBA許可權的,因此具有EXPORT_FULL_DATABASE/IMPORT_FULL_DATABASE角色許可權,但遠端資料庫使用者puser只是普通使用者,沒有此許可權,因此有這個提示錯誤。

解決方案1:

遠端庫中設定:

SQL> grant exp_full_database to puser;Grant succeeded.
再次執行expdp:

[oracle11g@Node1 expdp_dir]$ expdp parfile=link_10g.par Export: Release 11.2.0.1.0 - Production on Mon May 18 13:51:37 2015Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsStarting "USER"."SYS_EXPORT_TABLE_01":  user/******** parfile=link_10g.par Estimate in progress using BLOCKS method...Processing object type TABLE_EXPORT/TABLE/TABLE_DATATotal estimation using BLOCKS method: 64 KBProcessing object type TABLE_EXPORT/TABLE/TABLEProcessing object type TABLE_EXPORT/TABLE/INDEX/INDEXProcessing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINTProcessing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICSProcessing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS. . exported "PUSER"."L_R"                          20.49 KB      28 rowsMaster table "BISAL"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded******************************************************************************Dump file set for USER.SYS_EXPORT_TABLE_01 is:  /home/oracle11g/expdp_dir/link_10g.dumpJob "USER"."SYS_EXPORT_TABLE_01" successfully completed at 13:51:56

解決方案2:

楊長老的這篇博文(http://blog.itpub.net/4227/viewspace-448665/)說明了此問題。對於這個問題,還有種方法,就是建立一個本機使用者,不授予EXPORT_FULL_DATABASE/IMPORT_FULL_DATABASE角色。


總結

1. 9i是不支援expdp的,即使從10g的expdp使用dblink連到9i,也是不行的,從上述實驗可以看到,有些expdp使用的函數是在9i中沒有定義的。

2. 使用dblink方式的expdp匯出,要求要麼本機使用者沒有EXPORT_FULL_DATABASE/IMPORT_FULL_DATABASE角色,要麼本機使用者有這兩個角色,但此時要求遠端使用者有EXPORT_FULL_DATABASE角色,否則就會提示ORA-31631和ORA-39149這兩個錯誤。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.