Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

graph databases - multiple versions of neo4j server at the same machine

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 from the web. http://localhost:7474/

For 3.5.12 I changed conf/neo4j.conf file and set some other port numbers for not to conflict with the default ones.

3.5.8 version runs fine on :7474. When I start 3.5.12, the logs says it is running but when I check from browser it is not running. I tried 2 different port settings, none worked. Below is the log file. enter image description here

Why it is not running?

I see that many people recommended using docker. I also tried that.

I set up docker a container with command 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

here I have an existing /d1/data/databases/graph.db folder. When I go to localhost:7474 it is fine it shows me the existing database.

I set up another docker container with command 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

here I expect to see an EMPTY database but I see the already existing database again. When I go to the data folder inside db2. I see that it created some files here. WHY do I see the same database?

enter image description here

Also note that when I go to see the databases, headers of the web pages showing they are using the same bolt port?

can I copy the neo4j image and use different images to generate containers? Does that help?

I recognized that multiple databases are running and active but somehow I'm not able to reach the second one through a browser.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...