LoginSignup
6
6

More than 5 years have passed since last update.

RedmineとPostgreSQLをUnixドメインソケットで接続する。

Posted at

RedmineとPostgreSQL間の通信をUnixドメインソケットにすることが出来ます。
PostgreSQLの初期設定(pg_hba.conf)では、Unixドメインソケットの通信はpeer認証となっています。
redmine実行ユーザとPosgreSQLのユーザが同じ場合は、この初期設定(pg_hba.conf)を変更せずに使用できます。

環境

PostgreSQL v9.4.1
Redmine v3.0.0

設定

/var/lib/pgsql/9.4/data/pg_hba.conf
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            ident
# IPv6 local connections:
host    all             all             ::1/128                 ident

hostを/tmpにすると、PostgreSQLのソケットファイル/tmp/.s.PGSQL.5432経由で通信します。
もしソケットファイルの場所を変更している場合は、変更先のディレクトリ名を設定します。

/home/redmine/redmine/config/database.yml
# PostgreSQL configuration
production:
  adapter: postgresql
  database: redmine
  host: /tmp
  username: redmine
  encoding: utf8

参考

Can not connect to local PostgreSQL

6
6
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
6
6