centos7安装geomesa2.0.2_hbase_geoserver2.13.2的方法
centos7安装geomesa2.0.2_hbase_geoserver2.13.2的方法
安装geoserver服务器目录位置规划:
/usr/jdk
/usr/tomcat
/usr/geoserver
/usr/geomesa
master
slave1
slave2
geoserver服务器需要连接上网NAT模式(如果是虚拟机的话)
#安装geomesa在geoserver服务器上
#下载geomesa2.0.2地址:
https://github.com/locationtech/geomesa
Downloads
Current release: 2.0.2
HBase | Accumulo | Cassandra | Kafka | FileSystem | Source | CheckSums
选择当前发布版本Current release: 2.0.2下面的HBase的下载地址:
https://github.com/locationtech/geomesa/releases/download/geomesa_2.11-2.0.2/geomesa-hbase_2.11-2.0.2-bin.tar.gz
#解压到geoserver服务器上
/usr/geomesa
bin
conf
dist
docs
examples
lib
logs
#配置环境变量
vi /etc/profile
添加下面几行代码
export GEOMESA_HBASE_HOME=/usr/geomesa
export GEOMESA_LIB=/usr/geomesa/lib
export PATH=${GEOMESA_HBASE_HOME}/bin:$PATH
export CLASSPATH=${GEOMESA_HBASE_HOME}/lib:${GEOMESA_HBASE_HOME}/conf:$CLASSPATH
具体内容如下所示:
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
export JAVA_HOME=/usr/jdk
export PATH=${JAVA_HOME}/bin:$PATH
export JRE_HOME=/usr/jdk/jre
export PATH=${JRE_HOME}/bin:$PATH
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export CATALINA_HOME=/usr/tomcat
export CATALINA_BASE=/usr/tomcat
export PATH=${CATALINA_BASE}/bin:$PATH
export M2_HOME=/usr/maven
export PATH=$PATH:${M2_HOME}/bin
export GEOMESA_HBASE_HOME=/usr/geomesa
export GEOMESA_LIB=/usr/geomesa/lib
export PATH=${GEOMESA_HBASE_HOME}/bin:$PATH
export CLASSPATH=${GEOMESA_HBASE_HOME}/lib:${GEOMESA_HBASE_HOME}/conf:$CLASSPATH
export SCALA_HOME=/usr/scala
export PATH=${SCALA_HOME}/bin:$PATH
#拷贝geomesa插件到hbase集群服务器上
GeoMesa使用HBase的自定义过滤器来执行CQL查询,为了允许GeoMesa使用过滤器,需要将
${GEOMESA_HBASE_HOME}/dist/hbase/geomesa-hbase-distributed-runtime_2.11-2.0.2.jar
拷贝到${HBASE_HOME}/lib目录下。
具体操作把/usr/geomesa/dist/hbase/geomesa-hbase-distributed-runtime_2.11-2.0.2.jar
拷贝到hbase集群服务器上位置:/home/hadoop3/app/hbase/lib中
如我的测试用hbase集群服务器如下:
master /home/hadoop3/app/hbase/lib/geomesa-hbase-distributed-runtime_2.11-2.0.2.jar
slave1 /home/hadoop3/app/hbase/lib/geomesa-hbase-distributed-runtime_2.11-2.0.2.jar
slave2 /home/hadoop3/app/hbase/lib/geomesa-hbase-distributed-runtime_2.11-2.0.2.jar
注册Coprocessors
Geomesa使用HBase提供的coprocessor工具将处理过程移动到服务器端运行来提高查询效率,最简单的注册方式就是直接修改hbase-site.xml,
/home/hadoop3/app/hbase/conf/hbase-site.xml
增加以下内容:
<property>
<name>hbase.coprocessor.user.region.classes</name>
<value>org.locationtech.geomesa.hbase.coprocessor.GeoMesaCoprocessor</value>
</property>
最后运行bin/geomesa-hbase configure初始化Geomesa
y
y
n
#拷贝hbase中jar组件到geomesa的lib中
把hbase中lib库中如下文件
hadoop-auth-2.7.4.jar
hadoop-client-2.7.4.jar
hadoop-common-2.7.4.jar
//
hbase-client-1.3.1.jar
hbase-common-1.3.1.jar
hbase-hadoop-compat-1.3.1.jar
hbase-server-1.3.1.jar
//
zookeeper-3.4.10.jar
拷贝到/usr/geomesa/lib目录中
#运行install-jai.sh和install-jline.sh
需要连接上网才能下载相关的jar文件
cd usr/geomesa
bin/install-jai.sh
bin/install-jline.sh
自动解压到/usr/geomesa/lib中
#配置/usr/geomesa/conf
#添加core-site.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. See accompanying LICENSE file.
-->
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://master</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/home/hadoop3/data/tmp</value>
</property>
<property>
<name>ha.zookeeper.quorum</name>
<value>master:2181,slave1:2181,slave2:2181</value>
</property>
<!--修改core-site.xml中的ipc参数,防止出现连接journalnode服务ConnectException-->
<property>
<name>ipc.client.connect.max.retries</name>
<value>100</value>
<description>Indicates the number of retries a client will make to establish a server connection.</description>
</property>
<property>
<name>ipc.client.connect.retry.interval</name>
<value>10000</value>
<description>Indicates the number of milliseconds a client will wait for before retrying to establish a server connection.</description>
</property>
</configuration>
#添加hbase-site.xml文件
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<configuration>
<property>
<name>hbase.tmp.dir</name>
<value>/home/hadoop3/data/hbase/tmp</value>
</property>
<!--HBase数据目录位置,master是mater机器的域名(别名)-->
<property>
<name>hbase.root.dir</name>
<value>hdfs://master/hbase</value>
</property>
<!--启用分布式集群-->
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.master</name>
<value>60000</value><!--这里注意了,只需端口即可,不必再写主机名称了!-->
<description>指定 hbase 集群主控节点</description>
</property>
<!--默认HMaster HTTP访问端口-->
<property>
<name>hbase.master.info.port</name>
<value>16010</value>
</property>
<!--默认HRegionServer HTTP访问端口-->
<property>
<name>hbase.regionserver.info.port</name>
<value>16030</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>master,slave1,slave2</value>
<description>配置独立的zk集群地址,除了master,自已配了几台zookeeper,此处就配几台</description>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
<description> 连接到zookeeper的端口,默认是2181</description>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/home/hadoop3/data/hbase/zookeeper</value>
</property>
<property>
<name>zookeeper.session.timeout</name>
<value>60000000</value>
</property>
<property>
<name>hbase.coprocessor.user.region.classes</name>
<value>org.locationtech.geomesa.hbase.coprocessor.GeoMesaCoprocessor</value>
</property>
</configuration>
一般情况这两个文件可以从已经部署好的hbase集群和hadoop集群服务器的配置文件中拷贝过来并作一下修改,主要修改
把hdfs://mycluster/hbase改为hdfs://master/hbase
master为hbase服务器机器名或为IP地址
<property>
<name>hbase.root.dir</name>
<value>hdfs://master/hbase</value>
</property>
#修改geomesa-env.sh
/usr/geomesa/conf/geomesa-env.sh
export GEOMESA_HBASE_HOME=/usr/geomesa
export GEOMESA_LIB=${GEOMESA_HBASE_HOME}/lib
export GEOMESA_HADOOP_CLASSPATH=$CLASSPATH
#拷贝geomesa插件到geoserver中
解压/usr/geomesa/dist/gs-plugins/geomesa-hbase-gs-plugin_2.11-2.0.2-install.tar.gz获得文件geomesa-hbase-gs-plugin_2.11-2.0.2-shaded.jar,把
geomesa-hbase-gs-plugin_2.11-2.0.2-shaded.jar和
geomesa-process-wps_2.11-2.0.2.jar拷贝到
/usr/tomcat/webapps/geoserver/WEB-INF/lib中
#拷贝hbase中jar组件到geoserver的lib中
把hbase中lib库中如下文件
hadoop-auth-2.7.4.jar
hadoop-client-2.7.4.jar
hadoop-common-2.7.4.jar
//
hbase-client-1.3.1.jar
hbase-common-1.3.1.jar
hbase-hadoop-compat-1.3.1.jar
hbase-server-1.3.1.jar
//
zookeeper-3.4.10.jar
拷贝到/usr/tomcat/webapps/geoserver/WEB-INF/lib目录中
#可能依赖的Jar文件有:
hadoop-annotations-2.7.4.jar
hadoop-auth-2.7.4.jar
hadoop-common-2.7.4.jar
hadoop-mapreduce-client-core-2.7.4.jar
hadoop-yarn-api-2.7.4.jar
hadoop-yarn-common-2.7.4.jar
htrace-core-3.1.0-incubating.jar
commons-cli-1.2.jar
commons-io-2.5.jar (you may need to remove an older version (2.1) from geoserver)
hbase-common-1.3.1.jar
hbase-client-1.3.1.jar
hbase-server-1.3.1.jar
hbase-protocol-1.3.1.jar
metrics-core-2.2.0.jar
netty-3.6.2.Final.jar
netty-all-4.0.41.Final.jar
zookeeper-3.4.10.jar
commons-configuration-1.6.jar
You can use the bundled $GEOMESA_HBASE_HOME/bin/install-hadoop.sh script to install these JARs.
#配置geoserver/WEB-INF/classes
添加文件core-site.xml
添加文件hbase-site.xml
配置内容同上geomesa的配置内容
#geomesa上传shp数据到hbase
cd /usr/geomesa
如果shp文件中有Id字段要删除掉再上传
#上传数据
[root@geoserver geomesa]# geomesa-hbase ingest --catalog xzq_toGeo2000 --feature-name xzq_toGeo2000 --input-format shp "/usr/geomesa/xzq_toGeo2000.shp"
INFO Ingesting 1 file with 1 thread
INFO Shapefile ingestion complete in 00:00:09
INFO Ingested 302 features with no failures.
[root@geoserver geomesa]#
geomesa-hbase ingest --catalog geomesa --feature-name xzq_toGeo2000 --input-format shp "/usr/geomesa/xzq_toGeo2000.shp"
如果上传报错,请检查geomesa/conf的配置文件是否正确
geomesa/lib的库文件特别是hadoop和hbase版本是否正确
#删除数据
geomesa-hbase delete-catalog -c "guizhou_xzq"
geomesa-hbase delete-catalog -c "xzq_toGeo2000"
geomesa-hbase delete-catalog -c "geomesa"
#geoserver上发布hbase(geomesa)数据源
工作区:geomesa
数据源名称:xzq_toGeo2000
启用:打勾
hbase.catalog* =geomesa
hbase.zookeepers=master
或
hbase.zookeepers=master:2181,slave1:2181,slave2:2181
hbase.remote.filtering 不打勾
geomesa.stats.enable 打勾
geomesa.query.audit 打勾
保存 OK
#发布图层并Layer Preview
—-the—end—–
转载自:https://blog.csdn.net/hsg77/article/details/82221531