在断电和重新启动后找不到我的数据库 [英] Can't find my databases after power cut and reboot

查看:249
本文介绍了在断电和重新启动后找不到我的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OSX 10.9.3
psql 9.3.4



我有几个数据库,我正在工作,我们有一个晚上断电。现在不存在我的数据库(包括默认数据库(用户名))。



为什么所有的数据库都来自psql?他们不会得救吗?是否有可能仍然存在,但没有列出\dt?



任何关于如何恢复这些数据库的帮助将非常感谢!

解决方案

如果底层存储不安全,断电只会导致数据库损坏或丢失 - 某些廉价的消费者SSD不能正确刷新写入。但是,这个问题不太可能导致整个数据库只是消失,甚至不太可能您的数据库服务器将成功启动。



由于您使用的是OS X,因此很可能实际安装了多个PostgreSQL版本。我想说你在断电之前在一个PostgreSQL安装,并在断电后(并导致重新启动),你正在一个不同的PostgreSQL安装。



事实上,由于您安装了9.3.4版本,因此您的计算机上至少有一个其他PostgreSQL:Apple自带的内置版本。 / p>

如果你只是连接到错误的PostgreSQL实例,数据应该仍然存在,这只是一个连接到正确的PostgreSQL实例的问题 - 如果需要,



首先,尝试:

 

并确保您连接的服务器版本是您期望的。



我不能真正给出更多的具体说明如何找到PostgreSQL安装与其中的数据,因为Mac用户倾向于安装PostgreSQL多种不同的方式,并通常有几个副本安装。他们都开始不同的方式太 - 通过launchd,手动与pg_ctl,通过postgres.app启动器等等。所以,为了帮助你需要具体到哪个PostgreSQL版本,你安装,如何和在哪里。 / p>

我可以给你的一个提示是,你可以使用Terminal命令搜索PostgreSQL数据目录:

  sudo find / -name PG_VERSION 2> / dev / null 

将为每个安装的数据目录显示一堆 PG_VERSION 文件。您还可以列出PostgreSQL进程正在侦听的端口:

  sudo netstat -ltnp | grep postgres 

(假设在OS X上有效;我无法访问OS X机器测试)。


OSX 10.9.3 psql 9.3.4

I had several database that I was working on and we had a power cut over night. Now non of my database (including the default database (username)) are present.

Why have all the database gone from psql? Wouldn't they have been saved? Is there any possibly that they are still present but not listed by \dt?

Any help on how to recover these databases will be greatly appreciated!

解决方案

A power cut can only cause database corruption or loss if the underlying storage is unsafe - some cheap consumer SSDs don't flush writes properly, for example. However, it's really unlikely that this problem would cause whole databases to just vanish, and even less likely that your database server would start successfully if that happened.

Since you are on OS X, it is highly likely that you actually have more than one PostgreSQL version installed. I'd say you were working on one PostgreSQL install before the power cut, and after the power cut (and resulting reboot) you are working on a different PostgreSQL install.

In fact, since you have 9.3.4 installed, you have at least one other PostgreSQL on your computer: the one that came built-in that's bundled by Apple.

If you're just connecting to the wrong PostgreSQL instance the data should still all be there, it's just a matter of connecting to the correct PostgreSQL instance - and if necessary, starting it up first.

First, try:

SELECT version()

and make sure the server version you're connected to is what you expect.

I can't really give more specific instructions on how to find the PostgreSQL install with your data in it, because Mac users tend to install PostgreSQL in numerous different ways and often have several copies installed. They all get started up different ways too - via launchd, manually with pg_ctl, via postgres.app launcher, etc. So to help you I'd need specifics on exactly which PostgreSQL version(s) you installed, how, and where.

One tip I can give you is that you can search for PostgreSQL data directories with the Terminal command:

sudo find / -name PG_VERSION 2>/dev/null

which will show you a bunch of PG_VERSION files for each install's data dir. You can also list ports that PostgreSQL processes are listening on with:

sudo netstat -ltnp | grep postgres

(assuming that works on OS X; I don't have access to an OS X machine to test).

这篇关于在断电和重新启动后找不到我的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆