禁止Linux内核杀死postgresql进程

我有标准的“开箱即用”安装

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 

它有安装postgresql 8.4(启动脚本)

 /etc/init.d/postgresql 

数据目录

 /etc/postgresql/8.4/main/ 

我的问题是,有时内核决定在内存不足的时候杀掉一些Postgresql进程。 我想告诉内核,不应该selectPostgresql被杀死。 我从postgresql文档( http://www.postgresql.org/docs/9.1/static/kernel-resources.html )中echo -17 > /proc/self/oom_adj可以使用命令行echo -17 > /proc/self/oom_adj来避免kill。

我试图添加这个命令行到/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 

服务器问题集锦,包括 Linux(Ubuntu, Centos,Debian等)和Windows Server服务器.