手机版
你好,游客 登录 注册
背景:
阅读新闻

PostgreSQL 9.1.2源码编译

[日期:2012-02-12] 来源:Linux社区  作者:Linux [字体:大 中 小]

修改PostgreSQL脚本

[plain]
  1. #! /bin/sh  
  2.   
  3. # chkconfig: 2345 98 02  
  4. # description: PostgreSQL RDBMS  
  5.   
  6. # This is an example of a start/stop script for SysV-style init, such  
  7. # as is used on Linux systems.  You should edit some of the variables  
  8. # and maybe the 'echo' commands.  
  9. #  
  10. # Place this file at /etc/init.d/postgresql (or  
  11. # /etc/rc.d/init.d/postgresql) and make symlinks to  
  12. #   /etc/rc.d/rc0.d/K02postgresql  
  13. #   /etc/rc.d/rc1.d/K02postgresql  
  14. #   /etc/rc.d/rc2.d/K02postgresql  
  15. #   /etc/rc.d/rc3.d/S98postgresql  
  16. #   /etc/rc.d/rc4.d/S98postgresql  
  17. #   /etc/rc.d/rc5.d/S98postgresql  
  18. # Or, if you have chkconfig, simply:  
  19. # chkconfig --add postgresql  
  20. #  
  21. # Proper init scripts on Linux systems normally require setting lock  
  22. # and pid files under /var/run as well as reacting to network  
  23. # settings, so you should treat this with care.  
  24.   
  25. # Original author:  Ryan Kirkpatrick <pgsql@rkirkpat.net>  
  26.   
  27. # contrib/start-scripts/linux  
  28.   
  29. ## EDIT FROM HERE  
  30.   
  31. # Installation prefix  
  32. prefix=/opt/pgsql  
  33.   
  34. # Data directory  
  35. PGDATA="/opt/pgsql/data"  
  36.   
  37. # Who to run the postmaster as, usually "postgres".  (NOT "root")  
  38. PGUSER=postgres  
  39.   
  40. # Where to keep a log file  
  41. PGLOG="$prefix/logs/pgsql.log"  
  42.   
  43. # It's often a good idea to protect the postmaster from being killed by the  
  44. # OOM killer (which will tend to preferentially kill the postmaster because  
  45. # of the way it accounts for shared memory).  Setting the OOM_ADJ value to  
  46. # -17 will disable OOM kill altogether.  If you enable this, you probably want  
  47. # to compile PostgreSQL with "-DLINUX_OOM_ADJ=0", so that individual backends  
  48. # can still be killed by the OOM killer.  
  49. #OOM_ADJ=-17  
  50.   
  51. ## STOP EDITING HERE  
  52.   
  53. # The path that is to be used for the script  
  54. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin  
  55.   
  56. # What to use to start up the postmaster.  (If you want the script to wait  
  57. # until the server has started, you could use "pg_ctl start -w" here.  
  58. # But without -w, pg_ctl adds no value.)  
  59. DAEMON="$prefix/bin/postmaster"  
  60.   
  61. # What to use to shut down the postmaster  
  62. PGCTL="$prefix/bin/pg_ctl"  
  63.   
  64. set -e  
  65.   
  66. # Only start if we can find the postmaster.  
  67. test -x $DAEMON ||  
  68. {  
  69.     echo "$DAEMON not found"  
  70.     if [ "$1" = "stop" ]  
  71.     then exit 0  
  72.     else exit 5  
  73.     fi  
  74. }  
  75.   
  76.   
  77. # Parse command line parameters.  
  78. case $1 in  
  79.   start)  
  80.     echo -n "Starting PostgreSQL: "  
  81.     test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj  
  82.     su  $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1  
  83.     echo "ok"  
  84.     ;;  
  85.   stop)  
  86.     echo -n "Stopping PostgreSQL: "  
  87.     #su -  $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast"  
  88.     su  $PGUSER -c "$PGCTL stop -D '$PGDATA' -m fast"  
  89.     echo "ok"  
  90.     ;;  
  91.   restart)  
  92.     echo -n "Restarting PostgreSQL: "  
  93.     su  $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w"  
  94.     test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj  
  95.     su  $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1  
  96.     echo "ok"  
  97.     ;;  
  98.   reload)  
  99.         echo -n "Reload PostgreSQL: "  
  100.         su  $PGUSER -c "$PGCTL reload -D '$PGDATA' -s"  
  101.         echo "ok"  
  102.         ;;  
  103.   status)  
  104.     su  $PGUSER -c "$PGCTL status -D '$PGDATA'"  
  105.     ;;  
  106.   *)  
  107.     # Print help  
  108.     echo "Usage: $0 {start|stop|restart|reload|status}" 1>&2  
  109.     exit 1  
  110.     ;;  
  111. esac  
  112.   
  113. exit 0  

#service postgresql-9.1.2 restart


PS: 我机子上本来编译环境已经弄好了,所以可能会有些东西缺了,比如gcc ,make 等,可以直接yum

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款