multiple versions of neo4j server at the same machine

前端 未结 3 1396
青春惊慌失措
青春惊慌失措 2020-12-21 04:37

I downloaded 2 versions of neo4j on Ubuntu 18.04 which are \"neo4j-community-3.5.12\" and \"neo4j-community-3.5.8\"

I run 3.5.8 with default settings I can see it fr

相关标签:
3条回答
  • 2020-12-21 04:54

    Considering the docker commands-

    cmd1: sudo docker run --name db1 -p7474:7474 -p7687:7687 -d -v /db1/data:/data -v /db1/logs:/logs -v /db1/conf:/conf --env NEO4J_AUTH=none neo4j


    cmd2: sudo docker run --name db2 -p3001:7474 -p3002:7473 -p3003:7687 -d -v /db2/data:/data -v /db2/logs:/logs -v /db2/conf:/conf --env NEO4J_AUTH=none neo4j

    The container ports are defaults exposed as the same host port for db1 instance. Whereas for db2 instance series 3xxx has been used.

    To browse the UI provided by neo4j, you can use either 7474 or 3001 port which is mapped to 7474 container port.


    Neo4j browser uses defaults (from neo4j.conf) to connect to neo4j server. The default settings are as bolt://<machineip>:7687, where db1 instance has already exposed the container port to 7687 host port. A running instance is found on 7687 port which initiates a WebSocket connection for db1 and db2.


    How to connect to an appropriate instance?

    1. Use: :server disconnect and :server connect with the appropriate bolt://<machineip>:port connection string

    2. Map db1 instance bolt container port to different host port (i.e. other than 7687) As no defaults will be available

    3. (Preferred), set the same hostport:containerport combination e.g.

      cmd2: sudo docker run --name db2 -p3001:7474 -p3002:7473 -p3003:3003-d -v /db2/data:/data -v /db2/logs:/logs -v /db2/conf:/conf --env NEO4J_AUTH=none neo4j

      in this case, a Volume has to be mapped to provide neo4j.conf with updated values as dbms.connector.bolt.listen_address=:3003

    0 讨论(0)
  • 2020-12-21 05:04

    After a lot of effort, my solution is not to use docker.

    Go and download a community server from here. https://neo4j.com/download-center/#community. It will give you a compressed file. Extract it. You will have a folder named like neo4j-community-3.5.14. Make a copy of THAT FOLDER. For each server instance, make a copy.

    Inside the folder, there is a conf folder which has a file named neo4j.conf. Open that file. By changing some settings inside this folder, you can run many neo4j servers. Change the below settings

    To accept non-local connections, uncomment this line:

    dbms.connectors.default_listen_address=0.0.0.0

    change some port numbers so that they won't intersect with already used ones

    dbms.connector.bolt.listen_address=:3003 dbms.connector.https.listen_address=:3002 dbms.connector.http.listen_address=:3001

    0 讨论(0)
  • 2020-12-21 05:11

    In case anybody still needs it: Here is how to run two neo4j databases neo4j_01 and neo4j_02 in two different docker containers, saving the data in different directories and accessing them on different ports.

    docker container 1: neo4j_01

    docker run \
        --name neo4j_01 \
        -p1474:7474 -p1687:7687 \
        -d \
        -v $HOME/neo4j_01/neo4j/data:/data \
        -v $HOME/neo4j_01/neo4j/logs:/logs \
        -v $HOME/neo4j_01/neo4j/import:/var/lib/neo4j/import \
        -v $HOME/neo4j_01/neo4j/plugins:/plugins \
        --env NEO4J_AUTH=username/enterpasswordhere \
        neo4j:latest
    

    docker container 2: neo4j_02

        docker run \
        --name neo4j_02 \
        -p2474:7474 -p2687:7687 \
        -d \
        -v $HOME/neo4j_02/neo4j/data:/data \
        -v $HOME/neo4j_02/neo4j/logs:/logs \
        -v $HOME/neo4j_02/neo4j/import:/var/lib/neo4j/import \
        -v $HOME/neo4j_02/neo4j/plugins:/plugins \
        --env NEO4J_AUTH=username/enterpasswordhere \
        neo4j:latest
    

    After executing the code above e.g. neo4j_01 can be reached on port 1474 (when logging in you need to change the bolt port to 1687 in the first line and then enter username and password in second and third line)

    You can stop a container with docker kill neo4j_01 and restart it with docker start neo4j_01. Data will still be there. It is saved in $HOME/neo4j_01/neo4j/data.

    Doing it like this, I did not encounter any problems with ports/ accessing the wrong database etc.

    0 讨论(0)
提交回复
热议问题