Skip to content
andreasronge edited this page Dec 28, 2012 · 26 revisions

Introduction

Neo4j.rb (any of the neo4j-core, neo4j-wrapper and neo4j gems) can be used in a HA Cluster. The Neo4j HA Cluster can also be useful as a development tool. By using HA cluster you can have write support for the rails console, or use the Neo4j Server Admin UI to monitoring and debugging the graph database.

More info: Neo4j HA documentation and HA Cluster for example of Neo4j::Config configuration. Also check the license for neo4j-enterprise (different to neo4j-community).

Rails Console with Write Support

The rails console will start up in read-only mode if you already have a running rails application since Neo4j does not allow write access to the database from several processes.

As a workaround you can use Neo4j HA which will replicate databases between processes. To enable write access from a rails console using Neo4j HA:

  • Add development dependencies to your Gemfile: neo4j-advanced and neo4j-enterprise, example:
gem 'neo4j-community', '1.9.M03'
gem 'neo4j-advanced', '1.9.M03'
gem 'neo4j-enterprise', '1.9.M03'
  • in your application/config.rb, add
require 'neo4j/rails/ha_console/railtie' if Rails.env.development?
  • in config/application.rb : config.neo4j.storage_path = ... unless Rails.env.development? This is needed since the ha_console/railties will set the location of the database (rails console and rails server will have different databases which will be synchronized).

This works in neo4j version 2.2.3

Using the Neo4j Server Admin

Follow the instruction above for using rails console with write support.

  • Download the neo4j-enterprise from here.
  • Unpack the file.
  • Edit the conf/neo4j.properties file
ha.server_id=3
ha.initial_hosts=localhost:5001,localhost:5002,localhost:5003
ha.server=localhost:6003
ha.cluster_server=localhost:5003
ha.pull_interval=1
  • Edit the conf/neo4j-server.properties
# Uncomment this line:
org.neo4j.server.database.mode=HA

Notice its possible to use both the rails console using Neo4j HA and at the same time use the Neo4j Server UI using Neo4j HA.

Clone this wiki locally