无法规范化地址 localhost/<unresolved>:2222 因为它不可解析
Unable to canonicalize address localhost/<unresolved>:2222 because it's not resolvable
我想将 Java 与 Hbase 连接,但出现错误:
java.lang.IllegalArgumentException: 无法规范化地址
localhost/<unresolved>:2222 because it's not resolvable
at org.apache.zookeeper.SaslServerPrincipal.getServerPrincipal(SaslServerPrincipal.java:65)
at org.apache.zookeeper.SaslServerPrincipal.getServerPrincipal(SaslServerPrincipal.java:41)
at org.apache.zookeeper.ClientCnxn$SendThread.startConnect(ClientCnxn.java:1001)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1060)
这是我的代码:
Configuration conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.quorum", "localhost");
conf.set("hbase.rootdir", "hdfs://localhost:9000/hbase");
conf.set("hbase.cluster.distributed", "hbase.cluster.distributed");
conf.set("hbase.zookeeper.property.clientPort", "2222");
conf.set("hbase.zookeeper.property.dataDir", "/home/trannguyenhan/app/hbase-2.4.2/zookeeper");
conf.set("dfs.replication", "1");
HTable htable = new HTable(conf, "demo");
Put p = new Put(Bytes.toBytes("row1"));
p.add(Bytes.toBytes("demo_column"), Bytes.toBytes("name"), Bytes.toBytes("Nguyen Quang Huy"));
htable.put(p);
htable.close();
我的配置与文件hbase-site.xml中的配置相同。
能帮帮我吗,谢谢。
确保 Zookeeper 运行 在端口 2222 上,因为 Zookeeper 客户端默认端口是 2181。
telnet localhost 2222
要让 HBase 管理节点上的 ZooKeeper 仲裁,绑定到端口 2222(默认为 2181)确保 HBASE_MANAGE_ZK
在 conf/hbase-env.sh
中被注释掉或设置为 true,然后编辑 conf/hbase-site.xml
并设置 hbase.zookeeper.property.clientPort
和 hbase.zookeeper.quorum
.
hbase 示例-site.xml
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.tmp.dir</name>
<value>./tmp</value>
</property>
<property>
<name>hbase.rootdir</name>
<value>hdfs://server1:9000/hbase</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>zkserver1,zkserver2,zkserver3</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2222</value>
</property>
您还必须将 hbase.cluster.distributed
设置为 true
而不是 hbase.cluster.distributed
。
变化
conf.set("hbase.cluster.distributed", "hbase.cluster.distributed");
到
conf.set("hbase.cluster.distributed", "true");
我想将 Java 与 Hbase 连接,但出现错误: java.lang.IllegalArgumentException: 无法规范化地址
localhost/<unresolved>:2222 because it's not resolvable
at org.apache.zookeeper.SaslServerPrincipal.getServerPrincipal(SaslServerPrincipal.java:65)
at org.apache.zookeeper.SaslServerPrincipal.getServerPrincipal(SaslServerPrincipal.java:41)
at org.apache.zookeeper.ClientCnxn$SendThread.startConnect(ClientCnxn.java:1001)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1060)
这是我的代码:
Configuration conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.quorum", "localhost");
conf.set("hbase.rootdir", "hdfs://localhost:9000/hbase");
conf.set("hbase.cluster.distributed", "hbase.cluster.distributed");
conf.set("hbase.zookeeper.property.clientPort", "2222");
conf.set("hbase.zookeeper.property.dataDir", "/home/trannguyenhan/app/hbase-2.4.2/zookeeper");
conf.set("dfs.replication", "1");
HTable htable = new HTable(conf, "demo");
Put p = new Put(Bytes.toBytes("row1"));
p.add(Bytes.toBytes("demo_column"), Bytes.toBytes("name"), Bytes.toBytes("Nguyen Quang Huy"));
htable.put(p);
htable.close();
我的配置与文件hbase-site.xml中的配置相同。 能帮帮我吗,谢谢。
确保 Zookeeper 运行 在端口 2222 上,因为 Zookeeper 客户端默认端口是 2181。
telnet localhost 2222
要让 HBase 管理节点上的 ZooKeeper 仲裁,绑定到端口 2222(默认为 2181)确保 HBASE_MANAGE_ZK
在 conf/hbase-env.sh
中被注释掉或设置为 true,然后编辑 conf/hbase-site.xml
并设置 hbase.zookeeper.property.clientPort
和 hbase.zookeeper.quorum
.
hbase 示例-site.xml
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.tmp.dir</name>
<value>./tmp</value>
</property>
<property>
<name>hbase.rootdir</name>
<value>hdfs://server1:9000/hbase</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>zkserver1,zkserver2,zkserver3</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2222</value>
</property>
您还必须将 hbase.cluster.distributed
设置为 true
而不是 hbase.cluster.distributed
。
变化
conf.set("hbase.cluster.distributed", "hbase.cluster.distributed");
到
conf.set("hbase.cluster.distributed", "true");