• 技术文章 >数据库 >PostgreSQL

    如何启动postgresql

    silencementsilencement2019-12-24 14:28:45原创2975

    启动数据库服务器(posgres用户):

    [postgres@localhost bin]$ postgres -D /opt/postgresql/data/ > /opt/postgresql/log/pg_server.log 2>&1 &
    [1] 4508

    当然如果设置了环境变量

    PGDATA=/opt/postgresql/data
    export PGDATA

    后,可使用pg_ctl工具进行启动:

    [postgres@localhost log]$ pg_ctl start -l /opt/postgresql/log/pg_server.log
    pg_ctl: another server might be running; trying to start server anyway
    pg_ctl: could not start server
    Examine the log output.
    [postgres@localhost log]$

    因为之前已经启动,所以打印“another server might be running”。此时,查看日志,有如下信息:

    [postgres@localhost log]$ cat pg_server.log
    FATAL:  lock file "postmaster.pid" already exists
    HINT:  Is another postmaster (PID 4491) running in data directory "/opt/postgresql/data"?
    [postgres@localhost log]$

    当然,最简的启动方式是:

    [postgres@localhost ~]$ pg_ctl start
    server starting
    [postgres@localhost ~]$ LOG:  database system was shut down at 2011-07-09 13:58:00 CST
    LOG:  autovacuum launcher started
    LOG:  database system is ready to accept connections

    如果要在操作系统启动时就启动PG,可以在/etc/rc.d/rc.local 文件中加以下语句:

    /opt/postgresql/bin/pg_ctl start -l /opt/postgresql/log/pg_server.log -D /opt/postgresql/data
    专题推荐:postgresql
    上一篇:mongodb 社区版和企业版区别是什么 下一篇:postgresql 认证失败怎么解决

    相关文章推荐

    • postgresql如何创建数据库• postgresql如何备份表• 如何查看postgresql用户权限• postgresql可以递归查询么

    全部评论我要评论

    © 2021 Python学习网 苏ICP备2021003149号-1

  • 取消发布评论
  • 

    Python学习网