我是hadoop和hbase的新手,在windows8中安装了hadoop。我启动了hadoop-like-image和test-map-reduce-by-word-count程序,它正在工作
但我不能用hbase!我为eclipse使用hbase插件(我有一个用于连接和创建表的类。。。。
public class HBaseConnector {
private static Configuration configuration = null;
private static HTable hTable;
private static HBaseAdmin admin;
private static Logger logger = Logger.getLogger(HBaseConnector.class);
static {
configuration = HBaseConfiguration.create();
}
public void creatTable(String tableName, String[] familys) {
try {
admin = new HBaseAdmin(configuration);
if (admin.tableExists(tableName)) {
logger.debug(tableName + "table already exists !!");
} else {
HTableDescriptor tableDesc = new HTableDescriptor(tableName);
for (int i = 0; i < familys.length; i++) {
tableDesc.addFamily(new HColumnDescriptor(familys[i]));
}
admin.createTable(tableDesc);
logger.debug(tableName + " table created successfully !! ");
}
admin.close();
} catch (MasterNotRunningException e) {
logger.error(e.getMessage());
} catch (ZooKeeperConnectionException e) {
logger.error(e.getMessage());
} catch (IOException e) {
logger.error(e.getMessage());
}
}
在主要功能中,我有以下代码:
String tablename = "employee";
String[] familys = { "personal", "professional" };
HBaseConnector connector = new HBaseConnector();
connector.creatTable(tablename, familys);
但它无法连接:
18:59:34 WARN zookeeper.RecoverableZooKeeper: Possibly transient ZooKeeper exception: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/master
16/03/18 18:59:34 INFO util.RetryCounter: Sleeping 4000ms before retry #2...
16/03/18 18:59:34 INFO zookeeper.ClientCnxn: Opening socket connection to server 0:0:0:0:0:0:0:1/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (Unable to locate a login configuration)
16/03/18 18:59:34 ERROR zookeeper.ClientCnxnSocketNIO: Unable to open socket to 0:0:0:0:0:0:0:1/0:0:0:0:0:0:0:1:2181
16/03/18 18:59:34 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.SocketException: Address family not supported by protocol family: connect
at sun.nio.ch.Net.connect(Native Method)
at sun.nio.ch.SocketChannelImpl.connect(Unknown Source)
at org.apache.zookeeper.ClientCnxnSocketNIO.registerAndConnect(ClientCnxnSocketNIO.java:266)
at org.apache.zookeeper.ClientCnxnSocketNIO.connect(ClientCnxnSocketNIO.java:276)
at org.apache.zookeeper.ClientCnxn$SendThread.startConnect(ClientCnxn.java:958)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:993)
16/03/18 18:59:34 DEBUG zookeeper.ClientCnxnSocketNIO: Ignoring exception during shutdown input
java.nio.channels.ClosedChannelException
如何运行简单的hbase程序?
1条答案
按热度按时间eh57zj3b1#
在我看来,您似乎忘记了安装或启动hbase。hbase是一个额外的组件,据我所知,您只运行hdfs和yarn。
上一条日志消息显示无法连接到zookeeper。它是hadoop组件的(分布式)键/值存储。您的简单hbase程序正在尝试连接到zookeeper并获取值
/hbase/master
兹诺德。它无法执行此操作,因此无法继续并连接到hbase主机。安装hbase master+至少一个regionserver。如果您遵循安装文档,您还将处理zookeeper:
https://hbase.apache.org/book.html#standalone_dist
我个人的建议是:使用1.1.3而不是1.2.0,除非出于某种原因你真的需要1.2.0。我在启动1.2.0时遇到了问题。