#author("2018-06-21T13:06:31+00:00","default:haikikyou","haikikyou")
#author("2019-01-14T10:02:41+00:00","default:haikikyou","haikikyou")
#contents

* pgenv2 [#u56e47f6]

- ローカルマシン上で複数バージョンのPostgreSQLをインストールして管理するためのツール
- テストや開発時に役に立つことを目的として作成
- レプリケーションクラスタを構築したり、動作確認を行なうのにも有用

* 動作要件 [#be893d48]

- Bash 4.2 or later

* インストール [#q61b577c]

#geshi(bash){{{
$ git clone https://github.com/moritoru81/pgenv2.git
$ git clone https://github.com/moritetu/pgenv2.git
$ cd pgenv2
$ source install.sh
}}}

* 使用方法 [#n42a300c]

** 利用可能なバージョンを表示 [#j00178c6]

#geshi(bash){{{
$ pgenv versions
}}}

** インストール [#s0cffe32]

#geshi(bash){{{
$ pgenv install 10.4
# 11.1をdebugでインストール、ソースやインストール先は11.1debugとする
$ pgenv install --alias 11.1debug --debug --g3 11.1
}}}

** デフォルト使用を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
}}}

** 拡張機能 [#neb0a391]

拡張機能の雛形を作成

#geshi(bash){{{
$ pgenv extension init myext
}}}

拡張機能をビルド

#geshi(bash){{{
$ cd myext
$ pgenv extension install -v @all
}}}

拡張機能の確認

#geshi(bash){{{
$ pgenv extension run -v @all 'initdb  ${ver}data'
$ pgenv extension run -v @all 'pg_ctl start -l $ver.log -D ${ver}data -o "-p $((9000+i))"'
$ pgenv extension run -v @all 'psql -p $((9000+i)) postgres -c "create extension myext"'
$ pgenv extension run -v @all 'psql -p $((9000+i)) postgres -c "select myext()"'
}}}

** その他実行 [#p9fc421a]

環境変数のダンプ

#geshi(bash){{{
$ pgenv env -w
$ pgenv env -e myenv
}}}

環境変数を考慮した実行

#geshi(bash){{{
$ pgenv -e myenv <<<EOF
initdb pgdata
pg_ctl start -D pgdata -l pg.log
psql postgres
EOF
}}}

* 参考リンク [#lc0f8e01]

- https://github.com/moritoru81/pgenv2
- https://github.com/moritetu/pgenv2


トップ   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
目次
ダブルクリックで閉じるTOP | 閉じる
GO TO TOP