{"id":1977,"date":"2020-07-29T21:50:53","date_gmt":"2020-07-29T13:50:53","guid":{"rendered":"http:\/\/39.97.231.10\/?p=1977"},"modified":"2020-07-29T21:50:53","modified_gmt":"2020-07-29T13:50:53","slug":"postgresql-pg_ctl-%e5%b7%a5%e5%85%b7","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=1977","title":{"rendered":"PostgreSQL pg_ctl \u5de5\u5177"},"content":{"rendered":"<div class=\\\"blog_title\\\">\n<div>\n<span style=\\\"font-size: 1rem;\\\">pg_ctl \u662f PostgreSQL\u6570\u636e\u5e93\u81ea\u5e26\u7684\u5b9e\u7528\u5de5\u5177\uff0c\u5177\u6709\u4ee5\u4e0b\u529f\u80fd\uff1a<\/span>\n<\/div>\n<\/div>\n<div class=\\\"blog_content\\\">\n<div class=\\\"blog_detail\\\">\n<ol>\n<li>\u521d\u59cb\u5316PostgreSQL\u6570\u636e\u5e93\u5b9e\u4f8b<\/li>\n<li>\u542f\u52a8\uff0c\u505c\u6b62\uff0c\u91cd\u542fPostgreSQL\u6570\u636e\u5e93\u670d\u52a1<\/li>\n<li>\u67e5\u770bPostgreSQL\u6570\u636e\u5e93\u670d\u52a1\u7684\u72b6\u6001<\/li>\n<li>\u8ba9\u6570\u636e\u5e93\u91cd\u65b0\u8bfb\u53d6\u914d\u7f6e\u6587\u4ef6<\/li>\n<li>\u5c06\u5907\u5e93\u63d0\u5347\u4e3a\u4e3b\u5e93<\/li>\n<li>\u7ed9\u6307\u5b9a\u7684\u8fdb\u7a0b\u53d1\u9001\u4fe1\u53f7<\/li>\n<\/ol>\n<pre><code>Usage:\n  pg_ctl init[db] [-D DATADIR] [-s] [-o OPTIONS]\n  pg_ctl start    [-D DATADIR] [-l FILENAME] [-W] [-t SECS] [-s] [-o OPTIONS] [-p PATH] [-c]\n  pg_ctl stop     [-D DATADIR] [-m SHUTDOWN-MODE] [-W] [-t SECS] [-s]\n  pg_ctl restart  [-D DATADIR] [-m SHUTDOWN-MODE] [-W] [-t SECS] [-s] [-o OPTIONS] [-c]\n  pg_ctl reload   [-D DATADIR] [-s]\n  pg_ctl status   [-D DATADIR]\n  pg_ctl promote  [-D DATADIR] [-W] [-t SECS] [-s]\n  pg_ctl kill     SIGNALNAME PID\n<\/code><\/pre>\n<h5>1. \u521d\u59cb\u5316PostgreSQL\u6570\u636e\u5e93\u5b9e\u4f8b<\/h5>\n<p>pg_ctl init[db] [-s] [-D datadir] [-o options]<br \/>\n\u5b9e\u9645\u8c03\u7528initdb\u547d\u4ee4\u8fdb\u884c\u6570\u636e\u5e93\u5b9e\u4f8b\u7684\u521d\u59cb\u5316\u3002<br \/>\n\u793a\u4f8b\uff1a<br \/>\npg_ctl init -s -D \/data\/pg<br \/>\n-s \u53ea\u6253\u5370\u9519\u8bef\u548c\u544a\u8b66\u4fe1\u606f\uff0c\u4e0d\u6253\u5370\u63d0\u793a\u6027\u4fe1\u606f<br \/>\n-D datadir\uff0c\u6307\u5b9a\u6570\u636e\u5e93\u5b9e\u4f8b\u7684\u6570\u636e\u76ee\u5f55<br \/>\n-o options\uff0c\u76f4\u63a5\u4f20\u9012\u7ed9initdb\u547d\u4ee4\u7684\u53c2\u6570<\/p>\n<h5>2. \u542f\u52a8PostgreSQL\u6570\u636e\u5e93<\/h5>\n<p>pg_ctl start [-w] [-t seconds] [-s] [-D datadir] [-l filename] [-o options] [-p path] [-c]<br \/>\n\u793a\u4f8b\uff1a<br \/>\npg_ctl start -w -D \/data\/pg<br \/>\nstart\uff0c\u542f\u52a8\u6570\u636e\u5e93\u5b9e\u4f8b<br \/>\n-w\uff0c\u7b49\u5f85\u542f\u52a8\u5b8c\u6210<br \/>\n-t\uff0c\u7b49\u5f85\u542f\u52a8\u5b8c\u6210\u7b49\u5f85\u7684\u79d2\u6570\uff0c\u9ed8\u8ba460\u79d2<br \/>\n-s\uff0c\u53ea\u6253\u5370\u9519\u8bef\u548c\u544a\u8b66\u4fe1\u606f\uff0c\u4e0d\u6253\u5370\u63d0\u793a\u6027\u4fe1\u606f<br \/>\n-D datadir\uff0c\u6307\u5b9a\u6570\u636e\u5e93\u5b9e\u4f8b\u7684\u6570\u636e\u76ee\u5f55<br \/>\n-l\uff0c\u628a\u670d\u52a1\u5668\u65e5\u5fd7\u8f93\u51fa\u9644\u52a0\u5728filename\u6587\u4ef6\u4e0a<br \/>\n-o options\uff0c\u6307\u5b9a\u4f20\u9012\u7ed9postgres\u7a0b\u5e8f\u7684\u9009\u9879<br \/>\n-p path\uff0c\u6307\u5b9apostgres\u7a0b\u5e8f\u4f4d\u7f6e\uff0c\u9ed8\u8ba4\u4e0epg_ctl\u540c\u4e00\u4e2a\u76ee\u5f55<br \/>\n-c\uff0c\u63d0\u9ad8\u670d\u52a1\u5668\u7684\u8f6f\u9650\u5236(ulimit -c)\uff0c\u5141\u8bb8\u6570\u636e\u5e93\u5b9e\u4f8b\u5f02\u5e38\u65f6\u4ea7\u751f\u4e00\u4e2acoredump\u6587\u4ef6\uff0c\u4ee5\u4fbf\u4e8e\u95ee\u9898\u7684\u6392\u67e5\u4e0e\u5206\u6790<\/p>\n<h5>3. \u505c\u6b62PostgreSQL\u6570\u636e\u5e93<\/h5>\n<p>pg_ctl stop [-W] [-t seconds] [-s] [-D datadir] [-m s|f|i ]<br \/>\n\u793a\u4f8b\uff1a<br \/>\npg_ctl stop -D \/data\/pg -m f<br \/>\n-W\uff0c\u4e0d\u7b49\u5f85\u6570\u636e\u5e93\u505c\u4e0b\u6765\u5c31\u8fd4\u56de<br \/>\n-m\uff0c\u6307\u5b9a\u505c\u6b62\u7684\u6a21\u5f0f\uff0c\u53ef\u9009\u503cs(smart)\uff0cf(fast)\uff0ci(immediate)\u3002<\/p>\n<h5>4. \u91cd\u542fPostgreSQL\u6570\u636e\u5e93<\/h5>\n<p>pg_ctl restart [-w] [-t seconds] [-s] [-D datadir] [-c] [-m s|f|i ] [-o options]<br \/>\n\u793a\u4f8b\uff1a<br \/>\npg_ctl restart -D \/data\/pg<\/p>\n<h5>5. \u91cd\u65b0\u8bfb\u53d6\u914d\u7f6e\u6587\u4ef6<\/h5>\n<p>pg_ctl reload [-s] [-D datadir]<br \/>\n\u793a\u4f8b\uff1a<br \/>\npg_ctl reload -D \/data\/pg<br \/>\n\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u6539\u53d8\u53c2\u6570\u540e\uff0c\u9700\u8981\u4f7f\u7528\u4e0a\u8ff0\u547d\u4ee4\u4f7f\u53c2\u6570\u751f\u6548\u3002<\/p>\n<h5>6. \u67e5\u770b\u6570\u636e\u5e93\u5b9e\u4f8b\u72b6\u6001<\/h5>\n<p>pg_ctl status [-D datadir]<\/p>\n<h5>7. \u5c06\u5907\u5e93\u63d0\u5347\u4e3a\u4e3b\u5e93<\/h5>\n<p>pg_ctl promote\u00a0 [-D DATADIR] [-W] [-t SECS] [-s]<br \/>\n\u793a\u4f8b\uff1a<br \/>\npg_ctl promote -D \/data\/pg<\/p>\n<h5>8. \u7ed9\u8fdb\u7a0b\u53d1\u9001\u4fe1\u53f7<\/h5>\n<p>pg_ctl kill [signal_name] [process_id]<br \/>\n\u793a\u4f8b\uff1a<br \/>\npg_ctl kill INT 3900\n<\/p><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>pg_ctl \u662f PostgreSQL\u6570\u636e\u5e93\u81ea\u5e26\u7684\u5b9e\u7528\u5de5\u5177\uff0c\u5177\u6709\u4ee5\u4e0b\u529f\u80fd\uff1a \u521d\u59cb\u5316PostgreSQL\u6570\u636e\u5e93\u5b9e &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=1977\"> <span class=\"screen-reader-text\">PostgreSQL pg_ctl \u5de5\u5177<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[134,88],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"mailpoet_newsletter_max":false,"woocommerce_thumbnail":false,"woocommerce_single":false,"woocommerce_gallery_thumbnail":false,"shop_catalog":false,"shop_single":false,"shop_thumbnail":false},"uagb_author_info":{"display_name":"weijing","author_link":"http:\/\/www.weijing.co\/?author=4"},"uagb_comment_info":0,"uagb_excerpt":"pg_ctl \u662f PostgreSQL\u6570\u636e\u5e93\u81ea\u5e26\u7684\u5b9e\u7528\u5de5\u5177\uff0c\u5177\u6709\u4ee5\u4e0b\u529f\u80fd\uff1a \u521d\u59cb\u5316PostgreSQL\u6570\u636e\u5e93\u5b9e&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1977"}],"collection":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1977"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1977\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1977"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1977"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1977"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}