brew postgresql升级数据库在迁移和升级数据时失败

brew postgresql升级数据库在迁移和升级数据时失败,postgresql,macos,homebrew,Postgresql,Macos,Homebrew,我只是坐下来工作,忘记了我在2020年升级了brew,所以我当然有postgresql问题 我的上一个版本是12.x。现在我已经安装了13.1: $ brew info postgres Warning: Treating postgres as a formula. For the cask, use homebrew/cask/postgres postgresql: stable 13.1 (bottled), HEAD Ob

我只是坐下来工作,忘记了我在2020年升级了brew,所以我当然有postgresql问题

我的上一个版本是12.x。现在我已经安装了13.1:

$ brew info postgres                                
Warning: Treating postgres as a formula. For the cask, use homebrew/cask/postgres
postgresql: stable 13.1 (bottled), HEAD
Object-relational database system
https://www.postgresql.org/
/usr/local/Cellar/postgresql/13.1 (3,217 files, 42.6MB) *
  Poured from bottle on 2020-12-26 at 14:36:54
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/postgresql.rb
License: PostgreSQL
==> Dependencies
Build: pkg-config ✔
Required: icu4c ✔, krb5 ✔, openssl@1.1 ✔, readline ✔
==> Options
--HEAD
    Install HEAD version
==> Caveats
To migrate existing data from a previous major version of PostgreSQL run:
  brew postgresql-upgrade-database

This formula has created a default database cluster with:
  initdb --locale=C -E UTF-8 /usr/local/var/postgres
For more details, read:
  https://www.postgresql.org/docs/13/app-initdb.html

To have launchd start postgresql now and restart at login:
  brew services start postgresql
Or, if you don't want/need a background service you can just run:
  pg_ctl -D /usr/local/var/postgres start
==> Analytics
install: 181,394 (30 days), 574,628 (90 days), 1,984,700 (365 days)
install-on-request: 176,623 (30 days), 554,629 (90 days), 1,910,250 (365 days)
build-error: 0 (30 days)
在输出之后,我尝试运行
brew postgresql升级数据库
,但不起作用–以下是输出:

$ brew postgresql-upgrade-database --debug --verbose
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/postgresql.rb
==> Upgrading postgresql data from 12 to 13...
/usr/local/Cellar/postgresql@12/12.5/bin/pg_ctl -w -D /usr/local/var/postgres start
waiting for server to start....2021-01-04 17:37:33.282 CET [8190] FATAL:  database files are incompatible with server
2021-01-04 17:37:33.282 CET [8190] DETAIL:  The database cluster was initialized with PG_CONTROL_VERSION 1300, but the server was compiled with PG_CONTROL_VERSION 1201.
2021-01-04 17:37:33.282 CET [8190] HINT:  It looks like you need to initdb.
2021-01-04 17:37:33.282 CET [8190] LOG:  database system is shut down
 stopped waiting
pg_ctl: could not start server
Examine the log output.
==> Moving postgresql data from /usr/local/var/postgres to /usr/local/var/postgres.old...
==> Creating database...
/usr/local/opt/postgresql/bin/initdb /usr/local/var/postgres
The files belonging to this database system will be owned by user "nyc".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /usr/local/var/postgres ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Europe/Warsaw
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /usr/local/opt/postgresql/bin/pg_ctl -D /usr/local/var/postgres -l logfile start

==> Migrating and upgrading data...
/usr/local/opt/postgresql/bin/pg_upgrade -r -b /usr/local/Cellar/postgresql@12/12.5/bin -B /usr/local/opt/postgresql/bin -d /usr/local/var/postgres.old -D /usr/local/var/postgres -j 4
Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok

The source cluster was not shut down cleanly.
Failure, exiting
Error: Upgrading postgresql data from 12 to 13 failed!
==> Removing empty postgresql initdb database...
==> Moving postgresql data back from /usr/local/var/postgres.old to /usr/local/var/postgres...
Error: Failure while executing; `/usr/local/opt/postgresql/bin/pg_upgrade -r -b /usr/local/Cellar/postgresql@12/12.5/bin -B /usr/local/opt/postgresql/bin -d /usr/local/var/postgres.old -D /usr/local/var/postgres -j 4` exited with 1.
/usr/local/Homebrew/Library/Homebrew/utils.rb:303:in `safe_system'
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/cmd/postgresql-upgrade-database.rb:126:in `block in postgresql_upgrade_database'
/usr/local/Homebrew/Library/Homebrew/extend/pathname.rb:318:in `block in cd'
/usr/local/Homebrew/Library/Homebrew/extend/pathname.rb:318:in `chdir'
/usr/local/Homebrew/Library/Homebrew/extend/pathname.rb:318:in `cd'
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/cmd/postgresql-upgrade-database.rb:125:in `postgresql_upgrade_database'
/usr/local/Homebrew/Library/Homebrew/brew.rb:124:in `<main>'
$brew postgresql升级数据库--调试--详细
/usr/local/Homebrew/Library/Homebrew/brew.rb(Formulary::FormulaLoader):加载/usr/local/Homebrew/Library/Taps/Homebrew/Homebrew core/Formula/postgresql.rb
==>将postgresql数据从12升级到13。。。
/usr/本地/酒窖/postgresql@12/12.5/bin/pg_ctl-w-D/usr/local/var/postgres start
正在等待服务器启动…2021-01-04 17:37:33.282 CET[8190]致命:数据库文件与服务器不兼容
2021-01-04 17:37:33.282 CET[8190]详细信息:数据库集群使用PG_CONTROL_版本1300初始化,但服务器使用PG_CONTROL_版本1201编译。
2021-01-04 17:37:33.282 CET[8190]提示:看起来您需要初始化数据库。
2021-01-04 17:37:33.282 CET[8190]日志:数据库系统已关闭
停止等待
pg_ctl:无法启动服务器
检查日志输出。
==>将postgresql数据从/usr/local/var/postgres移动到/usr/local/var/postgres.old。。。
==>正在创建数据库。。。
/usr/local/opt/postgresql/bin/initdb/usr/local/var/postgres
属于此数据库系统的文件将归用户“nyc”所有。
此用户还必须拥有服务器进程。
数据库集群将使用区域设置“en_US.UTF-8”进行初始化。
默认数据库编码相应地被设置为“UTF8”。
默认文本搜索配置将设置为“英语”。
数据页校验和被禁用。
正在修复现有目录/usr/local/var/postgres上的权限。。。好啊
正在创建子目录。。。好啊
正在选择动态共享内存实现。。。posix
正在选择默认的最大连接数。。。100
正在选择默认共享缓冲区。。。128MB
正在选择默认时区。。。欧洲/华沙
正在创建配置文件。。。好啊
正在运行引导脚本。。。好啊
正在执行引导后初始化。。。好啊
正在将数据同步到磁盘。。。好啊
initdb:警告:为本地连接启用“信任”身份验证
您可以通过编辑pg_hba.conf或使用选项-A或
--auth local和--auth host,下次运行initdb时。
成功。现在可以使用以下命令启动数据库服务器:
/usr/local/opt/postgresql/bin/pg_ctl-D/usr/local/var/postgres-l日志文件启动
==>迁移和升级数据。。。
/usr/local/opt/postgresql/bin/pg_升级-r-b/usr/local/ceral/postgresql@12/12.5/bin-B/usr/local/opt/postgresql/bin-d/usr/local/var/postgres.old-d/usr/local/var/postgres-j4
执行一致性检查
-----------------------------
正在检查群集版本是否正常
源群集未完全关闭。
失败,退出
错误:将postgresql数据从12升级到13失败!
==>正在删除空的postgresql initdb数据库。。。
==>将postgresql数据从/usr/local/var/postgres.old移回/usr/local/var/postgres。。。
错误:执行时失败`/usr/local/opt/postgresql/bin/pg_升级-r-b/usr/local/ceral/postgresql@12/12.5/bin-B/usr/local/opt/postgresql/bin-d/usr/local/var/postgres.old-d/usr/local/var/postgres-j 4`与1一起退出。
/usr/local/Homebrew/Library/Homebrew/utils.rb:303:在“安全系统”中
/usr/local/Homebrew/Library/Taps/Homebrew/Homebrew core/cmd/postgresql升级数据库。rb:126:in`block in postgresql_upgrade_database'
/usr/local/Homebrew/Library/Homebrew/extend/pathname.rb:318:in'block in cd'
/usr/local/Homebrew/Library/Homebrew/extend/pathname.rb:318:in`chdir'
/usr/local/Homebrew/Library/Homebrew/extend/pathname.rb:318:in'cd'
/usr/local/Homebrew/Library/Taps/Homebrew/Homebrew core/cmd/postgresql升级数据库。rb:125:in“postgresql升级数据库”
/usr/local/Homebrew/Library/Homebrew/brew.rb:124:in`'

我怎样才能解决这个问题?

你能解决这个问题吗?嗯,是的,也不是——我没有任何有价值的表格,所以我就放弃了它们