DEV Community

Mahina Sheikh
Mahina Sheikh

Posted on

Easy Installation Guide for Age and Postgresql with minute changes.

Installing PostgreSQL from source can be a bit daunting at first, but it is a worthwhile endeavor as it provides greater control and flexibility over the installation process. In this blog, we will guide you through the installation process of PostgreSQL from source on Ubuntu.

Prerequisites
Before we start the installation process, we need to install the following essential libraries:

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

We also recommend installing the postgresql-server-dev package, which provides the development files for PostgreSQL server-side programming:

sudo apt-get -y install postgresql-server-dev-11
Enter fullscreen mode Exit fullscreen mode

Downloading and Installing PostgreSQL
Now, let's download and install PostgreSQL:

Create a directory for the installation files:

mkdir postgresql_installation
cd postgresql_installation
Enter fullscreen mode Exit fullscreen mode

Download the source package for PostgreSQL 11.8:

wget https://ftp.postgresql.org/pub/source/v11.18/postgresql-11.18.tar.gz
Enter fullscreen mode Exit fullscreen mode

Extract the downloaded tar file:

tar -xvf postgresql-11.18.tar.gz
Enter fullscreen mode Exit fullscreen mode

Change to the extracted directory:

cd postgresql-11.18
Enter fullscreen mode Exit fullscreen mode

Configure the installation by setting flags:

./configure --enable-debug --enable-cassert --prefix=$(pwd) CFLAGS="-ggdb -Og -fno-omit-frame-pointer"
Enter fullscreen mode Exit fullscreen mode

Install PostgreSQL:

make install
Enter fullscreen mode Exit fullscreen mode

Change back to the installation directory:

cd ../../
Enter fullscreen mode Exit fullscreen mode

Configuring AGE
Now, we'll install the AGE extension:

Clone the AGE repository:

git clone https://github.com/apache/age.git
Enter fullscreen mode Exit fullscreen mode

Change to the AGE directory:

cd age/
Enter fullscreen mode Exit fullscreen mode

Install AGE with PostgreSQL:

sudo make PG_CONFIG=/path/to/postgresql-11.18/bin/pg_config 
install
Enter fullscreen mode Exit fullscreen mode

Install the check:

make PG_CONFIG=/path/to/postgresql-11.18/bin/pg_config installcheck
Enter fullscreen mode Exit fullscreen mode

Initializing the Database Cluster
Now that we have installed PostgreSQL and AGE, let's initialize the database cluster:

Change to the PostgreSQL installation directory:

cd postgresql-11.18/
Enter fullscreen mode Exit fullscreen mode

Initialize the database cluster:

bin/initdb demo
Enter fullscreen mode Exit fullscreen mode

Starting the Server
We're almost there! Now let's start the server and create a database:

Start the server:

bin/pg_ctl -D demo -l logfile start
Enter fullscreen mode Exit fullscreen mode

Create a database:

bin/createdb demodb
Enter fullscreen mode Exit fullscreen mode

Loading the AGE Extension
Finally, we need to load the AGE extension and set the search_path and other variables:

Start the psql console:

bin/psql demodb
Enter fullscreen mode Exit fullscreen mode

Load the AGE extension:

CREATE EXTENSION age;
LOAD 'age';
Enter fullscreen mode Exit fullscreen mode

Set the search_path and other variables:

SET search_path = ag_catalog, "$user", public;
Enter fullscreen mode Exit fullscreen mode

Installing AGE-Viewer
AGE-Viewer is a web app that helps us visualize our data. Here's how to install it:

Install Node.js and NPM:

sudo apt install nodejs npm
Enter fullscreen mode Exit fullscreen mode

Clone the AGE-Viewer repository:

git clone https://github.com/apache/age-viewer.git
Enter fullscreen mode Exit fullscreen mode

Change to the AGE-Viewer directory:

cd age-viewer
Enter fullscreen mode Exit fullscreen mode

Set up the environment:

npm run setup
Enter fullscreen mode Exit fullscreen mode

Start the viewer:

npm run start
Enter fullscreen mode Exit fullscreen mode

This will start the viewer on localhost:3000. Open your web browser and navigate to localhost:3000 to access the viewer.

Once the viewer is running, you will need to connect it to your PostgreSQL server. Click on the Connect button on the top right corner of the viewer, and fill in the required information:

Server URL: the address of your PostgreSQL server. If it is running on the same machine as the viewer, you can use localhost.
Port: the port number on which your PostgreSQL server is listening. The default port number is 5432.
Username: the username of your PostgreSQL user.
Password: the password of your PostgreSQL user.
Database: the name of the database you want to connect to. In our case, it is demodb.
Once you have filled in the required information, click on the Connect button to connect to your database. If the connection is successful, you should see the name of your database in the top left corner of the viewer.

You can now explore your database using the viewer. The viewer provides a graphical interface to visualize the data stored in your database using various graph algorithms and layouts. You can also execute Cypher queries and view the results in the viewer.

Reference:
https://theundersurfers.netlify.app/age-installation/

Top comments (0)