码迷,mamicode.com
首页 > 编程语言 > 详细

JAVA操作HBase出错记录

时间:2014-09-02 17:16:45      阅读:496      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   os   io   java   strong   

简介环境:

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的映射。不然很容易错。

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

JAVA操作HBase出错记录

标签:des   style   blog   http   color   os   io   java   strong   

原文地址:http://www.cnblogs.com/williamlyf/p/3951616.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!