DEV Community

ERINFOLAMI PETER
ERINFOLAMI PETER

Posted on

APACHE AGE: Getting Started Part 2(AGE Installation)

Introduction

In this part of the series I'll be walking you through how to install the age extension on top of the running instance of your postgres database. The pre-requisites to this installation is having postgres installed on your machine check here for guide, and also you should have git installed.

Setting up and installation

Like i said in the previous article we'll be working with postgresql version 12, so we'll also try to install the version of AGE that's compatible with postgres 12. Before we proceed to the installation there are various methods the age extension can be installed, first is via the github repo, second is downloading the source code directly from the release page, third is through the use of docker. We'll be installing via github.

1. To get started we'll first clone the official apache github repository.

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

2. After cloning successfully cd into the directory and change into the PG12 release branch

cd age
git checkout release/PG12/1.1.1
Enter fullscreen mode Exit fullscreen mode

3. Run pg_config

ceejay@ceejay:~$ pg_config

BINDIR = /usr/lib/postgresql/12/bin

DOCDIR = /usr/share/doc/postgresql-doc-12

HTMLDIR = /usr/share/doc/postgresql-doc-12

INCLUDEDIR = /usr/include/postgresql

PKGINCLUDEDIR = /usr/include/postgresql

INCLUDEDIR-SERVER = /usr/include/postgresql/12/server

LIBDIR = /usr/lib/x86_64-linux-gnu

PKGLIBDIR = /usr/lib/postgresql/12/lib

LOCALEDIR = /usr/share/locale

MANDIR = /usr/share/postgresql/12/man

SHAREDIR = /usr/share/postgresql/12

SYSCONFDIR = /etc/postgresql-common

PGXS = /usr/lib/postgresql/12/lib/pgxs/src/makefiles/pgxs.mk

CONFIGURE = '--build=x86_64-linux-gnu' '--prefix=/usr' '--includedir=/usr/include' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--disable-option-checking' '--disable-silent-rules' '--libdir=/usr/lib/x86_64-linux-gnu' '--runstatedir=/run' '--disable-maintainer-mode' '--disable-dependency-tracking' '--with-tcl' '--with-perl' '--with-python' '--with-pam' '--with-openssl' '--with-libxml' '--with-libxslt' '--mandir=/usr/share/postgresql/12/man' '--docdir=/usr/share/doc/postgresql-doc-12' '--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share/' '--datadir=/usr/share/postgresql/12' '--bindir=/usr/lib/postgresql/12/bin' '--libdir=/usr/lib/x86_64-linux-gnu/' '--libexecdir=/usr/lib/postgresql/' '--includedir=/usr/include/postgresql/' '--with-extra-version= (Ubuntu 12.14-1.pgdg22.04+1)' '--enable-nls' '--enable-thread-safety' '--enable-debug' '--enable-dtrace' '--disable-rpath' '--with-uuid=e2fs' '--with-gnu-ld' '--with-gssapi' '--with-ldap' '--with-pgport=5432' '--with-system-tzdata=/usr/share/zoneinfo' 'AWK=mawk' 'MKDIR_P=/bin/mkdir -p' 'PROVE=/usr/bin/prove' 'PYTHON=/usr/bin/python3' 'TAR=/bin/tar' 'XSLTPROC=xsltproc --nonet' 'CFLAGS=-g -O2 -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer' 'LDFLAGS=-Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -Wl,-z,now' '--enable-tap-tests' '--with-icu' '--with-llvm' 'LLVM_CONFIG=/usr/bin/llvm-config-14' 'CLANG=/usr/bin/clang-14' '--with-systemd' '--with-selinux' 'build_alias=x86_64-linux-gnu' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'CXXFLAGS=-g -O2 -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security'

CC = gcc

CPPFLAGS = -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2

CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -g -O2 -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer

CFLAGS_SL = -fPIC

LDFLAGS = -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -Wl,-z,now -L/usr/lib/llvm-14/lib -Wl,--as-needed

LDFLAGS_EX = 

LDFLAGS_SL = 

LIBS = -lpgcommon -lpgport -lselinux -lxslt -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -lz -ledit -lcrypt -lm 

VERSION = PostgreSQL 12.14 (Ubuntu 12.14-1.pgdg22.04+1)
Enter fullscreen mode Exit fullscreen mode

Note: if you get an error that command not found then you should add your postgres installation directory to PATH. If you followed my previous article the default location is /usr/lib/postgresql/12/. You can add to path by using the following command export PATH="/usr/lib/postgresql/12/bin:$PATH"

4. Add the PG_CONFIG environment variable and install

export PG_CONFIG="/usr/lib/postgresql/12/bin/pg_config"
sudo make install
Enter fullscreen mode Exit fullscreen mode

You can also combine the two above into one command

sudo make PG_CONFIG="/usr/lib/postgresql/12/bin/pg_config" install
Enter fullscreen mode Exit fullscreen mode

This might take a while

After installation connect to a database on your postgres server. We created a db test in last article. we can connect to it

ceejay@ceejay:~/age$ psql test

psql (12.14 (Ubuntu 12.14-1.pgdg22.04+1))

Type "help" for help.



test=# 

Enter fullscreen mode Exit fullscreen mode

We can then create and load the extension into our database

test=# CREATE EXTENSION age;

CREATE EXTENSION

test=# LOAD 'age';

LOAD

test=# 
Enter fullscreen mode Exit fullscreen mode

We then add the ag_catalog to search_path, to simplify our queries

test=# SET search_path = ag_catalog, "$user", public;

SET

test=# 

Enter fullscreen mode Exit fullscreen mode

You can check the list of extensions installed with the following

test=# \dx

                 List of installed extensions

  Name   | Version |   Schema   |         Description          

---------+---------+------------+------------------------------

 age     | 1.1.1   | ag_catalog | AGE database extension

 plpgsql | 1.0     | pg_catalog | PL/pgSQL procedural language

(2 rows)



test=# 

Enter fullscreen mode Exit fullscreen mode

Conclusion

Now we've been able to successfully install the apache age extension on our postgres database. In the next parts of the series, we'll be playing with the graph extension itself and see the cool and powerful stuffs we can do with it. if you run into errors or issues while installing let me know in the comment section. See you in the next episode!.

Top comments (2)

Collapse
 
hamza_ghouri profile image
Hamza Mushtaque

Hey ERINFOLAMI PETER,
I have encountered an error while following your guide.
basically i was getting following error;

Image description
which can be resolved by running following command;

sudo apt install postgresql-server-dev-12
Enter fullscreen mode Exit fullscreen mode
Collapse
 
shadycj profile image
ERINFOLAMI PETER

Yes.. Thank you..