请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

程序连接不到HBase

HBaseUtils程序运行异常,

https://img1.sycdn.imooc.com//szimg/5a276f1c0001ef0206940301.jpg

下面是报错信息

https://img1.sycdn.imooc.com//szimg/5a276f5600013efb08870359.jpg

https://img1.sycdn.imooc.com//szimg/5a276f8000011d0309340425.jpg

在虚拟机中查看ZK日志,发现已经连接,但是之后会异常退出,可能的原因是连接时间长被中断

但是HBase日志中没有任何连接信息。意味着连接到zk并分配session之后,程序并没有连接HBase

ZK日志如下

2017-12-06 11:51:11,307 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@197] - Accepted socket connection from /192.168.43.233:52001

2017-12-06 11:51:11,313 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@839] - Client attempting to establish new session at /192.168.43.233:52001

2017-12-06 11:51:11,324 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@595] - Established session 0x16029dd9542000c with negotiated timeout 40000 for client /192.168.43.233:52001


程序报错后,并没有结束。继续卡住,过一段时间后exit 0 结束。此时ZK的日志文件增加

2017-12-06 11:59:46,211 [myid:] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@354] - Exception causing close of session 0x16029dd9542000c due to java.io.IOException: Connection reset by peer


2017-12-06 11:59:46,215 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1001] - Closed socket connection for client /192.168.43.233:52001 which had sessionid 0x16029dd9542000c


2017-12-06 12:00:26,000 [myid:] - INFO  [SessionTracker:ZooKeeperServer@325] - Expiring session 0x16029dd9542000c, timeout of 40000ms exceeded

2017-12-06 12:00:26,001 [myid:] - INFO  [ProcessThread(sid:0 cport:-1)::PrepRequestProcessor@494] - Processed session termination for sessionid: 0x16029dd9542000c

这段时间程序的状态是:先报错,但程序没有中断,最后过了一会,程序中断

去查看HBase日志文件,发现这段时间没有任何程序连接HBase

SecurityAuth.audit


2017-12-06 11:51:03,821 INFO SecurityLogger.org.apache.hadoop.hbase.Server: Auth successful for root (auth:SIMPLE)

2017-12-06 11:51:03,824 INFO SecurityLogger.org.apache.hadoop.hbase.Server: Connection from 127.0.0.1 port: 52904 with version info: version: "1.2.0-cdh5.7.0" url: "file:///data/jenkins/workspace/generic-binary-tarball-and-maven-deploy/CDH5.7.0-Packaging-HBase-2016-03-23_11-28-41/hbase-1.2.0-cdh5.7.0" revision: "Unknown" user: "jenkins" date: "Wed Mar 23 11:46:29 PDT 2016" src_checksum: "91b52afd1a8dfc556696ed78433f5621"


2017-12-06 11:56:04,003 INFO SecurityLogger.org.apache.hadoop.hbase.Server: Auth successful for root (auth:SIMPLE)

2017-12-06 11:56:04,004 INFO SecurityLogger.org.apache.hadoop.hbase.Server: Connection from 127.0.0.1 port: 52956 with version info: version: "1.2.0-cdh5.7.0" url: "file:///data/jenkins/workspace/generic-binary-tarball-and-maven-deploy/CDH5.7.0-Packaging-HBase-2016-03-23_11-28-41/hbase-1.2.0-cdh5.7.0" revision: "Unknown" user: "jenkins" date: "Wed Mar 23 11:46:29 PDT 2016" src_checksum: "91b52afd1a8dfc556696ed78433f5621"



2017-12-06 12:01:03,849 INFO SecurityLogger.org.apache.hadoop.hbase.Server: Auth successful for root (auth:SIMPLE)

2017-12-06 12:01:03,850 INFO SecurityLogger.org.apache.hadoop.hbase.Server: Connection from 127.0.0.1 port: 53008 with version info: version: "1.2.0-cdh5.7.0" url: "file:///data/jenkins/workspace/generic-binary-tarball-and-maven-deploy/CDH5.7.0-Packaging-HBase-2016-03-23_11-28-41/hbase-1.2.0-cdh5.7.0" revision: "Unknown" user: "jenkins" date: "Wed Mar 23 11:46:29 PDT 2016" src_checksum: "91b52afd1a8dfc556696ed78433f5621"


2017-12-06 12:06:04,632 INFO SecurityLogger.org.apache.hadoop.hbase.Server: Auth successful for root (auth:SIMPLE)

2017-12-06 12:06:04,633 INFO SecurityLogger.org.apache.hadoop.hbase.Server: Connection from 127.0.0.1 port: 53060 with version info: version: "1.2.0-cdh5.7.0" url: "file:///data/jenkins/workspace/generic-binary-tarball-and-maven-deploy/CDH5.7.0-Packaging-HBase-2016-03-23_11-28-41/hbase-1.2.0-cdh5.7.0" revision: "Unknown" user: "jenkins" date: "Wed Mar 23 11:46:29 PDT 2016" src_checksum: "91b52afd1a8dfc556696ed78433f5621"

HBase配置文件如下

https://img1.sycdn.imooc.com//szimg/5a27711c0001ce3e03450289.jpg

但是在HBase shell中可以创建表,可以put进数据。

https://img1.sycdn.imooc.com//szimg/5a27724d000190a403750207.jpg

每次使用API调用就会报如上错误,因为是初学者。。所以2天了没有解决。求老师帮忙

正在回答 回答被采纳积分+3

2回答

碧威009 2017-12-06 13:02:19

在windows下开发的话,你要连虚拟机的hbase去操作,你在idea里弄个hbase-site.xml试试,把hbase那些配置信息加上去

0 回复 有任何疑惑可以回复我~
  • 提问者 十里桃花舞丶 #1
    这个问题我发现是出在zk返回给程序hbase的注册地址,127.0.0.1,然后程序就真在本地找hbase,最后就导致连接异常。但是不知道该怎么解决。修改了虚拟机中的hbase配置文件,hbase.site.xml将localhost改成ip地址也不行,它还会给程序返回127.0.0.1
    回复 有任何疑惑可以回复我~ 2017-12-06 21:09:33
Michael_PK 2017-12-06 12:39:04

你的hdfs的端口是9000还是8020?

0 回复 有任何疑惑可以回复我~
  • 提问者 十里桃花舞丶 #1
    我的端口是9000
    回复 有任何疑惑可以回复我~ 2017-12-06 12:48:32
  • 提问者 十里桃花舞丶 #2
    hbase shell可以建表,也能put进去数据
    回复 有任何疑惑可以回复我~ 2017-12-06 12:51:25
  • 提问者 十里桃花舞丶 #3
    老师,我发现问题是出在程序连接到zk之后,zk返回hbase的注册地址,返回的是127.0.0.1,然后程序就在本地找hbase,找不到就会连接超时异常。这个应该怎么解决呀?
    回复 有任何疑惑可以回复我~ 2017-12-06 21:05:38
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信