文档

从HBase Client迁移到Tablestore HBase Client

更新时间:

Tablestore HBase Client是基于HBase Client的封装,使用方法和HBase Client基本一致,但仍存在一些差别。本文主要为您介绍如何从HBase Client迁移到Tablestore HBase Client 。

说明

如果您需要将HBase中的全量数据迁移到表格存储,请参见将HBase数据同步到表格存储

依赖

Tablestore HBase Client 1.2.0版本依赖了HBase Client 1.2.0版本和Tablestore Java SDK 4.2.1版本。pom.xml配置如下:

 <dependencies>
        <dependency>
            <groupId>com.aliyun.openservices</groupId>
            <artifactId>tablestore-hbase-client</artifactId>
            <version>1.2.0</version>
        </dependency>
    </dependencies>
			

如果需要使用其他版本的HBase Client或Tablestore Java SDK,可以使用exclusion标签。下面示例中使用HBase Client 1.2.1版本和Tablestore4.2.0版本。

   <dependencies>
        <dependency>
            <groupId>com.aliyun.openservices</groupId>
            <artifactId>tablestore-hbase-client</artifactId>
            <version>1.2.0</version>
            <exclusions>
                <exclusion>
                    <groupId>com.aliyun.openservices</groupId>
                    <artifactId>tablestore</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.hbase</groupId>
                    <artifactId>hbase-client</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.hbase</groupId>
            <artifactId>hbase-client</artifactId>
            <version>1.2.1</version>
        </dependency>
        <dependency>
            <groupId>com.aliyun.openservices</groupId>
            <artifactId>tablestore</artifactId>
            <classifier>jar-with-dependencies</classifier>
            <version>4.2.0</version>
        </dependency>
    </dependencies>
			

HBase Client 1.2.x和其他版本(例如1.1.x)存在接口变化,而Tablestore HBase Client 1.2.x版本只能兼容HBase Client 1.2.x。

  • 如果需要使用HBase Client 1.1.x版本,请使用Tablestore HBase Client 1.1.x版本。

  • 如果需要使用HBase Client 0.x.x版本,请参见迁移较早版本的 HBase

配置文件

从HBase Client迁移到Tablestore HBase Client,需要在配置文件中修改以下配置。

  • HBase Connection类型

    Connection需要配置为TablestoreConnection。

        <property>
            <name>hbase.client.connection.impl</name>
            <value>com.alicloud.tablestore.hbase.TablestoreConnection</value>
        </property>
    					
  • 表格存储的配置项

    表格存储是云服务,提供了严格的权限管理。要访问表格存储,需要配置密钥等信息。

    您必须完成以下四个配置项的配置才能成功访问表格存储。其中tablestore.client.endpoint为表格存储的服务地址,tablestore.client.instancename为表格存储实例名称。tablestore.client.accesskeyidtablestore.client.accesskeysecret分别为阿里云账号或者RAM用户的AccessKey ID和AccessKey Secret。

    <property>
        <name>tablestore.client.endpoint</name>
        <value>https://exampleinstabce.cn-hangzhou.ots.aliyuncs.com</value>
    </property>
    <property>
        <name>tablestore.client.instancename</name>
        <value>exampleinstabce</value>
    </property>
    <property>
        <name>tablestore.client.accesskeyid</name>
        <value>*****************</value>
    </property>
    <property>
        <name>tablestore.client.accesskeysecret</name>
        <value>***********</value>
    </property>							

    以下配置为可选配置项。

            <property>
                <name>hbase.client.tablestore.family</name>
                <value>f1</value>
            </property>
            <property>
                <name>hbase.client.tablestore.family.$tablename</name>
                <value>f2</value>
            </property>
            <property>
                <name>tablestore.client.max.connections</name>
                <value>300</value>
            </property>
            <property>
                <name>tablestore.client.socket.timeout</name>
                <value>15000</value>
            </property>
            <property>
                <name>tablestore.client.connection.timeout</name>
                <value>15000</value>
            </property>
            <property>
                <name>tablestore.client.operation.timeout</name>
                <value>2147483647</value>
            </property>
            <property>
                <name>tablestore.client.retries</name>
                <value>3</value>
            </property>
    							

    可选配置项说明如下:

    • hbase.client.tablestore.familyhbase.client.tablestore.family.$tablename

      表格存储只支持单列族,使用HBase API时,需要有一项family的内容,因此通过配置来填充此项family的内容。 其中,hbase.client.tablestore.family为全局配置,hbase.client.tablestore.family.$tablename为单个表的配置。

      配置规则为对表名为T的表,先查找hbase.client.tablestore.family.T,如果不存在则查找hbase.client.tablestore.family,如果仍不存在则取默认值f。

    • tablestore.client.max.connections:最大连接数,默认为300。

    • tablestore.client.socket.timeout:Socket超时时间,默认为15秒。

    • tablestore.client.connection.timeout:连接超时时间,默认为15秒。

    • tablestore.client.operation.timeout:API超时时间,默认为Integer.MAX_VALUE,类似于永不超时。

    • tablestore.client.retries:请求失败时的重试次数,默认为3次。

  • 本页导读 (1)
文档反馈