During our PostgreSQL DBA Essentials workshops we install PostgreSQL from source code. We do that, to provide the participants all the options they have. There is nothing wrong with using a packaged distribution of PostgreSQL, don’t get me wrong, but knowing how it is working in the background is always a good idea. One question that comes up quite frequently is, how you can compile/install only the client. but not the server itself. Not a big deal, lets have a look:
We usually set three environment variables before we configure the source tree:
PGHOME=/u01/app/postgres/product/14/db_2/ SEGSIZE=2 BLOCKSIZE=8
The meaning of those variables is:
- PGHOME: This is the target directory for the installation
- SEGSIZE: This is the segment size, which defines how large a PostgreSQL data file can grow on disk (2GB in this example)
- BLOCKSIZE: The size of PostgreSQL block, 8k
Once we have that, we configure the source tree like this (this is for PostgreSQL 14):
./configure --prefix=${PGHOME} --exec-prefix=${PGHOME} --bindir=${PGHOME}/bin --libdir=${PGHOME}/lib --sysconfdir=${PGHOME}/etc --includedir=${PGHOME}/include --datarootdir=${PGHOME}/share --datadir=${PGHOME}/share --with-pgport=5432 --with-perl --with-python --with-openssl --with-pam --with-ldap --with-libxml --with-libxslt --with-segsize=${SEGSIZE} --with-blocksize=${BLOCKSIZE} --with-llvm LLVM_CONFIG='/usr/bin/llvm-config' --with-uuid=ossp --with-lz4 --with-gssapi --with-systemd --with-icu --with-system-tzdata=/usr/share/zoneinfo
To install the client only, all you have to do is this:
[email protected]:/home/postgres/postgresql/ [pgdev] make -C src/bin install [email protected]:/home/postgres/postgresql/ [pgdev] make -C src/include install [email protected]:/home/postgres/postgresql/ [pgdev] make -C src/interfaces install
This will give you all the client utilities but not the server itself:
[email protected]:/home/postgres/postgresql/ [pg15] ls /u01/app/postgres/product/14/db_2/bin/ clusterdb dropdb initdb pg_basebackup pg_config pg_dump pg_receivewal pg_restore pg_test_timing pg_waldump vacuumdb createdb dropuser pg_amcheck pgbench pg_controldata pg_dumpall pg_recvlogical pg_rewind pg_upgrade psql createuser ecpg pg_archivecleanup pg_checksums pg_ctl pg_isready pg_resetwal pg_test_fsync pg_verifybackup reindexdb
That’s it, pretty easy.