JanusGraph 0.6.2对接AWS OpenSearch 7.x遇PermanentBackendException求助
问题场景
运行JanusGraph 0.6.2版本,将AWS OpenSearch(Elasticsearch兼容版)7.10作为索引后端,对接6.x版本时一切正常,但连接7.x版本时触发如下异常:
org.janusgraph.diskstorage.PermanentBackendException: method [PUT], host [https://vpc-xxxxxx.us-east-2.es.amazonaws.com:443], URI [/_cluster/settings], status line [HTTP/1.1 401 Unauthorized] {"Message":"Your request: '/_cluster/settings' payload is not allowed."}
版本信息
86 [main] INFO org.janusgraph.graphdb.server.JanusGraphServer - JanusGraph Version: 0.6.2 86 [main] INFO org.janusgraph.graphdb.server.JanusGraphServer - TinkerPop Version: 3.5.3
详细堆栈
3115 [main] INFO org.janusgraph.diskstorage.Backend - Configuring index [search] 3387 [main] INFO com.newforma.janusgraph.es.awsauth.AWSV4AuthHttpClientConfigCallback - Initialized AWSV4AuthHttpClientConfigCallback for region us-east-2 3782 [main] WARN org.apache.tinkerpop.gremlin.server.util.DefaultGraphManager - Graph [graph] configured at [/etc/opt/janusgraph/janusgraph.properties] could not be instantiated and will not be available in Gremlin Server. GraphFactory message: GraphFactory could not instantiate this Graph implementation [class org.janusgraph.core.JanusGraphFactory] java.lang.RuntimeException: GraphFactory could not instantiate this Graph implementation [class org.janusgraph.core.JanusGraphFactory] at org.apache.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:84) at org.apache.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:80) ... 14 more Caused by: java.lang.IllegalArgumentException: Could not instantiate implementation: org.janusgraph.diskstorage.es.ElasticSearchIndex at org.janusgraph.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:79) at org.janusgraph.diskstorage.Backend.getImplementationClass(Backend.java:527) at org.janusgraph.diskstorage.Backend.getIndexes(Backend.java:511) at org.janusgraph.diskstorage.Backend.<init>(Backend.java:239) at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:127) ... 19 more Caused by: org.janusgraph.diskstorage.PermanentBackendException: method [PUT], host [https://vpc-xxxxxx.us-east-2.es.amazonaws.com:443], URI [/_cluster/settings], status line [HTTP/1.1 401 Unauthorized] {"Message":"Your request: '/_cluster/settings' payload is not allowed."} at org.janusgraph.diskstorage.es.ElasticSearchIndex.setupMaxOpenScrollContextsIfNeeded(ElasticSearchIndex.java:445) at org.janusgraph.diskstorage.es.ElasticSearchIndex.<init>(ElasticSearchIndex.java:388) ... 32 more Caused by: org.elasticsearch.client.ResponseException: method [PUT], host [https://vpc-xxxxxx.us-east-2.es.amazonaws.com:443], URI [/_cluster/settings], status line [HTTP/1.1 401 Unauthorized] {"Message":"Your request: '/_cluster/settings' payload is not allowed."} at org.elasticsearch.client.RestClient.convertResponse(RestClient.java:326) at org.elasticsearch.client.RestClient.performRequest(RestClient.java:296) at org.elasticsearch.client.RestClient.performRequest(RestClient.java:270) at org.janusgraph.diskstorage.es.rest.RestElasticSearchClient.performRequest(RestElasticSearchClient.java:482) at org.janusgraph.diskstorage.es.rest.RestElasticSearchClient.performRequest(RestElasticSearchClient.java:473) at org.janusgraph.diskstorage.es.rest.RestElasticSearchClient.updateClusterSettings(RestElasticSearchClient.java:269) at org.janusgraph.diskstorage.es.ElasticSearchIndex.setupMaxOpenScrollContextsIfNeeded(ElasticSearchIndex.java:443)
问题原因
AWS OpenSearch(包括托管Elasticsearch 7.x及以上版本)限制了通过Elasticsearch API直接修改集群级设置(如action.search.max_open_scroll_contexts),而JanusGraph 0.6.2的Elasticsearch索引后端初始化时,默认会尝试调用PUT /_cluster/settings调整滚动上下文最大值,该操作在AWS托管环境中被拦截,导致401 Unauthorized错误。
解决方案
在JanusGraph的配置文件(如janusgraph.properties)中添加以下参数,禁用自动调整滚动上下文的功能:
index.search.es.setup-max-open-scroll-context=false
说明
该参数会让JanusGraph跳过初始化阶段修改集群滚动上下文的步骤,避免触发AWS的权限拦截。如果需要调整滚动上下文最大值,需通过AWS控制台或AWS CLI修改OpenSearch集群的参数,而非通过JanusGraph的API操作。
内容的提问来源于stack exchange,提问作者Abhiram
相关产品推荐
相关产品推荐

