目标
快速搭建起 GeoMesa HBase 环境,跑通官方示例程序。
步骤清单
- 搭建 HBASE 环境
- 部署 GeoMesa HBase
- 测试,下载官方示例程序,编译、运行
1. 搭建 HBASE 环境
可以搭建单机环境,参考 https://www.jianshu.com/p/bde9586fb8f0
(我当前安装的是 hbase-1.4.10)
2. 部署 GeoMesa HBase
2.1 下载
https://github.com/locationtech/geomesa/releases
(我当前选择的是 geomesa-hbase_2.11-2.3.0-bin.tar.gz)
2.2 配置环境变量
export HBASE_HOME=/Users/duy/tools/hbase-1.4.10
export PATH=$PATH:$HBASE_HOME/bin
export GEOMESA_HBASE_HOME=/Users/duy/tools/geomesa-hbase_2.11-2.3.0
export PATH=$PATH:$GEOMESA_HBASE_HOME/bin
2.3 安装所需的 jar
在 GEOMESA_HBASE_HOME 目录下执行:
$ bin/install-jai.sh
$ bin/install-jline.sh
${GEOMESA_HBASE_HOME}/dist/hbase/geomesa-hbase-distributed-runtime_xxx.jar
拷贝到${HBase_HOME}/lib
目录下。
2.4 注册 Coprocessors
hbase-site.xml 中添加:
<property>
<name>hbase.coprocessor.user.region.classes</name>
<value>org.locationtech.geomesa.hbase.coprocessor.GeoMesaCoprocessor</value>
</property>
2.5 初始化
bin/geomesa-hbase configure
3. 测试
3.1 下载示例程序
https://github.com/geomesa/geomesa-tutorials/releases
(我当前选择的是 geomesa-tutorials-2.3.0)
3.2 编译
$ mvn clean install -pl geomesa-tutorials-hbase/geomesa-tutorials-hbase-quickstart -am
3.3 运行
$ java -cp geomesa-tutorials-hbase/geomesa-tutorials-hbase-quickstart/target/geomesa-tutorials-hbase-quickstart-$VERSION.jar \
org.geomesa.example.hbase.HBaseQuickStart \
--hbase.zookeepers <zookeepers> \
--hbase.catalog <table>
$VERSION
替换为自己的版本,
<zookeepers>
指定 HBase Zookeeper,如果是单机模式,就写 localhost。
<table>
需要写一个不存在的表名,或者空表的表名。
执行结果:
Loading datastore
Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Creating schema: GLOBALEVENTID:String,Actor1Name:String,Actor1CountryCode:String,Actor2Name:String,Actor2CountryCode:String,EventCode:String,NumMentions:Integer,NumSources:Integer,NumArticles:Integer,ActionGeo_Type:Integer,ActionGeo_FullName:String,ActionGeo_CountryCode:String,dtg:Date,geom:Point:srid=4326
Generating test data
Writing test data
Wrote 2356 features
Running query BBOX(geom, -120.0,30.0,-75.0,55.0) AND dtg DURING 2017-12-31T00:00:00+00:00/2018-01-02T00:00:00+00:00
01 719026370=719026370|MEXICO|MEX|UNITED STATES|USA|193|4|1|4|3|Imperial Beach, California, United States|US|2018-01-01T00:00:00.000Z|POINT (-117.113 32.5839)
02 719025493=719025493|CIVILIAN||||013|5|1|5|3|San Diego, California, United States|US|2018-01-01T00:00:00.000Z|POINT (-117.157 32.7153)
03 719025402=719025402|POLICE||||112|5|1|5|3|Camp Pendleton, California, United States|US|2018-01-01T00:00:00.000Z|POINT (-117.393 33.2103)
04 719027018=719027018|UNITED STATES|USA|||190|2|1|2|3|Camp Pendleton, California, United States|US|2018-01-01T00:00:00.000Z|POINT (-117.393 33.2103)
05 719026757=719026757|RUSSIA|RUS|UKRANIAN||042|2|1|2|3|Irvine, California, United States|US|2018-01-01T00:00:00.000Z|POINT (-117.823 33.6695)
06 719027129=719027129|UNITED STATES|USA|ISRAELI|ISR|145|1|1|1|3|Irvine, California, United States|US|2018-01-01T00:00:00.000Z|POINT (-117.823 33.6695)
07 719027131=719027131|UNITED STATES|USA|ISRAEL|ISR|145|2|1|2|3|Irvine, California, United States|US|2018-01-01T00:00:00.000Z|POINT (-117.823 33.6695)
08 719026319=719026319|SENATOR||UNITED STATES|USA|051|2|1|2|2|Texas, United States|US|2018-01-01T00:00:00.000Z|POINT (-97.6475 31.106)
09 719027007=719027007|MASSACHUSETTS|USA|||172|7|1|4|2|Texas, United States|US|2018-01-01T00:00:00.000Z|POINT (-97.6475 31.106)
10 719027101=719027101|MICHIGAN|USA|UNIVERSITY||084|20|2|20|2|Texas, United States|US|2018-01-01T00:00:00.000Z|POINT (-97.6475 31.106)
Returned 669 total features
Running query BBOX(geom, -120.0,30.0,-75.0,55.0) AND dtg DURING 2017-12-31T00:00:00+00:00/2018-01-02T00:00:00+00:00
Returning attributes [GLOBALEVENTID, dtg, geom]
01 719025273=719025273|2018-01-01T00:00:00.000Z|POINT (-75.7 45.4167)
02 719025300=719025300|2018-01-01T00:00:00.000Z|POINT (-75.7 45.4167)
03 719025742=719025742|2018-01-01T00:00:00.000Z|POINT (-117.157 32.7153)
04 719025915=719025915|2018-01-01T00:00:00.000Z|POINT (-117.157 32.7153)
05 719025400=719025400|2018-01-01T00:00:00.000Z|POINT (-117.393 33.2103)
06 719025135=719025135|2018-01-01T00:00:00.000Z|POINT (-117.823 33.6695)
07 719026216=719026216|2018-01-01T00:00:00.000Z|POINT (-97.6475 31.106)
08 719026312=719026312|2018-01-01T00:00:00.000Z|POINT (-97.6475 31.106)
09 719026320=719026320|2018-01-01T00:00:00.000Z|POINT (-97.6475 31.106)
10 719026992=719026992|2018-01-01T00:00:00.000Z|POINT (-97.6475 31.106)
Returned 669 total features
Running query EventCode = '051'
01 719024909=719024909|||MELBOURNE|AUS|051|10|1|10|4|Melbourne, Victoria, Australia|AS|2018-01-01T00:00:00.000Z|POINT (144.967 -37.8167)
02 719025178=719025178|AUSTRALIA|AUS|COMMUNITY||051|20|2|20|4|Sydney, New South Wales, Australia|AS|2018-01-01T00:00:00.000Z|POINT (151.217 -33.8833)
03 719025965=719025965|MIDWIFE||||051|10|1|10|4|Sydney, New South Wales, Australia|AS|2018-01-01T00:00:00.000Z|POINT (151.217 -33.8833)
04 719025509=719025509|COMMUNITY||AUSTRALIA|AUS|051|2|1|2|1|Australia|AS|2018-01-01T00:00:00.000Z|POINT (135 -25)
05 719025742=719025742|KING||||051|22|3|22|3|San Diego, California, United States|US|2018-01-01T00:00:00.000Z|POINT (-117.157 32.7153)
06 719025745=719025745|KING||||051|4|2|4|2|California, United States|US|2018-01-01T00:00:00.000Z|POINT (-119.746 36.17)
07 719025743=719025743|AUTHORITIES||||051|60|12|60|3|Wichita, Kansas, United States|US|2018-01-01T00:00:00.000Z|POINT (-97.3375 37.6922)
08 719027205=719027205|UNITED STATES|USA|SIOUX||051|4|1|4|3|Sioux City, Iowa, United States|US|2018-01-01T00:00:00.000Z|POINT (-96.4003 42.5)
09 719025111=719025111|||UNITED STATES|USA|051|2|1|2|3|Pickens County, South Carolina, United States|US|2018-01-01T00:00:00.000Z|POINT (-82.7165 34.9168)
10 719026938=719026938|PITTSBURGH|USA|||051|5|1|5|3|York County, Pennsylvania, United States|US|2018-01-01T00:00:00.000Z|POINT (-77 40.1254)
Returned 138 total features
Running query EventCode = '051' AND dtg DURING 2017-12-31T00:00:00+00:00/2018-01-02T00:00:00+00:00
Returning attributes [GLOBALEVENTID, dtg, geom]
01 719025634=719025634|2018-01-01T00:00:00.000Z|POINT (178 -18)
02 719027116=719027116|2018-01-01T00:00:00.000Z|POINT (-117.157 32.7153)
03 719027117=719027117|2018-01-01T00:00:00.000Z|POINT (-119.746 36.17)
04 719025036=719025036|2018-01-01T00:00:00.000Z|POINT (-86.8073 32.799)
05 719026318=719026318|2018-01-01T00:00:00.000Z|POINT (-86.8073 32.799)
06 719026296=719026296|2018-01-01T00:00:00.000Z|POINT (-81.2793 33.4968)
07 719025744=719025744|2018-01-01T00:00:00.000Z|POINT (-77.0364 38.8951)
08 719026946=719026946|2018-01-01T00:00:00.000Z|POINT (-86.2604 39.8647)
09 719025279=719025279|2018-01-01T00:00:00.000Z|POINT (-80.1667 44.0833)
10 719027252=719027252|2018-01-01T00:00:00.000Z|POINT (-77.264 40.5773)
Returned 138 total features
Done