Geomesa连接Accumulo无响应问题求助
问题:Geomesa连接Accumulo时阻塞无响应
环境配置
同一服务器上部署了Accumulo(2.1.1)、Geomesa(2.13)及VDI,节点信息如下(仅使用第一个ZooKeeper):
zookeeper1 192.168.2.31 zookeeper2 192.168.2.32 zookeeper3 192.168.2.33 namenode 192.168.2.34 datanode1 192.168.2.35 datanode2 192.168.3.36 acc-master 192.168.2.37 acc-tserver 192.168.2.38
连接代码
尝试通过以下代码建立Geomesa与Accumulo的连接,程序始终阻塞无返回、无错误信息:
Map<String, String> parameters = new HashMap<>(); parameters.put("accumulo.instance.name", "myInstance"); parameters.put("accumulo.zookeepers", "127.0.0.1:9997"); parameters.put("accumulo.user", "keith"); parameters.put("accumulo.password", "accumulo2.1"); parameters.put("accumulo.catalog", "myNamespace.keithCatalog"); try { store = DataStoreFinder.getDataStore(parameters); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }
Schema操作
已通过以下命令创建Schema:
/opt/geomesa-accumulo_2.12-4.0.1/bin/geomesa-accumulo create-schema -c myNamespace.keithCatalog -s source:String,sensor:String,type:String,date:Date -f testSchema
在acc-master节点上可正常查看该Schema:
sudo /opt/geomesa-accumulo_2.12-4.0.1/bin/geomesa-accumulo describe-schema -c myNamespace.keithCalog -f testSchema INFO Describing attributes of feature 'testSchema' source | String sensor | String type | String date | Date User data: geomesa.index.dtg | date geomesa.indices | id:4:3: geomesa.stats.enable | true
排查情况
- 省略
catalog参数时会正常报错,但填写错误的catalog参数时,程序仍无响应 - 调用
DataStoreFinder.getAllDataStores()可获取到Accumulo数据存储工厂,确认工厂存在:
org.locationtech.geomesa.accumulo.data.AccumuloDataStoreFactory@18e36d14 Info: accumulo.instance.name=java.lang.String Accumulo Instance Name accumulo.zookeepers=java.lang.String Zookeepers accumulo.catalog=java.lang.String REQUIRED Accumulo catalog table name, including Accumulo namespace (if any) separated with a period accumulo.user=java.lang.String Accumulo user accumulo.password=java.lang.String Accumulo password accumulo.keytab.path=java.lang.String Path to keytab file geomesa.query.threads=java.lang.Integer The number of threads to use per query accumulo.query.record-threads=java.lang.Integer The number of threads to use for record retrieval accumulo.write.threads=java.lang.Integer The number of threads to use for writing records geomesa.query.timeout=java.lang.String The max time a query will be allowed to run before being killed, e.g. '60 seconds' accumulo.zookeepers.timeout=java.lang.String The timeout used for connections to Zookeeper accumulo.remote.arrow.enable=java.lang.Boolean Process Arrow encoding in Accumulo tablets servers as a distributed call accumulo.remote.bin.enable=java.lang.Boolean Process binary encoding in Accumulo tablets servers as a distributed call accumulo.remote.density.enable=java.lang.Boolean Process heatmap encoding in Accumulo tablets servers as a distributed call accumulo.remote.stats.enable=java.lang.Boolean Process statistical calculations in Accumulo tablets servers as a distributed call geomesa.stats.enable=java.lang.Boolean Generate and persist data statistics for new feature types geomesa.query.audit=java.lang.Boolean Audit queries being run geomesa.query.loose-bounding-box=java.lang.Boolean Use loose bounding boxes - queries will be faster but may return extraneous results geomesa.partition.scan.parallel=java.lang.Boolean Run scans in parallel for partitioned stores geomesa.security.auths=java.lang.String Super-set of authorizations that will be used for queries. The actual authorizations might differ, depending on the authorizations provider, but will be outside this set. Comma-delimited. geomesa.security.auths.force-empty=java.lang.Boolean Default to using no authorizations during queries, instead of using the connection user's authorizations namespace=java.lang.String Namespace password=java.lang.String
需求
成功获取数据存储实例,解决连接阻塞问题。
解决方案
1. 修正ZooKeeper地址配置
代码中使用127.0.0.1:9997作为ZooKeeper地址,但实际集群的第一个ZooKeeper节点是192.168.2.31,需做以下核对:
- 将连接参数中的zookeepers值替换为
192.168.2.31:2181(ZooKeeper默认端口为2181,代码中写的9997需确认是否与Accumulo配置的ZooKeeper端口一致) - 检查防火墙/安全组是否开放了对应端口,确保程序所在服务器能与ZooKeeper节点正常通信
2. 添加ZooKeeper超时参数
连接阻塞大概率是无超时配置导致的,在参数中添加超时限制,避免无限等待:
parameters.put("accumulo.zookeepers.timeout", "10 seconds");
配置后若连接失败会在超时后抛出异常,便于定位问题。
3. 核对Catalog名称拼写
查看Schema的命令中写的是myNamespace.keithCalog(末尾为Calog),但代码中是myNamespace.keithCatalog,需确认实际创建的Catalog名称是否正确,避免因名称不匹配引发异常。
4. 验证Accumulo连接可用性
在程序运行的服务器上,使用Accumulo命令行工具测试连接:
accumulo shell -u keith -p accumulo2.1 -z 192.168.2.31 -i myInstance
如果命令行也无法连接,说明是集群或网络问题;如果命令行能正常连接,再排查代码中的依赖或参数细节。
5. 检查依赖版本一致性
确保程序中使用的Accumulo客户端版本与集群的2.1.1完全一致,Geomesa 4.0.1与Accumulo 2.1.1兼容,但依赖冲突可能导致连接异常。
内容的提问来源于stack exchange,提问作者keith
相关产品推荐
相关产品推荐

