Appendix B. Tutorial

This chapter contains tutorials for deploying and operating Neo4j.

B.1. Set up a Neo4j cluster

This guide will give step-by-step instructions for setting up a basic cluster of three separate machines. For a description of the clustering architecture and related design considerations, refer to Introduction.

B.1.1. Download and configure

  • Download Neo4j Enterprise Edition from the Neo4j download site, and unpack on three separate machines.
  • 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.
Neo4j instance #1 — 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

dbms.connector.http.type=HTTP
dbms.connector.http.enabled=true
dbms.connector.http.address=0.0.0.0:7474

Neo4j instance #2 — 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

dbms.connector.http.type=HTTP
dbms.connector.http.enabled=true
dbms.connector.http.address=0.0.0.0:7474

Neo4j instance #3 — 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

dbms.connector.http.type=HTTP
dbms.connector.http.enabled=true
dbms.connector.http.address=0.0.0.0:7474

B.1.2. Start the Neo4j Servers

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

neo4j-01$ ./bin/neo4j start
neo4j-02$ ./bin/neo4j start
neo4j-03$ ./bin/neo4j start

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 Section 2.4.2, “Arbiter instances”.

That’s it! You now have a Neo4j 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 Section 2.4.1, “Setup and configuration”.