在Cloudera-quickstart-VM上运行的Hbase也通过使用hbase shell验证了Zookeeper和Hbase是否正在运行,但是当我尝试使用java程序创建一个表时,我得到了下面的错误。
public static void main(String[] args) throws IOException {
Configuration config=new HBaseConfiguration().create();
config.set("hbase.zookeeper.quorum","sandbox.hortonworks.com");
config.set("zookeeper.znode.parent", "/hbase-unsecure");
//config.set("hbase.master", "hostname"+":16000");
Connection conn=ConnectionFactory.createConnection(config);
Admin admin=conn.getAdmin();
HTableDescriptor tableName=new HTableDescriptor("notification");
tableName.addFamily(new HColumnDescriptor("attribute"));
tableName.addFamily(new HColumnDescriptor("metrics"));
if(!admin.tableExists(tableName.getTableName())) {
System.out.println("create table ...");
admin.createTable(tableName);
System.out.println("done");
}
}查找Cloudera Virtual Box配置
[maria_dev@sandbox ~]$ cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.2 sandbox.hortonworks.com找到window主机文件config:
127.0.0.1 localhost
# ::1 localhost
172.17.0.2 sandbox.hortonworks.com连接时出错
2020-07-04 19:09:02 INFO ClientCnxn:975 - Opening socket connection to server sandbox.hortonworks.com/172.17.0.2:2181. Will not attempt to authenticate using SASL (unknown error)
2020-07-04 19:09:23 WARN ClientCnxn:1102 - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection timed out: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
2020-07-04 19:09:23 DEBUG ClientCnxnSocketNIO:192 - Ignoring exception during shutdown input
java.nio.channels.ClosedChannelException
at sun.nio.ch.SocketChannelImpl.shutdownInput(SocketChannelImpl.java:780)
at sun.nio.ch.SocketAdaptor.shutdownInput(SocketAdaptor.java:399)
at org.apache.zookeeper.ClientCnxnSocketNIO.cleanup(ClientCnxnSocketNIO.java:189)
at org.apache.zookeeper.ClientCnxn$SendThread.cleanup(ClientCnxn.java:1185)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1110)
2020-07-04 19:09:23 DEBUG ClientCnxnSocketNIO:199 - Ignoring exception during shutdown output
java.nio.channels.ClosedChannelException发布于 2020-07-13 22:30:09
我不知道它是否相关,但create是一个静态函数。它一定是
Configuration config=HBaseConfiguration.create();
不
new HBaseConfiguration().create();。
还要确保您的zookeeper端口是2181。如果不是,则为其提供"hbase.zookeeper.property.clientPort“属性。
发布于 2020-08-02 20:30:52
虽然不可能准确地指出问题可能是在哪里造成的,但似乎您在服务器url中获得了太多内容:
sandbox.hortonworks.com/172.17.0.2:2181
假设域名或ip地址都可以,但两者合在一起是无效的。
此外,请记住,Hortonworks已经与Cloudera合并,并且HDP有一个后继者,称为Cloudera数据平台。对于所有新的群集设置,建议使用此选项。沙箱等效项可以通过here访问。
完全披露:我是Cloudera (前身为Hortonworks)的员工,HDP和CDP背后的公司
https://stackoverflow.com/questions/62730032
复制相似问题