拒绝连接

wz3gfoph  于 2021-06-10  发布在  ElasticSearch
关注(0)|答案(0)|浏览(305)

我对docker compose的liferay+elasticsearch设置有问题。启动compose bundle时,liferay抱怨无法连接到远程elasticsearch示例,但出现以下异常:

2020-11-15 21:39:55.042 ERROR [main][ElasticsearchEngineConfigurator:93] bundle com.liferay.portal.search.elasticsearch7.impl:2.0.30 (655)[com.liferay.portal.search.elasticsearch7.internal.ElasticsearchEngineConfigurator(1604)] : The activate method has thrown an exception 
 java.lang.RuntimeException: java.net.ConnectException: Connection refused
  at com.liferay.portal.search.elasticsearch7.internal.search.engine.adapter.cluster.HealthClusterRequestExecutorImpl.getClusterHealthResponse(HealthClusterRequestExecutorImpl.java:102)
  at com.liferay.portal.search.elasticsearch7.internal.search.engine.adapter.cluster.HealthClusterRequestExecutorImpl.execute(HealthClusterRequestExecutorImpl.java:49)
  at com.liferay.portal.search.elasticsearch7.internal.search.engine.adapter.cluster.ElasticsearchClusterRequestExecutor.executeClusterRequest(ElasticsearchClusterRequestExecutor.java:51)
  at com.liferay.portal.search.engine.adapter.cluster.HealthClusterRequest.accept(HealthClusterRequest.java:40)
  at com.liferay.portal.search.engine.adapter.cluster.HealthClusterRequest.accept(HealthClusterRequest.java:22)
  at com.liferay.portal.search.elasticsearch7.internal.search.engine.adapter.cluster.ElasticsearchClusterRequestExecutor.execute(ElasticsearchClusterRequestExecutor.java:44)
  at com.liferay.portal.search.elasticsearch7.internal.search.engine.adapter.ElasticsearchSearchEngineAdapterImpl.execute(ElasticsearchSearchEngineAdapterImpl.java:69)
  at com.liferay.portal.search.elasticsearch7.internal.ElasticsearchSearchEngine.waitForYellowStatus(ElasticsearchSearchEngine.java:334)
  at com.liferay.portal.search.elasticsearch7.internal.ElasticsearchSearchEngine.initialize(ElasticsearchSearchEngine.java:109)
  at com.liferay.portal.kernel.search.SearchEngineProxyWrapper.initialize(SearchEngineProxyWrapper.java:59)
  at com.liferay.portal.search.elasticsearch7.internal.BaseSearchEngineConfigurator.setSearchEngine(BaseSearchEngineConfigurator.java:500)
  at com.liferay.portal.search.elasticsearch7.internal.BaseSearchEngineConfigurator.initSearchEngine(BaseSearchEngineConfigurator.java:407)
  at com.liferay.portal.search.elasticsearch7.internal.BaseSearchEngineConfigurator.initialize(BaseSearchEngineConfigurator.java:341)
  at com.liferay.portal.search.elasticsearch7.internal.ElasticsearchEngineConfigurator.activate(ElasticsearchEngineConfigurator.java:52)
    # Loong stack trace with Casued by "java.net.ConnectException: Connection refused"

同时,我可以通过curl连接到机器,它们会响应:

liferay@a4b06641f395 /opt/liferay 
$ curl es-node-1:9200
{
  "name" : "es-node-1",
  "cluster_name" : "docker-elasticsearch",
  "cluster_uuid" : "iUW--n_ORe-zv40sBzUdpQ",
  "version" : {
    "number" : "7.9.3",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "c4138e51121ef06a6404866cddc601906fe5c868",
    "build_date" : "2020-10-16T10:36:16.141335Z",
    "build_snapshot" : false,
    "lucene_version" : "8.6.2",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

liferay@a4b06641f395 /opt/liferay 
$ curl es-node-1:9300
curl: (1) Received HTTP/0.9 when not allowed

我有追随者 docker-compose.yml 文件:

version: '3.2'

services:
  web:
    image: liferay/portal:7.3.4-ga5
    ports:
      - "3002:8080"
    depends_on:
      - appdb
      - liferaydb
      - es-node-1
      - es-node-2
    environment:
      LIFERAY_LIFERAY_PERIOD_HOME: /opt/liferay
      LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_DRIVER_UPPERCASEC_LASS_UPPERCASEN_AME: com.mysql.cj.jdbc.Driver
      LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_USERNAME: user
      LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_URL: jdbc:mysql://liferaydb/liferay_db?useFastDateParsing=false
      LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_PASSWORD: user_pass
      LIFERAY_PASSWORDS_PERIOD_ENCRYPTION_PERIOD_ALGORITHM_PERIOD_LEGACY: SHA
      LIFERAY_WEB_PERIOD_SERVER_PERIOD_HTTP_PERIOD_PORT: 8080
      LIFERAY_WEB_PERIOD_SERVER_PERIOD_PROTOCOL: http
      LIFERAY_WEB_PERIOD_SERVER_PERIOD_HOST: liferay.dev
      LIFERAY_LIVE_PERIOD_USERS_PERIOD_ENABLED: 1
    volumes:
      - ${PWD}/static/portal-ext.properties:/opt/liferay/portal-ext.properties
      - ${PWD}/deploy:/opt/liferay/deploy
      - ${PWD}/data/VAADIN:/opt/liferay/tomcat/webapps/ROOT/html/VAADIN
      - ${PWD}/static/ElasticsearchConfiguration.config:/opt/liferay/osgi/configs/com.liferay.portal.search.elasticsearch7.configuration.ElasticsearchConfiguration.config

  appdb:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: root_pass
      MYSQL_DATABASE: portlet_db
      MYSQL_USER: user
      MYSQL_PASSWORD: user_pass
    volumes:
      - ${PWD}/data/appdb:/var/lib/mysql

  liferaydb:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: root_pass
      MYSQL_DATABASE: liferay_db
      MYSQL_USER: user
      MYSQL_PASSWORD: user_pass
    volumes:
      - ${PWD}/data/liferaydb:/var/lib/mysql

  es-node-1:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.9.3
    environment:
      - node.name=es-node-1
      - cluster.name=docker-elasticsearch
      - bootstrap.memory_lock=true
      - discovery.seed_hosts=es-node-2
      - cluster.initial_master_nodes=es-node-1,es-node-2
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    deploy:
      resources:
        limits:
          memory: 1g
    volumes:
      - esdata1:/usr/share/elasticsearch/data
    ports:
      - 9200:9200

  es-node-2:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.9.3
    environment:
      - node.name=es-node-2
      - cluster.name=docker-elasticsearch
      - bootstrap.memory_lock=true
      - discovery.seed_hosts=es-node-1
      - cluster.initial_master_nodes=es-node-1,es-node-2
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata2:/usr/share/elasticsearch/data

volumes:
  esdata1:
  esdata2:

的内容 portal-ext.properties 为我的portlet定义数据源:

jdbc.ext.driverClassName=com.mysql.cj.jdbc.Driver
jdbc.ext.url=jdbc:mysql://appdb:3306/portlet_db
jdbc.ext.username=user
jdbc.ext.password=user_pass

的内容 ElasticsearchConfiguration.config 定义弹性连接:

operationMode=REMOTE
transportAddresses=["es-node-1:9300","es-node-2:9300"]
clusterName=docker-elasticsearch
logExceptionsOnly=true

有人知道怎么了吗?我试过在句子中加引号和不加引号 .config 但我好像不工作。
另外,我在liferay论坛上也问了同样的问题:https://liferay.dev/ask#/questions/portal/liferay-7-3-on-docker-with-elasticsearch-connection-拒绝

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题