Advance

Tutorial Setup Neo4j on Ubuntu 22.04

Tutorial Setup Neo4j on Ubuntu 22.04

Neo4j is a basic graph database that is classified as a no-sql database. High speed and the ability to run complex queries are the most prominent features of this database. The best use of Neo4j is to use it as a complement to other databases like Mongo and Cassandra. In this article, we are going to teach you step by step How to Setup Neo4j on Ubuntu 22.04. You can also check out the packages offered on the Eldernode website if you would like to purchase an Ubuntu VPS server.

How to IConfigure Neo4j on Ubuntu Linux

Recommended Article: How To Install ODrive On Ubuntu 20.04 [Complete]

Introduction to Neo4j and its Features

Neo4j is a New Database (NoSQL) database that uses a graph data model to store data and communicate between them. That is, it stores all data in the form of graphs and as a set of nodes and relations between them. Therefore, compared to other relational databases, there is no need to write complex joins, and various types of queries can be easily done by navigating and moving in the graph.

As mentioned, Neo4j is best used as a complement to other databases such as Mongo and Cassandra; The original data is stored in the Mongo or Cassandra database and the index of this data is stored in Neo4j along with some key parameters that are widely used in queries.

Most queries run on Neo4j and retrieve the original data from the original database using the keys found. This method is widely used in very large projects (such as social networks). The same is true for ElasticSearch.

Using graphs instead of tables in Neo4j, in addition to less and simpler coding, makes for a completely agile and flexible system for storing all kinds of data and relationships. Also, because of the use of graphs, having an intuitive view of the data and the relationship between them, analyzing and understanding projects will be easier even for non-experts.

Follow us in this article to show you How to Install Neo4j on Ubuntu 22.04.

Prerequisites for installing Neo4j on Ubuntu 22.04

-> Non-root user access

-> Initial server setup on Ubuntu 22.04

How to Install Neo4j on Ubuntu 22.04

Before we start installing Neo4j on Ubuntu 22.04, you should know that there is no copy of the Neo4j database engine in the official Ubuntu package repositories. Therefore, the GPG key from Neo4j must be added using the following command:

curl -fsSL https://debian.neo4j.com/neotechnology.gpg.key |sudo gpg --dearmor -o /usr/share/keyrings/neo4j.gpg

Now you need to add the Neo4j 4.1 repository to your system APT resources by running the following command:

echo "deb [signed-by=/usr/share/keyrings/neo4j.gpg] https://debian.neo4j.com stable 4.1" | sudo tee -a /etc/apt/sources.list.d/neo4j.list

Now that you’ve successfully added the Neo4j 4.1 repository, you’ll need to update your packet lists using the command below.

sudo apt update

It is also necessary to install the Neo4j package and all its dependencies after updating the packages by running the following command:

sudo apt install neo4j

In this step, you must enable Neo4j as a service by executing the following command:

sudo systemctl enable neo4j.service

After enabling the neo4j service, you now need to start it using the following command:

sudo systemctl start neo4j.service

You can now check the status of the neo4j service:

sudo systemctl status neo4j.service

Setup Neo4j on Ubuntu 22.04

As you saw in the previous section, you were taught how to install neo4j on Ubuntu 22.04. Now in this section we want to show you how to connect, configure and setup Neo4j. Please stay tuned for the rest of this article.

To interact with Neo4j on the command line, you can first use the following command and call it:

cypher-shell

After the first login, you need to change the administrator password. Note that your default password and username are neo4j.

Once you have successfully set up the administrator password and the connection has been established, you can now exit by running the following command:

:exit

In the rest of this article, we’re going to show you how to configure Neo4j to allow remote connection. To make the desired settings, you need to open the configuration file using the text editor you want.

sudo nano /etc/neo4j/neo4j.conf

Now you have to press ctrl+w to search for # dbms.default_listen_address = 0.0.0.0 and make it uncomment by deleting the # character:

The interesting thing here is that you should consider Neo4j 0.0.0.0 by default to all IPv4 interfaces in your system, including localhost. This means that if you want to restrict Neo4j to a specific IP address, you must configure that IP address.

Once you have made the desired settings in the configuration file, save it by pressing “Ctrl+X” and then “Y“.

On the other hand, it should be noted that if you want to configure Neo4j with an IPv6 address, you must configure a DNS name to be resolved to the IPv6 address. Another way is to add an entry to the /etc/hosts file on the remote system. Doing so will cause the address to be mapped to a name. Once you’ve done this correctly, you can use the DNS filename or host to connect to Neo4j.

Recommended Article: How to install WordPress with Apache in Ubuntu 20.04

How to Connect to the Server

Consider the following example. In the following example, a Neo4j server with an IPv6 address such as 2001:db8::1 requires a remote connection system that has an /etc/host input such as the following and replaces a prominent name with your_hostname:

2001:db8::1 your_hostname

You can now connect to the server remotely using the following command:

cypher-shell -a 'neo4j://your_hostname:7687'

You can also do the following if you want to restrict Neo4j to use the IPv6 localhost address of ::1 as in the following command:

cypher-shell -a 'neo4j://ip6-localhost:7687'

Firewall Settings for Neo4j

To configure the firewall using port 7687 to allow access to a remote host, you need to run the following command:

sudo ufw allow from 123.4.567.8 to any port 7687 proto tcp

Note1: In the commands, instead of the IP written, you should replace the IP address of the remote system you are using to access Neo4j.

You can access the entire network area using the following command:

sudo ufw allow from 192.0.2.0/24 to any port 7687 proto tcp

Note2: Put the IP of the network you want to access Neo4j instead of the IP entered in the command above.

Another possibility is that you want to allow hosts to access Neo4j remotely. To do this you need to use the following command:

sudo ufw allow from 2001:DB8::1/128 to any port 7687 proto tcp

Note3: In the above command, you must replace the IPv6 address of the system you want.

To allow access to IPv6 addresses, you need to run the following command in the first step:

sudo ufw allow from 2001:DB8::/32 to any port 7687 proto tcp

Note4: Replace the network range you want in the above command with 1234: 567 :: / 89.

You must now enable UFW using the following command to apply the rules:

sudo ufw reload

To check the status of UFW rules you can run the following command:

sudo ufw status
Recommended Article: How to Install and Uninstall Homebrew on Ubuntu 20.04

Conclusion

In some applications and websites, in addition to the data itself, it is very important to store the connection between the data. For example, in a social network, it is necessary to determine what other members a person is related to. Either a shopping site like Ebay or a search engine like Google need to maintain the relationships between objects and pages that evolve over time. In this type of application, the relationship between the data is even more valuable than the data itself (Relation-first Approach). Neo4j is a New Database (NoSQL) database that makes it easy to do this. In this article, we tried to teach you How to Setup Neo4j on Ubuntu 22.04.

We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day