运维开发网

ruby-on-rails – dropdb:数据库删除失败:错误:检查点请求失败

运维开发网 https://www.qedev.com 2020-08-03 16:50 出处:网络 作者:运维开发网整理
我只知道使用postgres数据库的基础知识并且已经使用它大约一年没有任何重大问题我无法通过文档或现有的stackoverflow问题. 但是现在我遇到了一个问题,我在我的mac上的pg db上一直出现以下错误.我尝试使用安装成功的brew安装更新的postgres,但我认为在此过程中我创建了另一个问题.错误是在尝试启动db时: LOG: database system shutdown was
我只知道使用postgres数据库的基础知识并且已经使用它大约一年没有任何重大问题我无法通过文档或现有的stackoverflow问题.

但是现在我遇到了一个问题,我在我的mac上的pg db上一直出现以下错误.我尝试使用安装成功的brew安装更新的postgres,但我认为在此过程中我创建了另一个问题.错误是在尝试启动db时:

LOG:  database system shutdown was interrupted; last known up at 2015-10-04 11:04:08 EDT
LOG:  database system was not properly shut down; automatic recovery in progress
LOG:  redo starts at 0/6000090
LOG:  record with zero length at 0/6001990
LOG:  redo done at 0/6001960
LOG:  last completed transaction was at log time 2015-10-04 10:56:33.121103-04
FATAL:  could not open directory "pg_logical/snapshots": No such file or directory
LOG:  startup process (PID 12905) exited with exit code 1
LOG:  aborting startup due to startup process failure

所以我按照说明here使用pg_resetxlog然后继续尝试“REINDEX,转储数据库,重新initdb,并重新加载数据库”每个pg文档9.4没有成功的结果.我只是在圈子里.

我可以从数据库开始,但我无法放弃它并重新开始.如果我运行dropdb dbname,我得到

dropdb: could not connect to database template1: 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"?

但是因为跑完后我无法启动数据库

pg_resetxlog -f /usr/local/var/postgres

并且返回“事务日志重置”我运行

pg_ctl start -D /usr/local/var/postgres

得到

pg_ctl: another server might be running; trying to start server anyway
server starting
FATAL:  lock file "postmaster.pid" already exists
HINT:  Is another postmaster (PID 13114) running in data directory "/usr/local/var/postgres"?

所以我跑了

ps auxwww | grep postgres

得到了

Travis          13127   0.0  0.0  2432772    660 s000  S+   11:24AM   0:00.00 grep postgres
Travis          13120   0.0  0.0  2468112    604   ??  Ss   11:21AM   0:00.00 postgres: stats collector process       
Travis          13119   0.0  0.0  2604776   1444   ??  Ss   11:21AM   0:00.00 postgres: autovacuum launcher process       
Travis          13118   0.0  0.0  2604776    732   ??  Ss   11:21AM   0:00.00 postgres: wal writer process       
Travis          13117   0.0  0.0  2612968   1776   ??  Ss   11:21AM   0:00.05 postgres: writer process       
Travis          13116   0.0  0.0  2604776    756   ??  Ss   11:21AM   0:00.00 postgres: checkpointer process       
Travis          13114   0.0  0.2  2604776  14576   ??  S    11:21AM   0:00.02 /usr/local/opt/postgresql/bin/postgres -D /usr/local/var/postgres -r /usr/local/var/postgres/server.log

所以我跑了

kill 13114

然后

ps auxwww | grep postgres

得到了

Travis          13139   0.0  0.0  2432772    652 s000  S+   11:25AM   0:00.00 grep postgres

当然,此时如果我再次尝试启动数据库,我会进入同一个圈子.

现在,如果我跑

pg_resetxlog -f /usr/local/var/postgres

其次是

psql template1

并尝试删除数据库没有任何反应.

它是rails项目的数据库.所以,如果我跑

rake db:drop

我得到了另一个

PG::InternalError: ERROR:  checkpoint request failed

它还说我检查过的服务器日志中有一个提示

生活:

tail -f /usr/local/var/postgres/server.log

要么:

tail /usr/local/var/postgres/server.log

得到

ERROR:  could not open directory "pg_logical/snapshots": No such file or directory
ERROR:  could not open directory "pg_logical/snapshots": No such file or directory
ERROR:  could not open directory "pg_logical/snapshots": No such file or directory
ERROR:  could not open directory "pg_logical/snapshots": No such file or directory
ERROR:  could not open directory "pg_logical/snapshots": No such file or directory
ERROR:  could not open directory "pg_logical/snapshots": No such file or directory
ERROR:  could not open directory "pg_logical/snapshots": No such file or directory
ERROR:  could not open directory "pg_logical/snapshots": No such file or directory
ERROR:  could not open directory "pg_logical/snapshots": No such file or directory
ERROR:  could not open directory "pg_logical/snapshots": No such file or directory

我不知道如何解决这个问题或者为什么它首先存在.搜索结果返回this但没有解决方案显示手动创建目录的完整路径

在这一点上,我很困惑,我认为我让事情变得更糟.

我检查了我的系统上的其他数据库,看到我的机器上的所有数据库现在都有同样的问题.另外我总是有1个grep postgres pid运行,我无法停止使用kill 13498或重启我的mac.

如何在不丢失机器上的所有数据库的情况下解决这个问题?

Brew信息postgres显示:

postgresql: stable 9.4.4 (bottled), devel 9.5alpha2
Object-relational database system
https://www.postgresql.org/
Conflicts with: postgres-xc
/usr/local/Cellar/postgresql/9.4.1_1 (2996 files, 40M)
  Poured from bottle
/usr/local/Cellar/postgresql/9.4.4 (3014 files, 40M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/postgresql.rb
==> Dependencies
Required: openssl ✔, readline ✔
==> Options
--32-bit
    Build 32-bit only
--with-dtrace
    Build with DTrace support
--with-python
    Build with python support
--without-perl
    Build without Perl support
--without-tcl
    Build without Tcl support
--devel
    Install development version 9.5alpha2
==> Caveats
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
  https://github.com/Homebrew/homebrew/issues/2510

To migrate existing data from a previous major version (pre-9.4) of PostgreSQL, see:
  https://www.postgresql.org/docs/9.4/static/upgrading.html

To have launchd start postgresql at login:
  ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Then to load postgresql now:
  launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Or, if you don't want/need launchctl, you can just run:
  postgres -D /usr/local/var/postgres

我正在跑优胜美地10.10.5

经过几个小时的研究后,我又重新开始工作而不会丢失任何数据库.

从我的其他mac我发现应该创建的目录应该在this帖子中引用需要创建的目录.我还创建了另外两个丢失的目录:

mkdir /usr/local/var/postgres/pg_logical
mkdir /usr/local/var/postgres/pg_logical/mappings
mkdir /usr/local/var/postgres/pg_logical/snapshots

接下来,我运行以下内容以获得良好的衡

brew update

brew doctor

然后我安装了酿造服务(info docs和article)

brew tap homebrew/services

接下来我运行以下内容,我从提示here派生,因为在故障排除/试错过程中,“pg_resetxlog -f /usr/local/var / postgres”命令开始抛出错误.

brew services stop postgresql

然后我试着平常

pg_ctl -D /usr/local/var/postgres start

一切都开始正常.由于现在安装了brew服务,我可以使用以下命令启动db:

brew services start postgresql

我仍然不确定为什么在创建目录后重新启动我的mac没有帮助.而且我也不确定为什么/如何/何时删除这些目录.而且我不确定究竟是什么造成了问题.但在做了我列出的事情后,一切正常.

0

精彩评论

暂无评论...
验证码 换一张
取 消