我写的是简单的"你好世界"使用Java API for HBase的应用程序。这是我的代码:
public static void main(String[] args) throws IOException {
Configuration conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.quorum", "localhost");
conf.set("hbase.zookeeper.property.clientPort", "2181");
HTable table = new HTable(conf, "myTable");
Scan s = new Scan();
s.addColumn(Bytes.toBytes("a"), Bytes.toBytes("b"));
ResultScanner scanner = table.getScanner(s);
for (Result rr = scanner.next(); rr != null; rr = scanner.next()) {
System.out.println("Found row: " + rr);
}
table.close();
}
结果我得到了:
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:host.name=localhost
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:java.version=1.8.0_45
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:java.vendor=Oracle Corporation
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:java.home=/usr/lib/jvm/java-8-oracle/jre
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:java.class.path=/home/bartek/workspace/HBaseTester/target/classes:/home/bartek/.m2/repository/org/apache/hadoop/hadoop-core/1.0.4/hadoop-core-1.0.4.jar:/home/bartek/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar:/home/bartek/.m2/repository/xmlenc/xmlenc/0.52/xmlenc-0.52.jar:/home/bartek/.m2/repository/commons-httpclient/commons-httpclient/3.0.1/commons-httpclient-3.0.1.jar:/home/bartek/.m2/repository/commons-codec/commons-codec/1.4/commons-codec-1.4.jar:/home/bartek/.m2/repository/org/apache/commons/commons-math/2.1/commons-math-2.1.jar:/home/bartek/.m2/repository/commons-configuration/commons-configuration/1.6/commons-configuration-1.6.jar:/home/bartek/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar:/home/bartek/.m2/repository/commons-digester/commons-digester/1.8/commons-digester-1.8.jar:/home/bartek/.m2/repository/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar:/home/bartek/.m2/repository/commons-beanutils/commons-beanutils-core/1.8.0/commons-beanutils-core-1.8.0.jar:/home/bartek/.m2/repository/commons-net/commons-net/1.4.1/commons-net-1.4.1.jar:/home/bartek/.m2/repository/org/mortbay/jetty/jetty/6.1.26/jetty-6.1.26.jar:/home/bartek/.m2/repository/org/mortbay/jetty/servlet-api/2.5-20081211/servlet-api-2.5-20081211.jar:/home/bartek/.m2/repository/org/mortbay/jetty/jetty-util/6.1.26/jetty-util-6.1.26.jar:/home/bartek/.m2/repository/tomcat/jasper-runtime/5.5.12/jasper-runtime-5.5.12.jar:/home/bartek/.m2/repository/tomcat/jasper-compiler/5.5.12/jasper-compiler-5.5.12.jar:/home/bartek/.m2/repository/org/mortbay/jetty/jsp-api-2.1/6.1.14/jsp-api-2.1-6.1.14.jar:/home/bartek/.m2/repository/org/mortbay/jetty/jsp-2.1/6.1.14/jsp-2.1-6.1.14.jar:/home/bartek/.m2/repository/ant/ant/1.6.5/ant-1.6.5.jar:/home/bartek/.m2/repository/commons-el/commons-el/1.0/commons-el-1.0.jar:/home/bartek/.m2/repository/net/java/dev/jets3t/jets3t/0.7.1/jets3t-0.7.1.jar:/home/bartek/.m2/repository/net/sf/kosmosfs/kfs/0.3/kfs-0.3.jar:/home/bartek/.m2/repository/hsqldb/hsqldb/1.8.0.10/hsqldb-1.8.0.10.jar:/home/bartek/.m2/repository/oro/oro/2.0.8/oro-2.0.8.jar:/home/bartek/.m2/repository/org/eclipse/jdt/core/3.1.1/core-3.1.1.jar:/home/bartek/.m2/repository/org/codehaus/jackson/jackson-mapper-asl/1.0.1/jackson-mapper-asl-1.0.1.jar:/home/bartek/.m2/repository/org/apache/hbase/hbase/0.94.14/hbase-0.94.14.jar:/home/bartek/.m2/repository/com/yammer/metrics/metrics-core/2.1.2/metrics-core-2.1.2.jar:/home/bartek/.m2/repository/com/google/guava/guava/11.0.2/guava-11.0.2.jar:/home/bartek/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar:/home/bartek/.m2/repository/com/github/stephenc/high-scale-lib/high-scale-lib/1.1.1/high-scale-lib-1.1.1.jar:/home/bartek/.m2/repository/commons-io/commons-io/2.1/commons-io-2.1.jar:/home/bartek/.m2/repository/commons-lang/commons-lang/2.5/commons-lang-2.5.jar:/home/bartek/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/home/bartek/.m2/repository/log4j/log4j/1.2.16/log4j-1.2.16.jar:/home/bartek/.m2/repository/org/apache/avro/avro/1.5.3/avro-1.5.3.jar:/home/bartek/.m2/repository/org/xerial/snappy/snappy-java/1.0.3.2/snappy-java-1.0.3.2.jar:/home/bartek/.m2/repository/org/apache/avro/avro-ipc/1.5.3/avro-ipc-1.5.3.jar:/home/bartek/.m2/repository/org/jboss/netty/netty/3.2.4.Final/netty-3.2.4.Final.jar:/home/bartek/.m2/repository/org/apache/velocity/velocity/1.7/velocity-1.7.jar:/home/bartek/.m2/repository/org/apache/zookeeper/zookeeper/3.4.5/zookeeper-3.4.5.jar:/home/bartek/.m2/repository/org/apache/thrift/libthrift/0.8.0/libthrift-0.8.0.jar:/home/bartek/.m2/repository/org/apache/httpcomponents/httpclient/4.1.2/httpclient-4.1.2.jar:/home/bartek/.m2/repository/org/apache/httpcomponents/httpcore/4.1.3/httpcore-4.1.3.jar:/home/bartek/.m2/repository/org/jruby/jruby-complete/1.6.5/jruby-complete-1.6.5.jar:/home/bartek/.m2/repository/org/mortbay/jetty/servlet-api-2.5/6.1.14/servlet-api-2.5-6.1.14.jar:/home/bartek/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.8.8/jackson-core-asl-1.8.8.jar:/home/bartek/.m2/repository/org/codehaus/jackson/jackson-jaxrs/1.8.8/jackson-jaxrs-1.8.8.jar:/home/bartek/.m2/repository/org/codehaus/jackson/jackson-xc/1.8.8/jackson-xc-1.8.8.jar:/home/bartek/.m2/repository/org/slf4j/slf4j-api/1.4.3/slf4j-api-1.4.3.jar:/home/bartek/.m2/repository/org/slf4j/slf4j-log4j12/1.4.3/slf4j-log4j12-1.4.3.jar:/home/bartek/.m2/repository/org/jamon/jamon-runtime/2.3.1/jamon-runtime-2.3.1.jar:/home/bartek/.m2/repository/com/google/protobuf/protobuf-java/2.4.0a/protobuf-java-2.4.0a.jar:/home/bartek/.m2/repository/com/sun/jersey/jersey-core/1.8/jersey-core-1.8.jar:/home/bartek/.m2/repository/com/sun/jersey/jersey-json/1.8/jersey-json-1.8.jar:/home/bartek/.m2/repository/org/codehaus/jettison/jettison/1.1/jettison-1.1.jar:/home/bartek/.m2/repository/com/sun/xml/bind/jaxb-impl/2.2.3-1/jaxb-impl-2.2.3-1.jar:/home/bartek/.m2/repository/com/sun/jersey/jersey-server/1.8/jersey-server-1.8.jar:/home/bartek/.m2/repository/asm/asm/3.1/asm-3.1.jar:/home/bartek/.m2/repository/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar:/home/bartek/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar:/home/bartek/.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:java.io.tmpdir=/tmp
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:java.compiler=<NA>
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:os.name=Linux
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:os.arch=amd64
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:os.version=3.16.0-34-generic
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:user.name=bartek
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:user.home=/home/bartek
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Client environment:user.dir=/home/bartek/workspace/HBaseTester
15/04/24 17:38:11 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=localhost:2181 sessionTimeout=180000 watcher=hconnection
15/04/24 17:38:11 INFO zookeeper.RecoverableZooKeeper: The identifier of this process is 9799@samsung
15/04/24 17:38:11 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
15/04/24 17:38:11 INFO zookeeper.ClientCnxn: Socket connection established to localhost/127.0.0.1:2181, initiating session
15/04/24 17:38:11 INFO zookeeper.ClientCnxn: Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x14cebe1a485000b, negotiated timeout = 40000
15/04/24 17:38:12 INFO client.HConnectionManager$HConnectionImplementation: Closed zookeeper sessionid=0x14cebe1a485000b
15/04/24 17:38:12 INFO zookeeper.ClientCnxn: EventThread shut down
15/04/24 17:38:12 INFO zookeeper.ZooKeeper: Session: 0x14cebe1a485000b closed
我在localhost上运行了HBase(版本0.94.14)实例,我不想在分布式模式下,在hdfs等上运行。只需一个实例。我可以通过在浏览器中打开http://localhost:60010/来查看其状态,一切似乎都可以。更重要的是,当我使用不同的应用程序(如Nutch或h-rider)时,一切正常(在HBase的同一个实例中,我尝试连接)。我尝试了不同的选项,例如在hbase-env.sh中设置环境变量$HBASE_HOME
或设置export HBASE_MANAGES_ZK=true
。在我的应用程序中有相同的版本包含在pom.xml中,所以我可以说没有版本冲突。
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase</artifactId>
<version>0.94.14</version>
</dependency>
我的$HBASE_HOME/conf/hbase-site.xml
:
<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///home/bartek/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>false</value>
</property>
如何让它运行?
编辑: 我已经将日志更改为DEBUG,这就是我现在所能得到的:
2015-05-04 14:31:42 DEBUG MutableMetricsFactory:42 - field org.apache.hadoop.metrics2.lib.MutableRate org.apache.hadoop.security.UserGroupInformation$UgiMetrics.loginSuccess with annotation @org.apache.hadoop.metrics2.annotation.Metric(always=false, about=, sampleName=Ops, type=DEFAULT, valueName=Time, value=[Rate of successful kerberos logins and latency (milliseconds)])
2015-05-04 14:31:42 DEBUG MutableMetricsFactory:42 - field org.apache.hadoop.metrics2.lib.MutableRate org.apache.hadoop.security.UserGroupInformation$UgiMetrics.loginFailure with annotation @org.apache.hadoop.metrics2.annotation.Metric(always=false, about=, sampleName=Ops, type=DEFAULT, valueName=Time, value=[Rate of failed kerberos logins and latency (milliseconds)])
2015-05-04 14:31:42 DEBUG MutableMetricsFactory:42 - field org.apache.hadoop.metrics2.lib.MutableRate org.apache.hadoop.security.UserGroupInformation$UgiMetrics.getGroups with annotation @org.apache.hadoop.metrics2.annotation.Metric(always=false, about=, sampleName=Ops, type=DEFAULT, valueName=Time, value=[GetGroups])
2015-05-04 14:31:42 DEBUG MetricsSystemImpl:231 - UgiMetrics, User and group related metrics
2015-05-04 14:31:42 DEBUG KerberosName:88 - Kerberos krb5 configuration not found, setting default realm to empty
2015-05-04 14:31:42 DEBUG Groups:278 - Creating new Groups object
2015-05-04 14:31:42 DEBUG NativeCodeLoader:46 - Trying to load the custom-built native-hadoop library...
2015-05-04 14:31:42 DEBUG NativeCodeLoader:55 - Failed to load native-hadoop with error: java.lang.UnsatisfiedLinkError: no hadoop in java.library.path
2015-05-04 14:31:42 DEBUG NativeCodeLoader:56 - java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2015-05-04 14:31:42 WARN NativeCodeLoader:62 - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
2015-05-04 14:31:42 DEBUG PerformanceAdvisory:41 - Falling back to shell based
2015-05-04 14:31:42 DEBUG JniBasedUnixGroupsMappingWithFallback:45 - Group mapping impl=org.apache.hadoop.security.ShellBasedUnixGroupsMapping
2015-05-04 14:31:42 DEBUG Shell:396 - setsid exited with exit code 0
2015-05-04 14:31:42 DEBUG Groups:91 - Group mapping impl=org.apache.hadoop.security.JniBasedUnixGroupsMappingWithFallback; cacheTimeout=300000; warningDeltaMs=5000
2015-05-04 14:31:42 DEBUG UserGroupInformation:209 - hadoop login
2015-05-04 14:31:42 DEBUG UserGroupInformation:144 - hadoop login commit
2015-05-04 14:31:42 DEBUG UserGroupInformation:174 - using local user:UnixPrincipal: bartek
2015-05-04 14:31:42 DEBUG UserGroupInformation:180 - Using user: "UnixPrincipal: bartek" with name bartek
2015-05-04 14:31:42 DEBUG UserGroupInformation:190 - User entry: "bartek"
2015-05-04 14:31:42 DEBUG UserGroupInformation:799 - UGI loginUser:bartek (auth:SIMPLE)
2015-05-04 14:31:42 DEBUG ZKUtil:120 - hconnection opening connection to ZooKeeper with ensemble (localhost:2181)
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:host.name=localhost
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:java.version=1.8.0_45
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:java.vendor=Oracle Corporation
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:java.home=/usr/lib/jvm/java-8-oracle/jre
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:java.class.path=[...] // same as before
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:java.io.tmpdir=/tmp
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:java.compiler=<NA>
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:os.name=Linux
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:os.arch=amd64
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:os.version=3.16.0-36-generic
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:user.name=bartek
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:user.home=/home/bartek
2015-05-04 14:31:42 INFO ZooKeeper:100 - Client environment:user.dir=/var/my-proj
2015-05-04 14:31:42 INFO ZooKeeper:438 - Initiating client connection, connectString=localhost:2181 sessionTimeout=180000 watcher=hconnection
2015-05-04 14:31:42 DEBUG ClientCnxn:99 - zookeeper.disableAutoWatchReset is false
2015-05-04 14:31:42 INFO RecoverableZooKeeper:104 - The identifier of this process is 7002@localhost
2015-05-04 14:31:42 INFO ClientCnxn:966 - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2015-05-04 14:31:42 INFO ClientCnxn:849 - Socket connection established to localhost/127.0.0.1:2181, initiating session
2015-05-04 14:31:42 DEBUG ClientCnxn:889 - Session establishment request sent on localhost/127.0.0.1:2181
2015-05-04 14:31:42 INFO ClientCnxn:1207 - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x14d1ecf01b2000a, negotiated timeout = 40000
2015-05-04 14:31:42 DEBUG ZooKeeperWatcher:294 - hconnection Received ZooKeeper Event, type=None, state=SyncConnected, path=null
2015-05-04 14:31:42 DEBUG ZooKeeperWatcher:371 - hconnection-0x14d1ecf01b2000a connected
2015-05-04 14:31:42 DEBUG ClientCnxn:815 - Reading reply sessionid:0x14d1ecf01b2000a, packet:: clientPath:null serverPath:null finished:false header:: 1,3 replyHeader:: 1,66,0 request:: '/hbase/hbaseid,F response:: s{13,13,1430740995346,1430740995346,0,0,0,0,55,0,13}
2015-05-04 14:31:42 DEBUG ClientCnxn:815 - Reading reply sessionid:0x14d1ecf01b2000a, packet:: clientPath:null serverPath:null finished:false header:: 2,4 replyHeader:: 2,66,0 request:: '/hbase/hbaseid,F response:: #ffffffff000e35383437406c6f63616c686f737434313335376236322d346335622d343132362d386465392d343166643434646664636562,s{13,13,1430740995346,1430740995346,0,0,0,0,55,0,13}
2015-05-04 14:31:42 DEBUG ZKUtil:1595 - hconnection-0x14d1ecf01b2000a Retrieved 36 byte(s) of data from znode /hbase/hbaseid; data=41357b62-4c5b-4126-8de9-41fd4...
2015-05-04 14:31:42 DEBUG ClientCnxn:815 - Reading reply sessionid:0x14d1ecf01b2000a, packet:: clientPath:null serverPath:null finished:false header:: 3,3 replyHeader:: 3,66,0 request:: '/hbase/master,T response:: s{10,10,1430740994742,1430740994742,0,0,0,93765041680154624,50,0,10}
2015-05-04 14:31:42 DEBUG ZKUtil:423 - hconnection-0x14d1ecf01b2000a Set watcher on existing znode /hbase/master
2015-05-04 14:31:42 DEBUG ClientCnxn:815 - Reading reply sessionid:0x14d1ecf01b2000a, packet:: clientPath:null serverPath:null finished:false header:: 4,4 replyHeader:: 4,66,0 request:: '/hbase/master,T response:: #ffffffff000e35383437406c6f63616c686f7374006c6f63616c686f73742c34333133352c31343330373430393933323238,s{10,10,1430740994742,1430740994742,0,0,0,93765041680154624,50,0,10}
2015-05-04 14:31:42 DEBUG ZKUtil:1595 - hconnection-0x14d1ecf01b2000a Retrieved 31 byte(s) of data from znode /hbase/master and set watcher; \x00\x00localhost,43135,14307...
2015-05-04 14:31:42 DEBUG ClientCnxn:815 - Reading reply sessionid:0x14d1ecf01b2000a, packet:: clientPath:null serverPath:null finished:false header:: 5,3 replyHeader:: 5,66,0 request:: '/hbase/root-region-server,T response:: s{30,30,1430741001288,1430741001288,0,0,0,0,48,0,30}
2015-05-04 14:31:42 DEBUG ZKUtil:423 - hconnection-0x14d1ecf01b2000a Set watcher on existing znode /hbase/root-region-server
2015-05-04 14:31:42 DEBUG ClientCnxn:815 - Reading reply sessionid:0x14d1ecf01b2000a, packet:: clientPath:null serverPath:null finished:false header:: 6,4 replyHeader:: 6,66,0 request:: '/hbase/root-region-server,T response:: #ffffffff000e35383437406c6f63616c686f73746c6f63616c686f73742c33353931382c31343330373430393933373635,s{30,30,1430741001288,1430741001288,0,0,0,0,48,0,30}
2015-05-04 14:31:42 DEBUG ZKUtil:1595 - hconnection-0x14d1ecf01b2000a Retrieved 29 byte(s) of data from znode /hbase/root-region-server and set watcher; localhost,35918,1430740993765
2015-05-04 14:31:42 DEBUG HBaseRPC:102 - Using RpcEngine: org.apache.hadoop.hbase.ipc.WritableRpcEngine
2015-05-04 14:31:42 DEBUG HBaseClient:868 - The ping interval is60000ms.
2015-05-04 14:31:42 DEBUG ClientCnxn:815 - Reading reply sessionid:0x14d1ecf01b2000a, packet:: clientPath:null serverPath:null finished:false header:: 7,3 replyHeader:: 7,66,0 request:: '/hbase,F response:: s{2,2,1430740993557,1430740993557,0,12,0,0,0,12,30}
2015-05-04 14:31:42 DEBUG ClientCnxn:815 - Reading reply sessionid:0x14d1ecf01b2000a, packet:: clientPath:null serverPath:null finished:false header:: 8,4 replyHeader:: 8,66,0 request:: '/hbase/root-region-server,T response:: #ffffffff000e35383437406c6f63616c686f73746c6f63616c686f73742c33353931382c31343330373430393933373635,s{30,30,1430741001288,1430741001288,0,0,0,0,48,0,30}
2015-05-04 14:31:42 DEBUG ZKUtil:1595 - hconnection-0x14d1ecf01b2000a Retrieved 29 byte(s) of data from znode /hbase/root-region-server and set watcher; localhost,35918,1430740993765
2015-05-04 14:31:42 DEBUG HConnectionManager$HConnectionImplementation:987 - Looked up root region location, connection=org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@7daa0fbd; serverName=localhost,35918,1430740993765
2015-05-04 14:31:42 DEBUG HBaseClient:436 - Connecting to org.apache.hadoop.hbase.ipc.HBaseClient$ConnectionId@6bad9bb9
2015-05-04 14:31:42 DEBUG HBaseClient:739 - closing ipc connection to localhost/127.0.0.1:35918: Could not set up IO Streams
java.io.IOException: Could not set up IO Streams
at org.apache.hadoop.hbase.ipc.HBaseClient$Connection.setupIOstreams(HBaseClient.java:456)
at org.apache.hadoop.hbase.ipc.HBaseClient.getConnection(HBaseClient.java:1141)
at org.apache.hadoop.hbase.ipc.HBaseClient.call(HBaseClient.java:988)
at org.apache.hadoop.hbase.ipc.WritableRpcEngine$Invoker.invoke(WritableRpcEngine.java:87)
at com.sun.proxy.$Proxy21.getProtocolVersion(Unknown Source)
at org.apache.hadoop.hbase.ipc.WritableRpcEngine.getProxy(WritableRpcEngine.java:141)
at org.apache.hadoop.hbase.ipc.HBaseRPC.waitForProxy(HBaseRPC.java:208)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getHRegionConnection(HConnectionManager.java:1473)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getHRegionConnection(HConnectionManager.java:1432)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getHRegionConnection(HConnectionManager.java:1419)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:1102)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:997)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:1099)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:1001)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:958)
at org.apache.hadoop.hbase.client.HTable.finishSetup(HTable.java:251)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:155)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:129)
at com.company.my.proj.test.core.HBaseTest.connectDirect(HBaseTest.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.NoSuchMethodError: org.apache.hadoop.net.NetUtils.getInputStream(Ljava/net/Socket;)Ljava/io/InputStream;
at org.apache.hadoop.hbase.ipc.HBaseClient$Connection.setupIOstreams(HBaseClient.java:439)
... 41 more
答案 0 :(得分:0)
试试这个:
public static void main(String[] args) throws IOException, Exception{
Configuration conf = HBaseConfiguration.create();
conf.set("hbase.master", "localhost:60000");
conf.set("hbase.zookeeper.quorum","localhost");
conf.set("hbase.zookeeper.property.clientPort", "2181");
HTable table = new HTable(conf, "mytable");
Get g = new Get(Bytes.toBytes("row1"));
Result result = table.get(g);
byte[]value=result.getValue(Bytes.toBytes("Columnfam1"),Bytes.toBytes("column");
String R = Bytes.toString(value);
System.out.println(R);
table.close();
}
答案 1 :(得分:0)
我认为我得到了解决方案,在我的操作系统中禁用IPv6(这里的Ubuntu)有所帮助。它可以像:https://askubuntu.com/a/484487/309788那样完成,但记得重新启动你的系统,在我的情况下,简单的配置是不够的。