Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 26, 2023 12:56 am GMT

Step-by-Step Guide to Install PostgreSQL via Package Management for Apache AGE on Ubuntu

PostgreSQL is a robust and reliable open-source relational database that supports ACID and is highly scalable, making it one of the most popular choices for data storage. With Apache AGE, it's possible to query and analyze graph data in PostgreSQL using the OpenCypher technology in conjunction with SQL. For this tutorial, I am using Ubuntu 22.04 LTS and will provide a step-by-step guide to install the new version of Apache AGE 1.3.0 for PostgreSQL 13. If you're curious to know what the main features of this version are, you can check out this article.

Requirements

To install Apache AGE on Ubuntu, you need the following libraries:

sudo apt-get install build-essential libreadline-dev zlib1g-dev flex bison

PostgreSQL Installation

To create your graph database with Apache AGE, you need PostgreSQL. Currently, the versions supported are 11, 12, and 13. You can obtain any of these versions from the Ubuntu package manager. You need to install both the postgresql library and the server:

sudo apt install postgresql-13 postgresql-server-dev-13

After installation, export the environment variable PATH to the executable and PostgreSQL configuration directories and PGDATA environment variable to the database data storage directory. When we install through the package manager, the files are installed by default in /usr/lib/postgresql/{version}, where {version} is the installed PostgreSQL version. In this case, it is version 13.

export PATH=/usr/lib/postgresql/13/bin:$PATHexport PGDATA=/usr/lib/postgresql/13/bin/data

Apache AGE

To install Apache AGE, download a compatible release with your version of PostgreSQL or clone the repository and switch to the branch compatible with your version of PostgreSQL. In this case, we will install version 1.3.0 for PostgreSQL 13:

git clone https://github.com/apache/age.gitgit checkout release/PG13/1.3.0

To proceed with the installation, export the PG_CONFIG variable to pg_config directory or run the make command passing the variable as an argument:

sudo make PG_CONFIG=/usr/lib/postgresql/13/bin/pg_config install

You can also export the variable to the same directory and then proceed with the installation:

export PG_CONFIG=/usr/lib/postgresql/13/bin/pg_configsudo make install

The pg_config is a utility that contains installation information about PostgreSQL, such as the version installed. When running pg_config for the current installation, the terminal returns the following information:

BINDIR = /usr/lib/postgresql/13/binDOCDIR = /usr/share/doc/postgresql-doc-13HTMLDIR = /usr/share/doc/postgresql-doc-13INCLUDEDIR = /usr/include/postgresqlPKGINCLUDEDIR = /usr/include/postgresqlINCLUDEDIR-SERVER = /usr/include/postgresql/13/serverLIBDIR = /usr/lib/x86_64-linux-gnuPKGLIBDIR = /usr/lib/postgresql/13/libLOCALEDIR = /usr/share/localeMANDIR = /usr/share/postgresql/13/manSHAREDIR = /usr/share/postgresql/13SYSCONFDIR = /etc/postgresql-commonPGXS = /usr/lib/postgresql/13/lib/pgxs/src/makefiles/pgxs.mkCONFIGURE =  '--build=x86_64-linux-gnu' '--prefix=/usr' '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--disable-option-checking' '--disable-silent-rules' '--libdir=${prefix}/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/13/man' '--docdir=/usr/share/doc/postgresql-doc-13' '--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share/' '--datadir=/usr/share/postgresql/13' '--bindir=/usr/lib/postgresql/13/bin' '--libdir=/usr/lib/x86_64-linux-gnu/' '--libexecdir=/usr/lib/postgresql/' '--includedir=/usr/include/postgresql/' '--with-extra-version= (Ubuntu 13.10-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 = gccCPPFLAGS = -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -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-pointerCFLAGS_SL = -fPICLDFLAGS = -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -Wl,-z,now -L/usr/lib/llvm-14/lib -Wl,--as-neededLDFLAGS_EX = LDFLAGS_SL = LIBS = -lpgcommon -lpgport -lselinux -lxslt -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -lz -lreadline -lm VERSION = PostgreSQL 13.10 (Ubuntu 13.10-1.pgdg22.04+1)

To verify if the installation is correct, run the regression tests:

make PG_CONFIG=/src/lib/postgresql/13/bin/pg_config installcheck

Se todos passarem, o console vai retornar a seguinte frase: All 24 tests passed.

Testing the Installation

Let's test our installation by creating a graph in a database with the default user postgres. Start the PostgreSQL service and check the status:

sudo service postgresql startservice postgresql status

If everything is correct, a similar message will appear in the terminal indicating that the service is active:

 postgresql.service - PostgreSQL RDBMS     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor pr>     Active: active (exited) since Tue 2023-04-25 19:34:59 -03; 41min ago   Main PID: 9761 (code=exited, status=0/SUCCESS)        CPU: 1msabr 25 19:34:59 carla-linux systemd[1]: Starting PostgreSQL RDBMS...abr 25 19:34:59 carla-linux systemd[1]: Finished PostgreSQL RDBMS.

Now start the command-line tool:

sudo -u postgres psql

Use the following command to install the extension on the server:

CREATE EXTENSION age;

Load the extension for each AGE connection:

LOAD 'age';

Use the following command to create a graph:

SELECT * FROM ag_catalog.create_graph('new_graph');

To simplify queries, add ag_catalog to your search_path with SET search_path = ag_catalog, "$user", public;. In this case, you could use the following command to create the graph:

SELECT * FROM create_graph('new_graph');

If everything is correct, the console will return:

NOTICE:  graph "new_graph" has been created create_graph --------------(1 row)

Conclusion

In this tutorial, we have seen how to install PostgreSQL via package manager and use it with Apache AGE. If you want to learn more about this project, visit https://age.apache.org/. If you want to know how to contribute, visit https://github.com/apache/age. All kinds of contributions are very welcome .

Errata

My intention is to provide access to technology information through reliable sources. If you have found any incorrect information, please contact me at [email protected].

Related Articles

Easy guide to install and configure PostgreSQL with Apache AGE on Windows
Apache AGE 1.3 Release for PostgreSQL 13
Easy Installation of PostgreSQL, AGE & Age-viewer on Mac
Installing apache age-viewer

References

Apache AGE. Apache AGE Documentation - Setup. 2023. Available at https://age.apache.org/age-manual/master/intro/setup.html. Accessed on 04/25/2023.


Original Link: https://dev.to/carlasanches/step-by-step-guide-to-install-apache-age-and-postgresql-via-package-management-on-ubuntu-259l

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To