启动HBase,要确认已启动Hadoop集群,Zookeeper
[root@node5 hadoop-2.5.1]# start-hbase.sh
进入Hbase
[root@node5 ~]# hbase shell
显示Hbase中的表
hbase(main):001:0> list
创建表方式一:
hbase(main):002:0> create 'user','info','data'
创建表方式二:
create 'user',{NAME => 'info',VERSIONS => '3'}
hbase(main):009:0> list
hbase(main):011:0> create 'm_user', {NAME => 'info', VERSIONS => '3'},{NAME => 'data', VERSIONS => '3'}
hbase(main):015:0> put 'user','rk0001','info:name','matrix'
hbase(main):016:0> put 'user','rk0001','info:gender','female'
hbase(main):017:0> put 'user','rk0001','info:age',20
hbase(main):019:0> put 'user','rk0001','data:pic','picture'
hbase(main):022:0> get 'user','rk0001'
hbase(main):023:0> get 'user','rk0001','info'
hbase(main):024:0> get 'user','rk0001','info:name','info:gender','info:age'
hbase(main):025:0> get 'user','rk0001','info','data'
hbase(main):027:0> get 'user','rk0001',{COLUMN => ['info','data']}
hbase(main):029:0> get 'user','rk0001',{COLUMN => ['info:name','data:pic']}
hbase(main):030:0> get 'user','rk0001',{COLUMN => 'info' ,VERSION => 2}
hbase(main):031:0> get 'user','rk0001',{COLUMN => 'info:name',VERSION => 5}
hbase(main):032:0> scan 'user'
hbase(main):033:0> scan 'user', {COLUMNS => 'info'}
hbase(main):033:0> scan 'user', {COLUMNS => 'info'}
hbase(main):034:0> scan 'user', {COLUMNS => 'info', RAW => true, VERSIONS => 5}
hbase(main):035:0> scan 'user', {COLUMNS => ['info', 'data']}
hbase(main):036:0> scan 'user', {COLUMNS => ['info:name', 'data:pic']}
hbase(main):037:0> scan 'user', {COLUMNS => 'info:name'}
hbase(main):038:0> scan 'user', {COLUMNS => 'info:name', VERSIONS => 5}
hbase(main):041:0> scan 'user', {COLUMNS => ['info', 'data'], FILTER => "(QualifierFilter(=,'substring:a'))"}
hbase(main):050:0> scan 'user', {COLUMNS => 'info', STARTROW => 'rk0001', ENDROW => 'rk0003'}
hbase(main):051:0> scan 'user',{FILTER=>"PrefixFilter('rk')"}
hbase(main):056:0* scan 'user', {TIMERANGE => [1458441570629, 1458441753608]}
hbase(main):057:0> delete 'user', 'rk0001', 'info:name'
hbase(main):059:0> delete 'user', 'rk0001', 'data:pic', 1458441753608
hbase(main):060:0> truncate 'user'
hbase(main):061:0> disable 'user'
hbase(main):062:0> alter 'user', NAME => 'f1'
hbase(main):063:0> alter 'user', NAME => 'f2'
hbase(main):064:0> enable 'user'
hbase(main):066:0> desc 'user'
alter ‘user’, NAME => ‘f1’, METHOD => ‘delete’ 或 alter ‘user’, ‘delete’ => ‘f1’
hbase(main):067:0> alter 'user', NAME => 'f1', METHOD => 'delete'
hbase(main):070:0> alter 'user', {NAME => 'f1'}, {NAME => 'f2', METHOD => 'delete'}
hbase(main):071:0> alter 'user', 'delete' => 'f1'
hbase(main):073:0> alter 'user', NAME => 'info', VERSIONS => 5
hbase(main):074:0> disable 'user'
hbase(main):075:0> drop 'user'
ERROR: java.util.concurrent.ExecutionException: org.apache.hadoop.ipc.RemoteException(java.io.IOException): File /hbase/.tmp/data/default/user/c5d0c0ae3199462216dbf4642987f4d5/.regioninfo could only be replicated to 0 nodes instead of minReplication (=1). There are 3 datanode(s) running and no node(s) are excluded in this operation.
ERROR: Can't get master address from ZooKeeper; znode data == null
重新格式化namenode。。。。