Cassie
Cassie

Reputation: 349

Switch active database with Neo4j docker image

I have imported my data to a new Neo4j database instead of the standard graph.db using import tool. I want to switch this database to web Neo4j. I used Neo4j docker image with /var/lib/neo4j volume. But I can't find my config file to change the active database, even after I mount conf directory specifically this file doesn't get generated. How can I switch active Neo4j database in web client or neo4j shell?

Here is the command with which I created neo4j container:

docker run --publish=7474:7474 --publish=7687:7687 --volume=/var/lib/neo4j/import:/var/lib/neo4j/import --env=NEO4J_dbms_allow_upgrade='true' --env=NEO4J_dbms.security.allow_csv_import_from_file_urls='true' neo4j:latest

Upvotes: 1

Views: 1405

Answers (1)

Rebecca Nelson
Rebecca Nelson

Reputation: 1296

You cannot change the active database of a live Neo4J instance.

Enterprise edition does allow for some values to be changed without rebooting; the keys allowed to be changed this way are listed at the online documentation, but dbms.active_database is not one of them.

Instead, you have a few options.

You can mount a /conf directory

The conf directory can be filled with configuration files that will completely override the default ones. They are not generated by Neo4J, you must take an entire neo4j.conf file and place it in the directory which is then mounted to the container. You can change whatever values you need to in that file.

After the mapped directory is updated with the new file, you will need to bounce your image (or exec a bounce of neo4j from within the image).

You can set the active database with an environment variable

Similar to how you've passed in the other environment variables, you can pass in other configuration options. If your new database was called newgraph.db and it resided in the same directory as graph.db, you would need only to pass in --env=NEO4J_dbms_active__database=newgraph.db. If it resides in a different directory, give that directory with --env=NEO4J_dbms_directories_data=/path/to/new/data/dir.

As these are passed as environment variables, changing them requires starting a new Docker image.

You could also build your own image.

The final and perhaps most drastic option would be to create your own image that is based off of neo4j's image and has all of the changes that you need. Typically, this would not be required, but if you want to clean up your invocation of docker and not keep around any mapped configuration directories, this is the way to go. It would also ensure anybody who has your custom image needs no additional configuration; whether this is desirable is up to you and your deployment architecture.

Upvotes: 3

Related Questions