Hbase MuleSoft Cloudhub 连接

Hbase MuleSoft Cloudhub Connectivity

我必须将 Cloudhub 连接到 Hbase。我尝试过社区版 HBase 连接器,但没有成功。然后我尝试使用 Java 代码并再次失败。从 HBase 团队,他们只提供了主 IP (10.99.X.X) 和端口 (2181) 和用户名 (hadoop).

我尝试过以下选项:

通过Java代码:

public Object transformMessage(MuleMessage message, String outputEncoding) throws TransformerException { 试试{

        Configuration conf = HBaseConfiguration.create();
        //conf.set("hbase.rotdir", "/hbase");
        conf.set("hbase.zookeeper.quorum", "10.99.X.X");
        conf.set("hbase.zookeeper.property.clientPort", "2181");
        conf.set("hbase.client.retries.number", "3");
        logger.info("############# Config Created ##########");
        // Create a get api for consignment table
        logger.info("############# Starting Consignment Test  ##########");
        // read from table
        // Creating a HTable instance
        HTable table = new HTable(conf, "consignment");
        logger.info("############# HTable instance Created ##########");
        // Create a Get object
        Get get = new Get(Bytes.toBytes("6910358750"));
        logger.info("############# RowKey Created ##########");
        // Set column family to be queried
        get.addFamily(Bytes.toBytes("consignment_detail"));
        logger.info("############# CF Created ##########");
        // Perform get and capture result in a iterable
        Result result = table.get(get);
        logger.info("############# Result Created ##########");
        // Print consignment data
        logger.info(result);

        logger.info(" #### Ending Consignment Test ###");

        // Begining Consignment Item Scanner api
        logger.info("############# Starting Consignmentitem test ##########");

        HTable table1 = new HTable(conf, "consignmentitem");
        logger.info("############# HTable instance Created ##########");
        // Create a scan object with start rowkey and end rowkey (partial
        // row key scan)
        // actual rowkey design: <consignment_id>-<trn>-<orderline>
        Scan scan = new Scan(Bytes.toBytes("6910358750"),Bytes.toBytes("6910358751"));
        logger.info("############# Partial RowKeys Created ##########");
        // Perform a scan using start and stop rowkeys
        ResultScanner scanner = table1.getScanner(scan);
        // Iterate over result and print them
        for (Result result1 = scanner.next(); result1 != null; result1 = scanner.next()) {
            logger.info("Printing Records\n");
            logger.info(result1);
        }
        return scanner;
    }  catch (MasterNotRunningException e) {
        logger.error("HBase connection failed! --> MasterNotRunningException");
        logger.error(e);
    } catch (ZooKeeperConnectionException e) {
        logger.error("Zookeeper connection failed! -->ZooKeeperConnectionException");
        logger.error(e);
    } catch (Exception e) {
        logger.error("Main Exception Found! -- Exception");
        logger.error(e);
    }
    return "Not Connected";

}

以上代码给出以下错误

java.net.UnknownHostException:未知主机:ip-10-99-X-X.ap-southeast-2.compute.internal

CloudHub 似乎无法找到主机名,因为 cloudHub 没有配置 DNS

当我尝试使用社区版 HBase 连接器时,出现以下异常:

org.apache.hadoop.hbase.MasterNotRunningException: 重试3次

请提出一些方法... 仪表 尼勒什 电子邮件:bit.nilesh.kumar@gmail.com

我相信 cloudhub 网络指南中包含了您问题的答案。

https://developer.mulesoft.com/docs/display/current/CloudHub+Networking+Guide

您似乎正在配置您的客户端以尝试连接到 private IP address (10.99.X.X). I'll assume you've already set up a VPC 上的 zookeeper 法定人数,这是您的 CloudHub 工作人员连接到您的专用网络所必需的。

您的 UnknownHostException 意味着您要连接的 HBase 服务器托管在 AWS 上,它定义了类似于错误消息中的私有域名。

那么可能发生的事情是这样的:

  1. Mu​​le 连接到 Zookeeper,询问有哪些 HBase 节点,然后返回 ip-10-99-X-X.ap-southeast-2.compute.internal
  2. Mu​​le 尝试连接到它以找到 HTable "consignment",但无法解析该名称的 IP 地址。

不幸的是,如果发生这种情况,需要对网络进行一些更改才能修复它。 VPC discovery form 中的常见问题解答是这样描述私有 DNS 的:

Currently we don't have the ability to relay DNS queries to internal DNS servers. You would need to either use IP addresses or public DNS entries. Beware of connecting to systems which may redirect to a Virtual IP endpoint by using an internal DNS entry.

您可以使用 public DNS 和可能的弹性 IP 来解决这个问题,但这需要您将 HBase 集群暴露给互联网。