DEV Community

Muhammad Zeeshan
Muhammad Zeeshan

Posted on

Step by Step Guide to Install Citus: Linux

This blog is the continuation of last blog. Where we explored about citus. In this blog we will look at the two different ways to install citus.

Method 1

Packaging repo

If you already have PostgreSQL installed its better to install the citus using this method.Run the following commands.
Install packages on ubuntu.

curl https://install.citusdata.com/community/deb.sh > add-citus-repo.sh
sudo bash add-citus-repo.sh
sudo apt-get -y install postgresql-15-citus-12.0  
Enter fullscreen mode Exit fullscreen mode

This will install the citus and the compatible postgres version. Citus version 12 and Postgres version 15.

add Citus to your local PostgreSQL database, add the following to postgresql.conf:

shared_preload_libraries = 'citus'
Enter fullscreen mode Exit fullscreen mode

Method 2: Install using source code.

Step 1

create the required directories. Open the terminal and run the commands.

mkdir citus
cd citus
mkdir pg
cd pg
Enter fullscreen mode Exit fullscreen mode

Step 2

Install required dependencies.

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

Step 3

Download and install postgres. In method one it automatically installed the postgres but here we need to download and install it manually.

Download

wget https://ftp.postgresql.org/pub/source/v15.3/postgresql-15.3.tar.gz && tar -xvf postgresql-15.3.tar.gz && rm -f postgresql-15.3.tar.gz
Enter fullscreen mode Exit fullscreen mode

Install

cd postgresql-15.3

# configure by setting flags
./configure --enable-debug --enable-cassert --prefix=$(pwd) CFLAGS="-ggdb -Og -fno-omit-frame-pointer"

# now install
make install

# go back to main citus directory
cd ../../
Enter fullscreen mode Exit fullscreen mode

Step 4

Now after installing postgres we need to install citus. Before that we need to install the required dependencies.

sudo apt-get install -y postgresql-server-dev-15 postgresql-15 \
                        autoconf flex git libcurl4-gnutls-dev 
libicu-dev \
                        libkrb5-dev liblz4-dev libpam0g-dev libreadline-dev \
                        libselinux1-dev libssl-dev libxslt1-dev libzstd-dev \
                        make uuid-dev

Enter fullscreen mode Exit fullscreen mode

Step 5

Clone citus using the github repo.

git clone https://github.com/citusdata/citus.git
cd citus
Enter fullscreen mode Exit fullscreen mode

Step 6

Install and configure citus

PG_CONFIG=/home/username/citus/pg/postgresql-15.3/bin/pg_config ./configure
make
sudo make install
Enter fullscreen mode Exit fullscreen mode

After running this config comamnd Here you can have an error that some dependencies are missing. You can run the command with --without flag or can download those dependencies.

You have successfully installed citus and postgres from the source code or using package. To load you again need to add the above prelaod command in postgresql.conf

Top comments (0)