绑定完请刷新页面
取消
刷新

分享好友

×
取消 复制
EDB Postgres MTK 使用小记
2022-03-30 15:05:34

EDB Postgres Sever Migration Toolkit 是PPAS自带的一款数据迁移工具。使用MTK可以方便的把目标数据库(ORACLE/MySQL/Sybase/MS SQL Sever)的数据对象和数据内容迁移到 PPAS or PostgreSQL 。

安装 MTK 软件

安装方式: 图像化 or command-line
测试案例为 text mode

  1. [root@Opython mtk]# ./edb-migrationtoolkit-51.0.0-1-linux-x64.run
  2. Language Selection
  3. Please select the installation language
  4. [1] English - English
  5. [2] Japanese - 日本語
  6. [3] Simplified Chinese - 简体中文
  7. [4] Traditional Chinese - 繁体中文
  8. [5] Korean - 한국어
  9. Please choose an option [1] :
  10. ----------------------------------------------------------------------------
  11. Welcome to the EDB Postgres Migration Toolkit Setup Wizard.
  12. ----------------------------------------------------------------------------
  13. Please read the following License Agreement. You must accept the terms of this
  14. agreement before continuing with the installation.
  15. Press [Enter] to continue:
  16. Limited Use Software License Agreement
  17. Version 2.9
  18. IMPORTANT - READ CAREFULLY
  19. ...............................................
  20. Please specify the directory where Migration Toolkit will be installed.
  21. Installation Directory [/opt/edb/mtk]:
  22. ----------------------------------------------------------------------------
  23. Setup is now ready to begin installing Migration Toolkit on your computer.
  24. Do you want to continue? [Y/n]: Y
  25. ----------------------------------------------------------------------------
  26. Please wait while Setup installs Migration Toolkit on your computer.
  27. Installing EDB Postgres Migration Toolkit
  28. % ______________ 50% ______________ 100%
  29. #########################################
  30. ----------------------------------------------------------------------------
  31. EnterpriseDB is the leading provider of value-added products and services for
  32. the Postgres community.
  33. Please visit our website at www.enterprisedb.com

安装 ORACLE client oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm

下载地址:http://www.oracle.com/technetwork/cn/database/features/instant-client/index-097480.html

  1. [root@Opython mtk]# rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
  2. Preparing... ########################################### []
  3. 1:oracle-instantclient11.########################################### []
  4. [root@Opython mtk]# cp /usr/lib/oracle/11.2/client64/lib/ojdbc6.jar /usr/lib/jvm/jre-1.7.0/lib/ext/

配置 toolkit.properties 配置文件(位置在 MTK 主目录 /etc 下)

  1. SRC_DB_URL=jdbc:oracle:thin:@1.2.3.4:1528:wprod11g #Ensure that the oracle instance client is avalible
  2. SRC_DB_USER=system
  3. SRC_DB_PASSWORD=oracle
  4. TARGET_DB_URL=jdbc:edb://5.6.7.8:5444/cww
  5. TARGET_DB_USER=pgmg
  6. TARGET_DB_PASSWORD=oracle

迁移测试

  1. /opt/edb/mtk/bin/runMTK.sh -dropSchema true SCOTT
  2. Running EnterpriseDB Migration Toolkit (Build 51.0.0) ...
  3. Source database connectivity info...
  4. conn =jdbc:oracle:thin:@
  5. user =system
  6. password=******
  7. Target database connectivity info...
  8. conn =jdbc:edb://
  9. user =pgmg
  10. password=******
  11. Connecting with source Oracle database server...
  12. Connected to Oracle, version 'Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
  13. With the Partitioning, OLAP, Data Mining and Real Application Testing options'
  14. Connecting with target EDB Postgres database server...
  15. Connected to EnterpriseDB, version '9.3.1.3'
  16. Importing redwood schema SCOTT...
  17. Dropping Schema: scott
  18. Creating Schema...scott
  19. Creating Tables...
  20. Creating Table: BONUS
  21. Creating Table: DEPT
  22. Creating Table: EMP
  23. Creating Table: SALGRADE
  24. Created 4 tables.
  25. Loading Table Data in 8 MB batches...
  26. Loading Table: BONUS ...
  27. [BONUS] Table Data Load Summary: Total Time(s): 0.089 Total Rows:
  28. Loading Table: DEPT ...
  29. [DEPT] Migrated 4 rows.
  30. [DEPT] Table Data Load Summary: Total Time(s): 0.051 Total Rows: 4
  31. Loading Table: EMP ...
  32. [EMP] Migrated 14 rows.
  33. [EMP] Table Data Load Summary: Total Time(s): 0.066 Total Rows: 14
  34. Loading Table: SALGRADE ...
  35. [SALGRADE] Migrated 5 rows.
  36. [SALGRADE] Table Data Load Summary: Total Time(s): 0.049 Total Rows: 5
  37. Data Load Summary: Total Time (sec): 0.563 Total Rows: 23 Total Size(MB): 0.0
  38. Creating Constraint: PK_DEPT
  39. Creating Constraint: PK_EMP
  40. Creating Constraint: FK_DEPTNO
  41. Schema SCOTT imported successfully.
  42. MTK-14003: One or more users couldn't be found in the source Oracle database.
  43. With -users mode, the user name should be in uppercase unless it is case-sensitive.
  44. One or more schema objects could not be imported during the migration process. Please review the migration output for more details.
  45. Migration logs have been saved to /root/.enterprisedb/migration-toolkit/logs
  46. ******************** Migration Summary ********************
  47. Tables: 4 out of 4
  48. Constraints: 3 out of 3
  49. Total objects: 7
  50. Successful count: 7
  51. Failed count: 0
  52. Invalid count: 0
  53. *************************************************************

数据检测

  1. cww=# \d scott.*
  2. Table "scott.bonus"
  3. Column | Type | Modifiers
  4. --------+-----------------------+-----------
  5. ename | character varying(10) |
  6. job | character varying(9) |
  7. sal | numeric |
  8. comm | numeric |
  9. Table "scott.dept"
  10. Column | Type | Modifiers
  11. --------+-----------------------+-----------
  12. deptno | numeric(2,) | not null
  13. dname | character varying(14) |
  14. loc | character varying(13) |
  15. Indexes:
  16. "pk_dept" PRIMARY KEY, btree (deptno)
  17. Referenced by:
  18. TABLE "scott.emp" CONSTRAINT "fk_deptno" FOREIGN KEY (deptno) REFERENCES scott.dept(deptno)
  19. Table "scott.emp"
  20. Column | Type | Modifiers
  21. ----------+-----------------------------+-----------
  22. empno | numeric(4,) | not null
  23. ename | character varying(10) |
  24. job | character varying(9) |
  25. mgr | numeric(4,) |
  26. hiredate | timestamp without time zone |
  27. sal | numeric(7,2) |
  28. comm | numeric(7,2) |
  29. deptno | numeric(2,) |
  30. Indexes:
  31. "pk_emp" PRIMARY KEY, btree (empno)
  32. Foreign-key constraints:
  33. "fk_deptno" FOREIGN KEY (deptno) REFERENCES scott.dept(deptno)
  34. Index "scott.pk_dept"
  35. Column | Type | Definition
  36. --------+--------------+------------
  37. deptno | numeric(2,) | deptno
  38. primary key, btree, for table "scott.dept"
  39. Index "scott.pk_emp"
  40. Column | Type | Definition
  41. --------+--------------+------------
  42. empno | numeric(4,) | empno
  43. primary key, btree, for table "scott.emp"
  44. Table "scott.salgrade"
  45. Column | Type | Modifiers
  46. --------+---------+-----------
  47. grade | numeric |
  48. losal | numeric |
  49. hisal | numeric |

EDB Migration Toolkit 支持数据对象类型

粘贴图片.png

MTK tools常用参数:

MTK 工具可根据需求使用参数灵活使用

  1. -verbose [on|off] Display application log messages on standard output (default: on).
  2. -schemaOnly Import the schema object definitions only.
  3. -dataOnly Import the table data only.
  4. -sourcedbtype db_type The -sourcedbtype option specifies the source database type.
  5. -targetdbtype db_type The -targetdbtype option specifies the target database type.
  6. -allTables Import all tables.
  7. -tables LIST Import comma-separated list of tables.
  8. -constraints Import the table constraints.
  9. -indexes Import the table indexes.
  10. -triggers Import the table triggers.
  11. -allViews Import all Views.
  12. -views LIST Import comma-separated list of Views.
  13. -allProcs Import all stored procedures.
  14. -procs LIST Import comma-separated list of stored procedures.
  15. -allFuncs Import all functions.
  16. -funcs LIST Import comma-separated list of functions.
  17. -allPackages Import all packages.
  18. -packages LIST Import comma-separated list of packages.
  19. -allSequences Import all sequences.
  20. -sequences LIST Import comma-separated list of sequences.
  21. -targetSchema NAME Name of the target schema (default: target schema is named after source schema).
  22. -allDBLinks Import all Database Links.
  23. -allSynonyms It enables the migration of all public and private synonyms from an Oracle 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.
  24. -allPublicSynonyms It enables the migration of all public synonyms from an Oracle 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.
  25. -allPrivateSynonyms It enables the migration of all private synonyms from an Oracle 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.
  26. -allQueues Import all queues from the source database.
  27. -queues LIST Import the selected queues from the source database. LIST is a comma-separated list of queue names.
  28. -skipUserSchemaCreation This option prevents implicit schema creation for a migrated Oracle user.
  29. -dropSchema [true|false] Drop the schema if it already exists in the target database (default: false).
  30. -truncLoad It disables any constraints on target table and truncates the data from the table before importing new data. This option can only be used with -dataOnly.
  31. -safeMode Transfer data in safe mode using plain SQL statements.
  32. -copyDelimiter Specify a single character to be used as delimiter in copy command when loading table data. Default is \t
  33. -batchSize Specify the Batch Size to be used by the bulk inserts. Valid values are 1-50000, default batch size is 1000, reduce if you run into Out of Memory exception
  34. -cpBatchSize Specify the Batch Size in MB, to be used in the Copy Command. Valid value is from 1 to 1024, default batch size is 8 MB.
  35. -fetchSize Specify fetch size in terms of number of rows should be fetched in result set at a time. This option can be used when tables contain millions of rows and you want to avoid out of memory errors.
  36. -filterProp The properties file that contains table where clause.
  37. -skipFKConst Skip migration of FK constraints.
  38. -skipCKConst Skip migration of Check constraints.
  39. -ignoreCheckConstFilter By default MTK does not migrate Check constraints and Default clauses from Sybase, use this option to turn off this filter.
  40. -fastCopy Bypass WAL logging to perform the COPY operation in an optimized way, default disabled.
  41. -customColTypeMapping LIST Use custom type mapping represented by a semi-colon separated list, where each entry is specified using COL_NAME_REG_EXPR=TYPE pair. e.g. .*ID=INTEGER
  42. -customColTypeMappingFile PROP_FILE The custom type mapping represented by a properties file, where each entry is specified using COL_NAME_REG_EXPR=TYPE pair. e.g. .*ID=INTEGER
  43. -offlineMigration [PATH] This performs offline migration and saves the DDL/DML scripts in files for a later execution. By default the script files will be saved under user home folder, if required follow -offlineMigration option with a custom path.
  44. -logDir LOG_PATH Specify a custom path to save the log file. By default, on Linux the logs will be saved under folder $HOME/.enterprisedb/migration-toolkit/logs. In case of Windows logs will be saved under folder %HOMEDRIVE%%HOMEPATH%\.enterprisedb\migration-toolkit\logs.
  45. -copyViaDBLinkOra This option can be used to copy data using dblink_ora COPY command. This option can only be used in Oracle to EnterpriseDB migration mode.
  46. -singleDataFile Use single SQL file for offline data storage for all tables. This option cannot be used in COPY format.
  47. -allUsers Import all users and roles from the source database.
  48. -users LIST Import the selected users/roles from the source database. LIST is a comma-separated list of user/role names e.g. -users MTK,SAMPLE
  49. -allProfiles Import all profiles from the source database.
  50. -profiles LIST Import the selected profiles from the source database. LIST is a comma-separated list of profile names e.g. -profiles USER_PROFILE,ADMIN_PROFILE
  51. -allRules Import all rules from the source database.
  52. -rules LIST Import the selected rules from the source database. LIST is a comma-separated list of rule names e.g. -rules high_sal_emp,low_sal_emp
  53. -allGroups Import all groups from the source database.
  54. -groups LIST Import the selected groups from the source database. LIST is a comma-separated list of group names e.g. -groups acct_emp,mkt_emp
  55. -allDomains Import all domain, enumeration and composite * from the source database.
  56. -domains LIST Import the selected domain, enumeration and composite * from the source database. LIST is a comma-separated list of domain names e.g. -domains d_email,d_dob, mood
  57. -object* Import the user-defined object *.
  58. -replaceNullChar <CHAR> If null character is part of a column value, the data migration fails over JDBC protocol. This option can be used to replace null character with a user-specified character.
  59. -importPartitionAsTable [LIST] Use this option to import Oracle Partitioned table as a normal table in EnterpriseDB. To apply the rule on a selected set of tables, follow the option by a comma-separated list of table names.
  60. -enableConstBeforeDataLoad Use this option to re-enable constraints (and triggers) before data load. This is useful in the scenario when the migrated table is mapped to a partition table in EnterpriseDB.
  61. -checkFunctionBodies [true|false] When set to false, it disables validation of the function body during function creation, this is to avoid errors if function contains forward references. Applicable when target database is Postgres/EnterpriseDB, default is true.
  62. -retryCount VALUE Specify the number of re-attempts performed by MTK to migrate objects that failed due to cross-schema dependencies. The VALUE parameter should be greater than , default is 2.
  63. -analyze It invokes ANALYZE operation against a target Postgres or Postgres Plus Advanced Server database. The ANALYZE collects statistics for the migrated tables that are utilized for efficient query plans.
  64. -vacuumAnalyze It invokes VACUUM and ANALYZE operations against a target Postgres or Postgres Plus Advanced Server database. The VACUUM reclaims dead tuple storage whereas ANALYZE collects statistics for the migrated tables that are utilized for efficient query plans.
  65. -loaderCount VALUE Specify the number of jobs (threads) to perform data load in parallel. The VALUE parameter should be greater than , default is 1.
  66. -logFileSize VALUE It represents the maximum file size limit (in MB) before rotating to a new log file, defaults to 50MB.
  67. -logFileCount VALUE It represents the number of files to maintain in log file rotation history, defaults to 20. Specify a value of zero to disable log file rotation.
  68. -useOraCase It preserves the identifier case while migrating from Oracle, except for functions, procedures and packages unless identifier names are given in quotes.
  69. -logBadSQL It saves the DDL scripts for the objects that fail to migrate, in a .sql file in log folder.
  70. -targetDBVersion It represents the major.minor version of the target database. This option is applicable for offline migration mode and is used to validate certain migration options as per target db version [default is 9.6 for EnterpriseDB database]

来自:https://blog.csdn.net/weixin_34054866/article/details/90329807


分享好友

分享这个小栈给你的朋友们,一起进步吧。

EDB Postgres
创建时间:2022-03-30 14:51:45
EDB Postgres
展开
订阅须知

• 所有用户可根据关注领域订阅专区或所有专区

• 付费订阅:虚拟交易,一经交易不退款;若特殊情况,可3日内客服咨询

• 专区发布评论属默认订阅所评论专区(除付费小栈外)

技术专家

查看更多
  • gaokeke123
    专家
戳我,来吐槽~