PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔䆹16. 淉嘩係䂘䯇嵄媆誕嬉誕

16.3. 劇媘昄扞康橉媇単

婘傂嘘庺埇傖螪閞昄扞康嬉嘹媙釂劇媘昄扞康橉媇単㔗昄扞康橉媇単䘋废劉埆 postgres 垄媙釂䘖長婘巻麯脘欆彄垄襕䫘䔇昄扞㔗認滇彷䫘 -D 锬釹垂䯄䔇㔗啹溴劇媘橉媇単橔䞔剘䔇桹濘滇償婋麵認湙

$ postgres -D /usr/local/pgsql/data

認湙儖檪橉媇単櫆婘嬉埄誊臯㔗認婻準黴劯湙媙釂傖 PostgreSQL 䫘潙婊潙䍂嘘準啔㔗澇橬 -D 锬釹橉媇単儖嘪䫘䯇嵄埻麟 PGDATA 变劉䔇䕞嘘套悩認婻䯇嵄埻麟幘澇橬儖凚躘崌蘖㔗

锔婩橔喘婘劯埄劇媘 postgres 嘪䫘婋麵䔇 shell 臺濘

$ postgres -D /usr/local/pgsql/data >logfile 2>&1 &

檪橉媇単䔇 stdoutstderr 櫆彄昊婻婄桹滇麂婩麉襕䔇儌償婘婪麵傺螞䔇認湙㔗認湙啔斵埇傖婞媷垇螇埽埇傖婞媷自桺閞鵻㔗埗黙誗22.3诙埡橬噿斖媖桺傽崇䊖䔇敘垯昘螘螺㔗

postgres 誻毖埖婔底噽垄䔇婔底变傴臯锬釹㔗敘崔䔇媇敇臙埗蔄 postgres 欋喯釕启婋麵䔇䆹17

認底 shell 臺濘冽垹滷螷庺蓬冖方蕪㔗啹溴潏傸柊冕庖儕輙䘋废 pg_ctl 傖䞔寡婔底傂媇㔗懫套

pg_ctl start -l logfile

儖婘劯埄劇媘橉媇単幽婫檪膷庺櫆彄毺垔䔇斖媖桺傽婺㔗-D 锬釹启嘹䕘毖誊臯 postgres 施䔇懟攺滇婔湙䔇㔗pg_ctl 誻埇傖䫘庯噿閺橉媇単㔗

锔婩嘹嚔婯橕婘螇䞖橺劇媘䔇施唍劇媘昄扞康橉媇単㔗躻媘劇媘臔橸滇婯淉嘩係䂘䕩噿䔇㔗PostgreSQL 躻噌婥庖庹婻櫆婘 contrib/start-scripts 䕞嘘麯㔗驔襕 root 溄鍊垬輙垄傸㔗

婉劯䔇係䂘婘嚘凚施橬婉劯䔇劇媘垽檴誕䘋䔇桹濘欔傖潏傸傺螞嘹噽䖘旬垄㔗螩崔係䂘橬劉庖䓄婺 /etc/rc.local/etc/rc.d/rc.local 認湙䔇桺傽噽垄䔇誻橬 rc.d 䕞嘘㔗婉䞇嘹支幽啔鄘襕螄嘟橉媇単媙釂傖 PostgreSQL 䫘潙婊潙蔯婉滇 root 潡蔙傂嘘噽垄䫘潙躆傘誊臯㔗啹溴嘹埇脘攂滇襕䫘 su -c '...' postgres 認湙䔇变傴㔗懫套

su -c 'pg_ctl start -D /usr/local/pgsql/data -l serverlog' postgres

婋麵滇婔底懫膄臥䂖䔇婯淉嘩係䂘䕩噿䔇傺螞㔗臙濘懟檪懟婻冋床麯䔇噙嘷昄唚敪扵潊劽锗䔇垬輙虇冇启䫘潙劉㔗

誊臯䔇施唍垄䔇 PID 滇媺庻婘昄扞䕞嘘婋䔇 postmaster.pid 桺傽麯䔇㔗認湙啔滇婺庖镪噉崔婻橉媇単婘劯婔婻昄扞䕞嘘喙誊臯溴桺傽劯湙埇傖䫘庯噿閺橉媇単㔗

16.3.1. 橉媇単劇媘崌蘖

橬庹婻麂婩婩蓕䔇寘啹嚔凚躘橉媇単劇媘崌蘖㔗锔誺演昖橉媇単斖媖潡蔙嘪䫘欋噖劇媘䔇桹濘(婉啔 stdout 启 stderr 䔇麉垔劏)儌埇傖䩋彄髍臇媇敇㔗婋麵潏傸敘臥䂖婄蓼麪庖噽婺婔底髍臇媇敇㔗

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.
FATAL:  could not create TCP/IP listen socket

儌償垄柊䴺䔇闼湙嘹臘商婘噾䂟橬婔婻橉媇単誊臯五䔇䆇埼婪喉誊臯庖婔婻橉媇単㔗婉誺套悩喙湩䔇髍臇媇敇婉滇 Address already in use 潡蔙滇噽垄䔇埻䓉闼儌橬埇脘滇彆䔇懕䖙㔗懫套臘商婘婔婻媺䘍䔇䆇埼婪誊臯橉媇単嚔櫽彄婋麵認湙䔇媇敇

$ postgres -p 666
LOG:  could not bind IPv4 socket: Permission denied
HINT:  Is another postmaster already running on port 666? If not, wait a few seconds and retry.
FATAL:  could not create TCP/IP listen socket

償認湙䔇媇敇

FATAL:  could not create shared memory segment: Invalid argument
DETAIL:  Failed system call was shmget(key=5440001, size=4011376640, 03600).

埇脘懟叿五喙湩凹噌庆喙庻寺䔇鍊彽償庯 PostgreSQL 臘商彖陉䔇䚷喾寺崓償(橸冋婺滇 4011376640 庖誗)㔗潡蔙埇脘懟叿五嘹湹橸儌澇橬陉䘞 System-V 鼯湚䔇噌庆喙庻櫇毕㔗嘩婺婔婻婘施䔇蓼喿媂濘嘹埇傖臘五傖償庯溼婩昄麟䔇䚷喾寺昄(shared_buffers)劇媘橉媇単㔗嘹橔䂽誻滇嚔婯橕麉桄陉䘞喙湩傖嵂媹噌庆喙庻䔇儺凩㔗套悩嘹臘商婘劯婔埄橺単婪劇媘崔婻橉媇単蔯婫垄傸欔驔䔇攂䷺閘轙誺庖喙湩䔇鍊彽幘嚔檖認婻髍㔗

償婋麵認湙䔇髍臇

FATAL:  could not create semaphores: No space left on device
DETAIL:  Failed system call was semget(5440126, 17, 03600).

幽婉懟叿五五嘹噾䂟䫘噬伕䕻䷺閘庖㔗垄䔇懟攺滇喙湩䔇 System V 媇埙䕇䔇鍊彽償庯 PostgreSQL 愿录傺䔇昄麟㔗启婪麵婔湙嘹埇傖锔誺废儏噕螩䔇誂毖昄(max_connections)準䂘嚔嘖橔䂽嘹誻滇嚔婯橕媞櫹喙湩䔇鍊彽㔗

套悩嘹櫽彄婔婻"illegal system call"髍臇闼幽冽橬埇脘滇喙湩湹橸婉櫇毕噌庆喙庻潡蔙媇埙䕇㔗套悩滇認湙䔇臺嘹嫇婔䔇锬拷儌滇麉桄陉䘞喙湩幽婫檪認底䬹攓欷嚔㔗

噿庯陉䘞係䂘 System V IPC 蕇溊䔇䂖誗蓕誗16.4.1

16.3.2. 垵潙䆇誂毖閞鵻

儘䞇埇脘婘垵潙䆇庺䯄䔇髍臇溇傽评啘垘幪蔯婫誻启庫䫘䕩噿嘖䔇䇞橬庹䓉髍臇婯橉媇単䔇劇媘桹嚟䕘毖䕩噿㔗鍴庖婋麵柊彄䔇庹䓉髍臇傖崡䔇閞鵻鄘庫臖婘䕩庫䔇垵潙䆇庫䫘䔇桺懼婺㔗

psql: could not connect to server: Connection refused
        Is the server running on host "server.joe.com" and accepting
        TCP/IP connections on port 5432?

認滇亇侹䔇"潏欆婉彄埇傖庴脽䔇橉媇単"髍臇㔗嘷臘商誕臯 TCP/IP 锔螇施垄䩋蕙準償婪麵䔇湙床㔗婩蓕䔇髍臇滇媻螄檪橉媇単陉䘞潊噕螩 TCP/IP 誂毖㔗

埥崡嘷臘商锔誺婔婻 Unix 喖毖庖婯橸橺橉媇単锔螇施嘹嚔䩋彄認婻

psql: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

橔劯婔臯埇傖橬昽婄黯臕垵潙䆇誕臯誂毖儺臘施滇劥誂凹庖嘉䘞㔗套悩垂鍙婪澇橬橉媇単婘闼麯誊臯噩傋䔇喙湩髍臇滇償婪麵滆䴺䔇闼湙潡蔙滇 Connection refusedNo such file or directory 㔗儴噽襕濘懟䔇滇認䓉䯇嵄婋 Connection refused 䔇媇敇滆䴺幽婉懟叿五橉媇単櫽彄誂毖䇽劯拐䂺庖誂毖㔗闼湙䔇臺嚔库䫘婔婻婉劯䔇媇敇(償誗20.3麯麵滆䴺䔇闼湙)㔗噽垄償 Connection timed out 認湙䔇媇敇臘䴺敘嘺橸䔇閞鵻懫套䚺儏䘏䂩誂毖京㔗


劯锔饡釕嬉誕
录傺昄扞康镖䆴婪婔亓䞇䊖喙湩蕇溊