PPAS命令列遷移工具

來源:互聯網
上載者:User

1

從其它資料庫遷移到PPAS時可遷移的資料庫物件間下表


 

 

2

安裝ppas時會有安裝migreation toolkit的選項,可以選擇安裝,也可以到www.enterprisedb.com下載安裝

 

3

編輯/opt/PostgresPlus/9.2AS/etc/toolkit.properties

linux-np3p:/opt/PostgresPlus/9.2AS # cat -netc/toolkit.properties

   SRC_DB_URL=jdbc:oracle:thin:@192.168.1.127:1521:orcl

   SRC_DB_USER=testuser

   SRC_DB_PASSWORD=testuserpw

   

   TARGET_DB_URL=jdbc:edb://localhost:5444/testdb1

   TARGET_DB_USER=testuser

   TARGET_DB_PASSWORD=123456

linux-np3p:/opt/PostgresPlus/9.2AS #

 

4

拷貝oracle的jdbc介面驅動到/opt/PortgresPlus/9.2AS/jre/lib/ext裡面

注意要拷貝和jre版本對應的驅動程式

 

5

遷移

linux-np3p:/opt/PostgresPlus/9.2AS/bin #./runMTK.sh testuser

來源資料庫串連資訊...

串連=jdbc:oracle:thin:@192.168.1.127:1521:orcl

使用者 =TESTUSER

密碼=******

目標資料庫連接資訊...

串連=jdbc:edb://localhost:5444/testdb2

使用者 =testuser

密碼=******

正在串連源Oracle資料庫伺服器...

正在串連目標EnterpriseDB資料庫伺服器...

正在匯入 Redwood 架構 testuser...

正在建立架構...testuser

正在建立表...

正在建立表: TEST1

已建立 1 個表。

正在以 8 MB  批次大小載入表資料...

正在載入表: TEST1...

[TEST1] 已遷移 2 行。

[TEST1] 表資料載入摘要: 時間總計 (秒): 0.375 行數總計: 2

資料載入摘要: 時間總計 (秒): 1.111 行數總計: 2 大小總計 (MB): 0.0

 

已成功匯入架構testuser。

 

正在建立使用者:TESTUSER

建立使用者 TESTUSER 時發生錯誤

 

在遷移進程中有一至多個架構對象無法匯入。有關更多詳細資料,請參閱遷移輸出資訊。

 

遷移日誌已儲存到/root/.enterprisedb/migration-toolkit/logs

 

******************** 遷移摘要 ********************

Tables: 1 來自 1

Users: 0 來自 1

 

全部對象: 2

成功計數: 1

失敗計數: 1

 

失敗對象列表

======================

Users

--------------------

1. TESTUSER

 

 

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

 

6

查詢遷移結果

linux-np3p:/opt/PostgresPlus/9.2AS/bin #./psql -U testuser testdb1

使用者 testuser 的口令:

psql (9.2.0.1)

輸入"help" 來擷取協助資訊.

 

testdb2=# select * from test1;

 id|    xname    

----+--------------

  1 |test / gaga

  2 |test / gaga

(2 行記錄)

 

testdb2=#

 

7

下面是runMTK.sh的內容,可以看到調用了工具edb-migrationtoolkit.jar

# ----------------------------------------------------------------------------

# --

# -- Copyright (c) 2004-2012 - EnterpriseDBCorporation.  All Rights Reserved.

# --

#----------------------------------------------------------------------------

 

/opt/PostgresPlus/9.2AS/jre/bin/java -Dprop=../etc/toolkit.properties-jar edb-migrationtoolkit.jar "$@"

 

8

下面是migreationtoolkit的協助資訊,列出了選擇性參數

 

linux-np3p:/opt/PostgresPlus/9.2AS #jre/bin/java -jar bin/edb-migrationtoolkit.jar -help

 

EnterpriseDB Migration Toolkit (Build 46)

 

用法: runMTK [-選項] SCHEMA

 

若未指定任何選項,則將匯入完整的架構。

 

其中,選項包括:

-help              顯示應用程式的命令列用法。

-version   顯示應用程式版本資訊。

-verbose [on|off] 以標準輸出顯示應用程式記錄檔訊息 (預設值: on)。

 

-schemaOnly   只匯入架構對象定義。

-dataOnly       只匯入表資料。若指定了 -tables,則只匯入所選表的資料。注意: 如果對目標表定義了任何外鍵約束,則此選項需與 -truncLoad 選項一起使用。

 

-sourcedbtype db_type The -sourcedbtypeoption specifies the source database type. db_type may be one of the followingvalues: mysql, oracle, sqlserver, sybase, postgresql, enterprisedb. db_type iscase-insensitive. By default, db_type is oracle.

-targetdbtype db_type The -targetdbtypeoption specifies the target database type. db_type may be one of the followingvalues: oracle, sqlserver, postgresql, enterprisedb. db_type iscase-insensitive. By default, db_type is enterprisedb.

 

-allTables 匯入所有表。

-tables LIST    匯入以逗號分隔的表列表。

-constraints     匯入資料表條件約束。

-indexes  匯入表索引。

-triggers  匯入表觸發器。

-allViews 匯入所有視圖。

-views LIST    匯入以逗號分隔的視圖列表。

-allProcs  匯入所有預存程序。

-procs LIST    匯入以逗號分隔的預存程序列表。

-allFuncs 匯入所有函數。

-funcs LIST    匯入以逗號分隔的函數列表。

-allPackages    匯入所有包。

-packages LIST 匯入以逗號分隔的包列表。

-allSequences  匯入所有序列。

-sequences LIST 匯入以逗號分隔的序列列表。

-targetSchema NAME 目標架構的名稱 (預設: 目標架構以源架構命名)。

-allDBLinks    匯入所有資料庫連結。

-allSynonyms  It enables the migration of all public and private synonyms from anOracle database to an Advanced Server database. If a synonym with the same name already exists in the target database,the existing synonym will be replaced with the migrated version.

-allPublicSynonyms       It enables the migration of all public synonyms from an Oracledatabase to an Advanced Server database. If a synonym with the same name already exists in the target database,the existing synonym will be replaced with the migrated version.

-allPrivateSynonyms      It enables the migration of all private synonyms from an Oracledatabase to an Advanced Server database. If a synonym with the same name already exists in the target database,the existing synonym will be replaced with the migrated version.

 

-dropSchema [true|false] 若架構已存在於目標資料庫中,則刪除此架構 (預設值: false)。

-truncLoad      此選項對目標表禁用任何約束,並且在匯入新資料之前先截斷表中的資料。此選項只能與 -dataOnly 一起使用。

-safeMode      使用純 SQL 陳述式,以安全模式傳輸資料。

-copyDelimiter       在載入表資料時,指定一個字元作為複製命令中的分隔字元。預設值為 \t

-batchSize      指定“批量插入”要使用的“批次大小”。有效值為 1-1000,預設批次大小為 1000,如果出現“記憶體不足”異常,則可以降低此值

-cpBatchSize   指定複製命令要使用的“批次大小”,以 MB 為單位。有效值大於 0,預設批次大小為 8 MB

-fetchSize       指定提取大小 (每次應從結果集中提取的行數)。當資料表含有數百萬個行,而您想避免發生記憶體不足錯誤時,可以使用此選項。

-filterProp      包含表 where 子句的屬性檔案。

-skipFKConst  跳過外鍵約束的遷移。

-skipCKConst 跳過檢查約束條件的遷移。

-ignoreCheckConstFilter       在預設的情況下MTK不從Sybase中遷移檢查約束和預設子句,使用這個選項可以關閉這個過濾功能。

-fastCopy       略過 WAL 日誌記錄,以最佳化方式執行 COPY 操作,預設情況下禁用。

-customColTypeMapping LIST     使用以分號分隔的列表表示的自訂類型映射,其中每個條目都使用 COL_NAME_REG_EXPR=TYPE 對來指定,例如 .*ID=INTEGER

-customColTypeMappingFile PROP_FILE   由屬性檔案表示的自訂類型映射,其中每個條目都使用 COL_NAME_REG_EXPR=TYPE 對來指定,例如 .*ID=INTEGER

-offlineMigration [DDL_PATH] 這將執行離線遷移並將 DDL 指令碼儲存在檔案中供以後執行。預設情況下,如果要求後跟-offlineMigration 選項以及自訂路徑,則指令檔將儲存在使用者主資料夾下。

-logDir LOG_PATH 指定用於儲存記錄檔的自訂路徑。預設情況下,記錄檔儲存在工作目錄中的“logs”檔案夾下。

-copyViaDBLinkOra 此選項可用來通過使用 dblink_ora COPY 命令複製資料。此選項僅限用在從 Oracle 到 EnterpriseDB 移轉模式中。

-singleDataFile       Use single SQL file for offline data storage for all tables.This option cannot be used in COPY format.

-allUsers 從來源資料庫匯入所有使用者和角色。

-users LIST 從來源資料庫匯入選定使用者/角色。LIST 是一個用逗號分隔的使用者/角色名稱列表,如 -users MTK,SAMPLE

-allRules 從來源資料庫匯入所有規則。

-rules LIST 從來源資料庫匯入選定規則。 LIST 是一個用逗號分隔的名稱列表,如 -rules high_sal_emp,low_sal_emp

-allGroups 從來源資料庫匯入所有組。

-groups LIST 從來源資料庫匯入選定組。 LIST 是一個用逗號分隔的組名稱列表,如 -groups acct_emp,mkt_emp

-allDomains 從來源資料庫匯入所有域、枚舉和複合類型。

-domains LIST 從來源資料庫匯入所選域、枚舉和複合類型。 LIST 是一個用逗號分隔的網域名稱稱列表,如 -domainsd_email,d_dob, mood

-objecttypes    匯入使用者定義的物件類型。

-replaceNullChar <CHAR> 如果Null 字元是列值得一部分,那麼通過JDBC協議遷移資料就會失敗.這個選項可以使用使用者指定的字元來替代Null 字元串。

-importPartitionAsTable [LIST] 通過使用這個選項能夠將Oracle中的分區表以常規表的形式匯入到EnterpriseDB中。為了在所選擇表集合上的應用規則,在選項後面應跟隨以逗號分隔的表名列表。

-enableConstBeforeDataLoad 通過使用這個選項可以在資料匯入前重新啟用約束(和觸發器).當要遷移的表在EnterpriseDB中對應的是一張分區表時,使用這個選項是非常有用的。

-checkFunctionBodies [true|false] 設定為 false 時,將禁用建立函數過程中的函數體驗證,從而避免在函數包含向前參考時發生錯誤。 目標資料庫為 Postgres/EnterpriseDB 時適用,預設值為 true。

-retryCount VALUE     指定 MTK 遷移由於跨架構相關性而失敗的對象的重試次數。 VALUE 參數應該大於 0,預設值為 2。

-analyze 它將對目標 Postgres 或 Postgres Plus Advanced Server 資料庫調用 ANALYZE 操作。 ANALYZE 收集用於有效查詢計劃的遷移表的統計資訊。

-vacuumAnalyze    它將對目標 Postgres或 PostgresPlus Advanced Server 資料庫調用 VACUUM 和 ANALYZE 操作。 VACUUM 回收非活動元組儲存,ANALYZE 收集用於有效查詢計劃的遷移表的統計資訊。

-loaderCount VALUE    指定並存執行資料載入的作業(線程)數目。 VALUE 參數應該大於 0,預設值為 1。

 

資料庫連接資訊:

應用程式將從檔案toolkit.properties中讀取源和目標資料庫伺服器的串連資訊.

更多的資訊參見MTK的自述文檔.

 

linux-np3p:/opt/PostgresPlus/9.2AS #

 

9

如果看中午協助資訊有歧義就看下面的英文協助資訊吧

ot@host19.2AS]# jre/bin/java -jar bin/edb-migrationtoolkit.jar -help

 

EnterpriseDBMigration Toolkit (Build 46)

 

Usage: runMTK[-options] SCHEMA

 

If no option isspecified, the complete schema will be imported.

 

where optionsinclude:

-help         Display the application command-lineusage.

-version     Display the application versioninformation.

-verbose[on|off] Display application log messages on standard output (default: on).

 

-schemaOnly     Import the schema object definitions only.

-dataOnly  Import the table data only. When -tables is inplace, it imports data only for the selected tables. Note: If there are any FKconstraints defined on target tables, use -truncLoad option along with thisoption.

 

-sourcedbtypedb_type The -sourcedbtype option specifies the source database type. db_typemay be one of the following values: mysql, oracle, sqlserver, sybase,postgresql, enterprisedb. db_type is case-insensitive. By default, db_type isoracle.

-targetdbtypedb_type The -targetdbtype option specifies the target database type. db_typemay be one of the following values: oracle, sqlserver, postgresql,enterprisedb. db_type is case-insensitive. By default, db_type is enterprisedb.

 

-allTables   Import all tables.

-tables LIST      Import comma-separated list of tables.

-constraints       Import the table constraints.

-indexes     Import the table indexes.

-triggers    Import the table triggers.

-allViews   Import all Views.

-views LIST      Import comma-separated list of Views.

-allProcs    Import all stored procedures.

-procs LIST      Import comma-separated list of storedprocedures.

-allFuncs   Import all functions.

-funcs LIST      Import comma-separated list of functions.

-allPackages      Import all packages.

-packages LISTImport comma-separated list of packages.

-allSequences    Import all sequences.

-sequences LISTImport comma-separated list of sequences.

-targetSchemaNAME Name of the target schema (default: target schema is named after sourceschema).

-allDBLinks      Import all Database Links.

-allSynonyms    It enables the migration of all public andprivate synonyms from an Oracle database to an Advanced Server database.  If a synonym with the same name alreadyexists in the target database, the existing synonym will be replaced with themigrated version.

-allPublicSynonyms  It enables the migration of all publicsynonyms from an Oracle database to an Advanced Server database.  If a synonym with the same name alreadyexists in the target database, the existing synonym will be replaced with themigrated version.

-allPrivateSynonyms It enables the migration of all privatesynonyms from an Oracle database to an Advanced Server database.  If a synonym with the same name alreadyexists in the target database, the existing synonym will be replaced with themigrated version.

 

-dropSchema[true|false] Drop the schema if it already exists in the target database(default: false).

-truncLoad It disables any constraints on target table andtruncates the data from the table before importing new data. This option canonly be used with -dataOnly.

-safeMode  Transfer data in safe mode using plain SQLstatements.

-copyDelimiter  Specify a single character to be used asdelimiter in copy command when loading table data. Default is \t

-batchSize  Specify the Batch Size to be used by the bulkinserts. Valid values are  1-1000,default batch size is 1000, reduce if you run into Out of Memory exception

-cpBatchSize     Specify the Batch Size in MB, to be usedin the Copy Command. Valid value is > 0, default batch size is 8 MB

-fetchSize  Specify fetch size in terms of number of rowsshould be fetched in result set at a time. This option can be used when tablescontain millions of rows and you want to avoid out of memory errors.

-filterProp The properties file that contains table whereclause.

-skipFKConst    Skip migration of FK constraints.

-skipCKConst    Skip migration of Check constraints.

-ignoreCheckConstFilter   By default MTK does not migrate Checkconstraints and Default clauses from Sybase, use this option to turn off thisfilter.

-fastCopy   Bypass WAL logging to perform the COPYoperation in an optimized way, default disabled.

-customColTypeMappingLIST Use custom type mapping representedby a semi-colon separated list, where each entry is specified usingCOL_NAME_REG_EXPR=TYPE pair. e.g. .*ID=INTEGER

-customColTypeMappingFilePROP_FILE     The custom type mappingrepresented by a properties file, where each entry is specified usingCOL_NAME_REG_EXPR=TYPE pair. e.g. .*ID=INTEGER

-offlineMigration[PATH] This performs offline migration and saves the DDL/DML scripts in filesfor a later execution. By default the script files will be saved under userhome folder, if required follow -offlineMigration option with a custom path.

-logDirLOG_PATH Specify a custom path to save the log file. By default, on Linux thelogs will be saved under folder $HOME/.enterprisedb/migration-toolkit/logs. Incase of Windows logs will be saved under folder%HOMEDRIVE%%HOMEPATH%\.enterprisedb\migration-toolkit\logs.

-copyViaDBLinkOraThis option can be used to copy data using dblink_ora COPY commad. This optioncan only be used in Oracle to EnterpriseDB migration mode.

-singleDataFile  Use single SQL file for offline data storagefor all tables. This option cannot be used in COPY format.

-allUsersImport all users and roles from the source database.

-users LISTImport the selected users/roles from the source database. LIST is acomma-separated list of user/role names e.g. -users MTK,SAMPLE

-allRulesImport all rules from the source database.

-rules LISTImport the selected rules from the source database. LIST is a comma-separatedlist of rule names e.g. -rules high_sal_emp,low_sal_emp

-allGroupsImport all groups from the source database.

-groups LISTImport the selected groups from the source database. LIST is a comma-separated listof group names e.g. -groups acct_emp,mkt_emp

-allDomainsImport all domain, enumeration and composite types from the source database.

-domains LISTImport the selected domain, enumeration and composite types from the sourcedatabase. LIST is a comma-separated list of domain names e.g. -domainsd_email,d_dob, mood

-objecttypes      Import the user-defined object types.

-replaceNullChar<CHAR> If null character is part of a column value, the data migrationfails over JDBC protocol. This option can be used to replace null characterwith a user-specified character.

-importPartitionAsTable[LIST] Use this option to import Oracle Partitioned table as a normal table inEnterpriseDB. To apply the rule on a selected set of tables, follow the optionby a comma-separated list of table names.

-enableConstBeforeDataLoadUse this option to re-enable constraints (and triggers) before data load. Thisis useful in the scenario when the migrated table is mapped to a partitiontable in EnterpriseDB.

-checkFunctionBodies[true|false] When set to false, it disables validation of the function bodyduring function creation, this is to avoid errors if function contains forwardreferences. Applicable when target database is Postgres/EnterpriseDB, defaultis true.

-retryCountVALUE  Specify the number of re-attemptsperformed by MTK to migrate objects that failed due to cross-schemadependencies. The VALUE parameter should be greater than 0, default is 2.

-analyze    It invokes ANALYZE operation against a targetPostgres or Postgres Plus Advanced Server database. The ANALYZE collectsstatistics for the migrated tables that are utilized for efficient query plans.

-vacuumAnalyze      It invokes VACUUM and ANALYZE operationsagainst a target Postgres or Postgres Plus Advanced Server database. The VACUUMreclaims dead tuple storage whereas ANALYZE collects statistics for themigrated tables that are utilized for efficient query plans.

-loaderCountVALUE       Specify the number of jobs(threads) to perform data load in parallel. The VALUE parameter should begreater than 0, default is 1.

 

DatabaseConnection Information:

The applicationwill read the connectivity information for the source and target databaseservers from toolkit.properties file.

Refer to MTKreadme document for more information.

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.