参加《21天晋级大数据实战营》——DAY7云上玩转KV存储实验小结
1、创建表格存储集群
点击购买即可。等待一段时间,集群生成:
注:安全组建议放行所有端口,以便测试。
2、准备ecs
注意:建议选的安全组跟表格存储集群一样。
3、HBase Shell访问集群
执行
curl -O -k "http://cloudtable-publish.obs.myhwclouds.com/quick_start_hbase_shell.sh"
获得集群地址
ZK:
cloudtable-richblue88-zk1-Op5s31N0.cloudtable.com:2181,cloudtable-richblue88-zk2-NjXOqtVT.cloudtable.com:2181,cloudtable-richblue88-zk3-cToI8pSr.cloudtable.com:2181
部署客户端
source quick_start_hbase_shell.sh cloudtable-richblue88-zk1-Op5s31N0.cloudtable.com:2181,cloudtable-richblue88-zk2-NjXOqtVT.cloudtable.com:2181,cloudtable-richblue88-zk3-cToI8pSr.cloudtable.com:2181
4、HBase命令
help
创建表
create 'cloudtable','cf'
查询表
list 'cloudtable'
插入记录
put 'cloudtable','row1','cf:a','value1'
扫描记录
scan 'cloudtable'
查询单条记录
get 'cloudtable','row1'
禁用表
disable 'cloudtable'
使能表
enable 'cloudtable'
删除表
disable 'cloudtable'
drop 'cloudtable'
退出
quit
5、GeoMesa命令
切换目录
cd geomesa-hbase_2.11-1.3.4/
查看classpath
bin/geomesa-hbase classpath
创建表
bin/geomesa-hbase create-schema -c geomesa -f test -s Who:String,What:java.lang.Long,When:Date,*Where:Point:srid=4326,Why:String
描述表
批量导入数据:
创建data目录
AAA,red,113.918417,22.505892,2017-04-09 18:03:46
BBB,white,113.960719,22.556511,2017-04-24 07:38:47
CCC,blue,114.088333,22.637222,2017-04-23 15:07:54
DDD,yellow,114.195456,22.596103,2017-04-21 21:27:06
EEE,black,113.897614,22.551331,2017-04-09 09:34:48
conf下,创建myschema.sft文件
geomesa.sfts.cars = {
attributes = [
{ name = "carid", type = "String", index = true }
{ name = "color", type = "String", index = false }
{ name = "time", type = "Date", index = false }
{ name = "geom", type = "Point", index = true,srid = 4326,default = true }
]
}
conf下创建myconvertor.convert文件
geomesa.converters.cars= {
type = "delimited-text",
format = "CSV",
id-field = "$fid",
fields = [
{ name = "fid", transform = "concat($1,$5)" }
{ name = "carid", transform = "$1::string" }
{ name = "color", transform = "$2::string" }
{ name = "lon", transform = "$3::double" }
{ name = "lat", transform = "$4::double" }
{ name = "geom", transform = "point($lon,$lat)" }
{ name = "time", transform = "date('YYYY-MM-dd HH:mm:ss',$5)" }
]
}
执行命令导入
bin/geomesa-hbase ingest -c geomesa -C conf/myconvertor.convert -s conf/myschema.sft data/data.csv
解释查询
bin/geomesa-hbase explain -c geomesa -f cars -q "carid = 'BBB'"
统计分析
bin/geomesa-hbase stats-analyze -c geomesa -f cars
bin/geomesa-hbase stats-bounds -c geomesa -f cars
bin/geomesa-hbase stats-count -c geomesa -f cars
bin/geomesa-hbase stats-histogram -c geomesa -f cars
选择1
bin/geomesa-hbase stats-top-k -c geomesa -f cars
导出feature
bin/geomesa-hbase export -c geomesa -f cars -q "carid = 'BBB'"
删除feature
bin/geomesa-hbase delete-features -c geomesa -f cars -q "carid = 'BBB'"
获取目录中的全部表的名称
bin/geomesa-hbase get-type-names -c geomesa
删除表
bin/geomesa-hbase remove-schema -c geomesa -f test
bin/geomesa-hbase remove-schema -c geomesa -f cars
删除目录
bin/geomesa-hbase delete-catalog -c geomesa
- 点赞
- 收藏
- 关注作者
评论(0)