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
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
Downloading and Installing PostgreSQL
Now, let's download and install PostgreSQL:
Create a directory for the installation files:
mkdir postgresql_installation
cd postgresql_installation
Download the source package for PostgreSQL 11.8:
wget https://ftp.postgresql.org/pub/source/v11.18/postgresql-11.18.tar.gz
Extract the downloaded tar file:
tar -xvf postgresql-11.18.tar.gz
Change to the extracted directory:
cd postgresql-11.18
Configure the installation by setting flags:
./configure --enable-debug --enable-cassert --prefix=$(pwd) CFLAGS="-ggdb -Og -fno-omit-frame-pointer"
Install PostgreSQL:
make install
Change back to the installation directory:
cd ../../
Configuring AGE
Now, we'll install the AGE extension:
Clone the AGE repository:
git clone https://github.com/apache/age.git
Change to the AGE directory:
cd age/
Install AGE with PostgreSQL:
sudo make PG_CONFIG=/path/to/postgresql-11.18/bin/pg_config
install
Install the check:
make PG_CONFIG=/path/to/postgresql-11.18/bin/pg_config installcheck
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/
Initialize the database cluster:
bin/initdb demo
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
Create a database:
bin/createdb demodb
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
Load the AGE extension:
CREATE EXTENSION age;
LOAD 'age';
Set the search_path and other variables:
SET search_path = ag_catalog, "$user", public;
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
Clone the AGE-Viewer repository:
git clone https://github.com/apache/age-viewer.git
Change to the AGE-Viewer directory:
cd age-viewer
Set up the environment:
npm run setup
Start the viewer:
npm run start
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)