pg_ctl

Ãû³Æ

pg_ctl  --  Æô¶¯£¬Í£Ö¹£¬ºÍÖØÆð postmaster

Óï·¨

pg_ctl [-w] [-D datadir][-p path] [-o "options"] start
pg_ctl [-w] [-D datadir] [-m [s[mart]|f[ast]|i[mmediate]]] stop
pg_ctl [-w] [-D datadir] [-m [s[mart]|f[ast]|i[mmediate]]
    [-o "options"] restart
pg_ctl [-D datadir] status

ÊäÈë

-w
ͨ¹ý¹Û²ì pid Îļþ£¨PGDATA/postmaster.pid£©µÄ´´½¨£¬µÈ´ýÊý¾Ý¿â·þÎñÆ÷µÄÆô¶¯£®ÔÚ 60 Ãëºó³¬Ê±£®
-D datadir
ÉùÃ÷Õâ¸öÊý¾Ý¿â°²×°µÄÊý¾Ý¿âλÖã®
-p path
ÉùÃ÷ postmaster Ó°ÏóµÄλÖã®
-o "options"
ÉùÃ÷Ö±½Ó´«µÝ¸ø postmaster µÄÑ¡Ï

 

 

ͨ³£ÕâЩ²ÎÊýÓõ¥»òË«ÒýºÅÒýÆð£¬ÒÔ±£Ö¤ËüÃÇÒÔÒ»×éµÄ·½Ê½´«µÝ£®

-m mode

 

 

ÉùÃ÷¹Ø±Õģʽ£®

smart, s

ÖÇÄÜģʽ£¬µÈ´ýËùÓпͻ§¶ËÍ˳ö£®ÕâÊÇȱʡ£®
f[ast], f

¿ìËÙģʽ£¬Ïòºó¶Ë·¢ËÍ SIGTERM£¬ÕâÒâζ×Å»îÔ¾µÄÊÂÎñ¶¼»Ø¾í£®
immediate, i

Á¢¼´Ä£Ê½£¬Ïòºó¶Ë·¢ËÍ SIGUSR1 ²¢ÇÒÈÃËüÃÇÍ˳ö£®ÔÚÕâÖÖģʽ£¬ÏÂÒ»´ÎÆô¶¯½«±ØÐë½øÐÐÊý¾Ý¿â»Ö¸´¹¤×÷£®
start

Æô¶¯ postmaster£®
stop

¹Ø±Õ postmaster£®
restart

ÖØÐÂÆô¶¯ postmaster£¬Ö´ÐÐÒ»´Î˳ÐòµÄ stop/start£®
status

ÏÔʾ postmaster µÄµ±Ç°×´Ì¬£®

Êä³ö

pg_ctl: postmaster is state (pid: #)

 

 

Postmaster ״̬£®

Èç¹û´æÔÚÒ»¸ö´íÎóÌõ¼þ£¬½«ÏÔʾ³öºó¶ËµÄ´íÎóÐÅÏ¢£®

ÃèÊö

pg_ctl ÊÇÒ»¸öÓÃÓÚÆô¶¯£¬Í£Ö¹ºÍÖØÆð postmaster µÄ¹¤¾ß£®

Ó÷¨

Æô¶¯ postmaster

ÒªÆô¶¯ postmaster£º
> pg_ctl start
Èç¹ûʹÓÃÁË -w£¬pg_ctl µÈ´ýÊý¾Ý¿â·þÎñÆ÷Æô¶¯£­Í¨¹ý¹Û²ì pid Îļþ£¨PGDATA/postmaster.pid£©µÄ´´½¨£¬×î¶àµÈ´ý 60 Ã룮

¼¤»î postmaster µÄ²ÎÊý´ÓÏÂÃæµÄ×ÊÔ´Àï»ñÈ¡£º

postmaster.opts.default °üº¬ÓÃÓÚ postmaster µÄ²ÎÊý£®È±Ê¡°²×°Ê±£¬´ò¿ªÁË -S Ñ¡ÏÒò´Ë pg_ctl start Òþº¬µØÊÇ£º
postmaster -S
Çë×¢Òâ postmaster.opts.default ÊÇÓÉ initdb ´Ó Postgres µÄ°²×°Ä¿Â¼£¨lib/postmaster.opts.default.sample ÊÇ°²×° Postgres ʱ´Ó src/bin/pg_ctl/postmaster.opts.default.sample £©ÀïµÄ» lib/postmaster.opts.default.sample ¿½±´À´µÄ£®

Òª¸²¸ÇȱʡµÄ²ÎÊý£¬Äã¿ÉÒÔʹÓà -D£¬-p ºÍ -o Ñ¡Ï

Ò»¸öÆô¶¯ postmaster£¬²¢µÈµ½l postmaster Æô¶¯ºó²ÅÍ˳öµÄÀý×ÓÊÇ£º

> pg_ctl -w start
ÒªÉùÃ÷ postmaster ¶þ½øÖÆ·¾¶£¬ÊÔÊÔ£º
> pg_ctl -p /usr/local/pgsq/bin/postmaster start
¶ÔÒ»¸öʹÓö˿Ú5433£¬²¢ÇÒÔËÐÐÔÚÎÞ´ÅÅÌͬ²½µÄģʽµÄ postmaster£¬Ê¹Óãº
> pg_ctl -o "-o -F -p 5433" start

Í£Ö¹ postmaster

> pg_ctl stop
Í£Ö¹ postmaster£®Ê¹Óà -m ¿ª¹ØÒÔÔÊÐíÎÒÃÇ¿ØÖƺó¶ËÊÇÈçºÎÍ£Ö¹µÄ£®-w µÈ´ý postmaster Í£Ö¹£®-m ÉùÃ÷Í£Ö¹µÄģʽ£®

ÖØÆð postmaster

Õâ¸ö¹¦Äܼ¸ºõµÈͬÓÚÍ£Ö¹ postmaster È»ºóÔÙ´ÎÆô¶¯Ëü£­³ýÁËÍ£Ö¹ËüÇ°µÄ²ÎÊý»¹ÒªÊ¹ÓÃÒÔÍ⣮ÕâÊÇͨ¹ýÔÚ $PGDATA/postmaster.opts ÎļþÀï´æ´¢ÕâЩ²ÎÊýʵÏֵģ®-w£¬-D£¬-m£¬-fast£¬-immediate Ò²¿ÉÒÔÔÚÖØÆðģʽʹÓ㬲¢ÇÒºÍÉÏÃæÓÐÒ»ÑùµÄº¬Ò壮

ÒªÓÃ×î¼òµ¥µÄ·½·¨ÖØÆð postmaster£º

> pg_ctl restart
ÒªÖØÆð postmaster£¬µÈËüÍ£Ö¹²¢ÖØÐÂÆô¶¯£º
> pg_ctl -w restart
ÒªÔÚ 5433 ¶Ë¿ÚÖØÆð²¢ÇÒÖØÆðºó¹Ø±Õ fsync£º
> pg_ctl -o "-o -F -p 5433" restart

postmaster ״̬

Òª´Ó postmaster »ñȡ״̬ÐÅÏ¢£º
> pg_ctl status
ÏÂÃæÊÇһЩ´Ó pg_ctl ÀïµÄÀý×Ó£º
pg_ctl: postmaster is running (pid: 13718)
options are:
/usr/local/src/pgsql/current/bin/postmaster
-p 5433
-D /usr/local/src/pgsql/current/data
-B 64
-b /usr/local/src/pgsql/current/bin/postgres
-N 32
-o '-F'