#author("2018-06-21T12:45:47+00:00","default:haikikyou","haikikyou") [[HaikikyouのIT関連技術メモ]] #contents * pgenv2 [#u56e47f6] - ローカルマシン上で複数バージョンのPostgreSQLをインストールして管理するためのツール - テストや開発時に役に立つことを目的として作成 - レプリケーションクラスタを構築したり、動作確認を行なうのにも有用 * 動作要件 [#be893d48] - Bash 4.2 or later * インストール [#q61b577c] #geshi{{{ $ git clone https://github.com/moritoru81/pgenv2.git $ cd pgenv2 $ source install.sh }}} * 使用方法 [#n42a300c] ** 利用可能なバージョンを表示 [#j00178c6] #geshi(bash){{{ $ pgenv versions }}} ** インストール [#s0cffe32] #geshi(bash){{{ $ pgenv install 10.4 }}} ** デフォルト使用を10,4にする [#ia112e71] #geshi(bash){{{ $ pgenv global 10.4 }}} ** クラスタ [#o4b1a864] *** クラスタ作成 [#cb216090] #geshi(bash){{{ $ pgenv cluster -D clusterdir -s standby primary }}} *** クラスタ停止 [#id351be3] #geshi(bash){{{ $ pgenv cluster -D clusterdir stop -a }}} *** クラスタ起動 [#aa3325ca] #geshi(bash){{{ $ pgenv cluster -D clusterdir start -a }}} *** クラスタ状態表示 [#c9ad98e6] #geshi(bash){{{ $ pgenv cluster -D clusterdir status }}} *** クラスタノード追加/削除 [#da35623d] #geshi(bash){{{ $ pgenv cluster -D clusterdir ctrl --attach --fork-off primary standby2 $ pgenv cluster -D clusterdir ctrl --dettach standby2 }}} *** クラスタのログをtail [#v462b19f] #geshi(bash){{{ # 全てのインスタンスの最新ログをtail $ pgenv cluster -D clusterdir tail -f --all # primaryの最新ログのみtail $ pgenv cluster -D clusterdir tail -f primary # 全てのインスタンスの全てのログをtail $ pgenv cluster -D clusterdir tail -f --all --all-logs }}} * 参考リンク [#lc0f8e01] - https://github.com/moritoru81/pgenv2