hbase操作(shellコマンド、例えばテーブルの作成、テーブルのクリア、削除、変更)およびhbaseテーブルのストレージ構造と原理

19614 ワード

2編のよい文章
http://www.cnblogs.com/nexiyi/p/hbase_shell.html
http://blog.csdn.net/u010967382/article/details/37878701?utm_source=tuicool&utm_medium=referral
  • hbase操作
  • hbase web操作
  • hbase shell基本操作
  • 1建表
  • 具体命令
  • 2表を作成した後、表describe
  • を表示します.
  • 3テーブルtruncate lmj_をクリアtest
  • 4削除テーブル
  • 5表構造を修正するdisable後enable
  • 6表に記録する操作4行に対する操作
  • 7テーブル操作権限
  • 8ネーミングスペース


  • hbaseの原理とタイムスタンプ管理の紹介
  • hbaseテーブル


  • hbase操作
    hbase web操作
         http://hmaster:60010
    hmaster ip   $HBASE_HOME/conf/hbase-site.xml 
    ip      
         env/hosts   
         windows    C:\Windows\System32\drivers\etc    hosts     )
    

    hbase shell基本操作:
    hbase shell   hbase console  
    whoami    
    help        
    help command       
    list      
    status            
    version     
    exits '   '      
    
    hbase shell     ctrl + backspace(        )
    

    1)建設表
          :create , {NAME => , VERSIONS => }
     
      
        hbase(main):004:0> exists 'test'
        hbase(main):005:0> create 'test','cf'
    
        hbase> create 't1', {NAME => 'f1', VERSIONS => 5}
        hbase> create 't1', {NAME => 'f1'}, {NAME => 'f2'}, {NAME => 'f3'}
                
        hbase> create 't1', 'f1', 'f2', 'f3'
                
        hbase> create 't1', {NAME => 'f1', VERSIONS => 1, TTL => 2592000, BLOCKCACHE => true}
        hbase> create 't1', 'f1', {SPLITS => ['10', '20', '30', '40']}
        hbase> create 't1', 'f1', {SPLITS_FILE => 'splits.txt'}
        hbase> # Optionally pre-split the table into NUMREGIONS, using
        hbase> # SPLITALGO ("HexStringSplit", "UniformSplit" or classname)
        hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit'}
              ,        。
        create 'lmj_test',
            {NAME => 'adn', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROWCOL', REPLICATION_SCOPE => '0', COMPRESSION => 'SNAPPY', VERSIONS => '1', TTL => '15768000', MIN_VERSIONS => '0', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', ENCODE_ON_DISK => 'true', IN_MEMORY => 'false', BLOCKCACHE => 'false'}, 
            {NAME => 'fixeddim', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROWCOL', REPLICATION_SCOPE => '0', COMPRESSION => 'SNAPPY', VERSIONS => '1', TTL => '15768000', MIN_VERSIONS => '0', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', ENCODE_ON_DISK => 'true', IN_MEMORY => 'false', BLOCKCACHE => 'false'}, 
            {NAME => 'social', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROWCOL', REPLICATION_SCOPE => '0', COMPRESSION => 'SNAPPY', VERSIONS => '1', TTL => '15768000', MIN_VERSIONS => '0', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', ENCODE_ON_DISK => 'true', IN_MEMORY => 'false', BLOCKCACHE => 'false'}
                    ,                
         create 'lmj_test',
            {NAME => 'adn', BLOOMFILTER => 'ROWCOL', VERSIONS => '1', TTL => '15768000', MIN_VERSIONS => '0', COMPRESSION => 'SNAPPY', BLOCKCACHE => 'false'},
            {NAME => 'fixeddim',BLOOMFILTER => 'ROWCOL', VERSIONS => '1', TTL => '15768000', MIN_VERSIONS => '0', COMPRESSION => 'SNAPPY', BLOCKCACHE => 'false'},
            {NAME => 'social',BLOOMFILTER => 'ROWCOL', VERSIONS => '1', TTL => '15768000', MIN_VERSIONS => '0',COMPRESSION => 'SNAPPY', BLOCKCACHE => 'false'}
    

    2) の の :describe
          
        {NAME => 'lmj_test', 
        FAMILIES => 
        [
        {NAME => 'adn', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROWCOL', REPLICATION_SCOPE => '0', COMPRESSION => 'SNAPPY', VERSIONS => '1', TTL => '15768000', MIN_VERSIONS => '0', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', ENCODE_ON_DISK => 'true', IN_MEMORY => 'false', BLOCKCACHE => 'false'}, 
                    {NAME => 'fixeddim', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROWCOL', REPLICATION_SCOPE => '0', COMPRESSION => 'SNAPPY', VERSIONS => '1', TTL => '15768000', MIN_VERSIONS => '0', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', ENCODE_ON_DISK => 'true', IN_MEMORY => 'false', BLOCKCACHE => 'false'}, 
                    {NAME => 'social', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROWCOL', REPLICATION_SCOPE => '0', COMPRESSION => 'SNAPPY', VERSIONS => '1', TTL => '15768000', MIN_VERSIONS => '0', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', ENCODE_ON_DISK => 'true', IN_MEMORY => 'false', BLOCKCACHE => 'false'}
                ]
            }
    
    )テーブルを にする:truncate'lmj_test’4) :
               ,  disable 'lmj_test',  drop 'lmj_test'
    
    ) の :まずdisable enable
            alter 't1', {NAME => 'f1'}, {NAME => 'f2', METHOD => 'delete'}
              :   test1 cf TTL 180 
                hbase(main)> disable 'test1'
                hbase(main)> alter 'test1',{NAME=>'body',TTL=>'15552000'},{NAME=>'meta', TTL=>'15552000'}
                hbase(main)> enable 'test1'
    
    6) に された (4 )
        put     
              :put 
    ,,,, ,timestamp , , put 't1', 'r1', 'c1', 'value', ts1 put 'lmj_test','00001','adn:adn_3','aaa',1432483200000 put 'lmj_test','00001','fixeddim:appcategory_1','1',1432483200000 put 'lmj_test','00001','fixeddim:interest_15','100',1432483200000 get ( 、 、 、 ) get 'lmj_test','000000104257464',{TIMESTAMP=>1432483200000} delete : delete , , , ( , ) delete 'lmj_test','000000104257464','f1:col1' ( ): deleteall , , , deleteall 'lmj_test','000000104257464' scan , , scan 'lxw_hbase', {LIMIT => 1} 4 org.apache.hadoop.hbase.client , API count count 'lxw_hbase', {INTERVAL => 100, CACHE => 500} # 100 , 500

    7)

                      , RWXCA  ,  READ, WRITE, EXEC, CREATE, ADMIN
        grant 'liu_mja','RW','lxw_hbase'    #     liu_mja lxw_hbase     
                
            user_permission 'lxw_hbase'
            
            revoke 'liu_mja','lxw_hbase'
    

    8)

                ,    namespace       ,            。
            :
        (http://blog.csdn.net/u010967382/article/details/37878701?utm_source=tuicool&utm_medium=referral)
    
        hbase             ,                      :
                ( Quota Management (HBASE-8410)):    namespace       ,    region table ; 
                    ( Namespace Security Administration (HBASE-9206)):                ; 
            Region    (Region server groups (HBASE-6721)):          ,         regionservers ,          。 
    
                 、  、  。
                   ,    ::
    #Create a namespace create_namespace 'my_ns' #create my_table in my_ns namespace create 'my_ns:my_table', 'fam' #drop namespace drop_namespace 'my_ns' #alter namespace alter_namespace 'my_ns', {METHOD => 'set', 'PROPERTY_NAME' => 'PROPERTY_VALUE'} : hbase , hbase default #namespace=default and table qualifier=bar create 'bar', 'fam' #namespace=foo and table qualifier=bar create 'foo:bar', 'fam'

    hbase


    hdfs
    MR
    zookeeper

    hbase

          
        、 ,     (family)
    


    hbase  (shell   ,   ,   ,    )   hbase        _ 1
    key1,key2,key3 row key ,
    column-family1,column-family2,column-family3
    , column-family1 column1 column2

      row      region  
       column      , row    ,  row   columns put  delete         (            put  delete)
       Row key column key(HBase    qualifier) bytes  ,      key  long integer  ,     java.util.Date.getTime()  System.currentTimeMillis()        key。
            cell  : row key1、column-family1、column1    ,      t  ,              t1:abc,t2:gdxdf
         cell          , timestamp  ,    ,         ,     
    
     (1) Row Key:nosql         ,  hbase         (       ),       (      64KB)。       ,              。
             :int         1,10,100,118,11,12,128,15,16。   int      ,          0(   0)。
    
     (2)     column family: schema    (    ),         。        ,
      create 'test','cf'
        put 'test','001','cf:c1','a1',1432483200000
        put 'test','002','cf:c2','a2'
        put 'test','001','cf2:c1','a1',1432483200000      ERROR: Unknown column family! Valid column names: cf:*
    
     (3) cell:    ,        
     (4)      timestamp  (          )
           cell          , timestamp  ,    (        ,        )。        64    。         ,       。                   。
                 ,        。         ,   GC(    )
                           ,        
    1, version       。        ,
        Column Family   HColumnDescriptor.setMaxVersions(int versions)  ,  Column Family  ,       ,      ,           major compact     。   1     
    2,TTL(Time To Live)      。  TTL   ,   forever。
       HColumnDescriptor.setTimeToLive(int seconds)    TTL。    Get/Scan      ,        major compact。  row   cell TTL   ,     ,HBase         ,  cell     ,    。
    

    ,version ,major compact , ,

    put
    currentTimeMillis。 timestamp, long integer ,
    get timestamp
    delete
    1. timestamp
    ( timestamp row , , , major compact )
    2. timstamp