2013-12-24 17 views
13

私はmavericksにアップグレードして新しい宝石をインストール/コンパイルするときに問題があったので、xcodeを再インストールして、醸造のアップデートとアップグレードを行いました。宝石は今働き、最近の再起動までしばらくポストグルが働いていました。今Postgreは問題を抱えているようです。更新/アップグレード後のポストグルの修正方法

postgres: 

postgres does not know where to find the server configuration file. 
You must specify the --config-file or -D invocation option or set the PGDATA environment variable. 


brew info postgres: 

postgresql: stable 9.3.2 (bottled) 
http://www.postgresql.org/ 
Conflicts with: postgres-xc 
/usr/local/Cellar/postgresql/9.2.4 (2842 files, 39M) 
    Built from source 
/usr/local/Cellar/postgresql/9.3.2 (2924 files, 39M) * 
    Poured from bottle 

postgres -D /usr/local/var/postgres: 

FATAL: database files are incompatible with server 
DETAIL: The data directory was initialized by PostgreSQL version 9.2, which is not compatible with this version 9.3.2. 

データベースを再び稼働させるには、今何をすべきですか?

答えて

4

既存のデータディレクトリにアクセスするには、何とかインストールされたPostgreSQL 9.2のコピーを入手する必要があります。自作を介して9.2をインストールするため

オプション:

  • postgresql式が9.3にアップグレードされる前から自作のチェックアウトを取得します。
  • postgresql92homebrew/versions tapからインストールします。
  • インストールpostgresql-9.2petere/postgresqlタップから(開示:これは私のプロジェクトです)
  • ソースからインストールしてください。

pg_dumpまたはpg_upgradeのいずれかを使用して9.3にアップグレードする必要があります。

pg_upgradeがこの目的のために提供されており、それを使用するのは簡単です。ちょうどあなたが新しいデータとバイナリに(-D及び-B)を古いデータとバイナリのための右のパス(-dと-b)と右のパスを指定していることを確認してください:

pg_upgrade \ 
-d /usr/local/var/postgres/9.2/ -D /usr/local/var/postgres/9.3/ \ 
-b /usr/local/Cellar/postgresql/9.2.4/bin/ -B /usr/local/Cellar/postgresql/9.3.2/bin/ 

すべての場合罰金、することができますその後、クリーンアップ、古いバージョンを行くbrew cleanup postgresql、 とPostgreSQLの新バージョンはRubyのPG宝石で使用されているネイティブライブラリの新しいバージョンを意味するので、あなたはそれを再コンパイルすることもできます。

gem uninstall pg 
ARCHFLAGS="-arch x86_64" gem install pg 
25
$ brew tap homebrew/versions 
$ brew install postgresql92 
$ brew switch postgresql 9.2.8 # might need to check this one, could be newer by the time you read this 
$ pg_dumpall > ninedottwo-dump 
$ brew uninstall postgresql92 
$ brew switch postgresql 9.3.4 # again, check version 
$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start 
$ createdb # i got an error about my database not existing, so i had to run this 
$ psql < ninedottwo-dump 
$ bundle exec rails s 

私をriで始めてくれたPeterのおかげでght方向。

編集:これはすべてを一度にすべてをアップグレードするために私を教えてあげる... 9.5から9.2の場合

+2

+1コメントを編集してください。誤ってアップグレードして元に戻す必要がある場合は、** rm -rf /usr/local/Cellar/postgresql/9.4...** ** brew switch postgresql 9.4 .... * * – Lisandro

+0

は2016年に有効ですか? – SuperUberDuper

+0

9.2と9.3と9.3と9.4の間のジャンプを橋渡しするように見えました...あなたのデータファイルをバックアップして、この手順を試してみて、それがどのようになったのか教えてください。 – sent1nel

1

、エルキャピタンには、私は他の人を助けるかもしれないカップルの問題に走りました。

switch文で使用されるパッケージの名前がバージョン番号(postgresql92とpostgresql)を含むように変更されたようです。

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start 

、私はPostgresのサーバを起動するために必要なダンプを実行するために

brew unlink postgresql 
brew link postgresql92 
brew switch postgresql92 9.2.13 # match version 

しかし、その後、私はに走った:だから、私はpostgresの現在のバージョンをアンリンクの追加ステップを持つことが必要

psql: could not connect to server: No such file or directory 
    Is the server running locally and accepting 
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"? 

私は、ログをチェックして、この発見:恐ろしい

could not open directory "pg_tblspc": No such file or directory 

this answerDonovanによれば、ヨセミテとエルキャピタンは必要なディレクトリを削除します。だから私はまた戻ってそうNate

mkdir /usr/local/var/postgres/{pg_tblspc,pg_twophase,pg_stat,pg_stat_tmp,pg_replslot,pg_snapshots}/ 

でフル更新されたバージョンを、この素晴らしいコマンドを使用してこれらのディレクトリを追加する必要がある:

brew tap homebrew/versions 
brew install postgresql92 
brew unlink postgresql 
brew switch postgresql92 9.2.13 # might need to check this one, could be newer by the time you read this 
mkdir /usr/local/var/postgres/{pg_tblspc,pg_twophase,pg_stat,pg_stat_tmp,pg_replslot,pg_snapshots}/ 
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start 
pg_dumpall > ninedottwo-dump 
pg_ctl -D /usr/local/var/postgres stop 
brew unlink postgresql92 
brew uninstall postgresql92 
brew switch postgresql 9.5.2 # again, check version 
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start 
createdb # i got an error about my database not existing, so i had to run this 
psql < ninedottwo-dump 
bundle install # need to make sure you have pg gem for 9.5 
bundle exec rails s 

すべてのクレジットは、sentinelに行くネイト、そしてドノバン。本当にありがとう!

関連する問題