我如何优雅地杀死陈旧的服务器进程postgres [英] how do I gracefully kill stale server process postgres

查看:280
本文介绍了我如何优雅地杀死陈旧的服务器进程postgres的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时在我们的实验室中,我们的postgres 8.3数据库将从pid文件中孤立出来,并且在尝试关闭数据库时会收到以下消息:

Occasionally in our lab, our postgres 8.3 database will get orphaned from the pid file, and we get this message when trying to shut down the database:

错误:pid文件无效,请手动杀死过时的服务器进程postgres

这种情况发生时,我们立即执行 pg_dump ,以便我们稍后可以恢复数据库。但是,如果我们只杀死-9个孤立的 postgres 进程,然后启动它,则数据库仅从上次成功关闭后的数据开始。但是,如果在杀死它之前 psql 可以使用它,则数据全部可用,因此 pg_dump 起作用的原因。

When this happens, we immediately do a pg_dump so we can restore the database later. But, if we just kill -9 the orphan postgres process and then start it, the database starts only with the data from the last successful shutdown. But if you psql to it before killing it, the data is all available, thus why the pg_dump works.

有没有办法正常关闭孤立的postgres进程,这样我们就不必通过pg_dump进行恢复了吗?还是有办法在杀死孤立进程后恢复数据库?

Is there a way to gracefully shutdown the orphaned postgres process so we don't have to go through the pg_dump and restore? Or is there a way to have the database recover after killing the orphaned process?

推荐答案

根据文档,您可以发送SIGTERM或SIGQUIT。 SIGTERM是首选。无论哪种方式,都不要使用SIGKILL(从您的个人经验中知道)。

According to the documentation you could either send SIGTERM or SIGQUIT. SIGTERM is preferred. Either way never use SIGKILL (as you know from personal experience).

编辑:另一方面,您遇到的情况是不正常的,并且可能表示配置错误或错误。请在 pgsql-admin 邮件列表中寻求帮助。

on the other hand what you experience is not normal and could indicate a mis-configuration or a bug. Please, ask for assistance on the pgsql-admin mailing list.

这篇关于我如何优雅地杀死陈旧的服务器进程postgres的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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