【发布时间】:2016-03-18 15:34:35
【问题描述】:
我是 hadoop 和 hbase 的新手,并在 windows8 中安装了 hadoop。 我启动 hadoop Like image 并通过字数统计程序测试 map-reduce 并且它的工作。(在 Eclipse 中)
但是我不能使用 hbase!我为 Eclipse 使用了一个 hbase 插件。 (来自eclipse市场网站) 我有一个用于连接和创建表的类,......
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 程序?
【问题讨论】:
标签: java eclipse hadoop hbase hadoop2