spring hbase样本与独立的hbase

时间:2015-08-01 06:54:33

标签: java spring hbase

在我的本地开发Ubuntu 14盒子上,我无法让hadoop和hbase独立运行。

BUt可以使hbase直接与文件系统一起工作(通过创建表并在hbase shell中放置值来验证)。

现在我想从春天开始阅读这张桌子。我开始使用代码https://github.com/spring-projects/spring-hadoop-samples/tree/master/hbase

如果我将IP和端口更改为qa服务器,则可以正常工作。但是,如果我想连接到我的本地hbase不能。

HBase的现场

   <property>
      <name>hbase.rootdir</name>
      <!-- value>hdfs://localhost:50070/hbase</value --> <!-- 8030-->
    <value>file:///usr/local/hbase/HFiles3</value>
   </property>

   <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/usr/local/hbase/zookeeper3</value>
  </property>     

   <property>
    <name>hbase.master.info.port</name>
    <value>8095</value>
  </property>

   <property>
    <name>hbase.regionserver.info.port</name>
    <value>8096</value> <!-- changed as i dont know where it was connecting other wise none of the usual ports -->
  </property>

应用context.xml中

    <context:property-placeholder location="hbase.properties"/>

    <context:component-scan base-package="org.springframework.samples.hadoop.hbase"/>

    <hdp:configuration id="hadoopConfiguration">
      fs.defaultFS=file:///usr/local/hbase/HFiles3
    </hdp:configuration>

<!--    configuration-ref="hadoopConfiguration" -->
    <hdp:hbase-configuration configuration-ref="hadoopConfiguration" zk-quorum="${hbase.zk.host}" zk-port="${hbase.zk.port}"/>

    <bean id="hbaseTemplate" class="org.springframework.data.hadoop.hbase.HbaseTemplate">
        <property name="configuration" ref="hbaseConfiguration"/>
    </bean>

hbase.properties

hbase.zk.host=localhost
hbase.zk.port=8095

记录(部分): ...

12:20:21,763  INFO           org.apache.zookeeper.ZooKeeper: 100 - Client environment:user.home=/home/t
12:20:21,763  INFO           org.apache.zookeeper.ZooKeeper: 100 - Client environment:user.dir=/home/t/prog/r/github/spring-hadoop-samples/hbase
12:20:21,765  INFO           org.apache.zookeeper.ZooKeeper: 438 - Initiating client connection, connectString=localhost:8095 sessionTimeout=90000 watcher=hconnection-0x5a7fd55c, quorum=localhost:8095, baseZNode=/hbase
12:20:21,802  INFO oop.hbase.zookeeper.RecoverableZooKeeper: 120 - Process identifier=hconnection-0x5a7fd55c connecting to ZooKeeper ensemble=localhost:8095
12:20:21,805  INFO          org.apache.zookeeper.ClientCnxn: 975 - Opening socket connection to server t/127.0.0.1:8095. Will not attempt to authenticate using SASL (unknown error)
12:20:21,828  INFO          org.apache.zookeeper.ClientCnxn: 852 - Socket connection established to t/127.0.0.1:8095, initiating session
12:20:21,834  WARN          org.apache.zookeeper.ClientCnxn:1102 - Session 0x0 for server t/127.0.0.1:8095, unexpected error, closing socket connection and attempting reconnect
java.io.IOException: Packet len1213486160 is out of range!
    at org.apache.zookeeper.ClientCnxnSocket.readLength(ClientCnxnSocket.java:112)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doIO(ClientCnxnSocketNIO.java:79)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:366)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
12:20:21,947  WARN oop.hbase.zookeeper.RecoverableZooKeeper: 253 - Possibly transient ZooKeeper, quorum=localhost:8095, exception=org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/hbaseid
12:20:21,947  INFO rg.apache.hadoop.hbase.util.RetryCounter: 155 - Sleeping 1000ms before retry #0...
12:20:23,325  INFO          org.apache.zookeeper.ClientCnxn: 975 - Opening socket connection to server t/127.0.0.1:8095. Will not attempt to authenticate using SASL (unknown error)
12:20:23,326  INFO          org.apache.zookeeper.ClientCnxn: 852 - Socket connection established to t/127.0.0.1:8095, initiating session
12:20:23,327  WARN          org.apache.zookeeper.ClientCnxn:1102 - Session 0x0 for server t/127.0.0.1:8095, unexpected error, closing socket connection and attempting reconnect
java.io.IOException: Packet len1213486160 is out of range!

...

我可以在没有hadoop的情况下为本地开发运行spring hbase吗?我是否需要运行一个独立的zookeeper并将该端口作为hbase.zk.port?什么是hbase.zk.port?

1 个答案:

答案 0 :(得分:1)

在独立模式下,它也连接到2181。来自hbase的日志:

  

2015-08-01 12:30:36,489 INFO [main] server.ZooKeeperServer:已创建   具有tickTime 2000 minSessionTimeout 4000 maxSessionTimeout的服务器   40000 datadir / usr / local / hbase / zookeeper3 / zookeeper_0 / version-2   snapdir / usr / local / hbase / zookeeper3 / zookeeper_0 / version-2 2015-08-01   12:30:36,504 INFO [main] server.NIOServerCnxnFactory:绑定到端口   0.0.0.0/0.0.0.0:2181 2015-08-01 12:30:36,638 INFO [NIOServerCxn.Factory:0.0.0.0 / 0.0.0.0:2181]   server.NIOServerCnxnFactory:接受来自的套接字连接   /127.0.0.1:60489

示例工作 - 'hadoop'本地文件URL和zk默认2181端口

<hdp:configuration id="hadoopConfiguration">
      fs.defaultFS=file:///usr/local/hbase/HFiles3
    </hdp:configuration> 

hbase.zk.port=2181