#navi(../)
* PostgreSQLのクライアント側のみのインストール方法 [#zd12fa0a]
本資料では、PostgreSQLのクライアントのみのインストール方法を以下に記します。

#contents
#htmlinsertpcsp(db-top.html,db-sp.html)

* 参考資料 [#g9659298]
-[[PostgreSQL 9.2.0文書 第 15章ソースコードからインストール>http://www.postgresql.jp/document/9.2/html/install-procedure.html]]

* CentOSのパッケージを利用した場合 [#eda4c2e3]
CentOSのパッケージを確認してみます。~
** CentOS 6の場合 [#uee2c295]
CentOS6でyumコマンドを使って調べた結果です。~
使用したCentOS6は64bit版です。
 $ yum search postgresql
 Loaded plugins: fastestmirror
 Loading mirror speeds from cached hostfile
  * base: ftp.iij.ad.jp
  * extras: ftp.iij.ad.jp
  * updates: centos.ustc.edu.cn
 =========================== N/S Matched: postgresql ============================
 freeradius-postgresql.x86_64 : Postgresql support for freeradius
 postgresql.i686 : PostgreSQL client programs
 postgresql.x86_64 : PostgreSQL client programs
 postgresql-contrib.x86_64 : Contributed modules distributed with PostgreSQL
 postgresql-devel.i686 : PostgreSQL development header files and libraries
 postgresql-devel.x86_64 : PostgreSQL development header files and libraries
 postgresql-docs.x86_64 : Extra documentation for PostgreSQL
 postgresql-jdbc.x86_64 : JDBC driver for PostgreSQL
 postgresql-jdbc.noarch : JDBC driver for PostgreSQL
 postgresql-libs.i686 : The shared libraries required for any PostgreSQL clients
 postgresql-libs.x86_64 : The shared libraries required for any PostgreSQL
 <snip>

上記の出力からわかるように、postgresql.i686, postgresql.x86_64がPostgreSQLのクライアントプログラムのパッケージであることが確認できます。~
- postgresql.i686 (32bit版)
- postgresql.x86_64 (64bit版)

yumコマンドで以下のようにすればPostgreSQLのクライアントプログラムをインストールすることができます。
 yum install postgresql

** CentOS 5の場合 [#w4264e75]
CentOS5でyumコマンドを使って調べた結果です。~
使用したCentOS5は64bit版です。
 $ yum search postgresql
 ============================= Matched: postgresql ==============================
 <snip>
 postgresql.x86_64 : PostgreSQL のクライアントプログラムとライブラリ
 postgresql-contrib.x86_64 : Contributed source and binaries distributed with
                           : PostgreSQL
 postgresql-dbi-link.noarch : Partial implementation of the SQL/MED portion of
                            : the SQL:2003 specification
 postgresql-devel.i386 : PostgreSQL 開発ヘッダーファイルとライブラリ
 postgresql-devel.x86_64 : PostgreSQL 開発ヘッダーファイルとライブラリ
 postgresql-docs.x86_64 : Extra documentation for PostgreSQL
 <snip>
 postgresql84.x86_64 : PostgreSQL client programs
 postgresql84-contrib.x86_64 : Contributed modules distributed with PostgreSQL
 postgresql84-devel.i386 : PostgreSQL development header files and libraries
 postgresql84-devel.x86_64 : PostgreSQL development header files and libraries
 <snip>


上記の出力からわかるように、postgresql, postgresql84の2つパッケージがPostgreSQLのクライアントプログラムのパッケージであることが確認できます。~
どちらのパッケージをインストールすればいいかをyum infoコマンドで確認してみます。
- postgresqlパッケージ
 $ yum info postgresql
 Installed Packages
 Name       : postgresql
 Arch       : x86_64
 Version    : 8.1.23
 Release    : 6.el5_8
 Size       : 11 M
 Repo       : installed
 Summary    : PostgreSQL のクライアントプログラムとライブラリ
 <snip>
- postgresql84パッケージ
 $ yum info postgresql84
 Available Packages
 Name       : postgresql84
 Arch       : x86_64
 Version    : 8.4.13
 Release    : 1.el5_8
 Size       : 3.7 M
 Repo       : base
 Summary    : PostgreSQL client programs

yum infoコマンドでパッケージを確認するとバージョンが異なる事が確認できました。~
したがって、みなさんの環境に応じて以下のコマンドでどちらかのパッケージをインストールします。

yumコマンドで以下のようにすればPostgreSQLのクライアントプログラムをインストールすることができます。
 yum install postgresql
または
 yum install postgresql84

** Ubuntuの場合 [#ub1bfed6]
Ubuntu12.04を使用して以下の資料を作成しました。~
apt-cacheコマンドでPostgreSQLのパッケージを確認してみます。
 sakura@ubuntu1204:~$ apt-cache search postgresql | grep ^postgresql
 postgresql - object-relational SQL database (supported version)
 postgresql-9.1 - object-relational SQL database, version 9.1 server
 postgresql-9.1-dbg - debug symbols for postgresql-9.1
 postgresql-client - front-end programs for PostgreSQL (supported version)
 postgresql-client-9.1 - front-end programs for PostgreSQL 9.1
 postgresql-contrib - additional facilities for PostgreSQL (supported version)
 postgresql-contrib-9.1 - additional facilities for PostgreSQL
 <snip>
 postgresql-8.4 - object-relational SQL database, version 8.4 server
 postgresql-client-8.4 - front-end programs for PostgreSQL 8.4
 postgresql-client-common - manager for multiple PostgreSQL client versions
 postgresql-common - PostgreSQL データベースクラスタマネージャ
 postgresql-contrib-8.4 - additional facilities for PostgreSQL
 postgresql-doc-8.4 - documentation for the PostgreSQL database management system
 postgresql-server-dev-8.4 - development files for PostgreSQL 8.4 server-side programming
 <snip>
apt-cacheで確認すると以下のように3つのクライアントパッケージが検索されました。
-postgresql-client
-postgresql-client-9.1
-postgresql-client-8.4

各パッケージの情報をapt-cache showで確認しました。
-postgresql-client
 sakura@ubuntu1204:~$ apt-cache show postgresql-client
 Package: postgresql-client
 Priority: optional
 Section: database
 Installed-Size: 63
 Maintainer: Martin Pitt <martin.pitt@ubuntu.com>
 Original-Maintainer: Martin Pitt <mpitt@debian.org>
 Architecture: all
 Source: postgresql-common (129ubuntu1)
 Version: 9.1+129ubuntu1
 Depends: postgresql-client-9.1
 Filename: pool/main/p/postgresql-common/postgresql-client_9.1+129ubuntu1_all.deb
-postgresql-client-8.4
 sakura@ubuntu1204:~$ apt-cache show postgresql-client-8.4
 Package: postgresql-client-8.4
 Priority: optional
 Section: universe/database
 Installed-Size: 4219
 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
 Original-Maintainer: Martin Pitt <mpitt@debian.org>
 Architecture: i386
 Source: postgresql-8.4
 Version: 8.4.15-0ubuntu12.04
 Provides: postgresql-client
-postgresql-client-9.1
 sakura@ubuntu1204:~$ apt-cache show postgresql-client-9.1
 Package: postgresql-client-9.1
 Priority: optional
 Section: database
 Installed-Size: 2708
 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
 Original-Maintainer: Martin Pitt <mpitt@debian.org>
 Architecture: i386
 Source: postgresql-9.1
 Version: 9.1.7-0ubuntu12.04
 Replaces: postgresql-9.1 (<< 9.1.7-0ubuntu12.04)
 Provides: postgresql-client
みなさんの環境に応じて以下のコマンドでパッケージをインストールします。

 apt-get install postgresql-client
または
 apt-get install postgresql-client-8.4
または
 apt-get install postgresql-client-9.1

* PostgreSQLのソースコードからインストールする場合 [#a2c9dd7c]
本記事では、PostgreSQL9.2を利用して動作確認をしました。~
上記の参考資料のURLに記述してある通り、コンパイル後に以下のコマンドを実行するとクライアント側のみのインストールができるようです。
 gmake -C src/bin install
 gmake -C src/include install
 gmake -C src/interfaces install
 gmake -C doc install
実際に試した時の出力などを下記に記します。~
PostgreSQLのソースをダウンロードし上記のクライアント側のみのインストールをしてみます。
+ PostgreSQLのソースコードの入手。~
本記事では、postgresql-9.1.7.tar.gzをダウンロードしました。
+ ダウンロードしたソースを展開します。
 [sakura@centos6 ~]$ tar zxvf postgresql-9.1.7.tar.gz
 drwxrwxrwx pgsql/pgsql       0 2012-12-04 05:37 postgresql-9.1.7/
 drwxrwxrwx pgsql/pgsql       0 2012-12-04 05:34 postgresql-9.1.7/contrib/
 drwxrwxrwx pgsql/pgsql       0 2012-12-04 05:34 postgresql-9.1.7/contrib/sslinfo/
 <snip>
+本記事ではCentOS6を使ってPostgreSQLをソースからインストールしています。~
以下のコマンドでコンパイルに必要なreadline-devel, zlib-develをインストールしました。
 yum install readline-devel zlib-devel
+ configureコマンドの実行~
インストールディレクトリを$HOME/pgsqlに設定しました。
 [sakura@centos6 ~]$ cd postgresql-9.1.7
 [sakura@centos6 postgresql-9.1.7]$ ./configure --prefix $HOME/pgsql
 checking build system type... x86_64-unknown-linux-gnu
 checking host system type... x86_64-unknown-linux-gnu
 checking which template to use... linux
 <snip>
+ makeコマンドでコンパイルします。
 [sakura@centos6 postgresql-9.1.7]$ make
 <snip>
 All of PostgreSQL successfully made. Ready to install.
+ PostgreSQLのドキュメントに書いてあった以下のコマンドを順番に実行します。
 gmake -C src/bin install
 gmake -C src/include install
 gmake -C src/interfaces install
 gmake -C doc install
ちなみにCentOSではgmakeとmakeは同じものです。
[sakura@centos6 ~]$ ls -l /usr/bin/gmake
 lrwxrwxrwx. 1 root root 4 12月 25 23:59 2012 /usr/bin/gmake -> make
configureでインストール先ディレクトリを$HOME/pgsqlに指定しました。~
上記コマンドによりインストールされたクライアントプログラムなどを確認することができます。~
 [sakura@centos6 ~]$ find $HOME/pgsql
 /home/sakura/pgsql
 /home/sakura/pgsql/bin
 /home/sakura/pgsql/bin/clusterdb
 /home/sakura/pgsql/bin/createdb
 /home/sakura/pgsql/bin/pg_basebackup
 /home/sakura/pgsql/bin/createuser
 /home/sakura/pgsql/bin/droplang
 /home/sakura/pgsql/bin/dropuser
 /home/sakura/pgsql/bin/vacuumdb
 /home/sakura/pgsql/bin/dropdb
 /home/sakura/pgsql/bin/pg_ctl
 /home/sakura/pgsql/bin/pg_dumpall
 /home/sakura/pgsql/bin/ecpg
 /home/sakura/pgsql/bin/psql
 /home/sakura/pgsql/bin/createlang
 /home/sakura/pgsql/bin/pg_resetxlog
 /home/sakura/pgsql/bin/reindexdb
 /home/sakura/pgsql/bin/pg_restore
 /home/sakura/pgsql/bin/initdb
 /home/sakura/pgsql/bin/pg_dump
 /home/sakura/pgsql/bin/pg_controldata
 /home/sakura/pgsql/bin/pg_config
 <省略>
上記findコマンドの出力の抜粋です。~
binディレクトリには上記のコマンドがインストールされています。~

以上、PostgreSQLのクライアントプログラムのインストールについて記述しました。

#htmlinsertpcsp(db-btm.html,db-sp.html)

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS