Hbase基础操作

hbase查询操作: 登陆: hbase shell

创建表: create_namespace 'ecitem' create "ecitem:ShoppingCart", {NAME =>'i',COMPRESSION =>'GZ', VERSIONS => 1, BLOCKCACHE => true, IN_MEMORY=>false}

插入数据: put 'ecitem:ShoppingCart','0032d16e0707a879a2729d85fb7c861983eebed8934c358341f7bb7295489195|USA','i:O','value01'

查看表所有数据: scan 'ecitem:ShoppingCart'

根据rowkey查询数据
格式:get 'ecitem:ShoppingCart','rowkey' get 'ecitem:ShoppingCart','0032d16e0707a879a2729d85fb7c861983eebed8934c358341f7bb7295489195|USA'

根据rowkey查询数据后查询指定字段
格式:get 'ecitem:ShoppingCart','rowkey','i:column' get 'ecitem:ShoppingCart','0032d16e0707a879a2729d85fb7c861983eebed8934c358341f7bb7295489195|USA','i:O'

删除数据 delete 'ecitem:ShoppingCart','0032d16e0707a879a2729d85fb7c861983eebed8934c358341f7bb7295489195|USA','i:O'

删除行 deleteall 'ecitem:ShoppingCart','0032d16e0707a879a2729d85fb7c861983eebed8934c358341f7bb7295489195|USA'

删除所有数据 truncate 'ecitem:ShoppingCart'

hbase 删除数据: rm /tmp/hbase-root/ -rf bin/hbase-cleanup.sh --cleanAll bin/zookeepers.sh clear

cdh下载地址: http://archive.cloudera.com/cdh5/cdh/5/

hbase 部署

export HBASE_HOME=/opt/hbase/hbase-1.0.0-cdh5.4.9 export PATH=$HBASE_HOME/bin:$PATH

export JAVA_HOME=/opt/java/jdk1.8.0_121

 hbase.rootdir <value>hdfs://DDD-WORK1:9000/hbasevalue>   hbase.cluster.distributed <value>truevalue>   hbase.zookeeper.quorum <value>DDD-WORK1,DDD-WORK2,DDD-WORK3value>   zookeeper.session.timeout <value>60000value>   hbase.zookeeper.property.clientPort <value>2181value>   hbase.zookeeper.property.dataDir <value>/opt/zookeeper/zookeeper-3.3.6/datavalue> 
scp -r hbase/ DDD-WORK1@10.126.34.43:/opt/hbase

regionservers
DDD-WORK2 DDD-WORK3

--zookeeper略

create_namespace "yeahmobi" create "yeahmobi:archive", {NAME =>'i',COMPRESSION =>'GZ', VERSIONS => 1, BLOCKCACHE => true, IN_MEMORY=>false} put 'yeahmobi:archive', 'scutshuxue', 'i:age', '24' CREATE EXTERNAL TABLE test(key string, value string) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,i:age") TBLPROPERTIES ("hbase.table.name" = "yeahmobi:archive");

你可能感兴趣的:(Hadoop大数据技术)