DEV Community

Hamza Mushtaque
Hamza Mushtaque

Posted on

Getting Started with APACHE AGE (Part 01): PostgreSQL installation On UBUNTU

Introduction
Welcome to the first part of the "Getting Started with APACHE AGE" blog series! In this series, we will explore the basics of Apache AGE, an open-source extension of PostgreSQL that provides native support for graph data. Graph databases have gained a lot of attention in recent years due to their ability to handle complex data relationships and provide faster query response times.

In this first part, we will focus on the installation of PostgreSQL on Ubuntu, which is a prerequisite for installing Apache AGE. We will walk through the step-by-step process of installing PostgreSQL, setting up the necessary configurations, and verifying the installation. This will set a strong foundation for the subsequent parts of the series, where we will dive deeper into the functionality of Apache AGE and explore its features.

So, if you are interested in working with graph data and want to explore the capabilities of Apache AGE, then stay tuned and follow along with this series!

If you face any error or difficulty during the installation process of Apache AGE and PostgreSQL, feel free to reach out to me. I am always ready to assist you in any way possible. You can contact me through the comments section of the blog or via email. Don't let any installation errors stop you from using this powerful graph database tool. I am here to help you get started with Apache AGE and answer any questions you may have.
Let's get started!!

Installation
As we talked earlier, Apache AGE is an extension for PostgreSQL, which means that in order to use it, you first need to install PostgreSQL on your machine.
For the purposes of this article series, we'll be focusing on versions 12 as it is one of the version of PostgreSQL, Apache AGE is compatible with. Before we can begin the PostgreSQL installation process, we need to make sure that certain dependencies are installed on our machine.

Run the following command in your UBUNTU Terminal!

t-get install build-essential libreadline-dev zlib1g-dev flex bison
Enter fullscreen mode Exit fullscreen mode

Now run

sudo apt install postgresql-server-dev-12
Enter fullscreen mode Exit fullscreen mode

this will install the development headers and libraries for PostgreSQL server version 12. These headers and libraries are required for compiling and building PostgreSQL extensions like Apache AGE, which is a PostgreSQL extension.

By installing the postgresql-server-dev-12 package, you will have the necessary files and tools to build and install PostgreSQL extensions on your system.

Now, we have required dependencies installed. Let's move towards installing PostgreSQL 12.

There are more than one ways to install PostgreSQL on your computer, one way is by compiling directly from the source code, you can go through this guide to try that.

But I'll be installing via the Ubuntu PostgreSQL apt repository. SO, if you wanna follow along, stick with me!

Run the following command in your UBUNTU Terminal!

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql-12
Enter fullscreen mode Exit fullscreen mode

Once you have completed the installation process, it is necessary to add the bin directory path to the PATH environment variable if it has not been added already. The default installation path for PostgreSQL version 12 is /usr/lib/postgresql/12/.

if you have followed my tutorial step by step and did not change any directory, it should be same for you. If you did change directory make sure to modify it accordingly.

Now run

export PATH="/usr/lib/postgresql/12/bin/:$PATH"
Enter fullscreen mode Exit fullscreen mode

It is important to confirm that the PostgreSQL service is running after installation. You can do this by running the following command.

sudo systemctl status postgresql
Enter fullscreen mode Exit fullscreen mode

If the service is inactive or not running, you can start it up by running;

sudo systemctl start postgresql
Enter fullscreen mode Exit fullscreen mode

To access the PostgreSQL database for the first time, you need to use the default admin user created by PostgreSQL. You can do this by running the following command

sudo -u postgres psql
Enter fullscreen mode Exit fullscreen mode

This command allows you to log in to the PostgreSQL server as the "postgres" user and opens the PostgreSQL command-line interface (CLI) where you can execute SQL commands and queries.

Conclusion
Hurray!!!
we have learned how to install PostgreSQL on Ubuntu, which is a prerequisite for using Apache AGE, a PostgreSQL extension. We have also installed some dependencies required for Apache AGE to work. Additionally, we have checked if PostgreSQL is running and added the PostgreSQL bin directory to the PATH env variable. Lastly, we have logged into the PostgreSQL database using the default admin user created by PostgreSQL. This was just the first step towards getting started with Apache AGE. In the next part, we will learn how to install Apache AGE and start working with it. Remember, if you face any difficulties or errors during installation, feel free to reach out for assistance.

Top comments (0)