在HBase中恢复 [英] Recovery in HBase

查看:130
本文介绍了在HBase中恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HBase支持单行原子事务。

用于实际检查。我写了下面的代码:

  Increment inc = new Increment(); //写入WAL 
inc .getWritetoWAL();
Put p = new Put(Bytes.toBytes(name10));
p.add(Bytes.toBytes(cf),Bytes.toBytes(name),Bytes.toBytes(Some Value 10));
table.setAutoFlush(false);
table.put(p);
table.close();

检查恢复,我在执行(在eclipse中调试)后立即停止了hbase, table.put(p)当我重新启动hbase时,表中没有更新新行。根据HBase中的文档,一旦写入memstore(缓存),它可以恢复,虽然崩溃发生,但在这里它不恢复,虽然WAL已启用.......
有没有在我的错误理解.......
提前为答复提供的答案.....

解决方案

什么与您的代码发生上面是客户端永远不会认沽提交到服务器,这样HBase的从未将其写入WAL不是可以恢复...



您有 table.setAutoFlush(false)放在put上方的行中。如果您查看文档,则表示:




在进行了大量看跌期权,确保setAutoFlush设置为
错在你HTable实例。否则,看跌期权将在$ b发送一个$ Ba时间到RegionServer。通过htable.add(put)和
htable.add(Put)添加到相同的写入缓冲区中。如果autoFlush
= false,则不会发送这些消息,直到写入缓冲器被填充。为了明确地刷新消息,呼叫flushCommits。调用close上
中的HTable实例将调用flushCommits。




因此,虽然通常将AutoFlush设置为false在这种情况下很好,但它意味着put不会发送到服务器。

HBase supports single row atomic transaction.
For checking that practically. I had written the following code

    Increment inc=new Increment();//For writing it to WAL
    inc.getWritetoWAL(); 
    Put p = new Put(Bytes.toBytes("name10"));
    p.add(Bytes.toBytes("cf"), Bytes.toBytes("name"),Bytes.toBytes("Some Value 10"));
    table.setAutoFlush(false);
    table.put(p);
    table.close();

To Check the recovery i had stopped the hbase immediately after executing(debugging in eclipse) the table.put(p) when i restarted the hbase the new row is not updated in the table. As per the documentation in HBase once it has written into memstore(cache) it can be recovered although crash happens but here it's not recovering although WAL has been enabled.....
Is there any wrong in my understanding.....
Thanx in advance for the replies.....

解决方案

What happens with your code above is that the client never gets to submit the put to the server so HBase never writes it to the WAL not it can recover...

You have table.setAutoFlush(false) in the line above the put. If you check out the documentation it says:

"When performing a lot of Puts, make sure that setAutoFlush is set to false on your HTable instance. Otherwise, the Puts will be sent one at a time to the RegionServer. Puts added via htable.add(Put) and htable.add( Put) wind up in the same write buffer. If autoFlush = false, these messages are not sent until the write-buffer is filled. To explicitly flush the messages, call flushCommits. Calling close on the HTable instance will invoke flushCommits."

So while normally setting AutoFlush to false is good in this case it means the put isn't sent to the server yet.

这篇关于在HBase中恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆