ฉันจะอัพเกรดฐานข้อมูล postgresl ได้อย่างไร ข้อผิดพลาดไม่เข้ากัน


26

ฉันติดตั้ง postgresql ผ่าน Homebrew

ฉันมีปัญหาดังต่อไปนี้หลังจากอัปเกรด:

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

ความผิดพลาด

คำตอบ:


36

สำหรับฉันใน OS X กับ Homebrew มันเป็นอย่างนี้

  1. ติดตั้ง postgres ใหม่ด้วย Homebrew (เริ่มได้รับข้อผิดพลาด)
  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 (สคริปต์นี้สร้างขึ้นสำหรับคุณโดยอัตโนมัติใน dir ปัจจุบันเมื่อคุณทำตามขั้นตอนข้างต้น)
  6. rm delete_old_cluster.sh

ยอดเยี่ยมและสิ่งที่ฉันต้องการเพื่อน! ขอบคุณ หลังจากการอัพเกรด Lion มาจาก Snow Leopard ตรวจสอบเซิร์ฟเวอร์ google คน !!
pjammer

มันทำงานได้อย่างสมบูรณ์แบบสำหรับฉันขอบคุณ! โปรดทราบว่า Postgres จะต้องไม่ถูกเรียกใช้ก่อนที่จะทำขั้นตอนเหล่านี้ดังนั้นหากคุณได้ติดตั้งมันผ่าน Homebrew launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plistให้แน่ใจว่าจะขนตัวแทนการเปิดตัวที่ทำให้มันเริ่มต้นโดยอัตโนมัติ: หลังจากทำตามขั้นตอนข้างต้นเสร็จแล้วให้โหลดใหม่อีกครั้ง:launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Markus Amalthea Magnuson

6

นี่คือวิธีที่ฉันทำกับ fedora:

  • เปลี่ยนชื่อไดเรกทอรีข้อมูลเก่าของคุณเป็น 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

1

ฉันพลาด / ลืมบรรทัด "initdb"

initdb -D / usr / local / var / postgres

หลังจากสร้างฐานข้อมูลแล้ว pg_upgrade จึงทำงานบนระบบ windows ของฉัน


0

สำหรับArch Linuxมีวิธีแก้ปัญหาใน wikiที่ทำงานได้ดีสำหรับฉัน:

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'
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.