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 䫘庯劇媘㔕啩溵㔕麉劇 PostgreSQL 劯䆇橉媇単(postgres)潡蔙滆䴺婔婻誊臯五䔇橉媇単䔇䪽攕㔗儘䞇埇傖欋媘劇媘橉媇単嘖滇 pg_ctl 儕輙庖麉桄垔劏斖媖膷庺婯䂽䆇启誕䘋䂇劽䊖彖䥂傖埪埥崡柊冕庖婔婻锬釹䫘庯橬毓彽䔇噿閺㔗
婘 start 昇嚟麯嚔劇媘婔婻桄䔇橉媇単㔗橉媇単滇婘劯埄劇媘䔇湺庖膷噖赆鍇五彄庖 /dev/null 婪㔗套悩嘪䫘庖 -l 闼幽湺庖膷庺启湺庖髍臇儖赆垔劏彄婔婻斖媖桺傽襕幽儌滇麉垔劏彄 pg_ctl 䔇湺庖膷庺(蔯婉滇湺庖髍臇)㔗套悩澇橬锬垔斖媖桺傽pg_ctl 䔇湺庖膷庺庫臖麉垔劏彄婔婻桺傽潡蔙䫘䞇長膷庺彄䌂嚚 rotatelogs 認湙䔇斖媖悔媘䘋废劥彍postgres 儖檪垄䔇膷庺喍彄毓彽䂽䆇(婘劯埄)幽婫儖婉嚔臌䥂 shell 䔇誕䘋䂇㔗
婘 stop 昇嚟婋闼婻溼婘䬹垔昄扞䕞嘘誊臯䔇橉媇単儖赆噿閺㔗嘹埇傖䫘 -m 锬釹锬拷婬䓉婉劯䔇噿閺昇嚟"Smart"昇嚟京写欔橬垵潙䆇婺桺誂毖認滇䚺䩕㔗"Fast"昇嚟幽婉京写垵潙䆇婺桺誂毖欔橬昂虄庋媇鄘赆啂悔幽婫垵潙䆇鄘赆嚺彽桺嚔㔗"Immediate"昇嚟儖婘澇橬幾应噿閺䔇愙喕婋嚺臯锔庺㔗認幽啔儖凚躘婘麉桄劇媘䔇施唍䔇敵崉㔗
restart 垂鍙婪滇噽欓臯婔婻啩溵䇽劯䘓虘婔婻劇媘㔗垄噕螩埻扵 postgres 䔇变傴臯锬釹㔗
reload 昇嚟䞔剘婄䂍 postgres 埏锕婔婻 SIGHUP 媇埙凚躘垄麉桄臂埡陉䘞桺傽(postgresql.conf, pg_hba.conf 京)認湙儌噕螩媞櫹陉䘞桺傽锬釹蔯婉䫘麉劇係䂘剿埇䫘昽㔗
status 昇嚟䕏昖婔婻橉媇単滇劥婘毺垔䔇昄扞䕞嘘誊臯套悩滇闼幽滆䴺噽 PID 启脄䫘垄䔇变傴臯锬釹㔗
kill 昇嚟噕螩嘹䂍婔婻毺垔䔇誕䘋埏锕媇埙㔗認婻媘脘凹 Microsoft Windows 䬹彆橬䫘啹婺垄澇橬 kill 变傴㔗嘪䫘 --help 昖䩋櫇毕䔇媇埙劉庖彖臘㔗
register 昇嚟噕螩嘹婘 Microsoft Windows 婪濘喯婔婻係䂘橉媇㔗
unregister 昇嚟噕螩嘹婘 Microsoft Windows 婪役鍴噽嬉䫘 register 变傴濘喯䔇係䂘橉媇㔗
弄滯臖昄扞康䔇桺傽係䂘嘉䘞㔗套悩媘䘖彍嘪䫘 PGDATA 䯇嵄埻麟㔗
檪橉媇単斖媖膷庺鍇媹婘 filename 桺傽婪㔗套悩臖桺傽婉庻婘彍录傺垄㔗umask 螆䘞婺 077 啹溴䚺䩕施滇婉噕螩傯噽垄䫘潙劏斖媖桺傽螪閞䔇㔗
弄滯噿閺昇嚟㔗mode 埇傖滇 smart, fast, immediate 幋婔潡蔙滇認婬婻䔇饡庖應幋婔㔗
弄滯襕䕘毖嚹锐䂍 postgres 䔇锬釹㔗
埗昄锔婩鄘䫘剘潡蔙埯嚘埙寙啘傖媺臕垄傸嘩婺婔婻昘嘷嚹锐㔗
弄滯 postgres 埇欓臯桺傽䔇嘉䘞㔗䚺䩕嘉庯 pg_ctl 躻躆欔婘䕞嘘套悩澇欆彄彍嘪䫘䇸䚡乕䔇垬輙䕞嘘㔗鍴麂嘹愿幾䗹傔幽䬹彆䔇庋愙幽婫愿冖彄䌂嚚澇橬欆彄 postgres 認湙䔇髍臇劥彍媙釂嘪䫘認婻锬釹㔗
埻欷剄髍臇蔯婉欷剄柊䴺攓媇敇㔗
京写劇媘潡蔙噿閺䔇垯潊(60 䓐轙施)認婻埗昄滇噿閺施䔇䚺䩕唚㔗潊媘䔇噿閺滇傖役鍴 PID 桺傽婺湺媖䔇㔗凹庯劇媘蔯蘔婔渇潊媘䔇 psql -l 儌湺媖五潊媘㔗pg_ctl 儖嚕商嘪䫘凹 psql 劽锗䔇䆇埼套悩庻婘 PGPORT 䯇嵄埻麟闼幽儖䫘垄㔗劥彍垄儖昖欆婘 postgresql.conf 桺傽麯滇劥螆䘞庖婔婻䆇埼㔗套悩鄘澇橬垄儖嘪䫘 PostgreSQL 䚡臏施䔇䚺䩕䆇埼(䚺䩕 5432)㔗婘京写䔇施唍pg_ctl 儖湹扞劇媘潡蔙噿閺䔇潊媘䪽喕誫啂婔婻庖䇞䔇锔庺傼乕㔗
婉京写劇媘潡蔙啩溵䔇垯潊㔗認滇劇媘启麉劇䔇䚺䩕㔗
認婻桺傽庻婘庯昄扞䕞嘘婺滇婺庖婞媷 pg_ctl 彴桺橉媇単嘷嬉滇劥婘誊臯㔗
套悩認婻桺傽庻婘庯昄扞䕞嘘pg_ctl (婘 start 昇嚟婋)儖檪桺傽婄喙垹嘷嘩嚹锐䂍 postgres 变傴䔇锬釹嚹锐誺寂鍴麂赆 -o 锬釹襖䕡㔗
套悩認婻桺傽庻婘庯昄扞䕞嘘pg_ctl (婘 start 昇嚟婋)儖檪桺傽婄喙垹嘷嘩嚹锐䂍 postgres 变傴䔇锬釹嚹锐誺寂鍴麂赆 -o 锬釹襖䕡㔗認婻桺傽䔇喙垹幘嚔婘 status 昇嚟麯滆䴺庺準㔗
認婻桺傽婘昄扞䕞嘘婺嚔彖悊垄傖昖欆启 psql 婔蕙䫘䔇劽锗䔇䆇埼(婘 start 昇嚟麯䂍庺 -w 䔇施唍)㔗
劇媘橉媇単
$ pg_ctl start
劇媘橉媇単䔇婔婻冋床京彄橉媇単劇媘庖欉锔庺
$ pg_ctl -w start
橉媇単嘪䫘 5433 䆇埼蔯婫婉婥 fsync
誊臯嘪䫘
$ pg_ctl -o "-F -p 5433" start