您好,登錄后才能下訂單哦!
一、快照機制snapshots
簡單在hbase上做個表做測試:
hbase(main):044:0> scan 'student'
ROW COLUMN+CELL
num1 column=shuxing:name, timestamp=1412189531346, value=jaybing
num2 column=shuxing:name, timestamp=1412189623682, value=jaychou
num3 column=shuxing:like, timestamp=1412189669404, value=game
3 row(s) in 0.0260 seconds
創建這個表的快照:
hbase(main):045:0> snapshot 'student','snapshot_student'
0 row(s) in 1.2620 seconds
[root@nn ~]# hadoop fs -ls /tmpdir/
Found 9 items
drwxr-xr-x - root supergroup 0 2014-10-02 02:58 /tmpdir/.hbase-snapshot
drwxr-xr-x - root supergroup 0 2014-10-01 21:48 /tmpdir/.tmp
drwxr-xr-x - root supergroup 0 2014-10-01 21:37 /tmpdir/WALs
drwxr-xr-x - root supergroup 0 2014-10-02 02:42 /tmpdir/archive
drwxr-xr-x - root supergroup 0 2014-09-28 00:42 /tmpdir/corrupt
drwxr-xr-x - root supergroup 0 2014-09-26 11:20 /tmpdir/data
-rw-r--r-- 2 root supergroup 42 2014-09-26 11:20 /tmpdir/hbase.id
-rw-r--r-- 2 root supergroup 7 2014-09-26 11:20 /tmpdir/hbase.version
drwxr-xr-x - root supergroup 0 2014-10-02 02:48 /tmpdir/oldWALs
[root@nn ~]# hadoop fs -ls /tmpdir/.hbase-snapshot
Found 2 items
drwxr-xr-x - root supergroup 0 2014-10-02 02:58 /tmpdir/.hbase-snapshot/.tmp
drwxr-xr-x - root supergroup 0 2014-10-02 02:58 /tmpdir/.hbase-snapshot/snapshot_student 這應該就是快照的數據文件;
刪除student表兩行,模擬數據文件損壞;
hbase(main):061:0> disable 'student'
0 row(s) in 2.0310 seconds
hbase(main):062:0> is_
is_a? is_disabled is_enabled
hbase(main):062:0> is_enabled 'student'
false
0 row(s) in 0.0800 seconds
hbase(main):063:0> drop
drop drop_all drop_namespace
hbase(main):063:0> drop 'student'
0 row(s) in 0.1940 seconds
hbase(main):064:0> list
TABLE
0 row(s) in 0.0200 seconds
=> []
用快照恢復表:
hbase(main):070:0> restore_snapshot 'snapshot_student'
0 row(s) in 6.4950 seconds
hbase(main):071:0> scan 'student'
ROW COLUMN+CELL
num1 column=shuxing:name, timestamp=1412189531346, value=jaybing
num2 column=shuxing:name, timestamp=1412189623682, value=jaychou
num3 column=shuxing:like, timestamp=1412189669404, value=game
3 row(s) in 0.2190 seconds
注: 快照只是保存著快照時hbase表那一刻的數據,至于快照以后的增量的數據,快照是 不支持的;
二、導出表Export
HBase的表導出工具是一個內置的功能,它使數據很容易從hbase導入hdfs目錄下的sequencefiles文件,它創造了一個Map reduce任務,通過一系列的hbase api來調用集群,獲取指定的表格的每一行數據,并將數據寫入指定 的HDFS目錄中;
........
三、拷貝表copytable
HBase的表拷貝工具和導出工具差不多,拷貝表也hbase api創建map reduce任務,從源數據讀取數據,不同的是拷貝的輸出是hbase 的另一個表;這個表可在本地集群,也可在遠程集群;
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。