3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PostgreSQLのインストールでServerとClientって何が違うの?

3
Posted at

PostgreSQLのインストールでServerとClientって何が違うの?

PostgreSQLのサーバー版とクライアント版って何が違うんでしょうね?
「クライアント版は単にサーバー版からRDBMS抜いただけ」なのか
「クライアント版はCLIクライアントだけ」なのか
せっかくなのでVM環境でインストールして調べてみました

(いやまぁpg_dump探してるだけなんですけどね。クライアントっちゃクライアントな気もするしサーバー付属ツールっちゃサーバー付属ツールな気もするし。結局公式見てもどっちのパッケージに入ってるのか説明らしいのが見当たらないし。サーバー版をインストールすれば入ってくるんでしょうけどそこまではしたくないというか、クライアント版だけで済んでくれるならいいんだけど。。。という方向けです。つまりイッツミー。)

テスト環境

  • Ubuntu 24.04
  • PostgreSQL18
  • PostgreSQL-client-18

Ubuntu 24.04上に公式手順のAutomated Repository Configurationでリポジトリを追加してaptでインストールしてみます。

PostgreSQL18 (サーバー)

sudo apt install -y postgresql-18

PostgreSQL-client-18 (クライアント)

sudo apt install -y postgresql-client-18

なにが違うんだべ?

まずインストール先を追いかけてみると

サーバー版の /usr/bin で ls -al | grep postgresql してみるとこんな感じに

lrwxrwxrwx  1 root root          37 Feb 26 11:04 clusterdb -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 createdb -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 createlang -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 createuser -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 dropdb -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 droplang -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 dropuser -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 pg_archivecleanup -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 pg_basebackup -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 pgbench -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 pg_dump -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 pg_dumpall -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 pg_isready -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 pg_receivewal -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 pg_receivexlog -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 pg_recvlogical -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 pg_restore -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 psql -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 reindexdb -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 vacuumdb -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Feb 26 11:04 vacuumlo -> ../share/postgresql-common/pg_wrapper

クライアント版はというとこんな感じに

lrwxrwxrwx  1 root root          37 Aug  9  2024 clusterdb -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 createdb -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 createlang -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 createuser -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 dropdb -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 droplang -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 dropuser -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 pg_archivecleanup -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 pg_basebackup -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 pgbench -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 pg_dump -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 pg_dumpall -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 pg_isready -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 pg_receivewal -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 pg_receivexlog -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 pg_recvlogical -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 pg_restore -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 psql -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 reindexdb -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 vacuumdb -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx  1 root root          37 Aug  9  2024 vacuumlo -> ../share/postgresql-common/pg_wrapper

クライアント部分については違いがないようですね。
psqlしか入ってないとかではなくて、pg_dumpやvacuumdbなんかもクライアント版でインストールされます。

ところでこのpg_wrapperというのはどうしてこういう構造にしたのかよくわかりませんが、とりあえずいったんこのPerlスクリプトを呼び出してから実体である/usr/lib/postgresql/18/のプログラムを呼び出しているようです。

実体のあるディレクトリを追いかけてみると

/usr/lib/postgresql/18/にlibとbinの2つのディレクトリがあります。

サーバー版はこんな感じ。

:~$ ls /usr/lib/postgresql/18/bin
clusterdb   dropuser    pg_archivecleanup  pg_combinebackup     pg_ctl      pg_receivewal   pg_rewind       pg_verifybackup  psql
createdb    initdb      pg_basebackup      pg_config            pg_dump     pg_recvlogical  pg_test_fsync   pg_waldump       reindexdb
createuser  oid2name    pgbench            pg_controldata       pg_dumpall  pg_resetwal     pg_test_timing  pg_walsummary    vacuumdb
dropdb      pg_amcheck  pg_checksums       pg_createsubscriber  pg_isready  pg_restore      pg_upgrade      postgres         vacuumlo
:~$ ls /usr/lib/postgresql/18/lib
amcheck.so              cyrillic_and_mic.so  fuzzystrmatch.so       moddatetime.so         pgstattuple.so    sslinfo.so            utf8_and_euc_kr.so
auth_delay.so           dblink.so            hstore.so              pageinspect.so         pg_surgery.so     tablefunc.so          utf8_and_euc_tw.so
auto_explain.so         dict_int.so          insert_username.so     passwordcheck.so       pg_trgm.so        tcn.so                utf8_and_gb18030.so
autoinc.so              dict_snowball.so     _int.so                pg_buffercache.so      pg_visibility.so  test_decoding.so      utf8_and_gbk.so
basebackup_to_shell.so  dict_xsyn.so         isn.so                 pgcrypto.so            pg_walinspect.so  tsm_system_rows.so    utf8_and_iso8859_1.so
basic_archive.so        earthdistance.so     latin2_and_win1250.so  pg_freespacemap.so     pgxml.so          tsm_system_time.so    utf8_and_iso8859.so
bitcode                 euc2004_sjis2004.so  latin_and_mic.so       pg_logicalinspect.so   pgxs              unaccent.so           utf8_and_johab.so
bloom.so                euc_cn_and_mic.so    libpqwalreceiver.so    pgoutput.so            plpgsql.so        utf8_and_big5.so      utf8_and_sjis2004.so
btree_gin.so            euc_jp_and_sjis.so   llvmjit.so             pg_overexplain.so      postgres_fdw.so   utf8_and_cyrillic.so  utf8_and_sjis.so
btree_gist.so           euc_kr_and_mic.so    llvmjit_types.bc       pg_prewarm.so          refint.so         utf8_and_euc2004.so   utf8_and_uhc.so
citext.so               euc_tw_and_big5.so   lo.so                  pgrowlocks.so          seg.so            utf8_and_euc_cn.so    utf8_and_win.so
cube.so                 file_fdw.so          ltree.so               pg_stat_statements.so  sepgsql.so        utf8_and_euc_jp.so    uuid-ossp.so

すごくたくさん入っています。サーバー版なので全部入ってるとこんな感じなんですね。
続いてクライアント版を見てみるとこんな感じです。

:~$ ls /usr/lib/postgresql/18/bin
clusterdb  createuser  dropuser    pg_basebackup     pg_config  pg_dumpall  pg_receivewal   pg_restore       psql       vacuumdb
createdb   dropdb      pg_amcheck  pg_combinebackup  pg_dump    pg_isready  pg_recvlogical  pg_verifybackup  reindexdb
:~$ ls /usr/lib/postgresql/18/lib
pgxs

サーバー版とクライアント版で微妙に違ってますが、ラッパーがリンクされていないコマンドとかはここに到達できるのかちょっと不思議ですね。
一番違うのは/usr/lib/postgresql/18/lib ディレクトリです。
クライアント版はディレクトリが作られるだけでほとんど空っぽですが、サーバー版だとそこに様々なモジュール群と思しきライブラリが展開されています。
大雑把に見た感じでは、「クライアント版ではリモートのサーバーに対して利用できるコマンドが選択されている」という感じに見えます。
合理的な感じはしますね。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?