{"id":810,"date":"2016-09-10T13:35:14","date_gmt":"2016-09-10T05:35:14","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=810"},"modified":"2016-09-10T13:50:29","modified_gmt":"2016-09-10T05:50:29","slug":"greenplum%e6%95%b0%e6%8d%ae%e5%ba%93%e5%b8%b8%e7%94%a8%e5%91%bd%e4%bb%a4%e5%a4%a7%e5%85%a8","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=810","title":{"rendered":"Greenplum\u6570\u636e\u5e93\u5e38\u7528\u547d\u4ee4\u5927\u5168"},"content":{"rendered":"<h2>\n\t\u6570\u636e\u5e93\u542f\u52a8\uff1agpstart<br \/>\n<\/h2>\n<p style=\"margin-left:21.0pt\">\n\t\u5e38\u7528\u53ef\u9009\u53c2\u6570\uff1a\n<\/p>\n<p style=\"margin-left:21.0pt\">\n\t-a\uff1a\u76f4\u63a5\u542f\u52a8\uff0c\u4e0d\u63d0\u793a\u7ec8\u7aef\u7528\u6237\u8f93\u5165\u786e\u8ba4\n<\/p>\n<p style=\"margin-left:21.0pt\">\n\t-m\uff1a\u53ea\u542f\u52a8master \u5b9e\u4f8b\uff0c\u4e3b\u8981\u5728\u6545\u969c\u5904\u7406\u65f6\u4f7f\u7528\n<\/p>\n<h2>\n\t\u6570\u636e\u5e93\u505c\u6b62\uff1agpstop<br \/>\n<\/h2>\n<p style=\"margin-left:21.0pt\">\n\t\u5e38\u7528\u53ef\u9009\u53c2\u6570\uff1a\n<\/p>\n<p style=\"margin-left:21.0pt\">\n\t-a\uff1a\u76f4\u63a5\u505c\u6b62\uff0c\u4e0d\u63d0\u793a\u7ec8\u7aef\u7528\u6237\u8f93\u5165\u786e\u8ba4\n<\/p>\n<p style=\"margin-left:21.0pt\">\n\t-m\uff1a\u53ea\u505c\u6b62master \u5b9e\u4f8b\uff0c\u4e0egpstart &ndash;m \u5bf9\u5e94\u4f7f\u7528\n<\/p>\n<p style=\"margin-left:21.0pt\">\n\t-M fast\uff1a\u505c\u6b62\u6570\u636e\u5e93\uff0c\u4e2d\u65ad\u6240\u6709\u6570\u636e\u5e93\u8fde\u63a5\uff0c\u56de\u6eda\u6b63\u5728\u8fd0\u884c\u7684\u4e8b\u52a1\n<\/p>\n<p style=\"margin-left:21.0pt\">\n\t-u\uff1a\u4e0d\u505c\u6b62\u6570\u636e\u5e93\uff0c\u53ea\u52a0\u8f7dpg_hba.conf \u548cpostgresql.conf\u4e2d\u8fd0\u884c\u65f6\u53c2\u6570\uff0c\u5f53\u6539\u52a8\u53c2\u6570\u914d\u7f6e\u65f6\u5019\u4f7f\u7528\n<\/p>\n<p style=\"margin-left:21.0pt\">\n\t-f\uff1a\u5f3a\u5236\u505c\u6b62\u6570\u636e\u5e93\n<\/p>\n<p style=\"margin-left:21.0pt\">\n\t-r\uff1a \u91cd\u542f\u6570\u636e\u5e93\n<\/p>\n<h2>\n\t\u67e5\u770b\u5b9e\u4f8b\u914d\u7f6e\u548c\u72b6\u6001<br \/>\n<\/h2>\n<p>\n\tselect * from gp_segment_configuration order by 1 ;\n<\/p>\n<p>\n\t\u4e3b\u8981\u5b57\u6bb5\u8bf4\u660e\uff1a\n<\/p>\n<p>\n\tContent\uff1a\u8be5\u5b57\u6bb5\u76f8\u7b49\u7684\u4e24\u4e2a\u5b9e\u4f8b\uff0c\u662f\u4e00\u5bf9\uff30\uff08primary instance\uff09\u548c\uff2d\uff08mirror&nbsp;Instance)\n<\/p>\n<p>\n\tIsprimary\uff1a\u5b9e\u4f8b\u662f\u5426\u4f5c\u4e3aprimary instance \u8fd0\u884c\n<\/p>\n<p>\n\tValid\uff1a\u5b9e\u4f8b\u662f\u5426\u6709\u6548\uff0c\u5982\u5904\u4e8efalse \u72b6\u6001\uff0c\u5219\u8bf4\u660e\u8be5\u5b9e\u4f8b\u5df2\u7ecfdown \u6389\n<\/p>\n<p>\n\tPort\uff1a\u5b9e\u4f8b\u8fd0\u884c\u7684\u7aef\u53e3\n<\/p>\n<p>\n\tDatadir:\u5b9e\u4f8b\u5bf9\u5e94\u7684\u6570\u636e\u76ee\u5f55\n<\/p>\n<p>\n\t\u6ce8\u5b9e\u4f8b\u914d\u7f6e\u7684\u6570\u636e\u8868\uff1agp_segment_configuration \u3001pg_filespace_entry\u3001gp_fault_strategy;\n<\/p>\n<p>\n\t\u5176\u5b83\u5e38\u7528\u7684\u7cfb\u7edf\u8868\uff1apg_class,pg_attribute,pg_database,pg_tables&hellip;&hellip;\n<\/p>\n<p>\n\t\u53ef\u4ee5\u7528tab\u6765\u5339\u914d\u8868\u540d\uff1b\n<\/p>\n<h2>\n\tgpstate \uff1a\u663e\u793aGreenplum\u6570\u636e\u5e93\u8fd0\u884c\u72b6\u6001\uff0c\u8be6\u7ec6\u914d\u7f6e\u7b49\u4fe1\u606f<br \/>\n<\/h2>\n<p>\n\t\u5e38\u7528\u53ef\u9009\u53c2\u6570:\n<\/p>\n<p style=\"margin-left:21.0pt\">\n\t-c\uff1aprimary instance \u548c mirror instance \u7684\u5bf9\u5e94\u5173\u7cfb&nbsp;\n<\/p>\n<p style=\"margin-left:21.0pt\">\n\t-m\uff1a\u53ea\u5217\u51famirror \u5b9e\u4f8b\u7684\u72b6\u6001\u548c\u914d\u7f6e\u4fe1\u606f\n<\/p>\n<p style=\"margin-left:21.0pt\">\n\t-f\uff1a\u663e\u793astandby master \u7684\u8be6\u7ec6\u4fe1\u606f\n<\/p>\n<p style=\"margin-left:21.0pt\">\n\t-s\uff1a\u67e5\u770b\u8be6\u7ec6\u72b6\u6001\uff0c\u5982\u5728\u540c\u6b65\uff0c\u53ef\u663e\u793a\u6570\u636e\u540c\u6b65\u5b8c\u6210\u767e\u5206\u6bd4\n<\/p>\n<p style=\"margin-left:21.0pt\">\n\t&#8211;version,\u67e5\u770b\u6570\u636e\u5e93version\uff08\u4e5f\u53ef\u4f7f\u7528pg_controldata\u67e5\u770b\u6570\u636e\u5e93\u7248\u672c\u548cpostgresql\u7248\u672c\uff09\n<\/p>\n<p>\n\t\u8be5\u547d\u4ee4\u9ed8\u8ba4\u5217\u51fa\u6570\u636e\u5e93\u8fd0\u884c\u72b6\u6001\u6c47\u603b\u4fe1\u606f\uff0c\u5e38\u7528\u4e8e\u65e5\u5e38\u5de1\u68c0\u3002\n<\/p>\n<h2>\n\t\u67e5\u770b\u7528\u6237\u4f1a\u8bdd\u548c\u63d0\u4ea4\u7684\u67e5\u8be2\u7b49\u4fe1\u606f<br \/>\n<\/h2>\n<p style=\"margin-left:33.4pt\">\n\tselect * from pg_stat_activity&nbsp;\n<\/p>\n<p style=\"margin-left:33.4pt\">\n\t\u8be5\u8868\u80fd\u67e5\u770b\u5230\u5f53\u524d\u6570\u636e\u5e93\u8fde\u63a5\u7684IP \u5730\u5740\uff0c\u7528\u6237\u540d\uff0c\u63d0\u4ea4\u7684\u67e5\u8be2\u7b49\u3002\u53e6\u5916\u4e5f\u53ef\u4ee5\u5728master \u4e3b\u673a\u4e0a\u67e5\u770b\u8fdb\u7a0b\uff0c\u5bf9\u6bcf\u4e2a\u5ba2\u6237\u7aef\u8fde\u63a5\uff0cmaster \u90fd\u4f1a\u521b\u5efa\u4e00\u4e2a\u8fdb\u7a0b\u3002\n<\/p>\n<p style=\"margin-left:33.4pt\">\n\tps -ef |grep -i postgres |grep -i con\n<\/p>\n<p style=\"margin-left:32.9pt\">\n\tpg_backend_pid()\uff1b\n<\/p>\n<p style=\"margin-left:32.9pt\">\n\tpg_cancel_backend(integer)\n<\/p>\n<h2>\n\t\u67e5\u770b\u6570\u636e\u5e93\u3001\u8868\u5360\u7528\u7a7a\u95f4<br \/>\n<\/h2>\n<p align=\"left\">\n\tselect pg_size_pretty(pg_relation_size(&#039;schema.tablename&#039;));(\u4e0epg_tables\u5b50\u67e5\u8be2\u67e5\u770b\u6240\u6709\u8868\u7684\u5360\u7528\u7a7a\u95f4)\n<\/p>\n<p align=\"left\">\n\tselect pg_size_pretty(pg_database_size(&#039;databasename));\u5fc5\u987b\u5728\u6570\u636e\u5e93\u6240\u5bf9\u5e94\u7684\u5b58\u50a8\u7cfb\u7edf\u91cc\uff0c\u81f3\u5c11\u4fdd\u755930%\u7684\u81ea\u7531\u7a7a\u95f4\uff0c\u65e5\u5e38\u5de1\u68c0\uff0c\u8981\u68c0\u67e5\u5b58\u50a8\u7a7a\u95f4\u7684\u5269\u4f59\u5bb9\u91cf\u3002\n<\/p>\n<p align=\"left\" style=\"margin-left:2.0pt\">\n\tset gp_enable_multiphase_agg=on;\n<\/p>\n<h2>\n\t\u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\uff0c\u56de\u6536\u7a7a\u95f4<br \/>\n<\/h2>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u5b9a\u671f\u4f7f\u7528Vacuum analyze tablename \u56de\u6536\u5783\u573e\u548c\u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\uff0c\u5c24\u5176\u5728\u5927\u6570\u636e\u91cf\u5220\u9664\uff0c\u5bfc\u5165\u4ee5\u540e\uff0c\u975e\u5e38\u91cd\u8981\u3001\u9700\u8981\u5b9a\u671f\u5bf9\u6570\u636e\u5b57\u5178\u505avacuum\u548creindex \uff0c\u5982pg_class,pg_attribute\u7b49\u7cfb\u7edf\u8868\u3002\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u53ef\u4ee5gp_toolkit.gp_bloat_diag\u770b\u81a8\u80c0\u5f88\u5927\u7684\u8868\uff1b\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tAlter table\u53ef\u4ee5\u7528\u6765\u4ee3\u66ffvacuum full \u56de\u6536\u7a7a\u95f4(\u9664\u4e86\u7cfb\u7edf\u8868):\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\talter table test set with (reorganize=true);\n<\/p>\n<h2>\n\t\u67e5\u770b\u6570\u636e\u5206\u5e03\u60c5\u51b5<br \/>\n<\/h2>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u4e24\u79cd\u65b9\u5f0f\uff1a\n<\/p>\n<ul>\n<li align=\"left\">\n\t\tSelect gp_segment_id,count(*) from&nbsp; tablename&nbsp; group by 1 ;\n\t<\/li>\n<li align=\"left\">\n\t\t\u5728\u547d\u4ee4\u8fd0\u884c\uff1agpskew -t public.ate -a postgres\n\t<\/li>\n<\/ul>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u5982\u6570\u636e\u5206\u5e03\u4e0d\u5747\u5300\uff0c\u5c06\u53d1\u6325\u4e0d\u4e86\u5e76\u884c\u8ba1\u7b97\u7684\u4f18\u52bf\uff0c\u4e25\u91cd\u5f71\u54cd\u6027\u80fd\u3002\n<\/p>\n<h2>\n\t\u767b\u5f55\u6bcf\u4e00\u4e2a\u5b9e\u4f8b\u6570\u636e\u5e93\u7684\u65b9\u6cd5<br \/>\n<\/h2>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tPGOPTIONS=&#039;-c gp_session_role=utility&#039; psql &nbsp;dbname &nbsp;&ndash;p&nbsp; xxxx\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u53ef\u4ee5\u901a\u8fc7\u8fd9\u4e2a\u547d\u4ee4\u767b\u5f55\u5b9e\u4f8b\uff0c\u4e00\u822c\u7528\u4e8e\u68c0\u6d4b\u5355\u4e2a\u5b9e\u4f8b\u662f\u5426\u8fd0\u884c\u6b63\u5e38\uff0c\u8fd8\u6709\u5c31\u662f\u7528\u4e8e\u5728\u96c6\u7fa4\u53d1\u751f\u4e0d\u4e00\u81f4\u65f6\uff08\u53ea\u6709\u5728\u975e\u5e38\u7279\u6b8a\u7684\u60c5\u51b5\u4e0b\u624d\u6709\u53ef\u80fd\u53d1\u751f\uff0c\u5982\u8868\u4e0d\u4e00\u81f4\u7b49\uff09\uff0c\u8fdb\u884c\u8868\u7ef4\u62a4\n<\/p>\n<h2>\n\t\u5b9e\u4f8b\u6062\u590d\uff1agprecoverseg<br \/>\n<\/h2>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u901a\u8fc7gpstate \u6216gp_segement_configuration \u53d1\u73b0\u6709\u5b9e\u4f8bdown \u6389\u4ee5\u540e\uff0c\u4f7f\u7528\u8be5\u547d\u4ee4\u8fdb\u884c\u6062\u590d\u3002\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tgprecoverseg -F\u5f3a\u5236\u6062\u590d\n<\/p>\n<h2>\n\t\u67e5\u770b\u9501\u4fe1\u606f<br \/>\n<\/h2>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u6ce8\uff1a<strong>\u5728Greenplum\u91cc\uff08\u622a\u81f3\u52304.0\u7248\u672c\uff09\uff0cINSERT \u548cCOPY\u90fd\u662f\u884c\u7ea7\u9501\uff0cUPDATE\/DELETE\u90fd\u662f\u8868\u7ea7\u9501\uff1b<\/strong>\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tSELECT locktype, database, c.relname, l.relation, l.transactionid, l.transaction, l.pid, l.mode, l.granted, a.current_query\n<\/p>\n<p align=\"left\" style=\"margin-left:49.25pt\">\n\tFROM pg_locks l, pg_class c, pg_stat_activity a\n<\/p>\n<p align=\"left\" style=\"margin-left:49.25pt\">\n\tWHERE l.relation=c.oid AND l.pid=a.procpid\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tORDER BY c.relname;\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u4e3b\u8981\u5b57\u6bb5\u8bf4\u660e\uff1a\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t<strong>relname<\/strong>: \u8868\u540d\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tlocktype\u3001mode \u6807\u8bc6\u4e86\u9501\u7684\u7c7b\u578b\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u6ce8\uff1a<strong>\u4e5f\u53ef\u4ee5\u901a\u8fc7pgadminIII\u7684\u5de5\u5177-&gt;\u670d\u52a1\u5668\u72b6\u6001\u67e5\u770b\u5f53\u524d\u8fd0\u884c\u7684SQL\u53ca\u9501\u7b49\u5f85\u60c5\u51b5\u3002\u53d1\u751fDeadlock\u65f6\uff0c\u7cfb\u7edf\u81ea\u52a8\u8ba9\u5176\u4e2d\u4e00\u4e2aSQL\u5931\u8d25\uff0c\u5e76\u63d0\u793adeadlock\u4fe1\u606f\u3002<\/strong>\n<\/p>\n<h2>\n\texplain<br \/>\n<\/h2>\n<p>\n\t\u5728\u63d0\u4ea4\u5927\u7684\u67e5\u8be2\u4e4b\u524d\uff0c\u4f7f\u7528explain\u5206\u6790\u6267\u884c\u8ba1\u5212\u3001\u53d1\u73b0\u6f5c\u5728\u4f18\u5316\u673a\u4f1a\uff0c\u907f\u514d\u5c06\u7cfb\u7edf\u8d44\u6e90\u71ac\u5c3d\u3002explain analyze&nbsp;sql,\u5c06\u6267\u884c\u4e00\u6b21SQL\uff0c\u5e76\u884c\u5c06\u8fc7\u7a0b\u4e2d\u7684\u5177\u4f53cost\u548c\u8fd0\u884c\u60c5\u51b5\u8bb0\u5f55\u4e0b\u6765\u4e5f\u53ef\u4ee5\u7528pgadminIII\u8fdb\u884cexplain\u7684\u56fe\u5f62\u5316\u663e\u793a\uff0c\u8fdb\u800c\u6765\u4f18\u5316\u6267\u884c\u8def\u5f84\uff0c\u5982\u8868\u5173\u8054\u7b56\u7565\u7b49\u3002\n<\/p>\n<p>\n\t\u6ce8\uff1a<strong>\u53ef\u4ee5\u5728Master\u7684postgresql.conf\u4e2d \u4fee\u6539<tt>log_min_duration_statement=5000s<\/tt><tt>\uff0c<\/tt>SQL\u8fd0\u884c\u8017\u65f6\u8d85\u8fc7\u8fd9\u4e2a\u503c\u5f97\u90fd\u5728pg_log\u7eaa\u5f55SQL\u7684\u5b9e\u9645\u8017\u65f6\uff0c\u7528\u6765\u76d1\u63a7\u8017\u65f6\u7684SQL\u3002<\/strong>\n<\/p>\n<h2>\n\t\u6570\u636e\u5e93\u5e76\u884c\u5907\u4efdgp_dump<br \/>\n<\/h2>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u5e38\u7528\u53c2\u6570\uff1a\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t-s: \u53ea\u5bfc\u51fa\u5bf9\u8c61\u5b9a\u4e49\uff08\u8868\u7ed3\u6784\uff0c\u51fd\u6570\u7b49\uff09\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t-n: \u53ea\u5bfc\u51fa\u67d0\u4e2aschema\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t<strong>gp_dump <\/strong><strong>\u9ed8\u8ba4\u5728<\/strong><strong>master <\/strong><strong>\u7684<\/strong><strong>data <\/strong><strong>\u76ee\u5f55\u4e0a\u4ea7\u751f\u8fd9\u4e9b\u6587\u4ef6\uff1a<\/strong>\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tgp_catalog_1_&lt;dbid&gt;_&lt;timestamp&gt; \uff1a\u5173\u4e8e\u6570\u636e\u5e93\u7cfb\u7edf\u914d\u7f6e\u7684\u5907\u4efd\u6587\u4ef6\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tgp_cdatabase_1_&lt;dbid&gt;_&lt;timestamp&gt;\uff1a\u6570\u636e\u5e93\u521b\u5efa\u8bed\u53e5\u7684\u5907\u4efd\u6587\u4ef6\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tgp_dump_1_&lt;dbid&gt;_&lt;timestamp&gt;\uff1a\u6570\u636e\u5e93\u5bf9\u8c61ddl\u8bed\u53e5\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tgp_dump_status_1_&lt;dbid&gt;_&lt;timestamp&gt;\uff1a\u5907\u4efd\u64cd\u4f5c\u7684\u65e5\u5fd7\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t<strong>\u5728\u6bcf\u4e2a<\/strong><strong>segment instance <\/strong><strong>\u4e0a\u7684<\/strong><strong>data<\/strong><strong>\u76ee\u5f55\u4e0a\u4ea7\u751f\u7684\u6587\u4ef6\uff1a<\/strong>\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tgp_dump_0_&lt;dbid&gt;_&lt;timestamp&gt;\uff1a\u7528\u6237\u6570\u636e\u5907\u4efd\u6587\u4ef6\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tgp_dump_status_0_&lt;dbid&gt;_&lt;timestamp&gt;\uff1a\u5907\u4efd\u65e5\u5fd7\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tgpcorndump\uff1a\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u53ef\u4ee5\u7528\u4e8e\u5907\u4efd\u6570\u636e\u5e93\u914d\u7f6e\u6587\u4ef6\u548c\u5168\u5c40\u6570\u636e\uff08\u5982\u89d2\u8272\u3001\u8d44\u6e90\u961f\u5217\u7b49\uff09\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tExample:gpcrondump -x mydatabase &nbsp;&ndash;u&nbsp; \/xxx\/ &nbsp;-c -g &ndash;G &ndash;a &ndash;q &gt;&gt;$DATE.log\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t-g&nbsp; \u5907\u4efdpostgresql.conf\u3001pg_hba.conf\u3001pg_ident.conf\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t-G&nbsp; \u5907\u4efd\u5168\u5c40\u5bf9\u8c61\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t-u&nbsp; \u5907\u4efd\u5230\u7684\u76ee\u5f55(\u5982\u679c\u6ca1\u6709-u\uff0c\u5219\u6570\u636e\u5907\u4efd\u5230\u6bcf\u4e2a\u6570\u636e\u76ee\u5f55\u91cc\u9762)\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tgpcrondump\u7684\u6587\u4ef6\u53ef\u4ee5\u7528gp_restore\u6062\u590d\n<\/p>\n<p align=\"left\">\n\t&nbsp;&nbsp;gp_restore &#8211;gp-c &#8211;gp-d=\/data\/backup\/db_dumps\/20110423\/ &#8211;gp-k=20110423103328&nbsp; -d gpadmin\n<\/p>\n<p align=\"left\">\n\t\u4e5f\u53ef\u4ee5\u7528gpdbresotre\u6062\u590d\uff1a(\u9700\u8981\u6570\u636e\u5728\u4e00\u4e2aHost\u4e0a)\n<\/p>\n<p align=\"left\">\n\tgpdbrestoree&nbsp; -R master=\/data\/backup\/db_dumps\/20110423\n<\/p>\n<p align=\"left\">\n\t-T \u53ef\u4ee5\u53ea\u6062\u590d\u5176\u4e2d\u7684\u67d0\u8868\uff08\u6bd4gp_dump\u591a\u8fd9\u4e2a\u53c2\u6570\uff09\n<\/p>\n<p align=\"left\">\n\tgpdbrestore -t 20120229182541 -T public.account\n<\/p>\n<h2>\n\t\u6570\u636e\u5e93\u6062\u590d gp_restore<br \/>\n<\/h2>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u5fc5\u9009\u53c2\u6570\uff1a\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t&#8211;gp-k=key \uff1akey \u4e3agp_dump \u5bfc\u51fa\u6765\u7684\u6587\u4ef6\u7684\u540e\u7f00\u65f6\u95f4\u6233\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t-d dbname&nbsp; \uff1a\u5c06\u5907\u4efd\u6587\u4ef6\u6062\u590d\u5230dbname\n<\/p>\n<h2>\n\t\u4e32\u884c\u5907\u4efd<br \/>\n<\/h2>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t<strong>pg_dump\/pg_dumpall<\/strong>\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t<strong>\u4e00\u822c\u7528\u4e8e\u73af\u5883\u8fc1\u79fb\u548c<\/strong><strong>DDL<\/strong><strong>\u3001<\/strong><strong>FUNCTION<\/strong><strong>\u7b49\u5907\u4efd\uff1b<\/strong>\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u5982\uff1apg_dump&nbsp; -s &nbsp;-n public &nbsp;demodb &ndash;f &nbsp;demodb.sql ,\u5c06\u53ea\u5907\u4efddemodb\u6570\u636e\u5e93\u4e2d\u7684public \u4e0b\u7684\u6240\u6709DDL\u548cFUNCTION\uff0c-s\u8868\u793a\u4e0d\u5907\u4efd\u6570\u636e\uff1b\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u6062\u590d\u65f6\uff0c\u4f7f\u7528psql&nbsp; -d demodb &ndash;f&nbsp; demodb.sql\n<\/p>\n<h2>\n\t\u6570\u636e\u5e93\u50f5\u5c38\u8fdb\u7a0b\u5904\u7406<br \/>\n<\/h2>\n<p style=\"margin-left:21.0pt\">\n\t\u9996\u5148\u4f7f\u7528kill -15 \u53bb\u505c\u6b62\u8fdb\u7a0b\uff0ckill -15 \u4e0d\u54cd\u5e94\uff0c\u518d\u7528kill -11;\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u4e0d\u8981\u7528kill -9\uff0c\u5426\u5219\u53ef\u80fd\u5bfc\u81f4\u6570\u636e\u5e93\u5b95\u673a\u4e14\u72b6\u6001\u4e0d\u4e00\u81f4\uff0c\u4e25\u91cd\u7684\u5bfc\u81f4\u6570\u636e\u5e93\u4e0d\u80fd\u91cd\u65b0\u542f\u52a8\uff0c\u53ef\u80fd\u9700\u8981\u7528pg_resetxlog\u53bb\u91cd\u7f6e\u65e5\u5fd7\uff0c\u6709\u53ef\u80fd\u5bfc\u81f4\u6570\u636e\u4e22\u5931\uff1b\n<\/p>\n<h2>\n\t\u53c2\u6570\u66f4\u6539<br \/>\n<\/h2>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u901a\u8fc7gpconfig\u914d\u7f6eMaster\u548c\u6240\u6709Segment\u7684postgresql.conf\u4e2d\u53c2\u6570\u3002\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tEXAMPLES\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tgpconfig -c work_mem -v 120MB &ndash;masteronly\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u4fee\u6539master\u4e0a\u7684work_mem =120MB\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tgpconfig -c max_connections -v 100 -m 10\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u4fee\u6539Master\u4e0amax_connections=10\uff0cSegment\u4e0a\u4fee\u6539\u6210100\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tgpconfig -r default_statistics_target\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u6ce8\u91ca\u53c2\u6570\uff0c\u4f7f\u7528\u7f3a\u7701\u53c2\u6570\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tgpconfig &ndash;l\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u5217\u51fa\u6240\u6709\u7684\u53c2\u6570\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tgpconfig -s max_connections&nbsp;&nbsp;&nbsp;\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t\u663e\u793a\u67d0\u4e2a\u53c2\u6570\n<\/p>\n<h2>\n\tGreenplum\u5176\u5b83\u5e38\u7528\u547d\u4ee4<br \/>\n<\/h2>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tgpssh&nbsp; -f&nbsp; all_hosts&mdash;\u901a\u8fc7SSH\u540c\u65f6\u8bbf\u95ee\u591a\u4e2a\u8282\u70b9\uff0c\u5e76\u53ef\u540c\u65f6\u6267\u884cshell\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tgpcheckperf&nbsp; &#8211;\u68c0\u67e5\u7f51\u7edc\u548c\u786c\u76d8\u6027\u80fd\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tcheckos&nbsp; -f all_hosts &ndash;\u68c0\u67e5OS\u5185\u6838\u548c\u53c2\u6570\n<\/p>\n<h2>\n\t\u68c0\u67e5Disk\u6027\u80fd<br \/>\n<\/h2>\n<p>\n\tgpcheckperf -d \/data\/gpdb_p1 -d \/data\/gpdb_p2 -d \/data\/gpdb_p3 &nbsp;-d \/data\/gpdb_p4&nbsp; -d \/data\/gpdb_p5&nbsp; -d \/data\/gpdb_p6&nbsp; -d \/data\/gpdb_p7&nbsp; -d \/data\/gpdb_p8&nbsp; -S 64GB &nbsp;-r ds -D -v &nbsp;-f hosts-setup\n<\/p>\n<h2>\n\t\u68c0\u67e5\u7f51\u7edc\u6027\u80fd<br \/>\n<\/h2>\n<p>\n\tgpcheckperf -d \/data\/gpdb_p1 -r N -f hosts-net0\n<\/p>\n<p>\n\tgpcheckperf -d \/data\/gpdb_p1 -r N -f hosts-net1\n<\/p>\n<p>\n\tgpcheckperf -d \/data\/gpdb_p1 -r N -f hosts-net2\n<\/p>\n<p>\n\tgpcheckperf -d \/data\/gpdb_p1 -r N -f hosts-net3\n<\/p>\n<h2>\n\tGreenplum\u5347\u7ea7\u548c\u6269\u5bb9<br \/>\n<\/h2>\n<h3>\n\t1\uff09Upgrade<br \/>\n<\/h3>\n<p>\n\t&#8211;\u5c0f\u7248\u672c\u5347\u7ea7\uff1a4.0.4 &mdash;&gt; 4.0.5\n<\/p>\n<p>\n\t\u66ff\u6362\/usr\/local\/greenplum-db\u5373\u53ef\n<\/p>\n<p>\n\t&#8211;\u5927\u7248\u672c\u5347\u7ea7\uff1a3.3.7 &mdash;&gt; 4.0.4\n<\/p>\n<p>\n\t$gpmigrator\n<\/p>\n<h3>\n\t2\uff09\u6269\u5bb9<br \/>\n<\/h3>\n<p>\n\t$gpexpand\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tCREATE EXTERNAL TABLE test_ext(\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t&nbsp; id integer,\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t&nbsp; name varchar(10),\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t&nbsp; dt date\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t)LOCATION (&#039;gpfdist:\/\/master:8081\/test.txt&#039;)\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t&nbsp;FORMAT &#039;text&#039; (delimiter &#039;,&#039; null &#039;\\\\N&#039; escape &#039;\\\\&#039;)\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\t&nbsp;ENCODING &#039;gb18030&#039;\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tLOG ERRORS INTO error_table SEGMENT REJECT LIMIT 3 ;\n<\/p>\n<p align=\"left\" style=\"margin-left:21.0pt\">\n\tnohup gpfdist -d \/tmp\/ -p 8081 &amp;\n<\/p>\n<p>\n\t<strong>\u7248\u6743\u58f0\u660e\uff1a\u672c\u6587\u4e3a\u535a\u4e3b\u539f\u521b\u6587\u7ae0\uff0c\u672a\u7ecf\u535a\u4e3b\u5141\u8bb8\u4e0d\u5f97\u8f6c\u8f7d\u3002<\/strong><\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=810\">Greenplum\u6570\u636e\u5e93\u5e38\u7528\u547d\u4ee4\u5927\u5168<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u6570\u636e\u5e93\u542f\u52a8\uff1agpstart \u5e38\u7528\u53ef\u9009\u53c2\u6570\uff1a -a\uff1a\u76f4\u63a5\u542f\u52a8\uff0c\u4e0d\u63d0\u793a\u7ec8\u7aef\u7528\u6237\u8f93\u5165\u786e\u8ba4 -m\uff1a\u53ea\u542f\u52a8master  [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[484,483,428,482],"class_list":["post-810","post","type-post","status-publish","format-standard","hentry","category-sql","tag-gprecoverseg","tag-gp_restore","tag-greenplum","tag-pg_dump"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/810","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=810"}],"version-history":[{"count":3,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/810\/revisions"}],"predecessor-version":[{"id":813,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/810\/revisions\/813"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=810"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=810"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}