连接被拒绝 - 使用 graphaware 连接 Neo4j/ES docker 个容器
connection refused - connecting Neo4j/ES docker containers with graphaware
我正在尝试使用 graphaware 连接 Neo4j 和 ES docker 容器,我得到了看起来像 docker-to-docker 连接问题。
org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:9201 [/127.0.0.1] failed: Connection refused (Connection refused)
我可以使用浏览器通过 http 访问两个容器数据。在这个阶段我不知道问题到底出在哪里,因为我对这些技术还很陌生。
我使用的版本:
- neo4j: 3.5.3
- 弹性搜索 6.6.1
- graphaware-neo4j-to-elasticsearch-3.5.2.53.11.jar
- graphaware-server-community-all-3.5.2.jar
- graphaware-uuid-3.5.2.53.17.jar
- docker: 18.09.3
这是我的 yml 文件。
version: '3.3'
services:
neo4j:
restart: always
image: neo4j:3.5.3
container_name: neo4j
environment:
- NEO4J_AUTH=none
- NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
- NEO4J_dbms_connector_http_listen__address=:7474
- NEO4J_dbms_connector_https_listen__address=:6477
- NEO4J_dbms_connector_bolt_listen__address=:7687
- NEO4J_dbms_memory_heap_initialSize=16G
- NEO4J_dbms_memory_heap_maxSize=16G
volumes:
- /home/leag/drive53/neo4j/data:/data
- ./neo4j/conf:/conf
- ./neo4j/plugins:/plugins
- /home/leag/drive53/imports:/import
ports:
- 7474:7474
- 7687:7687
networks:
- neo-ela
elastic:
build: .
container_name: elastic_container
volumes:
- ./elasticsearch/data:/usr/share/elasticsearch/data
- ./elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
environment:
- neo4j="http://neo4j"
ports:
- 9201:9201
networks:
- neo-ela
networks:
neo-ela:
driver: bridge
neo4j.conf 文件:
# This setting should only be set once for registering the framework and all the used submodules
dbms.unmanaged_extension_classes=com.graphaware.server=/graphaware
com.graphaware.runtime.enabled=true
#UIDM becomes the module ID:
com.graphaware.module.UIDM.1=com.graphaware.module.uuid.UuidBootstrapper
#optional, default is "uuid". (only if using the UUID module)
com.graphaware.module.UIDM.uuidProperty=uuid
#optional, default is all nodes:
#com.graphaware.module.UIDM.node=hasLabel('Label1') || hasLabel('Label2')
#optional, default is uuidIndex
com.graphaware.module.UIDM.uuidIndex=uuidIndex
#prevent the whole db to be assigned a new uuid if the uuid module is settle up together with neo4j2es
com.graphaware.module.UIDM.initializeUntil=0
#ES becomes the module ID:
com.graphaware.module.ES.2=com.graphaware.module.es.ElasticSearchModuleBootstrapper
#URI of Elasticsearch; elastic works as well
com.graphaware.module.ES.uri=127.0.0.1
#Port of Elasticsearch
com.graphaware.module.ES.port=9201
#optional, protocol of Elasticsearch connection, defaults to http
com.graphaware.module.ES.protocol=http
#optional, Elasticsearch index name, default is neo4j-index
com.graphaware.module.ES.index=neo4j-index
#optional, node property key of a propery that is used as unique identifier of the node. Must be the same as com.graphaware.module.UIDM.uuidProperty (only if using UUID module), defaults to uuid
#use "ID()" to use native Neo4j IDs as Elasticsearch IDs (not recommended)
com.graphaware.module.ES.keyProperty=uuid
#optional, whether to retry if a replication fails, defaults to false
com.graphaware.module.ES.retryOnError=false
#optional, size of the in-memory queue that queues up operations to be synchronised to Elasticsearch, defaults to 10000
com.graphaware.module.ES.queueSize=10000
#optional, size of the batch size to use during re-initialization, defaults to 1000
com.graphaware.module.ES.reindexBatchSize=2000
#optional, specify which nodes to index in Elasticsearch, defaults to all nodes
#com.graphaware.module.ES.node=hasLabel('Label1')
#optional, specify which node properties to index in Elasticsearch, defaults to all properties
#com.graphaware.module.ES.node.property=key != 'age'
#optional, specify whether to send updates to Elasticsearch in bulk, defaults to true (highly recommended)
com.graphaware.module.ES.bulk=true
#optional, read explanation below, defaults to 0
com.graphaware.module.ES.initializeUntil=0
和elasticsearch.yml
network.publish_host: 127.0.0.1
network.host: 127.0.0.1
transport.tcp.port: 9300
http.port: 9201
http.host: 127.0.0.1
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: "X-Requested-With, Content-Type, Content-Length, X-User"
问题很可能是您的 neo4j 正在尝试连接到 elasticsearch 运行 与 neo4j
在同一台机器上
#URI of Elasticsearch; elastic works as well
com.graphaware.module.ES.uri=127.0.0.1
#Port of Elasticsearch
com.graphaware.module.ES.port=9201
Elasticsearch 不在同一台机器上 运行,您应该避免在配置文件中使用 127.0.0.1,尝试将本地主机地址交换为 ES 的本地 dns 地址,这样
#URI of Elasticsearch; elastic works as well
com.graphaware.module.ES.uri=elastic
#Port of Elasticsearch
com.graphaware.module.ES.port=9201
我正在尝试使用 graphaware 连接 Neo4j 和 ES docker 容器,我得到了看起来像 docker-to-docker 连接问题。
org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:9201 [/127.0.0.1] failed: Connection refused (Connection refused)
我可以使用浏览器通过 http 访问两个容器数据。在这个阶段我不知道问题到底出在哪里,因为我对这些技术还很陌生。
我使用的版本:
- neo4j: 3.5.3
- 弹性搜索 6.6.1
- graphaware-neo4j-to-elasticsearch-3.5.2.53.11.jar
- graphaware-server-community-all-3.5.2.jar
- graphaware-uuid-3.5.2.53.17.jar
- docker: 18.09.3
这是我的 yml 文件。
version: '3.3'
services:
neo4j:
restart: always
image: neo4j:3.5.3
container_name: neo4j
environment:
- NEO4J_AUTH=none
- NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
- NEO4J_dbms_connector_http_listen__address=:7474
- NEO4J_dbms_connector_https_listen__address=:6477
- NEO4J_dbms_connector_bolt_listen__address=:7687
- NEO4J_dbms_memory_heap_initialSize=16G
- NEO4J_dbms_memory_heap_maxSize=16G
volumes:
- /home/leag/drive53/neo4j/data:/data
- ./neo4j/conf:/conf
- ./neo4j/plugins:/plugins
- /home/leag/drive53/imports:/import
ports:
- 7474:7474
- 7687:7687
networks:
- neo-ela
elastic:
build: .
container_name: elastic_container
volumes:
- ./elasticsearch/data:/usr/share/elasticsearch/data
- ./elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
environment:
- neo4j="http://neo4j"
ports:
- 9201:9201
networks:
- neo-ela
networks:
neo-ela:
driver: bridge
neo4j.conf 文件:
# This setting should only be set once for registering the framework and all the used submodules
dbms.unmanaged_extension_classes=com.graphaware.server=/graphaware
com.graphaware.runtime.enabled=true
#UIDM becomes the module ID:
com.graphaware.module.UIDM.1=com.graphaware.module.uuid.UuidBootstrapper
#optional, default is "uuid". (only if using the UUID module)
com.graphaware.module.UIDM.uuidProperty=uuid
#optional, default is all nodes:
#com.graphaware.module.UIDM.node=hasLabel('Label1') || hasLabel('Label2')
#optional, default is uuidIndex
com.graphaware.module.UIDM.uuidIndex=uuidIndex
#prevent the whole db to be assigned a new uuid if the uuid module is settle up together with neo4j2es
com.graphaware.module.UIDM.initializeUntil=0
#ES becomes the module ID:
com.graphaware.module.ES.2=com.graphaware.module.es.ElasticSearchModuleBootstrapper
#URI of Elasticsearch; elastic works as well
com.graphaware.module.ES.uri=127.0.0.1
#Port of Elasticsearch
com.graphaware.module.ES.port=9201
#optional, protocol of Elasticsearch connection, defaults to http
com.graphaware.module.ES.protocol=http
#optional, Elasticsearch index name, default is neo4j-index
com.graphaware.module.ES.index=neo4j-index
#optional, node property key of a propery that is used as unique identifier of the node. Must be the same as com.graphaware.module.UIDM.uuidProperty (only if using UUID module), defaults to uuid
#use "ID()" to use native Neo4j IDs as Elasticsearch IDs (not recommended)
com.graphaware.module.ES.keyProperty=uuid
#optional, whether to retry if a replication fails, defaults to false
com.graphaware.module.ES.retryOnError=false
#optional, size of the in-memory queue that queues up operations to be synchronised to Elasticsearch, defaults to 10000
com.graphaware.module.ES.queueSize=10000
#optional, size of the batch size to use during re-initialization, defaults to 1000
com.graphaware.module.ES.reindexBatchSize=2000
#optional, specify which nodes to index in Elasticsearch, defaults to all nodes
#com.graphaware.module.ES.node=hasLabel('Label1')
#optional, specify which node properties to index in Elasticsearch, defaults to all properties
#com.graphaware.module.ES.node.property=key != 'age'
#optional, specify whether to send updates to Elasticsearch in bulk, defaults to true (highly recommended)
com.graphaware.module.ES.bulk=true
#optional, read explanation below, defaults to 0
com.graphaware.module.ES.initializeUntil=0
和elasticsearch.yml
network.publish_host: 127.0.0.1
network.host: 127.0.0.1
transport.tcp.port: 9300
http.port: 9201
http.host: 127.0.0.1
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: "X-Requested-With, Content-Type, Content-Length, X-User"
问题很可能是您的 neo4j 正在尝试连接到 elasticsearch 运行 与 neo4j
在同一台机器上#URI of Elasticsearch; elastic works as well
com.graphaware.module.ES.uri=127.0.0.1
#Port of Elasticsearch
com.graphaware.module.ES.port=9201
Elasticsearch 不在同一台机器上 运行,您应该避免在配置文件中使用 127.0.0.1,尝试将本地主机地址交换为 ES 的本地 dns 地址,这样
#URI of Elasticsearch; elastic works as well
com.graphaware.module.ES.uri=elastic
#Port of Elasticsearch
com.graphaware.module.ES.port=9201