gpt4 book ai didi

java - 不是主机 :port while connecting hbase using java

转载 作者:可可西里 更新时间:2023-11-01 16:42:16 27 4
gpt4 key购买 nike

public class HbaseConnectorClass {

private HTable table;
private static final Logger log = LoggerFactory.getLogger(HbaseConnectorClass.class);

public static void main(String[] args) throws Exception {

System.out.println("trying to connect ......");
Configuration conf = HBaseConfiguration.create();

conf.set("hbase.zookeeper.quorum", "localhost");
conf.set("hbase.zookeeper.property.clientPort", "2222");
conf.set("hbase.master", "localhost:60000");

try
{
System.out.println("Hbase is running!");
HTable table = new HTable(conf,"personal");
Put put = new Put(Bytes.toBytes("doe-john-m-12345"));
put.add(Bytes.toBytes("personal"), Bytes.toBytes("givenName"), Bytes.toBytes("John"));
put.add(Bytes.toBytes("personal"), Bytes.toBytes("mi"), Bytes.toBytes("M"));
put.add(Bytes.toBytes("personal"), Bytes.toBytes("surame"), Bytes.toBytes("Doe"));
put.add(Bytes.toBytes("contactinfo"), Bytes.toBytes("email"), Bytes.toBytes("john.m.doe@gmail.com"));
table.put(put);
table.flushCommits();
table.close();

System.out.println("Table created");
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}

Exception in thread "main" java.lang.IllegalArgumentException: Not a host:port pair: PBUF hadoop�}�����*�} at org.apache.hadoop.hbase.util.Addressing.parseHostname(Addressing.java:60) at org.apache.hadoop.hbase.ServerName.(ServerName.java:96)at org.apache.hadoop.hbase.ServerName.parseVersionedServerName(ServerName.java:278) at org.apache.hadoop.hbase.MasterAddressTracker.bytesToServerName(MasterAddressTracker.java:77) at org.apache.hadoop.hbase.MasterAddressTracker.getMasterAddress(MasterAddressTracker.java:61) at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getMaster(HConnectionManager.java:631) at org.apache.hadoop.hbase.client.HBaseAdmin.(HBaseAdmin.java:106) at com.networkfleet.hbase.practice.HbaseConnectorClass.creatTable(HbaseConnectorClass.java:82)at com.networkfleet.hbase.practice.HbaseConnectorClass.main(HbaseConnectorClass.java:63)

最佳答案

很可能是由于 HBase 服务器和 HBase 客户端 jar 之间的版本不匹配

检查你的服务器和客户端版本

关于java - 不是主机 :port while connecting hbase using java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39784163/

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