DEV Community

Anzay
Anzay

Posted on

Installing AgensGraph on a MacOS

Introduction:

AgensGraph is a high-performance, transactional graph database that combines the power of a graph database with the flexibility and scalability of a relational database.

If you're a MacOS user just like me, here is a guide to installing AgensGraph and making the best of it.

We will be covering two methods of installation. One is with Homebrew, which is a very popular package manage for Mac and the other is without in case you're someone not familiar to Homebrew or wants to go by source.

Without any further delay, lets get right into it.

Method 1: Installing AgensGraph with Homebrew

Prerequisites:
Before going any further with the installation, ensure you have the following prerequisites:

  1. A macOS system (version 10.11 or later)
  2. Homebrew package manager (https://brew.sh/)
  3. Command Line Tools for Xcode (install via xcode-select --install)

Make sure all three items are something you have and are familiar with. This makes the process a little easier. If not, this guide will help you out!

Step 1: Install Homebrew

If you haven't installed Homebrew yet, open the Terminal application and execute the following command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Enter fullscreen mode Exit fullscreen mode

Once it's done, you can proceed with the next step.

Step 2: Install PostgreSQL

AgensGraph is built on top of PostgreSQL, so its a no-brainer that we will need to install it first.

You can use this command in the terminal to install PostgreSQL via Homebrew:

brew install postgresql
Enter fullscreen mode Exit fullscreen mode

Step 3: Create a PostgreSQL Database Cluster

To initialize the PostgreSQL database cluster, run the following command:

initdb /usr/local/var/postgres
Enter fullscreen mode Exit fullscreen mode

This is the path on my PC, on yours it might be something else, if the command above doesn't work, don't fret you just need to locate the right path.

Step 4: Start the PostgreSQL Server

Start the PostgreSQL server by this command:

pg_ctl -D /usr/local/var/postgres start
Enter fullscreen mode Exit fullscreen mode

Step 5: Install AgensGraph
When PostgreSQL is up and running, we can move on to installing AgensGraph:

brew install agensgraph
Enter fullscreen mode Exit fullscreen mode

Step 6: Initialize AgensGraph

Before any commands or usage of AgensGraph, the first step is to initialise it.

agens
Enter fullscreen mode Exit fullscreen mode

This will open the AgensGraph prompt. You can then create a new graph database by entering:

CREATE GRAPH my_graph;
Enter fullscreen mode Exit fullscreen mode

Step 7: Connect to AgensGraph
To connect to AgensGraph and start using it, execute the following command:

agens -d demo
Enter fullscreen mode Exit fullscreen mode

Replace demo with the name of your graph database if you choose to use something other then 'demo'.

Method 2: Installing AgensGraph without Homebrew

Now same as before, our end goal will be the same but the journey slightly different.

If you don't want to use Homebrew, here are the steps to take:

Step 1: Download and Install PostgreSQL

Check the official PostgreSQL website and download the PostgreSQL installer for macOS.

Follow the installation instructions as they pop up to complete the installation process.

Step 2: Verify PostgreSQL Installation

Now let's check if PostgreSQL was installed properly.

Open a new terminal and run the following command:

psql --version
Enter fullscreen mode Exit fullscreen mode

If a version is returned, that means the installation was successful.

Step 3: Initialize PostgreSQL Database Cluster

Now we initialize the PostgreSQL database cluster by using this command:

initdb /usr/local/var/postgres
Enter fullscreen mode Exit fullscreen mode

Again, first be sure to locate where Postgres is downloaded and installed for you, that is the path you must provide.

Step 4: Start the PostgreSQL Server

Use this command, same as before to launch the PostgreSQL server.

pg_ctl -D /usr/local/var/postgres start
Enter fullscreen mode Exit fullscreen mode

Step 5: Download and Install AgensGraph

Visit the AgensGraph website and download the AgensGraph binary package for macOS.

Extract the downloaded package and move it to your desired location. The extraction is usually done automatically on a MacOS.

Step 6: Set Environment Variables
Open the terminal if you don't have one open and execute the following command to set environment variables:

export PATH=/path/to/agensgraph/bin:$PATH
Enter fullscreen mode Exit fullscreen mode

Replace /path/to/agensgraph with the actual path to the AgensGraph installation directory. Again this step is very important, be sure to use the path that is on your PC. If the path is incorrect you will be shown an error.

Once all is done, you can initialise AgesnGraph and move on with data discovery!

Conclusion:

Congratulations! You have successfully installed AgensGraph on your macOS system using two different methods.

You can also install PostgreSQL through source code which has already been covered in another blogpost by me.

Happy coding and I hope this was helpful for you!

Top comments (0)