gpt4 book ai didi

java - Hadoop 和 hbase java 客户端..HbaseRPC 的问题

转载 作者:行者123 更新时间:2023-12-02 00:03:25 24 4
gpt4 key购买 nike

我正在尝试将数据插入到 hbase 中。我正在从远程计算机运行 java 程序。我已经提到了下面的代码。

try {
Configuration conf = HBaseConfiguration.create();
conf.clear();
conf.set("hbase.zookeeper.quorum", "<HOST_IP>:2181");
conf.set("hbase.zookeeper.property.clientPort", "2181");
conf.set("hbase.zookeeper.dns.nameserver", "<HOST_IP>");
conf.set("hbase.regionserver.port","60020");
conf.set("hbase.master", "<HOST_IP>:9000");
HTable table = new HTable(conf, "test");
Put put = new Put(Bytes.toBytes("row5"));
put.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"),
Bytes.toBytes("val1"));
put.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual2"),
Bytes.toBytes("val2"));
table.put(put);
} catch (MasterNotRunningException e) {
e.printStackTrace();
} catch (ZooKeeperConnectionException e) {
e.printStackTrace();
} catch (TableNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

我收到以下错误

INFO ipc.HbaseRPC: Server at localhost/127.0.0.1:60020 could not be reached after 1 tries, giving up.
org.apache.hadoop.hbase.client.RetriesExhaustedException: Failed setting up proxy interface org.apache.hadoop.hbase.ipc.HRegionInterface to localhost/127.0.0.1:60020 after attempts=1
at org.apache.hadoop.hbase.ipc.HBaseRPC.waitForProxy(HBaseRPC.java:355)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getHRegionConnection(HConnectionManager.java:1176)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getHRegionConnection(HConnectionManager.java:1195)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:898)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:797)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.relocateRegion(HConnectionManager.java:772)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:1002)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:801)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:766)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:189)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:163)
at com.tcs.hbase.HbaseSample.insertData(HbaseSample.java:30)
at com.tcs.hbase.HbaseSample.main(HbaseSample.java:82)
Caused by: java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
at org.apache.hadoop.net.SocketIOWithTimeout.connect(SocketIOWithTimeout.java:206)
at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:406)
at org.apache.hadoop.hbase.ipc.HBaseClient$Connection.setupIOstreams(HBaseClient.java:328)
at org.apache.hadoop.hbase.ipc.HBaseClient.getConnection(HBaseClient.java:883)
at org.apache.hadoop.hbase.ipc.HBaseClient.call(HBaseClient.java:750)
at org.apache.hadoop.hbase.ipc.HBaseRPC$Invoker.invoke(HBaseRPC.java:257)
at $Proxy4.getProtocolVersion(Unknown Source)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:419)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:393)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:444)
at org.apache.hadoop.hbase.ipc.HBaseRPC.waitForProxy(HBaseRPC.java:349)
... 12 more

当我在安装 hbase 的机器上运行相同的代码时,它工作正常。从日志中可以清楚地看出,rpc 正在解析为本地主机 IP。我想知道如何将rpc ip配置为安装hbase的机器的ip。

最佳答案

此问题的根本原因在于您的/etc/hosts 文件。如果你检查你的/etc/hosts 文件,你会发现一个类似于下面的条目(在我的例子中,mu 机器被命名为domainnameyouwanttogive)

127.0.0.1 本地主机127.0.1.1 域名您想要提供

以下行适用于支持 IPv6 的主机

::1 ip6-localhost ip6-环回fe00::0 ip6-localnetff00::0 ip6-mcastprefixff02::1 ip6-所有节点ff02::2 ip6-所有路由器

根本原因是domainnameyouwanttogive解析为127.0.1.1,这是不正确的,因为它应该解析为127.0.0.1(或外部IP)。由于我的外部 IP 是 192.168.58.10,我创建了以下/etc/hosts 配置;

127.0.0.1 本地主机192.168.43.3 想要提供的域名

以下行适用于支持 IPv6 的主机

::1 ip6-localhost ip6-环回fe00::0 ip6-localnetff00::0 ip6-mcastprefixff02::1 ip6-所有节点ff02::2 ip6-所有路由器

这将确保正确解析本地主机上的主机进程,并且您可以在开发系统上正确启动 HBase 安装。

关于java - Hadoop 和 hbase java 客户端..HbaseRPC 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14373517/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com