- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用SpringData将我的应用程序连接到Elastic search本地实例。当我执行常规的curl
获取ES信息时,它可以正常工作,但是我无法从Springboot应用程序连接到它。
Elasticsearch本地版本./elasticsearch -V => Version: 7.6.0
SpringData Elastic搜索版本3.1.11
> curl -XGET 'http://localhost:9200/_cluster/state?pretty'
{
"cluster_name" : "elasticsearch",
"cluster_uuid" : "1_8HMIK5QDug_xH80VZLgQ",
"version" : 54,
"state_uuid" : "YEe1FSwfRUuw0uw-T69fJQ",
"master_node" : "Nbktx7KrREetbyfL7v0Fog",
"blocks" : { },
"nodes" : {
"Nbktx7KrREetbyfL7v0Fog" : {
"name" : "k***-macOS",
"ephemeral_id" : "pqMw40oPTUmBoHsyTAz9cg",
"transport_address" : "127.0.0.1:9301",
"attributes" : {
"ml.machine_memory" : "17179869184",
"xpack.installed" : "true",
"ml.max_open_jobs" : "20"
}
}
},
@Value("$ELASTIC_HOST")
private String EsHost;
@Value("$ELASTIC_PORT")
private String EsPort;
@Bean
public ElasticsearchOperations elasticsearchTemplate() throws UnknownHostException {
return new ElasticsearchTemplate(elasticsearchClient());
}
@Bean
public Client elasticsearchClient() throws UnknownHostException {
Settings settings = Settings.builder()
.put("client.transport.sniff", true).build();
TransportClient client = new PreBuiltTransportClient(settings);
client.addTransportAddress( new TransportAddress(InetAddress.getByName(EsHost), Integer.valueOf(EsPort));
return client;
}
elasticsearch.yml
是默认文件,没有添加任何显式主机或端口。
Docker-compose
version: '3'
services:
elastic:
restart: always
image: docker.elastic.co/elasticsearch/elasticsearch:6.2.2
environment:
- cluster.name=elasticsearch
- node.name=es01
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
ports:
- "9201:9200"
- "9301:9300"
db:
restart: always
image: postgres
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: 'xxx'
POSTGRES_USER: 'xx'
POSTGRES_DB: 'xx'
api:
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:8080"
environment:
ENVIRONMENT_NAME: "dev"
REGION_NAME: "local"
POSTGRES_PASSWORD: "xx"
POSTGRES_USER: "xx"
POSTGRES_HOST: "db"
ELASTIC_HOST: "elastic"
ELASTIC_PORT: "9200"
depends_on:
- db
- elastic
ERROR:
"failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{JjFZc4y-RBCYbdELAsgaAQ}{elastic}{172.20.0.2:9200}]"}
It works if I change this to
environment:
ENVIRONMENT_NAME: "dev"
REGION_NAME: "local"
POSTGRES_PASSWORD: "xxx"
POSTGRES_USER: "xx"
POSTGRES_HOST: "db"
ELASTIC_HOST: "elastic"
ELASTIC_PORT: "9300" --> this is changed from 9200
client.addTransportAddress(new TransportAddress(InetAddress.getLocalHost(), 9201));
最佳答案
Spring Data Elasticsearch 3.1.11是使用版本6.2.2中的Elasticsearch客户端库构建的。因此,即使您设法与集群建立连接,客户端和集群之间也无法正常通信的机会非常高。
至于连接的设置:您应该将要连接的集群的名称添加到设置中:
Settings settings = Settings.builder()
.put("client.transport.sniff", true)
.put("cluster.name", "elasticsearch")
.build();
关于elasticsearch - SpringData Elasticsearch NoNodeAvailableException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60572213/
我从Elasticsearch得到以下错误。 `Apache Tomcat/7.0.64 - Error report HTTP Status 500 - Request processing fai
如果我没有设置大小,我将获得10次点击: SearchResponse sr = client.prepareSearch("xxx").setTypes("xxx")
尝试使用 ES 2 的 Java API 连接到 Elasticsearch 2 时出现以下错误。这是代码: Settings settings = Settings.settingsBuilder(
我正在使用SpringData将我的应用程序连接到Elastic search本地实例。当我执行常规的curl获取ES信息时,它可以正常工作,但是我无法从Springboot应用程序连接到它。 Ela
我使用 Cassandra docker 镜像,在 docker 容器上运行的 Spring Boot 服务,并使用 Datastax Java 驱动程序。 我可以使用下面的 docker compo
我尝试使用https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-docs-get.html , Elas
Settings settings = Settings.settingsBuilder() .put("cluster.name", "logging_elastic
无法连接到我的 Elasticsearch,开始于: docker-compose up 运行命令: curl -XGET http://localhost:9200/_nodes/http?pret
我正在像这样运行 elasticsearch 图像:docker-compose.yml version: '2' services: elasticsearch: image: elas
我没有使用 Elasticssearch。我正在尝试使用 CQL 在 cassandra 中执行一些数据库操作。我正在使用线程。运行代码时,我总是在一段时间后在线程中遇到异常:com.datastax
我正在尝试从我的 Java Web 服务中的 Elastic Search 进行搜索,这是我现在的使用方式: Client client = new PreBuiltTransportClie
我正在使用 Elasticsearch 5.2 和 Spring Boot 1.5.1。我通过 Spring 应用程序中的 Java 客户端连接到它。当我在端口 9300 或 9200 上连接到它时,
我从Install Elasticsearch with Docker下载了图像 并运行以下命令来启动: docker run -p 9200:9200 -p 9300:9300 -e "discov
我正在尝试通过给定的示例之一来了解 elastic4s here 但是当我尝试通过 TcpClient.transport 连接时,我不断收到以下异常: Exception in thread "ma
我决定在一个简单的待办事项列表应用程序中尝试首次使用 elasticsearch。我关注了this video要使用该模块并且不对模块本身进行任何修改,我所做的就是创建应用程序并在 Controlle
public static void main(String[] args) throws IOException { Settings settings = ImmutableSetting
在 Google Compute Engine 上,我创建了 3 个虚拟机并在其上安装了 Elasticsearch 5.1.2。我安装了用于单播发现的GCE Discovery Plugin。 从我
我已将 elasticsearch 版本从 elasticsearch-0.90.7 更新到 elasticsearch-1.3.1,并且应用程序在 elasticsearch-0.90.7 中运行正
我正在使用带防护罩和传输 Java 客户端的弹性云(以前发现的)。与 ES 通信的应用程序运行在 heroku 上。我正在使用一个节点在暂存环境中运行压力测试 { "cluster_name"
我正在运行 Elasticsearch v. 2.3.2 ,使用 Java 7。以下是 curl http://172.31.11.83:9200 的打印输出: { "name" : "ip-17
我是一名优秀的程序员,十分优秀!