一、快照機(jī)制snapshots
創(chuàng)新互聯(lián)專注于企業(yè)成都營(yíng)銷網(wǎng)站建設(shè)、網(wǎng)站重做改版、富錦網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、H5頁(yè)面制作、商城網(wǎng)站定制開發(fā)、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)網(wǎng)站制作、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁(yè)設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為富錦等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。
簡(jiǎn)單在hbase上做個(gè)表做測(cè)試:
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
創(chuàng)建這個(gè)表的快照:
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 這應(yīng)該就是快照的數(shù)據(jù)文件;
刪除student表兩行,模擬數(shù)據(jù)文件損壞;
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
=> []
用快照恢復(fù)表:
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
注: 快照只是保存著快照時(shí)hbase表那一刻的數(shù)據(jù),至于快照以后的增量的數(shù)據(jù),快照是 不支持的;
二、導(dǎo)出表Export
HBase的表導(dǎo)出工具是一個(gè)內(nèi)置的功能,它使數(shù)據(jù)很容易從hbase導(dǎo)入hdfs目錄下的sequencefiles文件,它創(chuàng)造了一個(gè)Map reduce任務(wù),通過(guò)一系列的hbase api來(lái)調(diào)用集群,獲取指定的表格的每一行數(shù)據(jù),并將數(shù)據(jù)寫入指定 的HDFS目錄中;
........
三、拷貝表copytable
HBase的表拷貝工具和導(dǎo)出工具差不多,拷貝表也hbase api創(chuàng)建map reduce任務(wù),從源數(shù)據(jù)讀取數(shù)據(jù),不同的是拷貝的輸出是hbase 的另一個(gè)表;這個(gè)表可在本地集群,也可在遠(yuǎn)程集群;