安装GeoMesa HBase小记-最终版

本人前几天安装GeoMesa HBase时,按照官网安装完成后,官网示例一直不能成功跑通,错误百出,准备放弃,吐槽一下官方文档,写的很烂,没啥发现,网上这方面资料很少,无意中发现一个叫铁头乔的网友的安装资料,虽然安装GeoMesa只有寥寥三行,但帮助很大,自己为何不能自己编译源码呢,于是开始按想法来实现。。。

下面是重新安装过程:

1 安装geomesa

git clone https://github.com/locationtech/geomesa.git
cd geomesa

maven进行编译:

mvn clean install -DskipTests=true

编译成功后,GeoMesa HBase的完整安装包位于geomesa-hbase\geomesa-hbase-dist\target目录下
解压,我安装在/usr/local下

sudo tar -xvf geomesa-hbase_2.11-2.1.0-SNAPSHOT-bin.tar.gz -C /usr/local/

改权限:(我安装的集群中都设置为此权限,各位可根据自己情况设置权限)

sudo chown -R wjk:hadoop /usr/local/geomesa-hbase_2.11-2.1.0-SNAPSHOT

拷贝到其它机器上:

sudo scp  -r /usr/local/geomesa-hbase_2.11-2.1.0-SNAPSHOT [email protected]:/usr/local/

2 配置
可以在geomesa-env.sh中配置,也可以在外部环境中配置环境变量和类路径设置 (例如bashrc文件)
本人已给装过hadoop群集、hbase等,所以就修改下.bashrc

sudo vim .bashrc 

添加如下:

export  GEOMESA_HBASE_HOME=/usr/local/geomesa-hbase_2.11-2.1.0-SNAPSHOT
export PATH=$PATH:$GEOMESA_HBASE_HOME/bin
export GEOMESA_HADOOP_CLASSPATH=$HADOOP_HOME
export GEOMESA_HBASE_CLASSPATH=$HBASE_HOME

加入环境变量
可以把以下加入/etc/profile中,使用命令更加方便

#geomesa-hbase
export  GEOMESA_HBASE_HOME=/usr/local/geomesa-hbase_2.11-2.1.0-SNAPSHOT
export PATH=$PATH:$GEOMESA_HBASE_HOME/bin
export PATH="${PATH}:${GEOMESA_HBASE_HOME}/bin"
export GEOMESA_HADOOP_CLASSPATH=$HADOOP_HOME
export GEOMESA_HBASE_CLASSPATH=$HBASE_HOME

应用

source /etc/profile

由于许可限制,必须单独安装形状文件支持的依赖项。使用以下命令执行此操作:
进入geomesa/bin下运行:

./install-jai.sh
./install-jline.sh

3 部署GeoMesa HBase分布式运行时JAR
GeoMesa使用HBase自定义过滤器来改进CQL查询的处理。要使用自定义筛选器,必须将分布式运行时jar部署到HBase,并将其部署到由调用的HBase配置变量指定的目录中 将/dist/hbase/geomesa-hbase-distributed-runtime_2.11-2.1.0-SNAPSHOT.jar拷贝到${HBase_HOME}/lib目录下。

cp /usr/local/geomesa-hbase_2.11-2.1.0-SNAPSHOT/dist/hbase/geomesa-hbase-distributed-runtime_2.11-2.1.0-SNAPSHOT.jar /usr/local/hbase/lib/

注意:此处还需要把geomesa-hbase-distributed-runtime_2.11-2.1.0-SNAPSHOT.jar 拷贝到/tmp/hbase-${usr}/hbase/lib/下,并且每个机器都要这样做,运行时会找这个jar包的。这个地方在其它资料里都没提到,但很重要。

cp /usr/local/geomesa-hbase_2.11-2.1.0-SNAPSHOT/dist/hbase/geomesa-hbase-distributed-runtime_2.11-2.1.0-SNAPSHOT.jar /tmp/hbase-wjk/hbase/lib/

4.注册协处理器
GeoMesa利用服务器端处理来加速某些查询。为了利用这些功能,GeoMesa协处理器必须在所有GeoMesa表上注册或在站点范围内注册,并且geomesa-hbase-distributed-runtime代码必须在类路径或HDFS URL上可用,具体取决于所使用的注册方法。
有许多方法可以注册协处理器,官方文档中提供了5种,参考https://www.geomesa.org/documentation/user/hbase/install.html
这里使用注册站点范围的方法
注册协处理器最简单的方法是指定协处理器hbase-site.xml。为此,只需将协处理器类名添加到hbase.coprocessor.user.region.classes密钥。

 
  
    hbase.coprocessor.user.region.classes
    org.locationtech.geomesa.hbase.coprocessor.GeoMesaCoprocessor 
   

改好后分发给其它机器

scp -r hbase-site.xml [email protected]:/usr/local/hbase/conf/ 

所有新的和现有的非系统表都可以访问GeoMesa协处理器。

5 重启集群
zookeeper和hbase都需要重启,可以的话最好重启下hadoop集群。

6 最后测试
显示

geomesa-hbase version 

GeoMesa tools version: 2.1.0-SNAPSHOT
Commit ID: 72ace4b8499fa0958a85a7b424f1fde47c446049
Branch: master
Build date: 2018-09-05T23:21:35-0400

测试官方示例:
下载并构建教程

git clone https://github.com/geomesa/geomesa-tutorials.git 

编译:

cd geomesa-tutorials 
mvn clean install -pl geomesa-tutorials-hbase/geomesa-tutorials-hbase-quickstart/ -am

编译时间有点长,等了几小时了,做好准备。。。

,完成后运行教程
在命令行上,运行:

java -cp /home/wjk/geomesa-tutorials/geomesa-tutorials-hbase/geomesa-tutorials-hbase-quickstart/target/geomesa-tutorials-hbase-quickstart-2.1.0-SNAPSHOT.jar org.geomesa.example.hbase.HBaseQuickStart \
--hbase.zookeepers 192.168.201.91,192.168.201.92,192.168.201.56 \
--hbase.catalog geomesa_hbase

以上可以修改zookeeper地址和hbase名

运行后,您应该看到以下输出:

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 719025281=719025281|CANADA|CAN|||051|8|1|8|4|Penticton, British Columbia, Canada|CA|2018-01-01T00:00:00.000Z|POINT (-119.583 49.5)
02 719024929=719024929|||CANADA|CAN|190|4|1|4|4|Okanagan, British Columbia, Canada|CA|2018-01-01T00:00:00.000Z|POINT (-119.35 50.3667)
03 719025855=719025855|PRESIDENT||MEXICO|MEX|0874|6|3|6|2|Minnesota, United States|US|2018-01-01T00:00:00.000Z|POINT (-93.9196 45.7326)
04 719026967=719026967|UNITED STATES|USA|||0831|4|1|4|2|Minnesota, United States|US|2018-01-01T00:00:00.000Z|POINT (-93.9196 45.7326)
05 719027201=719027201|MINNESOTA|USA|UNITED STATES|USA|114|2|1|2|2|Minnesota, United States|US|2018-01-01T00:00:00.000Z|POINT (-93.9196 45.7326)
06 719025275=719025275|CANADA|CAN|||015|4|1|4|4|Saskatoon, Saskatchewan, Canada|CA|2018-01-01T00:00:00.000Z|POINT (-106.667 52.1333)
07 719027017=719027017|UNITED STATES|USA|||190|2|1|2|3|San Diego, California, United States|US|2018-01-01T00:00:00.000Z|POINT (-117.157 32.7153)
08 719027116=719027116|UNITED STATES|USA|KING||051|8|1|8|3|San Diego, California, United States|US|2018-01-01T00:00:00.000Z|POINT (-117.157 32.7153)
09 719025124=719025124|||SACRAMENTO|USA|1823|8|1|8|3|Camp Pendleton, California, United States|US|2018-01-01T00:00:00.000Z|POINT (-117.393 33.2103)
10 719026572=719026572|DEMONSTRATOR||ISRAELI|ISR|145|1|1|1|3|Irvine, California, United States|US|2018-01-01T00:00:00.000Z|POINT (-117.823 33.6695)

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 719025270=719025270|2018-01-01T00:00:00.000Z|POINT (-80.0333 48.15)
02 719025809=719025809|2018-01-01T00:00:00.000Z|POINT (-75.7 45.4167)
03 719026370=719026370|2018-01-01T00:00:00.000Z|POINT (-117.113 32.5839)
04 719025493=719025493|2018-01-01T00:00:00.000Z|POINT (-117.157 32.7153)
05 719025402=719025402|2018-01-01T00:00:00.000Z|POINT (-117.393 33.2103)
06 719027018=719027018|2018-01-01T00:00:00.000Z|POINT (-117.393 33.2103)
07 719026757=719026757|2018-01-01T00:00:00.000Z|POINT (-117.823 33.6695)
08 719027129=719027129|2018-01-01T00:00:00.000Z|POINT (-117.823 33.6695)
09 719027131=719027131|2018-01-01T00:00:00.000Z|POINT (-117.823 33.6695)
10 719025133=719025133|2018-01-01T00:00:00.000Z|POINT (-111.388 33.7712)

Returned 669 total features

Running query EventCode = '051'
01 719024963=719024963|||CITIZEN||051|6|2|6|4|City Of Sydney, New South Wales, Australia|AS|2018-01-01T00:00:00.000Z|POINT (151.217 -33.8833)
02 719025168=719025168|AUSTRALIAN|AUS|||051|18|1|10|4|Sydney, New South Wales, Australia|AS|2018-01-01T00:00:00.000Z|POINT (151.217 -33.8833)
03 719025555=719025555|DENMARK|DNK|||051|2|1|2|1|Australia|AS|2018-01-01T00:00:00.000Z|POINT (135 -25)
04 719026936=719026936|UNITED STATES|USA|||051|4|1|4|4|Cabo San Lucas, Baja California Sur, Mexico|MX|2018-01-01T00:00:00.000Z|POINT (-109.9 22.8833)
05 719027176=719027176|CALIFORNIA|USA|BANGKOK|THA|051|8|1|8|2|California, United States|US|2018-01-01T00:00:00.000Z|POINT (-119.746 36.17)
06 719026939=719026939|CALIFORNIA|USA|||051|10|1|10|3|Sacramento, California, United States|US|2018-01-01T00:00:00.000Z|POINT (-121.494 38.5816)
07 719027064=719027064|UNITED STATES|USA|DEPUTY||051|2|1|2|3|Douglas County, Colorado, United States|US|2018-01-01T00:00:00.000Z|POINT (-104.951 39.3333)
08 719027065=719027065|UNITED STATES|USA|DEPUTY||051|2|1|2|3|Douglas County, Colorado, United States|US|2018-01-01T00:00:00.000Z|POINT (-104.951 39.3333)
09 719026940=719026940|UNITED STATES|USA|||051|20|5|20|3|Denver, Colorado, United States|US|2018-01-01T00:00:00.000Z|POINT (-104.985 39.7392)
10 719026941=719026941|UNITED STATES|USA|||051|6|3|6|3|Palm Beach, Florida, United States|US|2018-01-01T00:00:00.000Z|POINT (-80.0364 26.7056)

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 719026319=719026319|2018-01-01T00:00:00.000Z|POINT (-97.6475 31.106)
02 719027258=719027258|2018-01-01T00:00:00.000Z|POINT (-97.6475 31.106)
03 719026945=719026945|2018-01-01T00:00:00.000Z|POINT (-119.746 36.17)
04 719027115=719027115|2018-01-01T00:00:00.000Z|POINT (-121.494 38.5816)
05 719025112=719025112|2018-01-01T00:00:00.000Z|POINT (-97.3375 37.6922)
06 719025110=719025110|2018-01-01T00:00:00.000Z|POINT (-81.9296 33.7896)
07 719026297=719026297|2018-01-01T00:00:00.000Z|POINT (-77.0364 38.8951)
08 719026943=719026943|2018-01-01T00:00:00.000Z|POINT (-87.6501 41.85)
09 719026364=719026364|2018-01-01T00:00:00.000Z|POINT (-77.264 40.5773)
10 719027157=719027157|2018-01-01T00:00:00.000Z|POINT (-77.264 40.5773)

Returned 138 total features

Done

看到以上输出,恭喜你,运行成功啦。
查看hbase 生成了五个表:

geomesa_hbase                                                                                                                         
geomesa_hbase_gdelt_2dquickstart_attr_v5                                                                                              
geomesa_hbase_gdelt_2dquickstart_id                                                                                                   
geomesa_hbase_gdelt_2dquickstart_z2_v2                                                                                                
geomesa_hbase_gdelt_2dquickstart_z3_v2  

以上有参考萧博士的文章。感谢。

你可能感兴趣的:(geomesa,hbase,hadoop)