JAVA操作HBase出错记录

简介环境:

window7 x64

Eclipse Java EE IDE for Web Developers.(Version: Kepler Service Release 1)(Build id: 20130919-0819)

HBase (hbase-0.98.3-hadoop2-bin.tar.gz)

错误内容:(部分被我用【...】代替了,一些计算机信息)

 1 2014-09-02 15:39:22,900 WARN  [main] util.NativeCodeLoader (NativeCodeLoader.java:<clinit>(62)) - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
 2 2014-09-02 15:39:23,091 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
 3 2014-09-02 15:39:23,091 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:host.name=【...】
 4 2014-09-02 15:39:23,091 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.version=1.7.0_60
 5 2014-09-02 15:39:23,091 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.vendor=Oracle Corporation
 6 2014-09-02 15:39:23,091 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.home=【...】
 7 2014-09-02 15:39:23,091 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.class.path=【...】
 8 2014-09-02 15:39:23,092 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.library.path=【...】
 9 2014-09-02 15:39:23,092 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.io.tmpdir=【...】
10 2014-09-02 15:39:23,092 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.compiler=<NA>
11 2014-09-02 15:39:23,092 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:os.name=Windows 7
12 2014-09-02 15:39:23,092 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:os.arch=amd64
13 2014-09-02 15:39:23,092 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:os.version=6.1
14 2014-09-02 15:39:23,092 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:user.name=【...】
15 2014-09-02 15:39:23,092 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:user.home=【...】
16 2014-09-02 15:39:23,093 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:user.dir=【...】
17 2014-09-02 15:39:23,095 INFO  [main] zookeeper.ZooKeeper (ZooKeeper.java:<init>(438)) - Initiating client connection, connectString=192.168.0.210:2181 sessionTimeout=90000 watcher=hconnection-0x4bc2fdde, quorum=192.168.0.210:2181, baseZNode=/hbase
18 2014-09-02 15:39:23,128 INFO  [main] zookeeper.RecoverableZooKeeper (RecoverableZooKeeper.java:<init>(120)) - Process identifier=hconnection-0x4bc2fdde connecting to ZooKeeper ensemble=192.168.0.210:2181
19 2014-09-02 15:39:23,128 INFO  [main-SendThread(192.168.0.210:2181)] zookeeper.ClientCnxn (ClientCnxn.java:logStartConnect(975)) - Opening socket connection to server 192.168.0.210/192.168.0.210:2181. Will not attempt to authenticate using SASL (unknown error)
20 2014-09-02 15:39:23,131 INFO  [main-SendThread(192.168.0.210:2181)] zookeeper.ClientCnxn (ClientCnxn.java:primeConnection(852)) - Socket connection established to 192.168.0.210/192.168.0.210:2181, initiating session
21 2014-09-02 15:39:23,173 INFO  [main-SendThread(192.168.0.210:2181)] zookeeper.ClientCnxn (ClientCnxn.java:onConnected(1235)) - Session establishment complete on server 192.168.0.210/192.168.0.210:2181, sessionid = 0x1481be77ced001a, negotiated timeout = 40000
22 2014-09-02 15:39:23,414 INFO  [main] Configuration.deprecation (Configuration.java:warnOnceIfDeprecated(840)) - hadoop.native.lib is deprecated. Instead, use io.native.lib.available
23 2014-09-02 15:39:26,188 INFO  [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 1 of 35 failed; retrying after sleep of 100, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas
24 2014-09-02 15:39:26,320 INFO  [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 2 of 35 failed; retrying after sleep of 201, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas
25 2014-09-02 15:39:26,636 INFO  [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 3 of 35 failed; retrying after sleep of 302, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas
26 2014-09-02 15:39:27,143 INFO  [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 4 of 35 failed; retrying after sleep of 500, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas
27 2014-09-02 15:39:28,075 INFO  [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 5 of 35 failed; retrying after sleep of 1004, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas
28 2014-09-02 15:39:29,084 INFO  [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 6 of 35 failed; retrying after sleep of 2008, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas
29 2014-09-02 15:39:31,098 INFO  [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 7 of 35 failed; retrying after sleep of 4014, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas
30 2014-09-02 15:39:35,120 INFO  [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 8 of 35 failed; retrying after sleep of 10005, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas
31 2014-09-02 15:39:47,690 INFO  [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 9 of 35 failed; retrying after sleep of 10097, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas
32 2014-09-02 15:40:00,349 INFO  [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 10 of 35 failed; retrying after sleep of 10043, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas
33 2014-09-02 15:40:12,956 INFO  [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 11 of 35 failed; retrying after sleep of 10057, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas
34 2014-09-02 15:40:25,777 INFO  [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 12 of 35 failed; retrying after sleep of 20096, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas
35 2014-09-02 15:40:48,656 INFO  [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 13 of 35 failed; retrying after sleep of 20146, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas
36 2014-09-02 15:41:11,363 INFO  [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 14 of 35 failed; retrying after sleep of 20174, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas
37 2014-09-02 15:41:34,114 INFO  [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 15 of 35 failed; retrying after sleep of 20096, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas
38 2014-09-02 15:41:57,174 INFO  [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 16 of 35 failed; retrying after sleep of 20160, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas
39 2014-09-02 15:42:19,894 INFO  [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 17 of 35 failed; retrying after sleep of 20198, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas
40 ......可能还在运行

JAVA代码如下:(我把Hbase中hbase-0.98.3-hadoop2\lib下的jar包都加到工程中了)

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.HBaseAdmin;

public class HBaseTest {

    public static void main(String[] agrs) throws Exception {
        String strTBName = "tb_test"; // 表
        String strColFamily = "cf"; // 列族

        // 配置
        Configuration conf = HBaseConfiguration.create();
        conf.set("hbase.zookeeper.quorum", "【这里是Master的IP值】");

        // 管理员
        HBaseAdmin hbaseAdmin = new HBaseAdmin(conf);

        // 表名称
        TableName tableName = TableName.valueOf(strTBName);

        // 表描述器
        HTableDescriptor tableDesc = new HTableDescriptor(tableName);

        tableDesc.addFamily(new HColumnDescriptor(strColFamily));// 添加列族

        // 创建一个表,同步操作
        hbaseAdmin.createTable(tableDesc);

        System.out.println("创建表" + strTBName + "成功");
    }
}

首先我是看了这篇文章:http://javacrazyer.iteye.com/blog/1186881

其中评论11楼:(我的是按自己的配置来的)

11 楼 sujianhu 2014-04-23
我也碰到
13/07/05 19:50:05 INFO zookeeper.ClientCnxn: Opening socket connection to server 192.168.56.101/192.168.56.101:2181. Will not attempt to authenticate using SASL (无法定位登录配置)
13/07/05 19:50:05 INFO zookeeper.ClientCnxn: Socket connection established to 192.168.56.101/192.168.56.101:2181, initiating session
13/07/05 19:50:05 INFO zookeeper.ClientCnxn: Session establishment complete on server 192.168.56.101/192.168.56.101:2181, sessionid = 0x13fae9d00dd0005, negotiated timeout = 180000
13/07/05 19:50:06 INFO client.HConnectionManager$HConnectionImplementation: getMaster attempt 0 of 10 failed; retrying after sleep of 1008
最终找到原因是节点在zookeeper注册的是主机名
所以在eclipse 远程调试的时候要把windows的host文件加上节点信息例如
192.168.159.2 master master
192.168.159.3 save1 save1
192.168.159.4 save2 save2
192.168.159.5 save3 save3
这种错误基本都是host错误,查找了不少zookeeper的资料都说对ip支持很弱,所以要配置主机名与ip的映射。不然很容易错。

改完后,再运行就可以了!

时间: 2024-11-05 20:46:26

JAVA操作HBase出错记录的相关文章

java操作hbase例子

hbase安装方法请参考:hbase-0.94安装方法详解 hbase常用的shell命令请参考:hbase常用的shell命令例子 java操作hbase,在eclipse中创建一个java项目,将hbase安装文件根目录的jar包和lib目录下jar包导入项目,然后就可以编写java代码操作hbase了.下面代码给出来一个简单的示例 /** * @date 2015-07-23 21:28:10 * @author sgl */ package com.songguoliang.hbase;

Hadoop之——Java操作HBase

转载请注明出处:http://blog.csdn.net/l1028386804/article/details/46463617 不多说,直接上代码,大家都懂得 package hbase; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbas

java操作hbase样例

hbase安装方法请參考:hbase-0.94安装方法具体解释 hbase经常使用的shell命令请參考:hbase经常使用的shell命令样例 java操作hbase,在eclipse中创建一个java项目.将hbase安装文件根文件夹的jar包和lib文件夹下jar包导入项目,然后就能够编写java代码操作hbase了. 以下代码给出来一个简单的演示样例 /** * @date 2015-07-23 21:28:10 * @author sgl */ package com.songguol

新浪微博数据解析与java操作Hbase实例

之前发过一篇开发新浪微博的文章,对于大家比较感兴趣的内容之一便是如何解析新浪微博的JSON. 其实一开始的时候,也遇过一些挫折,比如直接用JsonArray和JsonObject去解析JSON内容的话,是解析不了的. 因为JSON的格式比较固定,像新浪微博返回的JSON内容则是多了一个中括号及statues标签,如下: { "statuses": [ { "created_at": "Tue May 31 17:46:55 +0800 2011"

Java操作hbase总结

用过以后,总得写个总结,不然,就忘喽. 一.寻找操作的jar包. java操作hbase,首先要考虑到使用hbase的jar包. 因为咱装的是CDH5,比较方便,使用SecureCRT工具,远程连接到你安装的那台服务器上. jar包的存放位置在/opt/cloudera/parcels/CDH/lib/hbase,找到,下载下来. 在当前路径下,有一个lib包,里面是支持hbase的hadoop的jar包,根据需求,可以下载下来. 二.找一个API文档当成手册,哪里不会查哪里 百度分享,http

java操作Hbase实例

所用HBase版本为1.1.2,hadoop版本为2.4 /* * 创建一个students表,并进行相关操作 */ import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apach

Java 操作Hbase 完整例子

开发工具:Eclipse,三步1.新建一个项目2.把hbase安装下的lib的文件都拷贝进来3.把lib目录下jar文件都引入4.lib下的client-facing-thirdparty 目录下的jar也都引入看图 package com.yue; import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.hbase.;import org.apache.hadoop.hbase.client.; import j

Java操作Hbase进行建表、删表以及对数据进行增删改查,条件查询

1.搭建环境 新建JAVA项目,添加的包有: 有关Hadoop的hadoop-core-0.20.204.0.jar 有关Hbase的hbase-0.90.4.jar.hbase-0.90.4-tests.jar以及Hbase资源包中lib目录下的所有jar包 2.主要程序 Java代码 package com.wujintao.hbase.test; import java.io.IOException; import java.util.ArrayList; import java.util

java操作hbase数据库

package com.wujintao.hbase.test; import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HColumnDesc