DataX/obhbasewriter/doc/obhbasewriter.md
2024-08-20 20:17:56 +08:00

6.6 KiB
Raw Permalink Blame History

OceanBase的table api为应用提供了ObHBase的访问接口因此OceanBase table api的reader与HBase writer的结构和配置方法类似。 1 快速介绍 obhbaseWriter 插件实现了从向ObHbase中写取数据。在底层实现上obhbaseWriter 通过 HBase 的 Java 客户端连接远程 HBase 服务,并通过 put 方式写入obHbase。 1.1支持功能 1、目前obhbasewriter支持的obHbase版本为OceanBase3.x以及4.x版本。 2、目前obhbasewriter支持源端多个字段拼接作为ObHbase 表的 rowkey具体配置参考rowkeyColumn配置 3、写入obhbase的时间戳版本支持用当前时间作为版本指定源端列作为版本指定一个时间 三种方式作为版本;

脚本配置

{
  "job": {
    "setting": {
      "speed": {
        "channel": 5
      }
    },
    "content": [
      {
        "reader": {
          "name": "txtfilereader",
          "parameter": {
            "path": "/normal.txt",
            "charset": "UTF-8",
            "column": [
              {
                "index": 0,
                "type": "String"
              },
              {
                "index": 1,
                "type": "string"
              },
              {
                "index": 2,
                "type": "string"
              },
              {
                "index": 3,
                "type": "string"
              },
              {
                "index": 4,
                "type": "string"
              },
              {
                "index": 5,
                "type": "string"
              },
              {
                "index": 6,
                "type": "string"
              }

            ],
            "fieldDelimiter": ","
          }
        },
        "writer": {
          "name": "obhbasewriter",
          "parameter": {
            "username": "username",
            "password": "password",
            "writerThreadCount": "20",
            "writeBufferHighMark": "2147483647",
            "rpcExecuteTimeout": "30000",
            "useOdpMode": "false",
            "obSysUser": "root",
            "obSysPassword": "",
            "column": [
              {
                "index": 0,
                "name": "family1:c1",
                "type": "string"
              },
              {
                "index": 1,
                "name": "family1:c2",
                "type": "string"
              },
              {
                "index": 2,
                "name": "family1:c3",
                "type": "string"
              },
              {
                "index": 3,
                "name": "family1:c4",
                "type": "string"
              },
              {
                "index": 4,
                "name": "family1:c5",
                "type": "string"
              },
              {
                "index": 5,
                "name": "family1:c6",
                "type": "string"
              },
              {
                "index": 6,
                "name": "family1:c7",
                "type": "string"
              }
            ],
            "mode": "normal",
            "rowkeyColumn": [
              {
                "index": 0,
                "type": "string"
              },
              {
                "index": 3,
                "type": "string"
              },
              {
                "index": 2,
                "type": "string"
              },
              {
                "index": 1,
                "type": "string"
              }
            ],
            "table": "htable3",
            "batchSize": "200",
            "dbName": "database",
            "jdbcUrl": "jdbc:mysql://ip:port/database?"
          }
        }
      }
    ]
  }
}
参数解释
  • connection

公有云和私有云需要配置的信息不同,具体如下: 公有云:

  • 数据库用户名;(在外层统一配置)
  • 用户密码;(在外层统一配置)
  • proxy的jdbc地址
  • 数据库名称;

私有云:

  • 数据库用户名;(在外层统一配置)
  • 用户密码;(在外层统一配置)
  • proxy的jdbc地址
  • obSysUsersys租户的用户名
  • obSysPasssys租户的密码
  • configUrl
    • 描述可以通过show parameters like 'obConfigUrl' 获得。
    • 必须:是
    • 默认值:无
  • jdbcUrl
    • 描述连接ob使用的jdbc url支持如下两种格式
      • jdbc:mysql://obproxyIp:obproxyPort/db
        • 此格式下username需要写成三段式格式
      • ||dsc_ob10_dsc||集群名:租户名||dsc_ob10_dsc||jdbc:mysql://obproxyIp:obproxyPort/db
        • 此格式下username仅填写用户名本身无需三段式写法
    • 必选:是
    • 默认值:无
  • table
    • 描述:所选取的需要同步的表。无需增加列族信息。
    • 必选:是
    • 默认值:无
  • username
    • 描述访问OceanBase的用户名
    • 必选:是
    • 默认值:无
  • useOdpMode
    • 描述是否通过proxy连接。无法提供sys租户帐密时需要设置为true
    • 必须:否
    • 默认值false
  • column
    • 描述要写入的hbase字段。index指定该列对应reader端column的索引从0开始name指定hbase表中的列必须为 列族:列名 的格式type指定写入数据类型用于转换HBase byte[]。配置格式如下:
"column": [ { "index":1, "name": "cf1:q1", "type": "string" }, { "index":2, "name": "cf1:q2", "type": "string" } 
  • 必选:是
    • 默认值:无
  • rowkeyColumn
    • 描述要写入的ObHbase的rowkey列。index指定该列对应reader端column的索引从0开始若为常量index为1type指定写入数据类型用于转换HBase byte[]value配置常量常作为多个字段的拼接符。obhbasewriter会将rowkeyColumn中所有列按照配置顺序进行拼接作为写入hbase的rowkey不能全为常量。配置格式如下
"rowkeyColumn": [ { "index":0, "type":"string" }, { "index":-1, "type":"string", "value":"_" } ]
  • 必选:是
    • 默认值:无
  • versionColumn
    • 描述指定写入obhbase的时间戳。支持当前时间、指定时间列指定时间三者选一。若不配置表示用当前时间。index指定对应reader端column的索引从0开始需保证能转换为long,若是Date类型会尝试用yyyy-MM-dd HH:mm:ss和yyyy-MM-dd HH:mm:ss SSS去解析若为指定时间index为1value指定时间的值,long值。配置格式如下
"versionColumn":{ "index":1 }

或者

"versionColumn":{ "index":1, "value":123456789 }
  • 必选:否
  • 默认值:无