Differences

This shows you the differences between two versions of the page.


hbase [2016/07/01 18:35] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +====== 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:
 +
 +<code>
 +hbase-daemon.sh start rest
 +</code>
 +
 +==== hbase shell ====
 +
 +To script stuff through hbase shell, there are two ways. One is to pipe things directly:
 +
 +<code>
 +echo list | hbase shell
 +</code>
 +
 +And the other is to write a script:
 +
 +<code>
 +echo list > test_script
 +hbase shell test_script
 +</code>
 +
 +To save history, add this to ''.irbrc'':
 +
 +<code>
 +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
 +</code>
 +
 +** Display status: **
 +
 +<code>
 +echo status | hbase shell
 +5 servers, 0 dead, 2365.2000 average load
 +</code>
 +
 +** List tables: **
 +
 +<code>
 +echo list | hbase shell
 +</code>
 +
 +** Describe the table: **
 +
 +<code>
 +echo "describe 'table'" | hbase shell
 +</code>
 +
 +==== 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]]
 +
 +<code>
 +hbase org.apache.hadoop.hbase.mapreduce.Export <tablename> <outputdir> [<versions> [<starttime> [<endtime>]]]
 +</code>
 +
 +For example, exporting table ''table_name'':
 +
 +<code>
 +hbase org.apache.hadoop.hbase.mapreduce.Export table_name /tmp/table_name
 +</code>
 +
 +** 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]]
 +
 +<code>
 +hbase -Dhbase.import.version=0.94 org.apache.hadoop.hbase.mapreduce.Import <tablename> <inputdir>
 +</code>
 +
 +==== 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:
 +
 +<code>
 +alter 'table', { TTL => 604800 }
 +major_compact 'table'
 +</code>

Navigation
QR Code
QR Code hbase (generated for current page)