In this tutorial, we'll explain how to install and configure Neo4j on Ubuntu 24.04.
Neo4j is a popular graph database that excels in managing complex relationships between data. In this tutorial, we will install and configure Neo4j on Ubuntu 24.04. This guide covers essential setup steps, including database optimization and security best practices.
Prerequisites
Before we begin, ensure you have the following:
- An Ubuntu 24.04 dedicated server or KVM VPS.
- A root user or normal user with sudo rights.
- Basic knowledge of Linux command-line operations.
Install and Configure Neo4j on Ubuntu 24.04
Step 1: Update the System
Ensure your system is updated before installing Neo4j.
sudo apt update && sudo apt upgrade -y
Step 2: Install Java
Neo4j requires Java to function properly. Install the OpenJDK package:
sudo apt install openjdk-17-jdk -y
Verify the installation:
java -version
Step 3: Add the Neo4j APT Repository
To get the latest Neo4j packages, you need to add their official repository to your APT sources.
Import Neo4j GPG key:
wget -O - https://debian.neo4j.com/neotechnology.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/neotechnology.gpg
Add the Neo4j repository:
echo 'deb [signed-by=/etc/apt/keyrings/neotechnology.gpg] https://debian.neo4j.com stable latest' | sudo tee -a /etc/apt/sources.list.d/neo4j.list
Update package list:
sudo apt update
Step 4: Install Neo4j
Now, install Neo4j using the APT package manager:
sudo apt install neo4j -y
Step 5: Start and Enable Neo4j Service
After the installation, start the Neo4j service and ensure it runs on system boot.
sudo systemctl start neo4j
sudo systemctl enable neo4j
Verify the service status:
sudo systemctl status neo4j
Step 6: Configure Firewall for Neo4j
Neo4j runs on port 7474
(HTTP) and 7687
(Bolt) by default. You need to allow these ports if you're using UFW (Uncomplicated Firewall).
sudo ufw allow 7474,7687/tcp
Enable UFW if it’s not already enabled:
sudo ufw enable
Step 7: Access Neo4j Web Interface
To manage the Neo4j instance, access the web interface. Open your browser and navigate to:
http://<your-server-ip>:7474
You will be prompted to enter username and a password for the default user and password is neo4j
.
Step 8: Configure Neo4j
1. Change Default Password
After accessing the web interface, change the default password as it’s critical for security. Alternatively, you can change the password via the CLI:
cypher-shell
The default username and password is neo4j
.
After you enter username and password, it will ask to change the current password.
2. Enable Authentication
Make sure authentication is enabled in production. This is the default setting, but you can verify it in the configuration file.
sudo nano /etc/neo4j/neo4j.conf
Ensure that the following line is uncommented and set to true:
dbms.security.auth_enabled=true
3. Optimize for Production
Modify Neo4j’s default configurations to ensure better performance and stability in production.
Increase Heap Memory: Set appropriate memory limits in the configuration file:
sudo nano /etc/neo4j/neo4j.conf
Adjust the following parameters according to your server's memory (e.g., for a server with 8 GB RAM):
server.memory.heap.initial_size=4G
server.memory.heap.max_size=4G
Enable Page Cache: To optimize read operations, configure the page cache based on available memory:
server.memory.pagecache.size=4G
This is not production-ready. We had issue with installing SSL. We had issue with Nginx too. If we install Nginx, in the browser server won't get connect to Neo4j. If we use IP address without SSL or Nginx, it will get connect to Neo4j. So try it on local machine first.
Conclusion
By following these steps, Neo4j instance on Ubuntu 24.04. This guide ensures your installation is optimized for performance. Remember to regularly monitor and update your system to maintain high availability and performance.