====== hbase ======
* [[Hadoop]]
* [[hdfs]]
* [[https://hbase.apache.org/book.html|Apache HBase Reference Guide]]
* [[https://wiki.apache.org/hadoop/Hbase/Shell|hbase shell commands]]
* [[https://learnhbase.wordpress.com/2013/03/02/hbase-shell-commands/|Learn HBase: shell commands]]
Start REST server:
hbase-daemon.sh start rest
==== hbase shell ====
To script stuff through hbase shell, there are two ways. One is to pipe things directly:
echo list | hbase shell
And the other is to write a script:
echo list > test_script
hbase shell test_script
To save history, add this to ''.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
** Display status: **
echo status | hbase shell
5 servers, 0 dead, 2365.2000 average load
** List tables: **
echo list | hbase shell
** Describe the table: **
echo "describe 'table'" | hbase shell
==== hbase backups ====
** Exporting a table **
From the docs: "Export is a utility that will dump the contents of table to HDFS in a sequence file." [[http://hbase.apache.org/book.html#_export|Source]]
hbase org.apache.hadoop.hbase.mapreduce.Export [ [ []]]
For example, exporting table ''table_name'':
hbase org.apache.hadoop.hbase.mapreduce.Export table_name /tmp/table_name
** Importing a table: **
From the docs: "Import is a utility that will load data that has been exported back into HBase." [[http://hbase.apache.org/book.html#_import|Source]]
hbase -Dhbase.import.version=0.94 org.apache.hadoop.hbase.mapreduce.Import
==== TTL ====
Changing TTL: "ColumnFamilies can set a TTL length in seconds, and HBase will automatically delete rows once the expiration time is reached. This applies to //all// versions of a row - even the current one. The TTL time encoded in the HBase for the row is specified in UTC." [[https://hbase.apache.org/book.html#ttl|Source]]
Change the TTL (time-to-live), and compact the data, which will erase anything older than that, in this case, one week:
alter 'table', { TTL => 604800 }
major_compact 'table'