gpt4 book ai didi

node.js - docker-compose中的Node和Neo4J

转载 作者:行者123 更新时间:2023-12-02 21:05:22 26 4
gpt4 key购买 nike

我试图在因果群集模式下运行neo4J。所有这些都应在docker-compose.yml内的配置下在docker中运行。集群的所有实例都在运行,但是当我尝试通过Node.js(当然也由相同的docker-compose.yml运行)连接到neo4J时,我得到的是:Neo4j :: executeQuery :: Error Neo4jError: getaddrinfo ENOTFOUND neo4j。我如何使它工作,即。在docker容器内以因果群集模式从节点连接到neo4J。这是我的docker-compose.yml:

version: '3'

networks:
lan:

services:

app:
build:
dockerfile: Dockerfile.dev
context: ./
links:
- core1
- core2
- core3
- read1
volumes:
- /app/node_modules
- ./:/app
ports:
- '3000:3000'
environment:
- REACT_APP_NEO4J_HOST=bolt://neo4j

core1:
image: neo4j:3.5.11-enterprise
networks:
- lan
ports:
- 7474:7474
- 6477:6477
- 7687:7687
volumes:
- $HOME/neo4j/neo4j-core1/conf:/conf
- $HOME/neo4j/neo4j-core1/data:/data
- $HOME/neo4j/neo4j-core1/logs:/logs
- $HOME/neo4j/neo4j-core1/plugins:/plugins
environment:
- REACT_APP_NEO4J_HOST=bolt://neo4j
- NEO4J_AUTH=neo4j/changeme
- NEO4J_dbms_mode=CORE
- NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
- NEO4J_causal__clustering_minimum__core__cluster__size__at__formation=3
- NEO4J_causal__clustering_minimum__core__cluster__size__at__runtime=3
- NEO4J_causal__clustering_initial__discovery__members=core1:5000,core2:5000,core3:5000
- NEO4J_dbms_connector_http_listen__address=:7474
- NEO4J_dbms_connector_https_listen__address=:6477
- NEO4J_dbms_connector_bolt_listen__address=:7687

core2:
image: neo4j:3.5.11-enterprise
networks:
- lan
ports:
- 7475:7475
- 6478:6478
- 7688:7688
volumes:
- $HOME/neo4j/neo4j-core2/conf:/conf
- $HOME/neo4j/neo4j-core2/data:/data
- $HOME/neo4j/neo4j-core2/logs:/logs
- $HOME/neo4j/neo4j-core1/plugins:/plugins
environment:
- REACT_APP_NEO4J_HOST=bolt://neo4j
- NEO4J_AUTH=neo4j/changeme
- NEO4J_dbms_mode=CORE
- NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
- NEO4J_causal__clustering_minimum__core__cluster__size__at__formation=3
- NEO4J_causal__clustering_minimum__core__cluster__size__at__runtime=3
- NEO4J_causal__clustering_initial__discovery__members=core1:5000,core2:5000,core3:5000
- NEO4J_dbms_connector_http_listen__address=:7475
- NEO4J_dbms_connector_https_listen__address=:6478
- NEO4J_dbms_connector_bolt_listen__address=:7688

core3:
image: neo4j:3.5.11-enterprise
networks:
- lan
ports:
- 7476:7476
- 6479:6479
- 7689:7689
volumes:
- $HOME/neo4j/neo4j-core3/conf:/conf
- $HOME/neo4j/neo4j-core3/data:/data
- $HOME/neo4j/neo4j-core3/logs:/logs
- $HOME/neo4j/neo4j-core1/plugins:/plugins
environment:
- REACT_APP_NEO4J_HOST=bolt://neo4j
- NEO4J_AUTH=neo4j/changeme
- NEO4J_dbms_mode=CORE
- NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
- NEO4J_causal__clustering_minimum__core__cluster__size__at__formation=3
- NEO4J_causal__clustering_minimum__core__cluster__size__at__runtime=3
- NEO4J_causal__clustering_initial__discovery__members=core1:5000,core2:5000,core3:5000
- NEO4J_dbms_connector_http_listen__address=:7476
- NEO4J_dbms_connector_https_listen__address=:6479
- NEO4J_dbms_connector_bolt_listen__address=:7689

read1:
image: neo4j:3.5.11-enterprise
networks:
- lan
ports:
- 7477:7477
- 6480:6480
- 7690:7690
volumes:
- $HOME/neo4j/neo4j-read1/conf:/conf
- $HOME/neo4j/neo4j-read1/data:/data
- $HOME/neo4j/neo4j-read1/logs:/logs
- $HOME/neo4j/neo4j-core1/plugins:/plugins
environment:
- REACT_APP_NEO4J_HOST=bolt://neo4j
- NEO4J_AUTH=neo4j/changeme
- NEO4J_dbms_mode=READ_REPLICA
- NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
- NEO4J_causalClustering_initialDiscoveryMembers=core1:5000,core2:5000,core3:5000
- NEO4J_dbms_connector_http_listen__address=:7477
- NEO4J_dbms_connector_https_listen__address=:6480
- NEO4J_dbms_connector_bolt_listen__address=:7690

还有我的DockerFile.dev:
FROM node:alpine
WORKDIR '/app'
RUN apk update && apk add yarn python g++ make && rm -rf /var/cache/apk/*
COPY ./package.json ./
RUN npm install
COPY . .
CMD ["npm", "run", "start"]

最佳答案

1)该应用程序应连接到同一网络。

app:
networks:
- lan

2)假设网络已经存在,名称为“lan”或创建一个新网络
  networks:
lan:
driver: bridge

3)docker-中的 不推荐使用“链接”-
  app:
build:
dockerfile: Dockerfile.dev
context: ./
links:
- core1
- core2
- core3
- read1

代替此用法- depends_on(如果需要保持加载顺序)

=======================

编辑请阅读有关后续问题的评论

关于node.js - docker-compose中的Node和Neo4J,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58412619/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com