我有标准的“开箱即用”安装
Linux version 3.0.1.stk64 (dfn@localhost.localdomain) (gcc version 4.5.1 20100924 (Red Hat 4.5.1-4) (GCC) ) #1 SMP Sat Aug 13 12:53:46 EDT 2011
Run Code Online (Sandbox Code Playgroud)
它已将 postgresql 8.4 安装为(启动脚本)
/etc/init.d/postgresql
Run Code Online (Sandbox Code Playgroud)
数据目录
/etc/postgresql/8.4/main/
Run Code Online (Sandbox Code Playgroud)
我的问题是有时内核决定在内存不足时杀死一些 Postgresql 进程。我想通知内核,不应选择杀死 Postgresql。我从 postgresql 文档(http://www.postgresql.org/docs/9.1/static/kernel-resources.html)中读到,echo -17 > /proc/self/oom_adj
可以使用命令行来避免杀死。
我试图将此命令行添加到/etc/init.d/postgresql
脚本中,但真的不知道将它放在哪里。
任何指示如何去做?顺便说一句,scipt ( /etc/init.d/postgresql
) 是:
#!/bin/sh
set -e
### BEGIN INIT INFO
# Provides: postgresql
# Required-Start: $local_fs $remote_fs $network $time
# Required-Stop: $local_fs $remote_fs $network $time
# Should-Start: $syslog
# Should-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: PostgreSQL RDBMS server
### END INIT INFO
# Setting environment variables for the postmaster here does not work; please
# set them in /etc/postgresql/<version>/<cluster>/environment instead.
[ -r /usr/share/postgresql-common/init.d-functions ] || exit 0
. /usr/share/postgresql-common/init.d-functions
# versions can be specified explicitly
if [ -n "$2" ]; then
versions="$2 $3 $4 $5 $6 $7 $8 $9"
else
get_versions
fi
case "$1" in
start|stop|restart|reload|status)
for v in $versions; do
$1 $v
done
;;
force-reload)
for v in $versions; do
reload $v
done
;;
*)
echo "Usage: $0 {start|stop|restart|reload|force-reload|status} [version ..]"
exit 1
;;
esac
exit 0
Run Code Online (Sandbox Code Playgroud)
您应该直接将 oom_adj 调整为 postmaster pid,添加如下行(未经测试):
pid=`cat $PGDATA/postmaster.pid | head -1`
echo -17 > /proc/$pid/oom_adj
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1112 次 |
最近记录: |