#author("2019-01-05T15:25:42+00:00","default:haikikyou","haikikyou")
#author("2020-02-17T00:36:59+09:00","default:haikikyou","haikikyou")
[[PostgreSQL/開発]]
#contents


* pgenv [#j5052c5b]

拙作ながら簡易的なスクリプトだが,十分に要件を満たしてくれる。

&label(dup){非推奨};

現在は、以下に移行している。

https://github.com/moritetu/pgenv2

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

#geshi(bash){{
$ 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
}}

または

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

** PostgreSQLのインストールとバージョン切り替え [#wb504a17]
#geshi(bash){{{
# バージョン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
}}}

** 現在のバージョンのパスを得る [#ec3046eb]

#geshi(bash){{{
$ 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
}}}

** インストールされているバージョン一覧を得る [#me8884fe]

#geshi(bash){{{
# *は現在のコンテキストのバージョン
$ pgenv list
  * 9.5.1
    9.6.3
}}}

** PostgreSQLの公式サイトからバージョン一覧を得る [#h4bef2c5]

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

** configureオプションの切り替え [#maf5d027]

優先度は,下に行くほど高い。&code(prefix);は,pgenv内でインストール時に指定する。

- configure_default_options
-- pgenvの下のファイルに書く
- configure_default_options-<version>
-- pgenvの下のファイルに書く
- CONFIGURE_OPTIONS
-- シェル変数で指定する
** その他オプション [#qe46038b]

#geshi(bash){{{
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
}}}


* 参考リンク [#e8710de1]

- https://github.com/moritetu/pgenv

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