qj_zhai 发表于 2011-12-23 14:46

postgres为什么不能用超户启动,我看代码都写死了,谁知道具体原因呢?

postgres为什么不能用超户启动,我看代码都写死了,谁知道具体原因呢?

zmoon 发表于 2011-12-23 21:03

根本原因是安全问题吧

asdf2110 发表于 2011-12-24 00:35

额,用源码安装,把检查用户的部分注掉

osdba 发表于 2011-12-29 21:14

是安全原因的,在root下运行对系统不是很安全。不建议通过改源码让PostgreSQL运行在root下。

sychangchun 发表于 2012-01-30 10:23

很多软件都用系统用户,不用超级用户。

hmily36 发表于 2012-04-02 18:17

安全原因,pg不能用root启动

scottsiu 发表于 2012-04-08 12:19

回复 1# qj_zhai

如果您是在Linux下的话可以通过su进行用户调用进行启动,通常我们会编写启动脚本如下,并放到/etc/init.d目录下#!/bin/bash
#
# chkconfig: 2345 85 15
# description: Starts and stops the Postgres Plus Advanced Server 9.1 database server

# Postgres Plus Advanced Server Service script for Linux

start()
{
        startserver=0
        if [ -e "/opt/PostgresPlus/9.1AS/data/postmaster.pid" ]
        then
                pidofpro=`head -n 1 /opt/PostgresPlus/9.1AS/data/postmaster.pid`
                alive=`ps -p $pidofpro | grep $pidofpro`

                if [ "x$alive" != "x" ]
                then
                        exit
                else
                        startserver=1
                fi
        else
                startserver=1
        fi
        if [ $startserver != 0 ]
        then
                echo $"Starting Postgres Plus Advanced Server 9.1: "
                su - enterprisedb -c "LD_LIBRARY_PATH=/opt/PostgresPlus/9.1AS/lib:$LD_LIBRARY_PATH /opt/PostgresPlus/9.1AS/bin/pg_ctl -w start -D \"/opt/PostgresPlus/9.1AS/data\" -l \"/opt/PostgresPlus/9.1AS/data/pg_log/startup.log\""
       
      if [ $? -eq 0 ];
                then
                        echo "Postgres Plus Advanced Server 9.1 started successfully"
            exit 0
                else
                        echo "Postgres Plus Advanced Server 9.1 did not start in a timely fashion, please see /opt/PostgresPlus/9.1AS/data/pg_log/startup.log for details"
            exit 1
                fi
        fi
}

stop()
{
        if [ -e "/opt/PostgresPlus/9.1AS/data/postmaster.pid" ]
        then
                pidofproc=`head -n 1 /opt/PostgresPlus/9.1AS/data/postmaster.pid`
                pidalive=`ps -p $pidofproc | grep $pidofproc`
               
                if [ "x$pidalive" != "x" ]
                then
                        echo $"Stopping Postgres Plus Advanced Server 9.1: "
                        su - enterprisedb -c "LD_LIBRARY_PATH=/opt/PostgresPlus/9.1AS/lib:$LD_LIBRARY_PATH /opt/PostgresPlus/9.1AS/bin/pg_ctl stop -m fast -w -D \"/opt/PostgresPlus/9.1AS/data\""
                fi
        fi
}

reload()
{
        echo $"Reloading Postgres Plus Advanced Server 9.1: "
        su - enterprisedb -c "LD_LIBRARY_PATH=/opt/PostgresPlus/9.1AS/lib:$LD_LIBRARY_PATH /opt/PostgresPlus/9.1AS/bin/pg_ctl reload -D \"/opt/PostgresPlus/9.1AS/data\""
}

# See how we were called.
case "$1" in
start)
      start
      ;;
stop)
      stop
      ;;
reload)
      reload
      ;;
condrestart|restart)
            stop
            sleep 3
            start
      ;;
status)
      su - enterprisedb -s /bin/bash -m -c "LD_LIBRARY_PATH=/opt/PostgresPlus/9.1AS/lib:$LD_LIBRARY_PATH /opt/PostgresPlus/9.1AS/bin/pg_ctl status -D \"/opt/PostgresPlus/9.1AS/data\""
      ;;
*)
      echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}"
      exit 1
esac

ulovko 发表于 2012-04-21 20:41

学习了,都是高手!

Hongqiyaodao 发表于 2012-05-06 04:56

页: [1]
查看完整版本: postgres为什么不能用超户启动,我看代码都写死了,谁知道具体原因呢?