CDH6.3.2安装 基本就是按照网上的安装教程即可;
说明:
geomesa_2.11-2.x和geomesa_2.11-3.1.1,安装有些许差异,
geomesa_2.11-2.x中,需要执行 `$GEOMESA_HBASE_HOME/bin/install-jai.sh`和
`$GEOMESA_HBASE_HOME/bin/install-jline.sh` ,但是下载不了依赖,geomesa_2.11-3.1.1版本已经没有这两个脚本
**本文是基于CDH6.3.2(hadoop3.0.0 hbase2.1.0)安装geomesa_2.11-3.1.1**
CDH和hbase组件版本
| CDH版本 | HBase版本|
| :--- | :---: |
| 6.3.x | 2.1.4 |
| 6.2.x | 2.1.2|
| 6.1.x | 2.1.1|
| 6.0.x | 2.0.2|
| 5.16.x | hbase-1.2.0 cdh5.16.2 489|
```
CDH机器
111.231.244.61 10.4.2.8
123.207.126.191 10.4.2.173
139.199.72.86 10.4.2.103
```
### 一、安装geomesa
#### 1.下载二进制包或者源码包,服务器上较慢,建议在本地下好上传到服务器
1)方式一:直接下载二进制包
```
wget "https://github.com/locationtech/geomesa/releases/download/geomesa_2.11-3.1.1/geomesa-hbase_2.11-3.1.1-bin.tar.gz"
```
2)方式二:下载源码重新编译
```
//此时clone下来的仓库最新是版本是geomesa-hbase_2.11-3.2.0-SNAPSHOT,
git clone https://github.com/locationtech/geomesa.git
git tag 查看所有release版本
//最新的release版本是geomesa_2.11-3.1.1,由于测试数据所在仓库最新tag是geomesa-tutorials-3.1.0,建议使用geomesa_2.11-3.1.0,cdh部署的是geomesa_2.11-3.1.1
git checkout geomesa_2.11-3.1.1
cd geomesa
mvn clean install -DskipTests=true
编译成功后,GeoMesa HBase的完整安装包位于geomesa-hbasegeomesa-hbase-disttarget目录下geomesa-hbase_2.11-3.2.0-SNAPSHOT-bin.tar.gz
```
待验证部分:下下来的源码中显示hadoop的version是2.8.5,hbase是2.2.3,cdh集群环境hadoop3.0.0 hbase2.1.0,不知道是否需要修改版本重新编译打包
经安装测试:直接下来下没有改版本的二进制包`geomesa-hbase_2.11-3.1.1-bin.tar.gz`在cdh集群可以运行
#### 2.上传解压并赋权
- 通过xftp将`geomesa-hbase_2.11-3.2.0-SNAPSHOT-bin.tar.gz`包上传至服务器目录,当前是在10.4.2.8 `/data/coffysun`目录下
```
//解压至固定目录 /data/ 下
tar -xvf geomesa-hbase_2.11-3.1.1-bin.tar.gz -C /data/
//修改权限
chown -R root:hadoop /data/geomesa-hbase_2.11-3.1.1/
//拷贝到cdh的其他两台机器上
scp -r /data/geomesa-hbase_2.11-3.1.1/ root@10.4.2.103:/data/
scp -r /data/geomesa-hbase_2.11-3.1.1/ root@10.4.2.173:/data/
```
#### 3.配置环境变量,直接修改/etc/profile
```
#geomesa-hbase
#geomesa-hbase_2.11-3.2.0-SNAPSHOT-bin.tar.gz解压后安装的目录
export GEOMESA_HBASE_HOME=/data/geomesa-hbase_2.11-3.1.1
export PATH=$PATH:$GEOMESA_HBASE_HOME/bin
#hadoop安装目录,cdh集群没有配置$HADOOP_HOME,直接写全路径
export GEOMESA_HADOOP_CLASSPATH=/opt/cloudera/parcels/CDH-6.3.2-1.cdh6.3.2.p0.1605554/lib/hadoop
#hbase安装目录,cdh集群没有配置$HBASE_HOME,直接写全路径
export GEOMESA_HBASE_CLASSPATH=/opt/cloudera/parcels/CDH-6.3.2-1.cdh6.3.2.p0.1605554/lib/hbase
```
修改后`source /etc/profile`
#### 4.部署GeoMesa HBase分布式运行时JAR
GeoMesa使用HBase自定义过滤器来改进CQL查询的处理。要使用自定义筛选器,必须将分布式运行时jar部署到HBase,并将其部署到由调用的HBase配置变量指定的目录中,
该jar包所在位置为:`$GEOMESA_HBASE_HOME/dist/hbase/`,该目录下有两个hbase运行jar包,一个是1.x版本,一个是2.x版本,本步骤下取`geomesa-hbase-distributed-runtime-hbase2_2.11-3.1.1.jar`
```
//官方给出的上传至hadoop hdfs目录 ${hbase.dynamic.jars.dir}, 即${hbase.rootdir}/lib ,该操作没有执行,hadoop hdfs上没有这个目录
hadoop fs -put ${GEOMESA_HBASE_HOME}/dist/hbase/geomesa-hbase-distributed-runtime-hbase2_2.11-$VERSION.jar ${hbase.dynamic.jars.dir}/
//修改为,将
$GEOMESA_HBASE_HOME/dist/hbase/geomesa-hbase-distributed-runtime-hbase2_2.11-3.1.1.jar拷贝到${HBase_HOME}/lib目录下,然后再复制到其他hbase节点的相同目录下
```
#### 5.注册协处理器
GeoMesa利用服务器端处理来加速某些查询。为了利用这些功能,GeoMesa协处理器必须在所有GeoMesa表上注册或在站点范围内注册,并且`geomesa-hbase-distributed-runtime`代码必须在类路径或HDFS URL上可用,具体取决于所使用的注册方法。
```
//官方给出如果将上述分布式jar包上传至hadoop hdfs目录 ${hbase.dynamic.jars.dir},则自动生效,上个步骤中我们没有上传至hadoop,
//修改hbase配置文件hbase-site.xml,CDH机器的hbase配置文件目录有两处,都修改,目录如下,(部署过程中该步骤没有执行)
路径:
/opt/cloudera/parcels/CDH-6.3.2-1.cdh6.3.2.p0.1605554/lib/hbase/conf/hbase-site.xml
/etc/hbase/conf/hbase-site.xml
//修改配置
<configuration>
<property>
<name>hbase.coprocessor.user.region.classes</name>
<value>org.locationtech.geomesa.hbase.coprocessor.GeoMesaCoprocessor</value>
</property>
</configuration>
//改好后分发给其它机器
scp -r hbase-site.xml root@10.4.2.173:/opt/cloudera/parcels/CDH-6.3.2-1.cdh6.3.2.p0.1605554/lib/hbase/conf/
scp -r hbase-site.xml root@10.4.2.173:/etc/hbase/conf/
```
**然后在cdh ui界面上修改hbase jvm大小为1024m(根据具体需求)**
**修改完后重启集群zookeeper和hbase都需要重启**
#### 6.查看安装版本
```
geomesa-hbase version
//步骤一提到,hadoop hbase的一些jar包版本不一样,我在执行时报是否重新拉依赖包,点击y,依赖包在服务器上下载比较慢,也有可能下载出错,将出错的jar包从maven仓库下下来再上传上去,依赖包如下:
Detected missing classpath entries:
com.google.guava:guava:27.0-jre:ja
commons-cli:commons-cli:1.2:ja
commons-configuration:commons-configuration:1.6:ja
commons-logging:commons-logging:1.1.3:ja
io.netty:netty-all:4.1.48.Final:ja
javax.servlet:servlet-api:2.4:ja
org.apache.hadoop:hadoop-auth:2.8.5:ja
org.apache.hadoop:hadoop-client:2.8.5:ja
org.apache.hadoop:hadoop-common:2.8.5:ja
org.apache.hadoop:hadoop-hdfs:2.8.5:ja
org.apache.hadoop:hadoop-hdfs-client:2.8.5:ja
org.apache.hadoop:hadoop-mapreduce-client-core:2.8.5:ja
org.apache.hbase:hbase-client:2.2.6:ja
org.apache.hbase:hbase-common:2.2.6:ja
org.apache.hbase:hbase-hadoop-compat:2.2.6:ja
org.apache.hbase:hbase-mapreduce:2.2.6:ja
org.apache.hbase:hbase-protocol:2.2.6:ja
org.apache.hbase:hbase-protocol-shaded:2.2.6:ja
org.apache.hbase.thirdparty:hbase-shaded-miscellaneous:2.2.1:ja
org.apache.hbase.thirdparty:hbase-shaded-netty:2.2.1:ja
org.apache.hbase.thirdparty:hbase-shaded-protobuf:2.2.1:ja
org.apache.htrace:htrace-core:3.1.0-incubating:ja
org.apache.htrace:htrace-core4:4.1.0-incubating:ja
org.apache.zookeeper:zookeeper:3.4.14:ja
//执行后显示如下:
Commit ID: 00ef69874411dc7bbefc219708ca112cd92494fb
Branch: 3.1.x
Build date: 2021-01-13T22:16:03 0000
```
#### 7.测试验证
```
//测试代码获取比较慢在本地clone打包后在上传至服务器
git clone https://github.com/geomesa/geomesa-tutorials.git
git tag 查看标签 //最新的是geomesa-tutorials-3.1.0
cd geomesa-tutorials
//上述安装geomesa-hbase对应的版本,我没找到geomesa-tutorials-3.1.1版本,使用3.1.0
git checkout geomesa-tutorials-3.1.0
//用idea打开项目,hadoop版本是2.8.5,hbase版本是2.2.3,网上有建议说改pom的版本为集群对应的版本,待验证,改完后执行:
mvn clean install -pl geomesa-tutorials-hbase/geomesa-tutorials-hbase-quickstart/ -am
jar包位置:
geomesa-tutorialsgeomesa-tutorials-hbasegeomesa-tutorials-hbase-quickstarttargetgeomesa-tutorials-hbase-quickstart-3.1.0.ja
上传至服务器,我放在10.4.2.8 /data/coffysun/GeoMesa/test_data/geomesa-tutorials-hbase-quickstart-3.1.0.ja
//执行:
java -cp /data/coffysun/GeoMesa/test_data/geomesa-tutorials-hbase-quickstart-3.1.0.jar org.geomesa.example.hbase.HBaseQuickStart
--hbase.zookeepers agent2.cdh,agent1.cdh,master.cdh
--hbase.catalog geomesa_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 719025603=719025603|SCHOOL||||182|5|1|5|2|Montana, United States|US|2018-01-01T00:00:00.000Z|POINT (-110.326 46.9048)
02 719025083=719025083|||UNITED STATES|USA|030|6|3|6|2|Minnesota, United States|US|2018-01-01T00:00:00.000Z|POINT (-93.9196 45.7326)
03 719025765=719025765|PRESIDENT||||131|15|3|15|2|Minnesota, United States|US|2018-01-01T00:00:00.000Z|POINT (-93.9196 45.7326)
04 719025803=719025803|PRESIDENT||CANADA|CAN|0874|9|3|9|2|Minnesota, United States|US|2018-01-01T00:00:00.000Z|POINT (-93.9196 45.7326)
05 719025804=719025804|PRESIDENT||CANADA|CAN|131|15|3|15|2|Minnesota, United States|US|2018-01-01T00:00:00.000Z|POINT (-93.9196 45.7326)
06 719025857=719025857|PRESIDENT||MEXICO|MEX|131|12|3|12|2|Minnesota, United States|US|2018-01-01T00:00:00.000Z|POINT (-93.9196 45.7326)
07 719026298=719026298|SENATOR||||051|6|2|6|2|Minnesota, United States|US|2018-01-01T00:00:00.000Z|POINT (-93.9196 45.7326)
08 719027150=719027150|MINNESOTA|USA|SENATE||051|13|2|11|2|Minnesota, United States|US|2018-01-01T00:00:00.000Z|POINT (-93.9196 45.7326)
09 719025299=719025299|CANADA|CAN|||015|2|1|2|4|Saskatchewan, Manitoba, Canada|CA|2018-01-01T00:00:00.000Z|POINT (-97.7167 52.15)
10 719025947=719025947|PREMIER||CANADA|CAN|015|2|1|2|4|Saskatchewan, Manitoba, Canada|CA|2018-01-01T00:00:00.000Z|POINT (-97.7167 52.15)
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 719026971=719026971|2018-01-01T00:00:00.000Z|POINT (-99.793 47.5362)
02 719025699=719025699|2018-01-01T00:00:00.000Z|POINT (-93.9196 45.7326)
03 719026947=719026947|2018-01-01T00:00:00.000Z|POINT (-93.9196 45.7326)
04 719024924=719024924|2018-01-01T00:00:00.000Z|POINT (-106.667 52.1333)
05 719025603=719025603|2018-01-01T00:00:00.000Z|POINT (-110.326 46.9048)
06 719025083=719025083|2018-01-01T00:00:00.000Z|POINT (-93.9196 45.7326)
07 719025765=719025765|2018-01-01T00:00:00.000Z|POINT (-93.9196 45.7326)
08 719025803=719025803|2018-01-01T00:00:00.000Z|POINT (-93.9196 45.7326)
09 719025804=719025804|2018-01-01T00:00:00.000Z|POINT (-93.9196 45.7326)
10 719025857=719025857|2018-01-01T00:00:00.000Z|POINT (-93.9196 45.7326)
Returned 669 total features
Running query EventCode = '051'
01 719025634=719025634|FIJI|FJI|||051|2|1|2|1|Fiji|FJ|2018-01-01T00:00:00.000Z|POINT (178 -18)
02 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)
03 719027117=719027117|LOS ANGELES|USA|KING||051|26|3|26|2|California, United States|US|2018-01-01T00:00:00.000Z|POINT (-119.746 36.17)
04 719025036=719025036|||SENATE||051|5|1|5|2|Alabama, United States|US|2018-01-01T00:00:00.000Z|POINT (-86.8073 32.799)
05 719026318=719026318|SENATE||UNITED STATES|USA|051|2|1|2|2|Alabama, United States|US|2018-01-01T00:00:00.000Z|POINT (-86.8073 32.799)
06 719026296=719026296|CHAMBER||||051|20|1|20|3|Springfield, South Carolina, United States|US|2018-01-01T00:00:00.000Z|POINT (-81.2793 33.4968)
07 719025744=719025744|CIVIL SERVANT||||051|20|1|10|3|White House, District of Columbia, United States|US|2018-01-01T00:00:00.000Z|POINT (-77.0364 38.8951)
08 719026946=719026946|INDIANA|USA|||051|12|1|12|2|Indiana, United States|US|2018-01-01T00:00:00.000Z|POINT (-86.2604 39.8647)
09 719025279=719025279|EDMONTON|CAN|||051|5|1|5|4|Dufferin County, Ontario, Canada|CA|2018-01-01T00:00:00.000Z|POINT (-80.1667 44.0833)
10 719027252=719027252|AMERICAN CIVIL LIBERTIES UNION|USA|||051|2|1|2|2|Pennsylvania, United States|US|2018-01-01T00:00:00.000Z|POINT (-77.264 40.5773)
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 719025248=719025248|2018-01-01T00:00:00.000Z|POINT (135 -25)
02 719026319=719026319|2018-01-01T00:00:00.000Z|POINT (-97.6475 31.106)
03 719027258=719027258|2018-01-01T00:00:00.000Z|POINT (-97.6475 31.106)
04 719026945=719026945|2018-01-01T00:00:00.000Z|POINT (-119.746 36.17)
05 719027115=719027115|2018-01-01T00:00:00.000Z|POINT (-121.494 38.5816)
06 719025112=719025112|2018-01-01T00:00:00.000Z|POINT (-97.3375 37.6922)
07 719025110=719025110|2018-01-01T00:00:00.000Z|POINT (-81.9296 33.7896)
08 719026297=719026297|2018-01-01T00:00:00.000Z|POINT (-77.0364 38.8951)
09 719026943=719026943|2018-01-01T00:00:00.000Z|POINT (-87.6501 41.85)
10 719026364=719026364|2018-01-01T00:00:00.000Z|POINT (-77.264 40.5773)
Returned 138 total features
Done
```
### 二、安装可视化组件geoserve
说明:最新版本的geoserver无需安装tomcat,直接下载下来修改配置即可
1.在官网上下载geoserver包,http://geoserver.org/release/2.18.0/
2.将包上传至服务器,我上传在10.4.2.8的`/data/coffysun/ geoserver-2.18.0-bin.zip`,
该zip包里面直接是各个模块目录,需要先创建好要安装的目录,我放在`/data/geoserver`下
3.修改/etc/profile
```
#geoserve
export GEOSERVER_HOME=/data/geoserve
```
**修改完后source /etc/profile**
4.修改geoserver安装目录下的start.ini,`${GEOSERVER_HOME}/start.ini`,主要是修改端口号
![enter image description here](/tfl/pictures/202101/tapd_20423693_1611911844_86.png)
5.启动服务,
```
nohup /data/geoserver/bin/startup.sh &
```
然后在本地访问查看服务是否正常 http://111.231.244.61:9501/geoserver/,
初始登录密码是admin/geoserve
![enter image description here](/tfl/pictures/202101/tapd_20423693_1611912174_79.png)
### 三、在geoserver中安装geomesa插件
为了使用GeoMesa作为数据源,在geoserver中发布标准地图服务,进行可视化的工作故,需要在geoserver中安装geomesa插件
1.将`${GEOMESA_HBASE_HOME}/lib`下的以下jar包copy到`${GEOSERVER_HOME}/webapps/geoserver/WEB-INF/lib`下,相关jar包如下:
```
commons-cli-1.2.ja
commons-configuration-1.6.ja
commons-io-2.5.ja
commons-logging-1.1.3.ja
netty-all-4.1.48.Final.ja
hadoop-auth-2.8.5.ja
hadoop-client-2.8.5.ja
hadoop-common-2.8.5.ja
hadoop-hdfs-2.8.5.ja
hadoop-hdfs-client-2.8.5.ja
hadoop-mapreduce-client-core-2.8.5.ja
hbase-client-2.2.6.ja
hbase-common-2.2.6.ja
hbase-hadoop-compat-2.2.6.ja
hbase-mapreduce-2.2.6.ja
hbase-protocol-2.2.6.ja
hbase-protocol-shaded-2.2.6.ja
hbase-shaded-miscellaneous-2.2.1.ja
hbase-shaded-netty-2.2.1.ja
hbase-shaded-protobuf-2.2.1.ja
htrace-core-3.1.0-incubating.ja
htrace-core4-4.1.0-incubating.ja
protobuf-java-2.5.0.ja
zookeeper-3.4.14.ja
```
2.将`${GEOMESA_HBASE_HOME}dist/gs-plugins/geomesa-hbase-gs-plugin_2.11-3.1.1-install.tar.gz` 解压,然后copy到`${GEOSERVER_HOME}/webapps/geoserver/WEB-INF/lib`下
```
//进入geomesa安装目录下dist
cd /data/geomesa-hbase_2.11-3.1.1/dist/gs-plugins
//创建新文件夹存储解压后的jar包
mkdir geomesa-hbase-plugin
//解压jar包到指定目录
tar -xzvf ./geomesa-hbase-gs-plugin_2.11-3.1.1-install.tar.gz -C geomesa-hbase-plugin
cp geomesa-hbase-plugin/* /data/geoserver/webapps/geoserver/WEB-INF/lib
```
3.geoserver中配置hbase
将hbase-site.xml文件复制到geoserver/WEB-INF/classes下。或者创建软连接
hbase配置路径:
`/opt/cloudera/parcels/CDH-6.3.2-1.cdh6.3.2.p0.1605554/lib/hbase/conf/hbase-site.xml`
`/etc/hbase/conf/hbase-site.xml`
因为hbase的hbase-site.xml文件在第一部分中没有配置(使用默认配置),里面是空的,copy到geoserver/WEB-INF/classes时修改为
```
<configuration>
<property>
<name>hbase.coprocessor.user.region.classes</name>
<value>org.locationtech.geomesa.hbase.coprocessor.GeoMesaCoprocessor</value>
</property>
</configuration>
```