前端之家收集整理的这篇文章主要介绍了
PostgreSQL学习第四篇--数据库启停,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
启动数据库:
pg_ctl start -D $PGDATA
关闭数据库:
pg_ctl stop -D $PGDATA [-m mode]
mode有三种模式:
1. smart :等待所有的连接终止后,关闭数据库。如果客户端连接不终止,则无法关闭数据库。看起来是Oracle的normal。
2. fast:快速关闭数据库,断开客户端的连接,让已有的事务回滚,然后正常关闭数据库,看起来是Oracle的immediate。
3. immediate:立即关闭数据库,相当于数据库进程立即停止,直接退出,下次启动数据库需要回复。看起来是Oracle的abort。
[postgres@single ~]$ pg_ctl start -D $PGDATA
server starting
[postgres@single ~]$ LOG: could not bind IPv6 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not,wait a few seconds and retry.
LOG: could not bind IPv4 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not,wait a few seconds and retry.
WARNING: could not create listen socket for "localhost"
FATAL: could not create any TCP/IP sockets
LOG: database system is shut down
发现是因为前面已经启动了-D /usr/pg/postgresql-9.6.1/data/
先停掉:
[postgres@single ~]$ pg_ctl stop -D /usr/pg/postgresql-9.6.1/data/
waiting for server to shut down.... done
server stopped
然后起:
[postgres@single ~]$ pg_ctl start -D $PGDATA
server starting
[postgres@single ~]$ LOG: database system was shut down at 2016-11-17 08:55:51 CST
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
可以了。
原文链接:https://www.f2er.com/postgresql/194246.html