保存历史记录目前可以在普通的 irb (jruby) shell 上运行。但由于某种原因,它在使用 hbase shell 时不起作用。
我过去曾见过其他机器上的 hbase shell 的历史记录,遵循与现在描述的相同的过程,并且它们确实有效,所以不确定这次我可能错过了哪些小细节。
我在 ~/.irbrc 中放入了以下内容:
$ cat  ~/.irbrc
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
启动irb时需要吗?是的..
hbase(main):001:0>   puts IRB.conf[:HISTORY_FILE]
/home/stephenb/.irb-save-history
:AT_EXIT=>[#<Proc:0x6bb5eba4@/shared/jruby-1.7.3/lib/ruby/1.9/irb/ext/save-history.rb:67
这个 jruby 脚本存在吗?是的 ..
$ ll /shared/jruby-1.7.3/lib/ruby/1.9/irb/ext/save-history.rb
-rw-r--r-- 1 stephenb stephenb 2119 Feb 21 07:53 /shared/jruby-1.7.3/lib/ruby/1.9/irb/ext/save-history.rb
hbase shell 历史记录有效吗?嗯,不适用于 HBASE 命令。但它确实显示了之前 IRB 会话中的内容(非 HBASE)
$ date
Mon Jun  3 12:28:41 PDT 2013
stephenb@gondolin:/shared/git2/etl/appminer/hive$ hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.92.2, r1379292, Fri Aug 31 13:13:53 UTC 2012
hbase(main):001:0> describe 'app'
DESCRIPTION                                                                              ENABLED                                         
 {NAME => 'app', FAMILIES => [{NAME => 'm', BLOOMFILTER => 'NONE', REPLICATION_SCOPE =>  true                                            
 '0', VERSIONS => '3', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647',                                                  
 BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}]}                                                                     
1 row(s) in 0.4500 seconds
hbase(main):002:0> quit
$ ll /home/stephenb/.irb-save-history
-rw-rw-r-- 1 stephenb stephenb 73 Jun  3 12:05 /home/stephenb/.irb-save-history
从调用“hbase shell”之前的“日期”以及之后历史文件的修改日期可以看出,历史文件没有更新。
我遇到了同样的问题。经过一番谷歌搜索后,我发现了这篇文章:http://www.nosql.se/page/2/,它提供了一个解决方案。.irbrc 文件必须如下所示:
# cat .irbrc
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history"
Kernel.at_exit do
    IRB.conf[:AT_EXIT].each do |i|
        i.call
    end
end
我不能说为什么(我不想学习 Ruby),但它确实有效。希望能帮助到你。