LoginSignup
3
7

More than 5 years have passed since last update.

ubuntuでpostgres導入に失敗した時の解決策

Posted at

環境

  • Vagrant 1.8.1
  • Ubuntu 14.04.5 LTS, Trusty Tahr

事象

N予備校のpostgreSQLの導入でエラーが発生、1時間ほど詰まったのでメモ

posqgreSQL9.5を導入したいのに、テキスト通りコマンドを実行してもエラーが発生します。

$ sudo apt-get update
$ sudo apt-get install postgresql-9.5
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています 
状態情報を読み取っています... 完了
E: パッケージ postgresql-9.5 が見つかりません
E: 正規表現 'postgresql-9.5' ではパッケージは見つかりませんでした

ちなみにsudo apt-get installを実行すると9.3がインストールされます。

原因

ダウンロード先リポジトリに、http://apt.postgresql.org/pub/repos/apt/がないことが原因です。

デフォルトのリポジトリだと最新versionは9.3のようです。

解決

UbuntuにPostgreSQLをインストール

postgreSQL公式

postgrSQL公式の手順に則ってれば問題ありません。

まずubuntuのバージョン確認です。

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="14.04.2 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.2 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"

VERSIONTrustyですね

postgrSQL公式のプルダウンを該当のubuntuのバージョンにしましょう。

fullsizeoutput_4c4.jpeg

apt-getで独自リポジトリを設定したい場合は、/etc/apt/sources.list.d/に設定ファイルを作ります。

$ sudo touch /etc/apt/sources.list.d/pgdg.list
$ sudo echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
" >> /etc/apt/sources.list.d/pgdg.list

次にリポジトリを認証する鍵情報をローカルキーチェーンに取り込んでおきます。

$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
  sudo apt-key add -

最後にapt-getを実行しましょう。

$ sudo apt-get update
$ sudo apt-get install postgresql-9.5
3
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
7