大家好,我是新手,我是在Windows下运行的start-dfs.cmd start-yarn.cmd 和start-hbase.cmd,我的hbase-site.xml如下:
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://localhost:9000/hbase</value>
</property>
</configuration>
而且启动java也无法联接
这是我的代码,创建一个表:
public class Hbase {
public static void main(String args[]) throws Exception{
createTable();
}
public static void createTable() throws IOException{
Configuration conf=HBaseConfiguration.create();
//Connection conn= ConnectionFactory.createConnection(conf);
HBaseAdmin hBaseAdmin = new HBaseAdmin(conf);
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf("test"));
desc.addFamily(new HColumnDescriptor("test_1"));
desc.addFamily(new HColumnDescriptor("test_2"));
desc.addFamily(new HColumnDescriptor("test_3"));
if(hBaseAdmin.tableExists("test")){
System.out.println("table is exists !");
System.exit(0);
}else{
hBaseAdmin.createTable(desc);
System.out.println("成功创建表!");
}
}
以下是出现的问题:
2016-03-06 23:00:31,519 WARN [org.apache.zookeeper.ClientCnxn] - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
2016-03-06 23:00:34,416 WARN [org.apache.zookeeper.ClientCnxn] - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
|
|