PostgreSQL
インストール
- postgresql-x.x.x-windows-x64.exe を実行する。
-
- 開発用に利用する場合は、タスクバーの「ここに入力して検索」に services.msc を入力して Enter キーを押す。
- 「サービス」より以下のサービスのスタートアップの種類を手動に設定しておく。
- postgresql-x64-x
- pgbouncer
- pgsql_start.cmd ファイルを作成して手動起動できるようにしておく。
- pgsql_start.cmd
powershell start-process net -argumentlist \"start postgresql-x64-x\" -verb runas powershell start-process net -argumentlist \"start pgbouncer\" -verb runas
※x はインストールバージョンで置き換える。
- pgsql_stop.cmd ファイルを作成して手動停止できるようにしておく。
- pgsql_stop.cmd
powershell start-process net -argumentlist \"stop postgresql-x64-x\" -verb runas powershell start-process net -argumentlist \"stop pgbouncer\" -verb runas
※x はインストールバージョンで置き換える。
pgBouncer の設定
- pgbouncer_edit.cmd ファイルを作成して、設定を編集できるようにしておく。
- pgbouncer_edit.cmd
powershell start-process notepad -argumentlist \"C:\\Program Files (x86)\\PgBouncer\\share\\pgbouncer.ini\" -verb runas
- pgbouncer.ini の以下の部分を修正する。
[databases] database_name = host=localhost dbname=database_name user=user_name password=********
; any, trust, plain, crypt, md5 auth_type = any ;auth_file = 8.0/main/global/pg_auth ;auth_file = C:\Program Files (x86)\PgBouncer\etc\userlist.txt
- pgBouncer サービスを再起動して設定を反映させる。
アプリの設定
- pgBouncer を利用するには、6432 ポートを利用するように設定する。
- DB に接続できない場合は以下のログを確認する。
C:\Program Files (x86)\PgBouncer\log\pgbouncer.log