postgresql 重启 postgres

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3620584/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 22:40:16  来源:igfitidea点击:

Restarting postgres

postgresql

提问by Simon

Is there any danger running /etc/init.d/postgresql restart?? We just had an incident where some relations "disappeared" and I ran the said command. Just got bollocked by the sysadmin, however he did not justify why this was a bad thing to do. I did put the webapp in maintenance mode so there wasn't any transactions/ queries going on at the time.

跑步有危险/etc/init.d/postgresql restart吗??我们刚刚发生了一些关系“消失”的事件,我运行了上述命令。刚刚被系统管理员骂了一顿,但是他没有证明为什么这是一件坏事。我确实将 webapp 置于维护模式,因此当时没有任何事务/查询正在进行。



Thanks guys... So in short it wont damage anything but it could loose lots of valuable diagnostic info.

谢谢大家... 简而言之,它不会损坏任何东西,但可能会丢失许多有价值的诊断信息。

采纳答案by Peter Tillemans

No, there is no danger of restarting postgres using the init.d method.

不,使用 init.d 方法重新启动 postgres 没有危险。

However, to restart it because something weird happened is not a good idea, because it limits severely the amount of information you can collect to find the root cause and limits opportunities to fix it.

但是,因为发生了一些奇怪的事情而重新启动它并不是一个好主意,因为它严重限制了您可以收集以查找根本原因的信息量并限制了修复它的机会。

Also in all the years I have been involved with postgresql, I never encountered a situation in which a restart "fixed" the problem. The immediate 'incident' might be resolved but if there's a problem, it will still be there.

同样在我参与 postgresql 的所有年里,我从未遇到过重启“修复”问题的情况。直接的“事件”可能会得到解决,但如果有问题,它仍然会存在。

回答by localfilmmaker

The only way relations would disappear on a restart of Postgres, would be if they were temp tables or created relations within an open transaction. When the db restarts it would close all connections and thus all temp tables would be dropped and open transactions would be rolled back. But anything that was committed would be safe from a restart.

关系在 Postgres 重新启动时消失的唯一方法是,如果它们是临时表或在打开的事务中创建的关系。当数据库重新启动时,它将关闭所有连接,因此所有临时表都将被删除,并且打开的事务将被回滚。但是提交的任何内容都不会重新启动。

回答by Frank Heikens

Relations don't disappear because of a restart, you might loose some running transactions, but that's it. PostgreSQL does not destroy your database when it restarts, don't worry.

关系不会因为重启而消失,你可能会丢失一些正在运行的事务,但仅此而已。PostgreSQL 在重启时不会破坏你的数据库,不用担心。