ES云托管在Azure中。它工作在春季数据ES 4.1.5(ES客户机7.9.3)中。但是spring数据ES 4.4.1 (ES客户端7.17.4)需要集群:monitor/main权限。
我的管理员不想批准这样的许可。
"root_cause":[{"type":"security_exception","reason":"action [cluster:monitor/main] is unauthorized for user [xxxx] with roles我第一次问问题是在这篇文章里。Val指出/终结点集群级API需要此权限。why does it need cluster:monitor/main permission
我做了一些调试,并发现了更多的细节。在SimpleElasticsearchRepository初始化期间,Spring数据ES正在发送HEAD /和GET /。
对不起,我不能让格式正常工作。所以我在这里附上截图
SimpleElasticsearchRepository -> RestIndexTemplate ->
在SimpleElasticsearchRepository初始化过程中,索引是空的。,因此对实际索引的正常HEAD请求变成了HEAD /。此用户帐户没有发送HEAD /的权限


既然目的是检查索引是否存在,那么如果索引为空,是否可以跳过与服务器的检查?因为它变成了检查集群级别信息的请求。以下的请求需要完全不同的许可。
头/头
头/actual_index

更新,包括我的原始帖子。
发布于 2022-07-22 19:20:47
我发现了关于这些问题的细节。
在SimpleElasticsearchRepository初始化期间,它会执行以下操作。我的索引是createIndex = true。因此,它将检查是否存在()。但是索引在这里是空的,所以HEAD / my_index变成HEAD /。
我不知道为什么索引在这里是空的。但我将createIndex = false设为跳过它。
if (this.shouldCreateIndexAndMapping() && !this.indexOperations.exists()) {
this.indexOperations.createWithMapping();
}根据我的测试,GET /正在每个会话发送一次。它的作用就像网络连接性测试。如果有任何错误,它将被忽略。
//MainClientExec - exchange: 1开始执行-- GET / HTTP/1.1\r -每个会话一次
11:58:46.648 [main] DEBUG org.apache.http.impl.nio.client.MainClientExec - [exchange: 1] start execution
11:58:46.967 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> GET / HTTP/1.1
11:58:46.967 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> X-Elastic-Client-Meta: es=7.17.4p,jv=1.8,t=7.17.4p,hc=4.1.4,kt=1.6,gy=2.4
11:58:46.967 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Length: 0
11:58:46.967 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: xxx.azure.elastic-cloud.com:9243
11:58:46.967 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive
11:58:46.967 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: elasticsearch-java/7.17.4-SNAPSHOT (Java/1.8.0_331)
11:58:46.967 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> Authorization: Basic xxx
11:58:47.105 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 403 Forbidden[\r][\n]"
11:58:47.105 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Length: 4157[\r][\n]"
11:58:47.105 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Type: application/json; charset=UTF-8[\r][\n]"
11:58:47.105 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "X-Cloud-Request-Id: 3TA-1pHlTXuLbAoue0rKZw[\r][\n]"
11:58:47.105 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "X-Elastic-Product: Elasticsearch[\r][\n]"
11:58:47.105 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "X-Found-Handling-Cluster: aaf9bff719c349bbad7a015615a994f7[\r][\n]"
11:58:47.105 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "X-Found-Handling-Instance: instance-0000000001[\r][\n]"
11:58:47.105 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "Date: Fri, 22 Jul 2022 16:58:46 GMT[\r][\n]"
11:58:47.105 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
11:58:47.105 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "{"error":{"root_cause":[{"type":"security_exception","reason":"action [cluster:monitor/main] is unauthorized for user
11:58:47.115 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 403 Forbidden
11:58:47.115 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.MainClientExec - [exchange: 1] Response received HTTP/1.1 403 Forbidden
11:58:47.126 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.InternalIODispatch - http-outgoing-0 [ACTIVE(4157)] Input ready
11:58:47.126 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.MainClientExec - [exchange: 1] Consume content
11:58:47.131 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.InternalHttpAsyncClient - [exchange: 1] Connection can be kept alive indefinitely
11:58:47.131 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.MainClientExec - [exchange: 1] Response processed
11:58:47.131 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.InternalHttpAsyncClient - [exchange: 1] releasing connection
11:58:47.131 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl - http-outgoing-0
11:58:47.131 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager - Releasing connection: [id: http-outgoing-0][route: {s}->https://
11:58:47.131 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager - Connection [id: http-outgoing-0][route: {s}->https://
11:58:47.132 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl - http-outgoing-0 10.2
11:58:47.133 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager - Connection released: [id: http-outgoing-0][然后,发送真正的查询。
//MainClientExec - exchange: 2开始执行- GET /my_index/_doc/asdf HTTP/1.1
11:58:47.137 [main] DEBUG org.apache.http.impl.nio.client.MainClientExec - [exchange: 2] start execution
11:58:47.147 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> GET /my_index/_doc/asdf HTTP/1.1
11:58:47.147 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> X-Elastic-Client-Meta: es=7.17.4p,jv=1.8,t=7.17.4p,hc=4.1.4,kt=1.6,gy=2.4
11:58:47.147 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Length: 0
11:58:47.147 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: xxx.azure.elastic-cloud.com:9243
11:58:47.147 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive
11:58:47.147 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: elasticsearch-java/7.17.4-SNAPSHOT (Java/1.8.0_331)
11:58:47.147 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> Authorization: Basic xx==
11:58:47.148 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl - http-outgoing-0 10.24.15.131:58069<->52.158.162.229:9243[ACTIVE][rw:w][ACTIVE][rw][NOT_HANDSHAKING][0][0][0]: Event set [w]
11:58:47.148 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.MainClientExec - [exchange: 2] Request completed
11:58:47.148 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl - http-outgoing-0 10.24.15.131:58069<->52.158.162.229:9243[ACTIVE][rw:w][ACTIVE][rw][NOT_HANDSHAKING][0][0][372]: 343 bytes written
11:58:47.148 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 >> "GET /my_index/_doc/asdf HTTP/1.1[\r][\n]"
11:58:47.148 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 >> "X-Elastic-Client-Meta: es=7.17.4p,jv=1.8,t=7.17.4p,hc=4.1.4,kt=1.6,gy=2.4[\r][\n]"https://stackoverflow.com/questions/73055858
复制相似问题