pg_ctl 啓動、關閉、重啓 postgressql
pg_ctl start [-w] [-s] [-D datadir] [-l filename] [-o options] [-p path] pg_ctl stop [-W] [-s] [-D datadir] [-m s[mart] | f[ast] | i[mmediate] ] pg_ctl restart [-w] [-s] [-D datadir] [-m s[mart] | f[ast] | i[mmediate] ] [-o options] pg_ctl reload [-s] [-D datadir] pg_ctl status [-D datadir] pg_ctl kill [signal_name] [process_id] pg_ctl register [-N servicename] [-U username] [-P password] [-D datadir] [-w] [-o options] pg_ctl unregister [-N servicename]
具體說明見參考資料。緩存
# 查找 pg_ctl [root@localhost ~]# whereis pg_ctl pg_ctl: /usr/bin/pg_ctl /usr/share/man/man1/pg_ctl.1.gz # 啓動 postgres [root@localhost ~]# su postgres bash-4.2$ /usr/bin/pg_ctl -D /var/lib/pgsql/data start could not change directory to "/root" pg_ctl: another server might be running; trying to start server anyway server starting bash-4.2$ FATAL: lock file "postmaster.pid" already exists HINT: Is another postmaster (PID 30063) running in data directory "/var/lib/pgsql/data"?
出現以下錯誤 could not change directory to "/root",由於在 postgres 中不能自動切換路徑,解決方法bash
bash-4.2$ cd /usr/bin bash-4.2$ pwd /usr/bin bash-4.2$ ./pg_ctl -D /var/lib/pgsql/data start server starting
可能出現以下錯誤 pg_ctl: PID file "/var/lib/pgsql/data/postmaster.pid" does not exist,能夠查看啓動日誌post
我操做時是由於磁盤滿了,沒法建立新的文件 postmaster.pid,清除緩存騰出一點空間便可。spa