Set up an HA cluster

Download and configure

  1. Download Neo4j Enterprise Edition from the Neo4j download site, and unpack on three separate machines.

  2. Configure the HA related settings for each installation as outlined below. Note that all three installations have the same configuration except for the ha.server_id property.

Example 1. Configuration of neo4j.conf for each of the three HA servers

Neo4j instance #1 on the server named neo4j-01.local

conf/neo4j.conf
# Unique server id for this Neo4j instance
# can not be negative id and must be unique
ha.server_id=1

# List of other known instances in this cluster
ha.initial_hosts=neo4j-01.local:5001,neo4j-02.local:5001,neo4j-03.local:5001
# Alternatively, use IP addresses:
#ha.initial_hosts=192.168.0.20:5001,192.168.0.21:5001,192.168.0.22:5001

# HA - High Availability
# SINGLE - Single mode, default.
dbms.mode=HA

# HTTP Connector
dbms.connector.http.enabled=true
dbms.connector.http.listen_address=:7474

Neo4j instance #2 on the server named neo4j-02.local

conf/neo4j.conf
# Unique server id for this Neo4j instance
# can not be negative id and must be unique
ha.server_id=2

# List of other known instances in this cluster
ha.initial_hosts=neo4j-01.local:5001,neo4j-02.local:5001,neo4j-03.local:5001
# Alternatively, use IP addresses:
#ha.initial_hosts=192.168.0.20:5001,192.168.0.21:5001,192.168.0.22:5001

# HA - High Availability
# SINGLE - Single mode, default.
dbms.mode=HA

# HTTP Connector
dbms.connector.http.enabled=true
dbms.connector.http.listen_address=:7474

Neo4j instance #3 on the server named neo4j-03.local

conf/neo4j.conf
# Unique server id for this Neo4j instance
# can not be negative id and must be unique
ha.server_id=3

# List of other known instances in this cluster
ha.initial_hosts=neo4j-01.local:5001,neo4j-02.local:5001,neo4j-03.local:5001
# Alternatively, use IP addresses:
#ha.initial_hosts=192.168.0.20:5001,192.168.0.21:5001,192.168.0.22:5001

# HA - High Availability
# SINGLE - Single mode, default.
dbms.mode=HA

# HTTP Connector
dbms.connector.http.enabled=true
dbms.connector.http.listen_address=:7474

Start the Neo4j Servers

Start the Neo4j servers as usual. Note that the startup order does not matter.

Example 2. Start the three HA servers
neo4j-01$ ./bin/neo4j start
neo4j-02$ ./bin/neo4j start
neo4j-03$ ./bin/neo4j start
Startup Time

When running in HA mode, the startup script returns immediately instead of waiting for the server to become available. The database will be unavailable until all members listed in ha.initial_hosts are online and communicating with each other. In the example above this happens when you have started all three instances. To keep track of the startup state you can follow the messages in neo4j.log — the path is printed before the startup script returns.

Now, you should be able to access the three servers and check their HA status. Open the locations below in a web browser and issue the following command in the editor after having set a password for the database: :play sysinfo

  • http://neo4j-01.local:7474/

  • http://neo4j-02.local:7474/

  • http://neo4j-03.local:7474/

You can replace database #3 with an 'arbiter' instance, see Arbiter instances.

That is it! You now have a Neo4j HA cluster of three instances running. You can start by making a change on any instance and those changes will be propagated between them. For more cluster related configuration options take a look at Setup and configuration.