postgresl 데이터베이스를 어떻게 업그레이드합니까? 비 호환성 오류 pg_upgrade -d /usr/local/var/postgres/ -D /usr/local/var/postgres

Homebrew를 통해 postgresql을 설치했습니다.

업그레이드 후 다음과 같은 문제가 있습니다.

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

업그레이드 방법에 대한 팁이 있습니까? 나는 다음을 시도했다.

$ pg_upgrade -d /usr/local/var/postgres/ -D /usr/local/var/postgres -b
/usr/local/Cellar/postgresql/9.0.4/bin -B /usr/local/Cellar/postgresql/9.1.2/bin

작동하지 않았다. 출력은 다음과 같습니다.

Performing Consistency Checks
Checking current, bin, and data directories                 ok
Checking cluster versions
This utility can only upgrade to PostgreSQL version 9.1.
Failure, exiting

오류.



답변

Homebrew가 포함 된 OS X의 경우 다음과 같습니다.

  1. Homebrew와 함께 새 postgres를 설치했습니다 (오류가 발생하기 시작 함)
  2. mv /usr/local/var/postgres /usr/local/var/postgres.old
  3. initdb -D /usr/local/var/postgres
  4. pg_upgrade -b /usr/local/Cellar/postgresql/9.0.4/bin -B /usr/local/Cellar/postgresql/9.1.2/bin -d /usr/local/var/postgres.old -D /usr/local/var/postgres
  5. ./delete_old_cluster.sh (이 스크립트는 위의 단계를 수행 할 때 현재 디렉토리에 자동으로 작성됩니다)
  6. rm delete_old_cluster.sh

답변

페도라에서 내가 한 일은 다음과 같습니다.

  • 이전 데이터 디렉토리의 이름을 data.old로 바꾸십시오.
  • postgresql-setup initdb이것을 실행 하면 새로운 데이터 디렉토리가 생성됩니다
  • 그런 다음 실행 pg_upgrade -b /usr/lib64/pgsql/postgresql-9.0/bin/ -B /usr/bin/ -d data.old/ -D data

나는 당신을 위해 생각합니다 :

pg_upgrade -b /usr/local/Cellar/postgresql/9.0.4/bin -B /usr/bin/ -d /usr/local/var/postgres.old/ -D /usr/local/var/postgres/
  • 또한 pg_hba.conf 및 postgresql.conf를 data.old에서 새 데이터 디렉토리로 복사하려고합니다.
  • postgresql을 다시 시작하십시오.

답변

“initdb”줄을 놓쳤거나 잊어 버렸습니다

initdb -D / usr / local / var / postgres

DB가 생성 된 후 pg_upgrade는 Windows 시스템에서 작동했습니다.


답변

들어 아치 리눅스 하는이 위키의 솔루션 나를 위해 벌금을했다 :

pacman -S --needed postgresql-old-upgrade
su -
su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/data-9.2'
su - postgres -c 'mkdir /var/lib/postgres/data'
su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'
su - postgres -c 'pg_upgrade -b /opt/pgsql-9.2/bin/ -B /usr/bin/ -d /var/lib/postgres/data-9.2 -D /var/lib/postgres/data'