pgenv †
拙作ながら簡易的なスクリプトだが,十分に要件を満たしてくれる。
非推奨
現在は、以下に移行している。
https://github.com/moritetu/pgenv2
インストール †
$ git clone https://github.com/moritetu/pgenv $ cat <<EOS >> ~/.bash_profile ### start pgenv source `pwd`/pgenv/profile export PATH=`pwd`/pgenv/bin:\$PATH ### end pgenv EOS $ source ~/.bash_profile $ pgenv help
または
$ git clone https://github.com/moritetu/pgenv $ source pgenv/install.sh
PostgreSQLのインストールとバージョン切り替え †
# バージョン9.6.3をインストール (CFLAGSを-g3にする) $ pgenv install --g3 9.6.4 # デフォルトバージョンを9.6.3にする $ pgenv global 9.6.3 # デフォルトバージョンを一時的に9.6.3にしてサブシェルを起動する $ pgenv shell 9.6.3
現在のバージョンのパスを得る †
$ pgenv prefix $ pgenv prefix 9.6.3 $ pgenv source-prefix $ pgenv source-prefix 9.6.3 # 複数のインスタンスを起動する $ `pgenv prefx 9.5.4`/bin/pg_ctl -D db954 -w start $ `pgenv prefx 9.5.5`/bin/pg_ctl -D db955 -w -o '-p 5433' start
インストールされているバージョン一覧を得る †
# *は現在のコンテキストのバージョン $ pgenv list * 9.5.1 9.6.3
PostgreSQLの公式サイトからバージョン一覧を得る †
$ pgenv directories
configureオプションの切り替え †
優先度は,下に行くほど高い。prefix
は,pgenv内でインストール時に指定する。
- configure_default_options
- pgenvの下のファイルに書く
- configure_default_options-<version>
- pgenvの下のファイルに書く
- CONFIGURE_OPTIONS
- シェル変数で指定する
その他オプション †
usage: pgenv <command> [<args>] COMMAND: install [--g3] [--clean] [--shell] [--global] <version> Install PostgreSQL with the specified version. uninstall <version> Uninstall the specified version. version Show the version of the installed PostgreSQL. shell [--no-exec] <version> Switch current context to the specified version. global <version> Switch global context to the specified version. list Show installed version list. prefix [<version>] Show path to the specified version. source-prefix [<version>] Show path to the source directory of the specified version. diff <version1>:<version2>:<file> Show diffs of file beween version1 and version2. (diff -u ...). '@' equals the current version. ex) --diff 9.5.4:9.6.3:src/backend/parser/analyze.c edit <version>:<file> Open editor with the specified file. grep <version>:<directory>:"<regex>" Find and Grep. select [-g|--global] [--no-exec] Interactively select version in current context. (do exec $SHELL) directories Get and show version list from postgresql source repository link <version> <source> Create a symbolic link <version> to <source> under the version directory. help Show usage. COMMAND FOR CLUSTER: setup-cluster [--datadir] <synchronous standby number>:<ansynchronous standby number> Create a cluster. stop-cluster [--node <node>[,<node>...]>] <datadir> Stop a cluster. remove-cluster <datadir> Remove a cluster. ENVIRONMENT VARIABLES: LOG_LEVEL 0:debug, 1:info, 2:warn, 3:error CONFIGURE_OPTIONS This value is passed to the configure script of PostgreSQL. Default is '--enable-debug --with-libxml'. Also you can pass options to configure script, using file 'configure_default_options'. INSTALL: # ~/.bash_profile source /Users/guest/workspace/github/pgenv/profile Example) Install PostgreSQL Version 9.6.3 and set the global context to 9.6.3. $ pgenv install --g3 9.6.3 $ pgenv global 9.6.3 $ psql -V