java连接hbase长时间无反应问题

1.本地环境hbase1.2.1错用了hadoop-core.jar,应该使用hadoop2版本的jar

2.本地环境没有配置region Servers的host

要现在hbase安装主机上的ect\hosts文件里加上主机ip和主机名,如下第一行所示。192.168.187.209 ubuntu001

192.168.187.209 ubuntu001
#192.168.187.209    localhost

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters


192.168.187.209 192-168-187-209

因为我用windows系统调hbasePAI,在C\Windows\System32\drivers\etc\hosts 下添加用样的内容
整体如下

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   192.168.10.106             Administrator
127.0.0.1       syf
192.168.10.106             Administrator
192.168.187.209 ubuntu001
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如何用Java连接HBase和使用Maven管理项目? 要连接HBase和使用Maven来管理项目,你需要以下步骤: 1.安装和配置HBase:在你的机器上安装HBase,并确保HBase配置正确。 2.创建Maven项目:在你的IDE中创建一个新的Maven项目。 3.添加依赖项:在Maven项目中添加HBase和Hadoop的依赖项,以便能够正确连接HBase。 4.连接HBase:使用Java HBase API连接HBase,并执行相关操作,例如读取和写入数据。你可以在HBaseJava API文档中找到相关信息。 例子代码: ``` import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; import org.apache.hadoop.hbase.client.Table; public class HBaseExample { public static void main(String[] args) { Configuration config = HBaseConfiguration.create(); config.set("hbase.zookeeper.quorum", "localhost"); config.set("hbase.zookeeper.property.clientPort", "2181"); Connection connection = ConnectionFactory.createConnection(config); Table table = connection.getTable(TableName.valueOf("mytable")); // do some operations on the table table.close(); connection.close(); } } ``` 这是一个使用Java HBase API连接HBase的简单示例。在代码中,首先我们创建一个HBaseConfiguration并设置一些必要的参数,例如HBase ZooKeeper的位置和端口号。然后,我们使用ConnectionFactory.createConnection创建一个HBase连接。接下来,我们获取一个Table对象并执行一些操作。最后,我们关闭Table和连接对象。 希望这可以帮助你了解如何使用Java连接HBase和使用Maven管理项目。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值