Linux executable (.tar)

Before you install Neo4j on Linux from a tarball and run it as a console application or a service, check System Requirements to see if your setup is suitable.

Install Neo4j from a tarball

  1. If it is not already installed, get OpenJDK 11 or Oracle Java 11.

  2. Download the latest Neo4j tarball from Neo4j Download Center and unpack it:

    tar zxf neo4j-enterprise-4.4.34-unix.tar.gz
  3. Move the extracted files to your server’s /opt directory and create a symlink to it:

    mv neo4j-enterprise-4.4.34 /opt/
    ln -s /opt/neo4j-enterprise-4.4.34 /opt/neo4j
  4. Create a neo4j user and group:

    groupadd neo4j
    useradd -g neo4j neo4j -s /bin/bash
  5. Give the directory the correct ownership using one of the options:

    • Ubuntu

      chown -R neo4j:adm /opt/neo4j-enterprise-4.4.34
    • RedHat

      chown -R neo4j /opt/neo4j-enterprise-4.4.34
  6. Start Neo4j:

    1. To run Neo4j as a console application, use: <NEO4J_HOME>/bin/neo4j console.

    2. To run Neo4j in a background process, use: <NEO4J_HOME>/bin/neo4j start.

  7. Open http://localhost:7474 in your web browser.

  8. Connect using the username neo4j with the default password neo4j. You will then be prompted to change the password.

  9. Stop the server by typing Ctrl-C in the console.

Configure Neo4j to start automatically on system boot

You can create a Neo4j service and configure it to start automatically on system boot.

  1. Create the file /lib/systemd/system/neo4j.service with the following contents:

    [Unit]
    Description=Neo4j Graph Database
    After=network-online.target
    Wants=network-online.target
    
    [Service]
    ExecStart=/opt/neo4j/bin/neo4j console
    Restart=on-abnormal
    User=neo4j
    Group=neo4j
    Environment="NEO4J_CONF=/opt/neo4j/conf" "NEO4J_HOME=/opt/neo4j"
    LimitNOFILE=60000
    TimeoutSec=120
    
    [Install]
    WantedBy=multi-user.target
    //Reload systemctl to pick up the new service file
    systemctl daemon-reload
  2. Configure Neo4j to start at boot time:

    systemctl enable neo4j
  3. Start Neo4j:

    systemctl start neo4j
  4. Check the status of the newly created service:

    systemctl status neo4j
  5. Reboot the system (if desired) to verify that Neo4j restarts on boot:

    reboot

For more information on operating the Neo4j system service, see Neo4j system service.

Setting the number of open files

Linux platforms impose an upper limit on the number of concurrently open files per user and session. To check your limit for the current session, run the command ulimit -n. The default value is 1024.

user@localhost:~$ ulimit -n
1024

However, if you experience exceptions on Too many open files or Could not stat() directory, you have to increase the limit to 40000 or more, depending on your usage patterns. This is especially true when many indexes are used, or the server installation sees too many open network connections or sockets.

A quick solution is the command ulimit -n <the-new-limit>, but it will set a new limit only for the root user and will affect only the current session. If you want to set the value system-wide, follow the instructions for your platform.

The following steps set the open file descriptor limit to 60000 for the user neo4j under Ubuntu 16.04 LTS, Debian 8, CentOS 7, or later versions.

Running Neo4j as a service

  1. Open the neo4j.service file with root privileges.

    user@localhost:~$ sudo systemctl edit neo4j.service
  2. Append the [Service] section to the neo4j.service file.

    [Service]
    LimitNOFILE=60000

Running Neo4j as an interactive user (e.g., for testing purposes)

  1. Open the user.conf file with root privileges in a text editor, for example, Vim.

    user@localhost:~$ sudo vi /etc/systemd/user.conf
  2. Uncomment and define the value of DefaultLimitNOFILE, found in the [Manager] section.

    [Manager]
    ...
    DefaultLimitNOFILE=60000
  3. Open the /etc/security/limits.conf file.

    user@localhost:~$ sudo vi /etc/security/limits.conf
  4. Define the following values:

    neo4j	soft	nofile	60000
    neo4j	hard	nofile	60000
  5. Reload the systemd settings.

    user@localhost:~$ sudo systemctl daemon-reload
  6. Reboot your machine.

Uninstall Neo4j

Follow these steps to uninstall Neo4j on Linux:

  1. (Optional) Create a backup to avoid losing your data.

  2. Stop all Neo4j running services:

    ---
    sudo systemctl stop neo4j
    sudo systemctl disable neo4j
    ---
  3. Delete NEO4J_HOME and the file /lib/systemd/system/neo4j.service:

    ---
    rm /lib/systemd/system/neo4j.service
    rm -rf NEO4J_HOME
    ---