さくらのVPS*1を借りたので何も考えずにPostgreSQL9.0を入れようとしたらはまったという話。
#追記、下記現象はデフォルトの環境では起きないみたいです。
#私の環境がおかしかったらしい。
#けどま、はまった人が1人いたら30人はいるはずなので残しておきます。
さくらのVPSはCentOS5.5なのだけれど、契約してログインした直後はほとんど何もインストールされていない。
PostgreSQL9.0をインストールするときにはまる方法は以下の通り。
まず、
wget http://www.pgrpms.org/reporpms/9.0/pgdg-centos-9.0-2.noarch.rpm rpm -ivh pgdg-centos-9.0-2.noarch.rpm
としてリポジトリの情報をとってくる。で、
PostgreSQL RPM Repository (with Yum)
の中段にある「Important note」にあるように、
vi /etc/yum.repos.d/CentOS-Base.repo
として、baseセクションとupdateセクションに
exclude=postgresql*
とかいておもむろに
yum install httpd postgresql-server
とかやると、
Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.2.3-43.el5.centos.3 set to be updated --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd --> Running transaction check ---> Package apr-util.x86_64 0:1.2.7-11.el5_5.2 set to be updated --> Processing Dependency: libpq.so.4()(64bit) for package: apr-util --> Finished Dependency Resolution apr-util-1.2.7-11.el5_5.2.x86_64 from updates has depsolving problems --> Missing Dependency: libpq.so.4()(64bit) is needed by package apr-util-1.2.7-11.el5_5.2.x86_64 (updates) Error: Missing Dependency: libpq.so.4()(64bit) is needed by package apr-util-1.2.7-11.el5_5.2.x86_64 (updates) You could try using --skip-broken to work around the problem You could try running: package-cleanup --problems package-cleanup --dupes rpm -Va --nofiles --nodigest
と、libpq.so.4への参照がないとか言って怒られる。PostgreSQL8系のいつごろからかlibpq.so.4ではなくlibpq.so.5がインストールされるようになっているから怒られるのだけれど、PostgreSQL8.4とかでは怒られなかったし、ほかのサーバーでインストールしたときは怒られなかったのに、何で・・・?
と思ってググってみると、libpq.so.4を提供しているパッケージは
compat-postgresql-libs
というパッケージらしい。ほう、と思って
yum search compat-postgresql-libs
するも
Warning: No matches found for: compat-postgresql-libs No Matches found
Fxxk!
というわけで、見事にはまれます。
pg_config, ruby pg, postgresql 9.0 problem after upgrade, centos 5 - Stack OverflowやCentOS5.5へPostgreSQL9.0をyumでインストールする - bose999の試験管の中の話でも触れられているけど、そもそも、PostgreSQL9.0のリポジトリには、compat-postgresql-libsパッケージがないのが問題。8.4のリポジトリにはあるのに。
なわけで、解決方法としては
rpm -e pgdg-centos wget http://www.pgrpms.org/reporpms/8.4/pgdg-centos-8.4-2.noarch.rpm rpm -ivh wget pgdg-centos-8.4-2.noarch.rpm yum install compat-postgresql-libs
としてcompatライブラリ*2を入れたのち、
rpm -e pgdg-centos rpm -ivh pgdg-centos-9.0-2.noarch.rpm
として、
yum install httpd postgresql-server
とすると、
Complete!
となり、ヒャッハーです。