pig2 发表于 2013-12-11 18:15:33

总结Eclipse 远程连接 HBase问题及解决方案大全

第一种情况:
1.测试hbase:
a)      cd hbase-0.90.4b)      bin/start-hbase.shc)      bin/hbase shelld)      create‘database’,’cf’e)      listf)         如果成功则可以看到有下面的结果:
[*]hbase(main):001:0>list TABLEdatabase    1 row(s)in 0.5910 seconds

2. 创建Java project, 将hbase-0.90.4下面的lib目录拷贝到工程,将其中的jar包加入classpath, 还有hbase-0.90.5.jar 和 test.jar
3. 创建类
public class HelloHBase {
public static void main(String[] args) throws IOException {
Configuration conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.quorum", "192.168.128.128");
HBaseAdmin admin = new HBaseAdmin(conf);
HTableDescriptor tableDescriptor = admin.getTableDescriptor(Bytes.toBytes("database"));
byte[] name = tableDescriptor.getName();
System.out.println(new String(name));
HColumnDescriptor[] columnFamilies = tableDescriptor.getColumnFamilies();
for (HColumnDescriptor d : columnFamilies) {
System.out.println(d.getNameAsString());
}
}

运行,此时应该打印出下面两行:database cf若没有,说明配置失败,请检查其他设置。
==============================================问题1:java.net.ConnectException: Connection refused: no further information
a. zookeeper.ClientCnxn: Session 0x0 for server null,
解决: zppkeeper未启动,或无法连接,从查看各节点zookeeper启动状态、端口占用、防火墙等方面查看原因
b. getMaster attempt 4 of 10 failed; retrying after sleep of 2000
解决:查看 master log , 如果有信息org.apache.hadoop.hbase.regionserver.HRegionServer: Serving as BRDVM0240,43992,1373943529301, RPC listening on /127.0.0.1:43992, sessionid=0x13fe56a7d4b0001

则说明, HRegionServer 监听的端口是localhost 127.0.0.1, 需要修改 server端 /etc/hosts 文件, 127.0.0.1            
   servername localhost.localdomain localhost
去掉 servername, 然后重启hbase
第二种情况:
java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:567)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1119)
12/09/03 15:37:15 INFO zookeeper.ClientCnxn: Opening socket connection to server /192.168.0.118:2181
12/09/03 15:37:16 INFO zookeeper.ClientCnxn: EventThread shut down
12/09/03 15:37:16 INFO zookeeper.ZooKeeper: Session: 0x0 closed
Exception in thread "main" org.apache.hadoop.hbase.ZooKeeperConnectionException: HBase is able to connect to ZooKeeper but the connection closes immediately. This could be a sign that the server has too many connections (30 is the default). Consider inspecting your ZK server logs for that error and then make sure you are reusing HBaseConfiguration as often as you can. See HTable's javadoc for more information.
at org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.<init>(ZooKeeperWatcher.java:156)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getZooKeeperWatcher(HConnectionManager.java:1209)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.setupZookeeperTrackers(HConnectionManager.java:511)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.<init>(HConnectionManager.java:502)
at org.apache.hadoop.hbase.client.HConnectionManager.getConnection(HConnectionManager.java:172)
at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:92)
at com.biencloud.test.first_hbase.main(first_hbase.java:22)
Caused by: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase
at org.apache.zookeeper.KeeperException.create(KeeperException.java:90)
at org.apache.zookeeper.KeeperException.create(KeeperException.java:42)
at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:809)
at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:837)
at org.apache.hadoop.hbase.zookeeper.ZKUtil.createAndFailSilent(ZKUtil.java:931)
at org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.<init>(ZooKeeperWatcher.java:134)
... 6 more

这个错误说明eclipse没有连接到zookeeper,在程序中添加zookeeper配置信息即可,具体如下:
Configuration conf=HBaseConfiguration.create();
conf.set("hbase.zookeeper.quorum","192.168.0.118, 192.168.0.186, 192.168.0.182");
conf.set("hbase.zookeeper.property.clientPort","2222");


pig2 发表于 2013-12-11 18:21:51

在给大家多分享几个:
eclipse下使用javaapi连接hbase记录 1.hadoop工程已经配置好,把hbase目录放到windows下,用来导入jar包。
2.确保windowshosts文件配置完成,确保java环境配置完成。
3.创建hadoop工程,把hbase下的jar包全部导入工程,不清楚到底需要哪个包,注意,可能你的hbase下的包不全,网上搜索。这里创建一个普通的工程,把hadoop的jar包导入工程也可以。
4.新建一个类输入代码如下:(前提是先创建了一个database的表)
package hbase1;


import java.io.IOException;


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.client.HBaseAdmin;
import org.apache.hadoop.hbase.util.Bytes;


public class test{
public static void main(String[] args) throws IOException {
Configuration conf = HBaseConfiguration.create();

conf.set("hbase.zookeeper.quorum", "testhd2");
HBaseAdmin admin = new HBaseAdmin(conf);
HTableDescriptor tableDescriptor = admin.getTableDescriptor(Bytes.toBytes("database"));
byte[] name = tableDescriptor.getName();
System.out.println(new String(name));
HColumnDescriptor[] columnFamilies = tableDescriptor.getColumnFamilies();
for (HColumnDescriptor d : columnFamilies) {
System.out.println(d.getNameAsString());
System.out.println("12345");
}
}
}
这里注意testhd2是zookeeper的服务器,不要连接namenode。应该把所有的zookeeper都写上,‘,’隔开,写一个也可以

5.可能会遇到错误
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/protobuf/Message
at org.apache.hadoop.hbase.io.HbaseObjectWritable.<clinit>(HbaseObjectWritable.java:263)
at org.apache.hadoop.hbase.ipc.Invocation.write(Invocation.java:139)
at org.apache.hadoop.hbase.ipc.HBaseClient$Connection.sendParam(HBaseClient.java:638)
at org.apache.hadoop.hbase.ipc.HBaseClient.call(HBaseClient.java:1001)
at org.apache.hadoop.hbase.ipc.WritableRpcEngine$Invoker.invoke(WritableRpcEngine.java:150)
at $Proxy5.getProtocolVersion(Unknown Source)
at org.apache.hadoop.hbase.ipc.WritableRpcEngine.getProxy(WritableRpcEngine.java:183)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:335)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:312)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:364)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getMaster(HConnectionManager.java:682)
at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:110)
at hbase1.test.main(test.java:20)
Caused by: java.lang.ClassNotFoundException: com.google.protobuf.Message
这是因为缺少jar包,是缺少hbase/lib下的protobuf-java-2.4.1.jar包,这里用了个稍微有点差别的版本成功了,最好用对应的版本。有了jar包,导入工程后,成功。

rsgg03 发表于 2013-12-11 18:24:55

最近看了很多关于hbase的遇到问题的,自己也遇到了,解决了一部分,和大家分享一下


我的hbase在虚拟机下,想用windows下的eclipse连接虚拟机的hbase,前段时间一直不行,不知怎的今天试了一下,行了,下面说一下问题和解决方法

问题

13/01/09 16:17:51 WARN client.ZooKeeperSaslClient: SecurityException: java.lang.SecurityException: 无法定位登录配置 occurred when trying to find JAAS configuration.
13/01/09 16:17:51 INFO client.ZooKeeperSaslClient: Client will not SASL-authenticate because the default JAAS configuration section 'Client' could not be found. If you are not using SASL, you may ignore this. On the other hand, if you expected SASL to work, please fix your JAAS configuration.
13/01/09 16:17:51 INFO zookeeper.ClientCnxn: Socket connection established to 192.168.0.130/192.168.0.130:2181, initiating session
13/01/09 16:17:51 INFO zookeeper.ClientCnxn: Session establishment complete on server 192.168.0.130/192.168.0.130:2181, sessionid = 0x13c1e24b569001b, negotiated timeout = 180000
13/01/09 16:17:51 INFO client.HConnectionManager$HConnectionImplementation: getMaster attempt 0 of 10 failed; retrying after sleep of 1000
java.net.UnknownHostException: unknown host: stu-virtual-machine
    at org.apache.hadoop.hbase.ipc.HBaseClient$Connection.<init>(HBaseClient.java:227)
    at org.apache.hadoop.hbase.ipc.HBaseClient.getConnection(HBaseClient.java:1035)
    at org.apache.hadoop.hbase.ipc.HBaseClient.call(HBaseClient.java:897)
    at org.apache.hadoop.hbase.ipc.WritableRpcEngine$Invoker.invoke(WritableRpcEngine.java:150)
    at $Proxy1.getProtocolVersion(Unknown Source)
    at org.apache.hadoop.hbase.ipc.WritableRpcEngine.getProxy(WritableRpcEngine.java:183)
    at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:303)
    at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:280)
    at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:332)
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getMaster(HConnectionManager.java:656)
    at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:108)
    at Test2.createTable(Test2.java:47)
    at Test2.main(Test2.java:210)
13/01/09 16:17:52 INFO client.HConnectionManager$HConnectionImplementation: getMaster attempt 1 of 10 failed; retrying after sleep of 1000
java.net.UnknownHostException: unknown host: stu-virtual-machine
    at org.apache.hadoop.hbase.ipc.HBaseClient$Connection.<init>(HBaseClient.java:227)
    at org.apache.hadoop.hbase.ipc.HBaseClient.getConnection(HBaseClient.java:1035)
    at org.apache.hadoop.hbase.ipc.HBaseClient.call(HBaseClient.java:897)
    at org.apache.hadoop.hbase.ipc.WritableRpcEngine$Invoker.invoke(WritableRpcEngine.java:150)
    at $Proxy1.getProtocolVersion(Unknown Source)
    at org.apache.hadoop.hbase.ipc.WritableRpcEngine.getProxy(WritableRpcEngine.java:183)
    at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:303)
    at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:280)
    at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:332)
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getMaster(HConnectionManager.java:656)
    at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:108)
    at Test2.createTable(Test2.java:47)
    at Test2.main(Test2.java:210)
解决方法:

首先需要设置C:\Windows\System32\drivers\etc的hosts,添加上虚拟机的ip和名称对应,要有:conf.set("hbase.master", "192.168.0.130:60000");这样就能连接hbase了,同时也能创建表了,

rsgg03 发表于 2013-12-11 18:29:42

本帖最后由 rsgg03 于 2013-12-11 18:31 编辑

hadoop和hbase都部署在linux下,但是我们习惯在windows下使用eclipse编写java,所以就有了这个蛋疼的事情
环境:windows7 eclipse hbase-0.92.0
1、把需要用到的jar导入
需要的jar可以在linux下的HADOOP_HOME/lib和HBASE_HOME/lib下找到,需要的jar包如下:

2、配置文件hbase-site.xml:
<DIV> </DIV>3、测试函数:public static void main(String[] args) throws IOException {



Configuration conf = HBaseConfiguration.create(); HTable table = new
HTable(conf, "testtable"); Put put = new Put(Bytes.toBytes("row1"));
put.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"),
Bytes.toBytes("val1")); put.add(Bytes.toBytes("colfam1"),
Bytes.toBytes("qual2"), Bytes.toBytes("val2")); table.put(put);
table.close();

}
中间遇到一个exception:
13/01/07 09:10:34 INFO client.HConnectionManager$HConnectionImplementation: getMaster attempt 0 of 10 failed; retrying after sleep of 1000
java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:574)
at org.apache.hadoop.net.SocketIOWithTimeout.connect(SocketIOWithTimeout.java:206)
at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:373)
at org.apache.hadoop.hbase.ipc.HBaseClient$Connection.setupConnection(HBaseClient.java:328)
at org.apache.hadoop.hbase.ipc.HBaseClient$Connection.setupIOstreams(HBaseClient.java:362)
at org.apache.hadoop.hbase.ipc.HBaseClient.getConnection(HBaseClient.java:1026)
at org.apache.hadoop.hbase.ipc.HBaseClient.call(HBaseClient.java:878)
at org.apache.hadoop.hbase.ipc.WritableRpcEngine$Invoker.invoke(WritableRpcEngine.java:150)
at $Proxy4.getProtocolVersion(Unknown Source)
at org.apache.hadoop.hbase.ipc.WritableRpcEngine.getProxy(WritableRpcEngine.java:183)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:303)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:280)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:332)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getMaster(HConnectionManager.java:642)
at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:106)
at test.HBaseHelper.<init>(HBaseHelper.java:24)
at test.HBaseHelper.getHelper(HBaseHelper.java:28)
at test.PutExample.main(PutExample.java:17)

解决:
源码中org.apache.hadoop.hbase.HconnectionManager这个类里面

这个isa无论你在hbase-site.xml是否有设置
<property>
<name>hbase.master</name>
<value>192.168.1.128:60000</value>
</property>
取值都是你外网的地址xxx.xxx.xxx.xxx:60000,有时候没有联网时是127.0.0.1:60000,(bug)为此吧windows的C:\Windows\System32\drivers\etc的hosts文件加上一句:
192.168.1.128 localhost.localdomain localhost

原理:client要连接虚拟机的HMaster,HMaster的端口在虚拟机中hbase设置时60000,client首先通过${hbase.ip}:2181端口和hbase通信,hbase返回HMaster所在的机子的hostname(hbase是为集群设置的,对hosts很敏感),虚拟机中的hostname是localhost.localdomain,因此isa通过sn( ServerName sn )取到ip地址,因此需要在hosts设置HMaster所在的主机hostname的ip

4、查看结果:
在hbase shell下:
hbase(main):003:0> scan 'testtable'
ROW COLUMN+CELL
row1 column=colfam1:qual1, timestamp=1300108258094, value=val1
row2 column=colfam1:qual1, timestamp=1300108258094, value=val2
插入成功





ascentzhen 发表于 2014-8-5 16:59:12

这篇文章挺好的,就是我发现上面的广告整的太不好了,版主能否去掉下

chuyuan_zhou 发表于 2014-12-22 14:25:24

飘过,关注!

旧收音机 发表于 2015-6-23 22:19:24



那位贤弟知道这个是什么问题?

2015-06-23 22:13:55,179 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT
2015-06-23 22:13:55,187 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:host.name=Hiter
2015-06-23 22:13:55,187 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.version=1.7.0_45
2015-06-23 22:13:55,187 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.vendor=Oracle Corporation
2015-06-23 22:13:55,187 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.home=E:\MyEclipse2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre
2015-06-23 22:13:55,187 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.class.path=E:\lianxi\hbase\bin;E:\lianxi\hbase\lib\activation-1.1.jar;E:\lianxi\hbase\lib\aopalliance-1.0.jar;E:\lianxi\hbase\lib\asm-3.1.jar;E:\lianxi\hbase\lib\avro-1.7.4.jar;E:\lianxi\hbase\lib\commons-beanutils-1.7.0.jar;E:\lianxi\hbase\lib\commons-beanutils-core-1.8.0.jar;E:\lianxi\hbase\lib\commons-cli-1.2.jar;E:\lianxi\hbase\lib\commons-codec-1.7.jar;E:\lianxi\hbase\lib\commons-collections-3.2.1.jar;E:\lianxi\hbase\lib\commons-compress-1.4.1.jar;E:\lianxi\hbase\lib\commons-configuration-1.6.jar;E:\lianxi\hbase\lib\commons-daemon-1.0.13.jar;E:\lianxi\hbase\lib\commons-digester-1.8.jar;E:\lianxi\hbase\lib\commons-el-1.0.jar;E:\lianxi\hbase\lib\commons-httpclient-3.1.jar;E:\lianxi\hbase\lib\commons-io-2.4.jar;E:\lianxi\hbase\lib\commons-lang-2.6.jar;E:\lianxi\hbase\lib\commons-logging-1.1.1.jar;E:\lianxi\hbase\lib\commons-math-2.1.jar;E:\lianxi\hbase\lib\commons-net-3.1.jar;E:\lianxi\hbase\lib\findbugs-annotations-1.3.9-1.jar;E:\lianxi\hbase\lib\gmbal-api-only-3.0.0-b023.jar;E:\lianxi\hbase\lib\grizzly-framework-2.1.2.jar;E:\lianxi\hbase\lib\grizzly-http-2.1.2.jar;E:\lianxi\hbase\lib\grizzly-http-server-2.1.2.jar;E:\lianxi\hbase\lib\grizzly-http-servlet-2.1.2.jar;E:\lianxi\hbase\lib\grizzly-rcm-2.1.2.jar;E:\lianxi\hbase\lib\guava-12.0.1.jar;E:\lianxi\hbase\lib\guice-3.0.jar;E:\lianxi\hbase\lib\guice-servlet-3.0.jar;E:\lianxi\hbase\lib\hadoop-annotations-2.2.0.jar;E:\lianxi\hbase\lib\hadoop-auth-2.2.0.jar;E:\lianxi\hbase\lib\hadoop-client-2.2.0.jar;E:\lianxi\hbase\lib\hadoop-common-2.2.0.jar;E:\lianxi\hbase\lib\hadoop-hdfs-2.2.0-tests.jar;E:\lianxi\hbase\lib\hadoop-hdfs-2.2.0.jar;E:\lianxi\hbase\lib\hadoop-mapreduce-client-app-2.2.0.jar;E:\lianxi\hbase\lib\hadoop-mapreduce-client-common-2.2.0.jar;E:\lianxi\hbase\lib\hadoop-mapreduce-client-core-2.2.0.jar;E:\lianxi\hbase\lib\hadoop-mapreduce-client-jobclient-2.2.0-tests.jar;E:\lianxi\hbase\lib\hadoop-mapreduce-client-jobclient-2.2.0.jar;E:\lianxi\hbase\lib\hadoop-mapreduce-client-shuffle-2.2.0.jar;E:\lianxi\hbase\lib\hadoop-yarn-api-2.2.0.jar;E:\lianxi\hbase\lib\hadoop-yarn-client-2.2.0.jar;E:\lianxi\hbase\lib\hadoop-yarn-common-2.2.0.jar;E:\lianxi\hbase\lib\hadoop-yarn-server-common-2.2.0.jar;E:\lianxi\hbase\lib\hadoop-yarn-server-nodemanager-2.2.0.jar;E:\lianxi\hbase\lib\hamcrest-core-1.3.jar;E:\lianxi\hbase\lib\hbase-client-0.96.2-hadoop2.jar;E:\lianxi\hbase\lib\hbase-common-0.96.2-hadoop2-tests.jar;E:\lianxi\hbase\lib\hbase-common-0.96.2-hadoop2.jar;E:\lianxi\hbase\lib\hbase-examples-0.96.2-hadoop2.jar;E:\lianxi\hbase\lib\hbase-hadoop-compat-0.96.2-hadoop2.jar;E:\lianxi\hbase\lib\hbase-hadoop2-compat-0.96.2-hadoop2.jar;E:\lianxi\hbase\lib\hbase-it-0.96.2-hadoop2-tests.jar;E:\lianxi\hbase\lib\hbase-it-0.96.2-hadoop2.jar;E:\lianxi\hbase\lib\hbase-prefix-tree-0.96.2-hadoop2.jar;E:\lianxi\hbase\lib\hbase-protocol-0.96.2-hadoop2.jar;E:\lianxi\hbase\lib\hbase-server-0.96.2-hadoop2-tests.jar;E:\lianxi\hbase\lib\hbase-server-0.96.2-hadoop2.jar;E:\lianxi\hbase\lib\hbase-shell-0.96.2-hadoop2.jar;E:\lianxi\hbase\lib\hbase-testing-util-0.96.2-hadoop2.jar;E:\lianxi\hbase\lib\hbase-thrift-0.96.2-hadoop2.jar;E:\lianxi\hbase\lib\htrace-core-2.04.jar;E:\lianxi\hbase\lib\httpclient-4.1.3.jar;E:\lianxi\hbase\lib\httpcore-4.1.3.jar;E:\lianxi\hbase\lib\jackson-core-asl-1.8.8.jar;E:\lianxi\hbase\lib\jackson-jaxrs-1.8.8.jar;E:\lianxi\hbase\lib\jackson-mapper-asl-1.8.8.jar;E:\lianxi\hbase\lib\jackson-xc-1.8.8.jar;E:\lianxi\hbase\lib\jamon-runtime-2.3.1.jar;E:\lianxi\hbase\lib\jasper-compiler-5.5.23.jar;E:\lianxi\hbase\lib\jasper-runtime-5.5.23.jar;E:\lianxi\hbase\lib\javax.inject-1.jar;E:\lianxi\hbase\lib\javax.servlet-3.1.jar;E:\lianxi\hbase\lib\javax.servlet-api-3.0.1.jar;E:\lianxi\hbase\lib\jaxb-api-2.2.2.jar;E:\lianxi\hbase\lib\jaxb-impl-2.2.3-1.jar;E:\lianxi\hbase\lib\jersey-client-1.9.jar;E:\lianxi\hbase\lib\jersey-core-1.8.jar;E:\lianxi\hbase\lib\jersey-grizzly2-1.9.jar;E:\lianxi\hbase\lib\jersey-guice-1.9.jar;E:\lianxi\hbase\lib\jersey-json-1.8.jar;E:\lianxi\hbase\lib\jersey-server-1.8.jar;E:\lianxi\hbase\lib\jersey-test-framework-core-1.9.jar;E:\lianxi\hbase\lib\jersey-test-framework-grizzly2-1.9.jar;E:\lianxi\hbase\lib\jets3t-0.6.1.jar;E:\lianxi\hbase\lib\jettison-1.3.1.jar;E:\lianxi\hbase\lib\jetty-6.1.26.jar;E:\lianxi\hbase\lib\jetty-sslengine-6.1.26.jar;E:\lianxi\hbase\lib\jetty-util-6.1.26.jar;E:\lianxi\hbase\lib\jruby-complete-1.6.8.jar;E:\lianxi\hbase\lib\jsch-0.1.42.jar;E:\lianxi\hbase\lib\jsp-2.1-6.1.14.jar;E:\lianxi\hbase\lib\jsp-api-2.1-6.1.14.jar;E:\lianxi\hbase\lib\jsr305-1.3.9.jar;E:\lianxi\hbase\lib\junit-4.11.jar;E:\lianxi\hbase\lib\libthrift-0.9.0.jar;E:\lianxi\hbase\lib\log4j-1.2.17.jar;E:\lianxi\hbase\lib\management-api-3.0.0-b012.jar;E:\lianxi\hbase\lib\metrics-core-2.1.2.jar;E:\lianxi\hbase\lib\netty-3.6.6.Final.jar;E:\lianxi\hbase\lib\paranamer-2.3.jar;E:\lianxi\hbase\lib\protobuf-java-2.5.0.jar;E:\lianxi\hbase\lib\servlet-api-2.5-6.1.14.jar;E:\lianxi\hbase\lib\slf4j-api-1.6.4.jar;E:\lianxi\hbase\lib\slf4j-log4j12-1.6.4.jar;E:\lianxi\hbase\lib\snappy-java-1.0.4.1.jar;E:\lianxi\hbase\lib\xmlenc-0.52.jar;E:\lianxi\hbase\lib\xz-1.0.jar;E:\lianxi\hbase\lib\zookeeper-3.4.5.jar
2015-06-23 22:13:55,190 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.library.path=E:\MyEclipse2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files (x86)\Common Files\NetSarang;G:\apache-maven-3.0.5\bin;F:\oracle\product\10.2.0\db_2\bin;E:\oracle\product\12.1.0\dbhome_1\bin;C:\Program Files\Java\jdk1.7.0_60/bin;C:\Program Files\Java\jdk1.7.0_60/jre/bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x64;C:\ProgramData\Lenovo\ReadyApps;E:\program\bin;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;E:\hadoop\hadoop-2.5.1\bin;.
2015-06-23 22:13:55,190 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.io.tmpdir=C:\Users\Adolf\AppData\Local\Temp\
2015-06-23 22:13:55,190 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.compiler=<NA>
2015-06-23 22:13:55,191 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:os.name=Windows 8
2015-06-23 22:13:55,191 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:os.arch=amd64
2015-06-23 22:13:55,191 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:os.version=6.2
2015-06-23 22:13:55,191 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:user.name=Adolf
2015-06-23 22:13:55,191 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:user.home=C:\Users\Adolf
2015-06-23 22:13:55,193 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:user.dir=E:\lianxi\hbase
2015-06-23 22:13:55,196 INFO zookeeper.ZooKeeper (ZooKeeper.java:<init>(438)) - Initiating client connection, connectString=192.168.1.205:2181,192.168.1.204:2181,192.168.1.206:2181 sessionTimeout=90000 watcher=hconnection-0x4c4d89ab, quorum=192.168.1.205:2181,192.168.1.204:2181,192.168.1.206:2181, baseZNode=/hbase
2015-06-23 22:13:55,280 INFO zookeeper.RecoverableZooKeeper (RecoverableZooKeeper.java:<init>(120)) - Process identifier=hconnection-0x4c4d89ab connecting to ZooKeeper ensemble=192.168.1.205:2181,192.168.1.204:2181,192.168.1.206:2181
2015-06-23 22:13:55,284 INFO zookeeper.ClientCnxn (ClientCnxn.java:logStartConnect(966)) - Opening socket connection to server love/192.168.1.206:2181. Will not attempt to authenticate using SASL (unknown error)
2015-06-23 22:13:55,291 INFO zookeeper.ClientCnxn (ClientCnxn.java:primeConnection(849)) - Socket connection established to love/192.168.1.206:2181, initiating session
2015-06-23 22:13:55,346 INFO zookeeper.ClientCnxn (ClientCnxn.java:onConnected(1207)) - Session establishment complete on server love/192.168.1.206:2181, sessionid = 0x24e20afe5640000, negotiated timeout = 40000
2015-06-23 22:13:56,037 INFO Configuration.deprecation (Configuration.java:warnOnceIfDeprecated(840)) - hadoop.native.lib is deprecated. Instead, use io.native.lib.available
2015-06-23 22:13:56,663 INFO client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1577)) - getMaster attempt 1 of 35 failed; retrying after sleep of 100, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: localhost.localdomain
2015-06-23 22:13:56,769 INFO client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1577)) - getMaster attempt 2 of 35 failed; retrying after sleep of 201, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: localhost.localdomain
2015-06-23 22:13:56,975 INFO client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1577)) - getMaster attempt 3 of 35 failed; retrying after sleep of 301, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: localhost.localdomain
2015-06-23 22:13:57,288 INFO client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1577)) - getMaster attempt 4 of 35 failed; retrying after sleep of 502, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: localhost.localdomain
2015-06-23 22:13:57,796 INFO client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1577)) - getMaster attempt 5 of 35 failed; retrying after sleep of 1007, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: localhost.localdomain
2015-06-23 22:13:58,808 INFO client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1577)) - getMaster attempt 6 of 35 failed; retrying after sleep of 2011, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: localhost.localdomain
2015-06-23 22:14:00,826 INFO client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1577)) - getMaster attempt 7 of 35 failed; retrying after sleep of 4033, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: localhost.localdomain
2015-06-23 22:14:04,865 INFO client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1577)) - getMaster attempt 8 of 35 failed; retrying after sleep of 10070, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: localhost.localdomain
2015-06-23 22:14:14,979 INFO client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1577)) - getMaster attempt 9 of 35 failed; retrying after sleep of 10099, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: localhost.localdomain
2015-06-23 22:14:25,091 INFO client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1577)) - getMaster attempt 10 of 35 failed; retrying after sleep of 10011, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: localhost.localdomain
2015-06-23 22:14:35,114 INFO client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1577)) - getMaster attempt 11 of 35 failed; retrying after sleep of 10011, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: localhost.localdomain
2015-06-23 22:14:45,139 INFO client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1577)) - getMaster attempt 12 of 35 failed; retrying after sleep of 20115, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: localhost.localdomain
2015-06-23 22:15:05,267 INFO client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1577)) - getMaster attempt 13 of 35 failed; retrying after sleep of 20076, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: localhost.localdomain
2015-06-23 22:15:25,355 INFO client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1577)) - getMaster attempt 14 of 35 failed; retrying after sleep of 20172, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: localhost.localdomain
2015-06-23 22:15:45,540 INFO client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1577)) - getMaster attempt 15 of 35 failed; retrying after sleep of 20102, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: localhost.localdomain
2015-06-23 22:16:05,659 INFO client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1577)) - getMaster attempt 16 of 35 failed; retrying after sleep of 20002, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: localhost.localdomain
2015-06-23 22:16:25,723 INFO client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1577)) - getMaster attempt 17 of 35 failed; retrying after sleep of 20143, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: localhost.localdomain
2015-06-23 22:16:45,879 INFO client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1577)) - getMaster attempt 18 of 35 failed; retrying after sleep of 20178, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: localhost.localdomain
2015-06-23 22:17:06,070 INFO client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1577)) - getMaster attempt 19 of 35 failed; retrying after sleep of 20106, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: localhost.localdomain


buildhappy 发表于 2015-8-22 11:53:43

你好我的链接代码如下package hadoop.hbase;

import java.io.IOException;

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.MasterNotRunningException;
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
import org.apache.hadoop.hbase.client.HBaseAdmin;

public class HbaseBasicOpt {
        static HBaseConfiguration cfg = null;
        static {
                Configuration conf = new Configuration();
                conf.set("hbase.zookeeper.quorum" , "10.108.112.149");
                conf.set("hbase.zookeeper.property.clientPort" , "2222");//9091
                //conf.set("hbase.master", "10.108.112.149:6000");       
                cfg = new HBaseConfiguration(conf);
        }
       
        /**
       * 创建表
       * @param tableName
       * @throws IOException
       * @throws ZooKeeperConnectionException
       * @throws MasterNotRunningException
       */
        public staticvoid createTable(String tableName) throws MasterNotRunningException, ZooKeeperConnectionException, IOException{
                HBaseAdmin admin = new HBaseAdmin(cfg);
                System.out.println(admin.tableExists(tableName));
                if(admin.tableExists(tableName)){
                        System.out.println("table exits");
                }else{
                        HTableDescriptor desc = new HTableDescriptor(tableName);
                        desc.addFamily(new HColumnDescriptor("name"));
                        admin.createTable(desc);
                        System.out.println("create done");
                }
        }
       
        public static void main(String[] args) throws MasterNotRunningException, ZooKeeperConnectionException, IOException{
                createTable("home");
        }
}


但是启动程序后一直阻塞,知道链接关闭请问是什么问题啊:
15/08/22 11:40:19 WARN hbase.HBaseConfiguration: instantiating HBaseConfiguration() is deprecated. Please use HBaseConfiguration#create() to construct a plain Configuration
...
15/08/22 11:40:19 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=10.108.112.149:2222 sessionTimeout=90000 watcher=catalogtracker-on-hconnection-0x19b4d0f, quorum=10.108.112.149:2222, baseZNode=/hbase
15/08/22 11:40:19 INFO zookeeper.ClientCnxn: Opening socket connection to server 10.108.112.149/10.108.112.149:2222. Will not attempt to authenticate using SASL (unknown error)
15/08/22 11:40:19 INFO zookeeper.RecoverableZooKeeper: Process identifier=catalogtracker-on-hconnection-0x19b4d0f connecting to ZooKeeper ensemble=10.108.112.149:2222
15/08/22 11:40:19 INFO zookeeper.ClientCnxn: Socket connection established to 10.108.112.149/10.108.112.149:2222, initiating session
15/08/22 11:40:19 INFO zookeeper.ClientCnxn: Session establishment complete on server 10.108.112.149/10.108.112.149:2222, sessionid = 0x14f5367a0cf000b, negotiated timeout = 90000
15/08/22 11:49:34 INFO zookeeper.ZooKeeper: Session: 0x14f5367a0cf000b closed


xmhxmhxmh 发表于 2015-8-27 11:25:33

楼主,现在HBaseAdmin 过时了

zhangblh 发表于 2015-9-1 15:24:36

xmhxmhxmh 发表于 2015-8-27 11:25
楼主,现在HBaseAdmin 过时了

这位兄台指教下,现在流行什么样的方式咧?
页: [1] 2 3
查看完整版本: 总结Eclipse 远程连接 HBase问题及解决方案大全