文档中心MogDBMogDB StackUqbar

文档:v2.0

支持的版本:

MVD 使用说明

MVD 为纯命令行工具,只能在 Shell 界面中执行。可通过 -h 选项查看命令帮助信息,如下:

Introduction:
    MVD is a data verification tool for Heterogeneous Databases.

Options:
    -h, --help           : Show help message
    -v, --version        : Show tool version [2.2.14]
    -x, --debug          : Run in debug mode, means more output logs
    -c, --config-file    : Using a config file with format json
        --mtk-config     : Using a config file from MTK tool with format json
    -d, --func-dimension : [Advanced Option] Functions used in data comparison
                         : Default: avg:a,min:np,max:np,median:np
                         : Format: <name>:<primary_type>    -- Same function name among all database
                         :         <primary_type> := a|p|np, a = all, p = primary table, np = not [p]
                         :                           can be ignored, then use default [a]
                         : Format: <name>:<function_list>:<primary_type>
                         :         <function_list> := <db_type> = <function_name> | <db_type> = <function_name>
                         :         <db_type> := ORACLE|DB2|MYSQL|POSTGRESQL|MOGDB|OPENGAUSS
                         : Example 'testmin:oracle=min|mogdb=min|mysql=min|db2=min:p'
    -s, --source-db      : Source database to be verified
                         : Format: <db_type>:<ip>:<port>:<name>:<user>:<password>
                         :         <db_type> := ORACLE|DB2|MYSQL|POSTGRESQL|MOGDB|OPENGAUSS
    -t, --target-db      : Target database to be verified, format see also '-s'
    -w, --workers        : Parallel workers (1~32), default: 8
    -T, --table          : Check a single table
                         : Format: <owner>.<table_name>
                         :   Tips: if this option was specified, then '-i' and '-e' will be ignored
    -i, --include        : White list, patterns used for object filter, all patterns combined with comma
                         : Format: <type>:<owner>.<object_name>,...
                         :         <type>:<object_name>
                         :         <owner>.<object_name>
                         :         <object_name>
                         : Notes: 1. <type> can use: */%/TABLE/VIEW/SEQUENCE/PROCEDURE/FUNCTION/OTHERS
                         :        2. Can use */% in <owner> and <object_name> field, means to match all
    -e, --exclude        : Black list, patterns used for object filter, format see also '-i'
    -f, --result-file    : Result file, used to save result, default to print result to screen
    -F, --result-format  : Result file data format: json (default), plain
    -R, --row-dir        : Row directory for differences data (MD5 & KEY)
        --row-feedback   : Query row data when differences found, otherwise just key condition listed
        --ignore-float   : Ignore float data type in comparison
    -l, --logfile        : Write output information to logfile

Usage:
    1. Verify a single table  (Using Statistics Analysis)
       ./mvd_macos_x86_64 -s 'ORACLE:127.0.0.1:1521:orcl:scott:tiger' -t 'MOGDB:127.0.0.1:5432:postgres:hongye:pwd' -T 'HONGYE.TEST'
    2. Verify a single schema  (Using MD5 ROW-BY-ROW)
       ./mvd_macos_x86_64 -s 'ORACLE:127.0.0.1:1521:orcl:scott:tiger' -t 'MOGDB:127.0.0.1:5432:postgres:hongye:pwd' -i 'HONGYE.*' -R './diff'

命令选项说明

命令选项 选项说明
-h, --help 显示工具的帮助信息
-v, --version 显示工具的当前版本信息
-x, --debug 开启 DEBUG 模式,输出更详细的日志内容,仅在出现问题后的调试过程中使用
-c, --config-file 指定程序运行时的配置参数(json格式),使用配置参数代替具体命令行选项
--mtk-config 指定 MTK 运行时的配置文件(json格式),校验 MTK 同步过程中涉及到的对象和表的数据
-d, --func-dimension 高级选项,不是特别清晰该选项含义时,请勿使用。
指定数据对比过程中的统计函数维度,输入格式为:
1. <name>:<primary_type>
2. <name>:<function_list>:<primary_type>
其中:
primary_type 可选值为 a = 所有表, p = 主键表, np = 非主键表
name 函数名称,若函数名称即为实际数据库中的函数,那么无需指定 function_list,否则需要指定改函数在各个数据库中的实际表现
function_list 指定该函数在各个数据库中的不同表现形式,格式为: <db_type>=<function_name>
-s, --source-db 指定对比的源端数据库,其输入格式为: <db_type>:<ip>:<port>:<name>:<user>:<password>
其中 db_type 可选值如下: ORACLE, DB2, MYSQL, POSTGRESQL, MOGDB, OPENGAUSS
-t, --target-db 指定对比的目标端数据库,其输入格式与 -s 一样。
-w, --workers 指定数据对比过程中的并发进程数量,范围是 1~32,默认是 8 个并发
-T, --table 仅仅只针对单张表进行对比,输入格式为: <owner>.<table_name>,不可使用通配符,会与 -i-e 选项冲突。
-i, --include 需要包含进行对比的对象列表,可指定多个匹配模式,使用逗号分隔。
匹配格式包括:<type>:<owner>.<object_name>, <owner>.<object_name>, <object_name>, ...
可以在 OWNER, OBJECT_NAME 中使用 *% 来标识通配符
TYPE 类型包括: */%/TABLE/VIEW/SEQUENCE/PROCEDURE/FUNCTION/OTHERS
-e, --exclude 需要排除的对象列表,其格式与 -i 一样。
-f, --result-file 对比结果的输出文件,默认无输出文件,直接在当前执行的命令行窗口展示结果
-F, --result-format 对比结果的格式,支持 json, plain 两种,默认 plain 方式,即便于人工阅读的文本格式
-R, --row-dir 执行逐行 MD5 对比模式,指定行差异结果的输出文件夹,每张有差异的表,都会在该目录中创建一个差异文件
--row-feedback 是否回显差异行的完整数据,默认只显示差异行的 KEY (Oracle 中的 ROWID, PG 中的 CTID 等)
--ignore-float 是否在数据对比过程中,忽略浮点类型 (float, double, real 等非精确类型),默认不忽略
-l, --logfile 指定工具运行的日志文件

常用命令示例

以下为一些常用场景下的命令示例(以 2.0 MacOS 版本程序为例)。

注意: 特征值统计对比方式可能效率较慢,推荐使用 MD5 逐行对比模式。

  1. 对比 Oracle 到 MogDB 的结构和数据差异:

    ./mvd_macos_x86_64 -s 'ORACLE:127.0.0.1:1521:orcl:hongye:pwd' -t 'MOGDB:127.0.0.1:5432:omm:hongye:pwd' -i 'mtk.*' -R './diff'
  2. 对比 DB2 到 MogDB 的结构和数据差异:

    ./mvd_macos_x86_64 -s 'DB2:127.0.0.1:50000:HONGYE:db2inst1:pwd' -t 'MOGDB:127.0.0.1:5432:db2_mtk1:hongye:pwd' -i 'mtk.*' -R './diff'
  3. 对比 MySQL 到 MogDB 的结构和数据差异:

    ./mvd_macos_x86_64 -s 'MYSQL:127.0.0.1:3306:hongye:root:pwd' -t 'MOGDB:127.0.0.1:5432:mysql_mtk:hongye:pwd' -i 'mtk.*' -R './diff'
  4. 只对某一张表执行数据对比(特征值对比):

    ./mvd_macos_x86_64 -s 'ORACLE:127.0.0.1:1521:orcl:scott:tiger' -t 'MOGDB:127.0.0.1:5432:postgres:hongye:pwd' -T 'HONGYE.TEST'
  5. 对比数据和结构,并精确识别差异行:

    ./mvd_macos_x86_64 -s 'ORACLE:127.0.0.1:1521:orcl:scott:tiger' -t 'MOGDB:127.0.0.1:5432:postgres:hongye:pwd' -i 'mtk.*' -R './diff'
  6. 根据 MTK 的配置文件,进行迁移后的数据校验:

    ./mvd_macos_x86_64 --mtk-config oracle2opengauss.json
Copyright © 2011-2024 www.enmotech.com All rights reserved.