Skip to content

Building pgvector

linuxonz edited this page Sep 18, 2025 · 1 revision

Building pgvector

Below versions of pgvector are available in respective distributions at the time of creation of these build instructions:

  • RHEL 10.0 has 0.6.2
  • SLES 15 SP7 has 0.8.0
  • Ubuntu 24.04 has 0.6.0
  • Ubuntu 25.04 has 0.8.0

The instructions provided below specify the steps to build pgvector 0.8.0 on Linux on IBM Z for following distributions:

  • RHEL (8.10, 9.4, 9.6, 10.0)
  • SLES 15 SP6
  • Ubuntu (22.04, 24.04)

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified
  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.

1. Build using script

If you want to build pgvector using manual steps, go to STEP 2.

Use the following commands to build pgvector using the build script. Please make sure you have wget installed.

wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/pgvector/0.8.0/build_pgvector.sh

# Build pgvector
bash build_pgvector.sh   [Provide -t option for executing build with tests]

If the build completes successfully, go to STEP 4. In case of error, check logs for more details or go to STEP 2 to follow manual build steps.

2. Install Dependencies

export SOURCE_ROOT=/<source_root>/

2.1. Install Basic Dependencies

  • RHEL 8.10

    sudo yum install -y make gcc gcc-c++ git git perl-IPC-Run diffutils perl-Test-Harness perl-core redhat-rpm-config
  • RHEL (9.4, 9.6, 10.0)

    sudo yum install -y postgresql postgresql-server postgresql-server-devel postgresql-contrib make gcc gcc-c++ git git perl-IPC-Run diffutils perl-Test-Harness perl-core redhat-rpm-config bzip2 readline-devel zlib-devel wget
  • SLES 15 SP6

    sudo zypper install -y postgresql postgresql-server postgresql-server-devel postgresql-contrib make gcc gcc-c++ git perl-IPC-Run perl diffutils bzip2 readline-devel zlib-devel wget
  • Ubuntu (22.04)

    sudo apt update && sudo apt install -y postgresql-14 postgresql-server-dev-14 make gcc g++ git build-essential libipc-run-perl
  • Ubuntu (24.04)

    sudo apt update && sudo apt install -y postgresql-16 postgresql-server-dev-16 make gcc g++ git build-essential libipc-run-perl

2.2. Install POSTGRESQL (Only for RHEL 8.10)

cd $SOURCE_ROOT
wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/PostgreSQL/16.9/build_postgresql.sh
bash build_postgresql.sh
export PATH=$PATH:/usr/local/pgsql/bin

3. Build pgvector

3.1. Download pgvector

cd $SOURCE_ROOT
git clone -b v0.8.0 https://github.com/pgvector/pgvector.git
cd pgvector

3.2. Build pgvector

make
sudo make install    #except RHEL 8.10
sudo env "PATH=$PATH" make install   #for RHEL 8.10

4. Verify (Optional)

4.1. Start postgresql server

# Only for Ubuntu
sudo service postgresql start
sudo -u postgres psql -c "CREATE USER postgres WITH PASSWORD 'postgres';"
sudo -u postgres psql -c "ALTER USER postgres WITH SUPERUSER;"
sudo -u postgres psql -c " CREATE DATABASE postgres OWNER postgres;"
sudo service postgresql restart
sudo service postgresql status

# Only for RHEL and SLES
cd $SOURCE_ROOT
mkdir -p ~/pgdata
initdb -D ~/pgdata
pg_ctl -D ~/pgdata -l logfile -o "-k /tmp" start
psql -h /tmp -d postgres -c "CREATE USER postgres WITH PASSWORD 'postgres';"
psql -h /tmp -U postgres -d postgres -c "ALTER USER postgres WITH SUPERUSER;"
psql -h /tmp -U postgres -d postgres -c "CREATE DATABASE postgres OWNER postgres;"
pg_ctl -D ~/pgdata restart
pg_ctl -D ~/pgdata status

4.2. verify

psql -U postgres -d postgres              #Ubuntu
psql -h /tmp -U postgres -d postgres      #RHEL and SLES
CREATE EXTENSION vector;
\dx

Output should look like:

                             List of installed extensions
  Name   | Version |   Schema   |                     Description
---------+---------+------------+------------------------------------------------------
 plpgsql | 1.0     | pg_catalog | PL/pgSQL procedural language
 vector  | 0.8.0   | public     | vector data type and ivfflat and hnsw access methods
(2 rows)

5. Testing (Optional)

5.1. Run regression tests (start postgresql)

cd $SOURCE_ROOT/pgvector
export PGHOST=/tmp  #RHEL and SLES
make installcheck 

5.2. Run TAP tests

#for Ubuntu
cd $SOURCE_ROOT/pgvector
make prove_installcheck   

#for RHEL 9.4, 9.6
cd $SOURCE_ROOT
wget https://ftp.postgresql.org/pub/source/v13.20/postgresql-13.20.tar.bz2
tar -xf postgresql-13.20.tar.bz2
export PERL5LIB=$SOURCE_ROOT/postgresql-13.20/src/test/perl
cd $SOURCE_ROOT/pgvector
make prove_installcheck

#for SLES, RHEL 10 
wget https://ftp.postgresql.org/pub/source/v16.9/postgresql-16.9.tar.bz2
tar -xf postgresql-16.9.tar.bz2

#for SLES , RHEL (10, 8.10)
export PERL5LIB=$SOURCE_ROOT/postgresql-16.9/src/test/perl
cd $SOURCE_ROOT/pgvector
make prove_installcheck PROVE_FLAGS="-I $SOURCE_ROOT/postgresql-16.9/src/test/perl -I ./test/perl"

References:

Clone this wiki locally