{"id":1008,"date":"2020-09-07T11:21:51","date_gmt":"2020-09-07T03:21:51","guid":{"rendered":"http:\/\/www.gbase8.cn\/?p=1008"},"modified":"2022-02-11T15:54:01","modified_gmt":"2022-02-11T07:54:01","slug":"gbase-8a-%e7%a9%ba%e6%b4%9e%e7%8e%87%ef%bc%8c%e8%a2%ab%e5%88%a0%e9%99%a4%e6%95%b0%e6%8d%ae%e7%9a%84%e6%af%94%e4%be%8b%ef%bc%8cshring-space-%e9%87%8a%e6%94%be%e7%a3%81%e7%9b%98%e7%a9%ba%e9%97%b4","status":"publish","type":"post","link":"https:\/\/www.gbase8.cn\/en\/1008","title":{"rendered":"\u5357\u5927\u901a\u7528GBase 8a \u7a7a\u6d1e\u7387\uff0c\u88ab\u5220\u9664\u6570\u636e\u7684\u6bd4\u4f8b\uff0cshring space \u91ca\u653e\u78c1\u76d8\u7a7a\u95f4"},"content":{"rendered":"\n<p>GBase 8a\u6570\u636e\u5e93\u5728\u6570\u636e\u88ab\u5220\u9664\u65f6\uff0c\u5e76\u6ca1\u6709\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\uff0c\u800c\u662f\u53ea\u6253\u4e86\u4e00\u4e2a\u3010\u5df2\u5220\u9664\u3011\u7684\u6807\u8bb0\u3002\uff0c\u8fd9\u5c31\u4f1a\u5bfc\u81f4\u6709\u6548\u6570\u636e\uff0c\u5728\u78c1\u76d8\u4e0a\u662f\u4e0d\u8fde\u7eed\u7684\uff0c\u5176\u6bd4\u4f8b\u5c31\u662f\u7a7a\u6d1e\u7387\u3002 \u5728\u5927\u6570\u636e\u573a\u666f\uff0c\u5c11\u91cf\u7a7a\u6d1e\u662f\u53ef\u4ee5\u63a5\u53d7\u7684\uff0c\u4f46\u5982\u679c\u5df2\u7ecf\u5bf9\u6027\u80fd\u6709\u4e86\u5b9e\u8d28\u5f71\u54cd\uff0c\u5219\u9700\u8981\u8fdb\u884cshrink space\u91cd\u6574\u3002<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">\u76ee\u5f55\u5bfc\u822a<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2af8494d229\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2af8494d229\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.gbase8.cn\/en\/1008\/#%E8%AD%A6%E5%91%8A\" >\u8b66\u544a<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.gbase8.cn\/en\/1008\/#%E6%8E%92%E6%9F%A5%E6%96%B9%E6%A1%881%EF%BC%8C%E9%80%9A%E8%BF%87%E5%85%83%E6%95%B0%E6%8D%AE\" >\u6392\u67e5\u65b9\u68481\uff0c\u901a\u8fc7\u5143\u6570\u636e<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.gbase8.cn\/en\/1008\/#%E5%9C%BA%E6%99%AF\" >\u573a\u666f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.gbase8.cn\/en\/1008\/#%E5%88%A0%E9%99%A4%E4%B8%80%E9%83%A8%E5%88%86%E6%95%B0%E6%8D%AE%EF%BC%8C%E5%86%8D%E6%9F%A5%E7%9C%8B\" >\u5220\u9664\u4e00\u90e8\u5206\u6570\u636e\uff0c\u518d\u67e5\u770b<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.gbase8.cn\/en\/1008\/#%E6%8E%92%E6%9F%A5%E6%96%B9%E6%A1%882%EF%BC%8C%E6%9F%A5rowid\" >\u6392\u67e5\u65b9\u68482\uff0c\u67e5rowid<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.gbase8.cn\/en\/1008\/#%E6%8E%92%E6%9F%A5%E6%96%B9%E6%A1%883%E8%80%81%E7%89%88%E6%9C%AC%E6%8E%A8%E8%8D%90\" >\u6392\u67e5\u65b9\u68483(\u8001\u7248\u672c\u63a8\u8350)<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.gbase8.cn\/en\/1008\/#%E8%AF%84%E4%BC%B0%E4%B8%80%E4%B8%AADC%E9%9C%80%E8%A6%81%E5%8D%A0%E7%94%A8%E7%9A%84%E7%A9%BA%E9%97%B4\" >\u8bc4\u4f30\u4e00\u4e2aDC\u9700\u8981\u5360\u7528\u7684\u7a7a\u95f4<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.gbase8.cn\/en\/1008\/#%E8%AE%A1%E7%AE%97%E8%A1%A8%E5%BA%94%E5%8D%A0%E7%94%A8%E5%A4%9A%E5%B0%91%E7%A9%BA%E9%97%B4\" >\u8ba1\u7b97\u8868\u5e94\u5360\u7528\u591a\u5c11\u7a7a\u95f4<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.gbase8.cn\/en\/1008\/#%E8%AE%A1%E7%AE%97%E5%BD%93%E5%89%8D%E5%8D%A0%E7%94%A8%E7%A9%BA%E9%97%B4\" >\u8ba1\u7b97\u5f53\u524d\u5360\u7528\u7a7a\u95f4<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.gbase8.cn\/en\/1008\/#%E8%AE%A1%E7%AE%97%E5%8F%AF%E9%87%8A%E6%94%BE%E7%A9%BA%E9%97%B4%E5%92%8C%E6%AF%94%E4%BE%8B\" >\u8ba1\u7b97\u53ef\u91ca\u653e\u7a7a\u95f4\u548c\u6bd4\u4f8b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.gbase8.cn\/en\/1008\/#%E5%AE%8C%E6%95%B4%E4%BB%A3%E7%A0%81\" >\u5b8c\u6574\u4ee3\u7801<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.gbase8.cn\/en\/1008\/#%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%884%EF%BC%88%E6%96%B0%E7%89%88%E6%9C%AC%E5%B7%A5%E5%85%B7\" >\u89e3\u51b3\u65b9\u68484\uff08\u65b0\u7248\u672c\u5de5\u5177)<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.gbase8.cn\/en\/1008\/#%E5%91%BD%E4%BB%A4%E4%BB%8B%E7%BB%8D\" >\u547d\u4ee4\u4ecb\u7ecd<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.gbase8.cn\/en\/1008\/#%E4%BD%BF%E7%94%A8%E6%A0%B7%E4%BE%8B\" >\u4f7f\u7528\u6837\u4f8b<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.gbase8.cn\/en\/1008\/#%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88\" >\u89e3\u51b3\u65b9\u6848<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/www.gbase8.cn\/en\/1008\/#%E9%80%9A%E8%BF%87%E9%87%8D%E5%BB%BA%E8%A1%A8\" >\u901a\u8fc7\u91cd\u5efa\u8868<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/www.gbase8.cn\/en\/1008\/#%E9%80%9A%E8%BF%87shink_space\" >\u901a\u8fc7shink space<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%AD%A6%E5%91%8A\"><\/span>\u8b66\u544a<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u5728\u65b9\u68481\u7684\u529f\u80fd\u5b8c\u5584\u524d\uff0c<span class=\"has-inline-color has-luminous-vivid-orange-color\">\u5efa\u8bae\u8001\u7248\u672c\u4f7f\u7528\u65b9\u68483\uff0c2022\u5e74\u4ee5\u540e\u7684\u65b0\u7248\u672c\u4f7f\u7528\u65b9\u68484<\/span>\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%8E%92%E6%9F%A5%E6%96%B9%E6%A1%881%EF%BC%8C%E9%80%9A%E8%BF%87%E5%85%83%E6%95%B0%E6%8D%AE\"><\/span>\u6392\u67e5\u65b9\u68481\uff0c\u901a\u8fc7\u5143\u6570\u636e<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u6570\u636e\u5e93\u7684\u5143\u6570\u636e\u8868\uff0c\u63d0\u4f9b\u4e86\u67e5\u8be2\u7a7a\u6d1e\u7387\u7684\u65b9\u6cd5,\u5176\u4e2d\u7684DELETE_RATIO\u5c31\u662f\u7a7a\u6d1e\u7387\u3002<\/p>\n\n\n\n<p><span class=\"has-inline-color has-luminous-vivid-orange-color\">\u5728\u81ea\u6d4b\u4e2d\u53d1\u73b0\u3010\u622a\u6b622021-12-30\u3011\uff0c\u5982\u679c\u8868\u8fdb\u884c\u8fc7shrink space \u64cd\u4f5c\u6210\u529f\u5e76\u786e\u5b9e\u5220\u6389\u4e86seg\u6587\u4ef6, \u5219\u7a7a\u6d1e\u7387\u67e5\u8be2\u7ed3\u679c\u662f\u4e0d\u6b63\u786e\u7684\u3002\u540e\u7eed\u7248\u672c\u5b8c\u5584\u540e\u6211\u4f1a\u66f4\u65b0\u672c\u6587\u3002<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select * from performance_schema.tables where table_schema='DBNAME' and table_name='TBNAME';<\/code><\/pre>\n\n\n\n<p>\u5982\u4e0b\u662f\u4e00\u4e2a\u9a8c\u8bc1\u573a\u666f<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%9C%BA%E6%99%AF\"><\/span>\u573a\u666f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; select * from  performance_schema.tables where table_schema='testdb' and table_name='hr';\n+--------------+------------+-----------+-------------+------------+--------------+----------------+-----------------+--------------+\n| TABLE_SCHEMA | TABLE_NAME | MAX_ROWID | DELETE_ROWS | TABLE_ROWS | STORAGE_SIZE | DELETABLE_SIZE | SHRINKABLE_SIZE | DELETE_RATIO |\n+--------------+------------+-----------+-------------+------------+--------------+----------------+-----------------+--------------+\n| testdb       | hr         |     31216 |           0 |      31216 |       651264 |              0 |               0 |            0 |\n+--------------+------------+-----------+-------------+------------+--------------+----------------+-----------------+--------------+\n1 row in set (Elapsed: 00:00:00.00)\n\ngbase&gt; desc hr;\n+----------+---------------+------+-----+---------+-------+\n| Field    | Type          | Null | Key | Default | Extra |\n+----------+---------------+------+-----+---------+-------+\n| id       | int(11)       | YES  |     | NULL    |       |\n| name     | varchar(100)  | YES  |     | NULL    |       |\n| joindate | date          | YES  |     | NULL    |       |\n| salary   | decimal(10,2) | YES  |     | NULL    |       |\n+----------+---------------+------+-----+---------+-------+\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%88%A0%E9%99%A4%E4%B8%80%E9%83%A8%E5%88%86%E6%95%B0%E6%8D%AE%EF%BC%8C%E5%86%8D%E6%9F%A5%E7%9C%8B\"><\/span>\u5220\u9664\u4e00\u90e8\u5206\u6570\u636e\uff0c\u518d\u67e5\u770b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; delete from hr where salary &gt; 0.9;\nQuery OK, 3114 rows affected (Elapsed: 00:00:00.14)\n\ngbase&gt; select * from  performance_schema.tables where table_schema='testdb' and table_name='hr';\n+--------------+------------+-----------+-------------+------------+--------------+----------------+-----------------+--------------+\n| TABLE_SCHEMA | TABLE_NAME | MAX_ROWID | DELETE_ROWS | TABLE_ROWS | STORAGE_SIZE | DELETABLE_SIZE | SHRINKABLE_SIZE | DELETE_RATIO |\n+--------------+------------+-----------+-------------+------------+--------------+----------------+-----------------+--------------+\n| testdb       | hr         |     31216 |        3114 |      28102 |       659456 |          65785 |               0 |         9.98 |\n+--------------+------------+-----------+-------------+------------+--------------+----------------+-----------------+--------------+\n1 row in set (Elapsed: 00:00:00.00)\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%8E%92%E6%9F%A5%E6%96%B9%E6%A1%882%EF%BC%8C%E6%9F%A5rowid\"><\/span>\u6392\u67e5\u65b9\u68482\uff0c\u67e5rowid<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u5728\u8868\u7684\u5206\u7247\uff08gncli),\u6ce8\u610f\u4e0d\u662fgccli\uff0c\u6267\u884c\u5982\u4e0bSQL,\u6839\u636e\u6700\u5c0f\u884c\u53f7(\u5c0f\u4e8e\u5b83\u7684\u90fd\u662f\u88ab\u5220\u9664\u7684\uff09\uff0c \u6700\u5927-\u6700\u5c0f-count(*) , \u8868\u793a\u6570\u636e\u4e4b\u95f4\u7684\u7a7a\u6d1e\u884c\u6570\u3002\u8d8a\u5927\u8bc1\u660e\u7a7a\u7684\u8d8a\u591a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select min(rowid), max(rowid),count(*)  from XXXX_nX<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%8E%92%E6%9F%A5%E6%96%B9%E6%A1%883%E8%80%81%E7%89%88%E6%9C%AC%E6%8E%A8%E8%8D%90\"><\/span>\u6392\u67e5\u65b9\u68483(\u8001\u7248\u672c\u63a8\u8350)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u5168\u90e8\u5728\u6570\u636e\u8282\u70b9\uff0c\u5206\u7247\u7ea7\u522b\u64cd\u4f5c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%AF%84%E4%BC%B0%E4%B8%80%E4%B8%AADC%E9%9C%80%E8%A6%81%E5%8D%A0%E7%94%A8%E7%9A%84%E7%A9%BA%E9%97%B4\"><\/span>\u8bc4\u4f30\u4e00\u4e2aDC\u9700\u8981\u5360\u7528\u7684\u7a7a\u95f4<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u4f7f\u7528\u73b0\u6709\u7684metadump\u5de5\u5177\u8bc4\u4f30\u4e00\u4e2aDC\u5360\u7528\u7684\u7a7a\u95f4\uff0c\u5982\u679c\u6709\u591a\u4e2a\u5217\uff0c\u9700\u8981\u6bcf\u4e2a\u5217\u7d2f\u8ba1\u3002<\/p>\n\n\n\n<p>\u5982\u4e0b\u662f\u67e5\u770b\u7b2c\u4e00\u4e2a\u5217C00000.seg\u7684\u6bcf\u4e2aDC\u5360\u7528\u7a7a\u95f4\u7684\u547d\u4ee4\uff0c\u5176\u4e2d\u7684total_size\u662f\u4e00\u4e2aDC(65536\u884c)\u5360\u7528\u7684\u7a7a\u95f4(75007\u5b57\u8282)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@rh6-1 zxq]# metadump \/opt\/gnode\/userdata\/gbase\/testdb\/sys_tablespace\/t1_n1\/C00000.seg\nThis tool is designed for use at GBase internally,and is unsupported externally.\nGBase makes no claims and holds no liability regarding the external use of this tool.\nThis tool is copyrighted and his redistribution is restricted.\n\/opt\/gnode\/userdata\/gbase\/testdb\/sys_tablespace\/t1_n1\/C00000.seg\ntotal_size,75007\noptimal_mode,32\nno_obj-1,19270\nno_nulls,0\nmax_val,888887\nsave_checksum,117988097<\/code><\/pre>\n\n\n\n<p>\u8868\u6709\u591a\u4e2a\u5217\uff0c\u90a3\u5c31\u6309\u7167\u987a\u5e8f\uff0c\u7edf\u8ba1\u6bcf\u4e2a\u5217\u7684\uff0c\u6ce8\u610f\u4e00\u4e2a\u5217\u6709\u591a\u4e2a\u6570\u636e\u6587\u4ef6\u65f6\uff0c\u9009\u62e9\u5176\u4e2d\u4e00\u4e2a\u5c31\u884c\uff0c\u4e0d\u8981\u91cd\u590d\u4e86\u3002\u5982\u4e0b\u662f\u4e00\u4e2a\u7edf\u8ba1\u7684\u811a\u672c\uff0c\u9700\u8981\u5728dbaUser(\u4e00\u822c\u662fgbase\uff09\u64cd\u4f5c\u7cfb\u7edf\u7528\u6237\u4e0b\u8fd0\u884c\u3002\u53c2\u6570\u662f\u5e93\u540d\u548c\u8868\u5206\u7247\u540d\u5b57(\u5e26_nX\u7684)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dbname=$1\ntbname=$2\ndata_path=${GBASE_BASE}\/userdata\/gbase\/${dbname}\/sys_tablespace\/${tbname}\nif &#91; ! -d ${data_path} ]; then\n  echo \"${dbname}.${tbname} not exists at ${data_path}\"\n  exit 1;\nfi\n# \u6bcf\u4e2a\u5217\u7684\u4e00\u4e2aDC\u5927\u5c0f\u5360\u7528\u7684\u78c1\u76d8\u5bb9\u91cf\u603b\u8ba1\none_dc_size=0\nfor segname in `ls ${data_path}\/ |cut -d\\. -f 1 |uniq`\ndo\n  echo -n Checking $segname' ';\n  # \u591a\u4e2asegment\u9009\u62e9\u6700\u65b0\u7684\u8bc4\u4f30\n  tmpname=`ls ${data_path}\/${segname}.* -t | head -n 1`\n  size=`metadump ${tmpname}|grep total_size|cut -d',' -f 2`;\n  echo -e \"\\t\"${size}\n#  echo ${size};\n  let one_dc_size+=size;\n#  echo sum=${total};\ndone;\n\nif &#91; ${one_dc_size} -le 0 ]; then\n  echo \"no data file found in ${data_path}\";\n  exit 2\nfi\n\necho one_dc_disk_size=${one_dc_size}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%AE%A1%E7%AE%97%E8%A1%A8%E5%BA%94%E5%8D%A0%E7%94%A8%E5%A4%9A%E5%B0%91%E7%A9%BA%E9%97%B4\"><\/span>\u8ba1\u7b97\u8868\u5e94\u5360\u7528\u591a\u5c11\u7a7a\u95f4<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u518d\u6b21\u5f3a\u8c03\uff0c\u8fd9\u4e2a\u662f\u5206\u7247\u57fa\u672c\u7684\uff0c\u4e0d\u662f\u96c6\u7fa4\u7ea7\u522b\u7684\u3002\u7136\u540e\u6839\u636e\u5f53\u524d\u8868\u7684\u884c\u6570\uff0c\u8ba1\u7b97\u51faDC\u6570\u91cf\uff0c\u6839\u636e\u4e0a\u4e00\u6b65\u5f97\u5230\u7684\u4e00\u4e2aDC\u5360\u7528\u7684\u78c1\u76d8\u7a7a\u95f4\uff0c\u8ba1\u7b97\u51fa\u5f53\u524dDC\u6570\uff0c\u9700\u8981\u5360\u7528\u7684\u7a7a\u95f4\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u8868\u603b\u884c\u6570\ncount=`gncli -uroot -e\"select count(*) from ${dbname}.${tbname}\" -N`\necho record_count=${count}\n\n# \u8ba1\u7b97\u7406\u8bba\u78c1\u76d8\u5360\u7528\nlet calc_size=count*one_dc_size\/65536\necho calc_disk_size=${calc_size}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%AE%A1%E7%AE%97%E5%BD%93%E5%89%8D%E5%8D%A0%E7%94%A8%E7%A9%BA%E9%97%B4\"><\/span>\u8ba1\u7b97\u5f53\u524d\u5360\u7528\u7a7a\u95f4<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \u5f53\u524d\u6570\u636e\u6587\u4ef6\u5927\u5c0f\u5408\u8ba1\ncurrent_Size=`ls  -lt ${data_path} | head -n 1 | cut -d' ' -f 2`\nlet current_Size*=1024\necho current_disk_size=${current_Size}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%AE%A1%E7%AE%97%E5%8F%AF%E9%87%8A%E6%94%BE%E7%A9%BA%E9%97%B4%E5%92%8C%E6%AF%94%E4%BE%8B\"><\/span>\u8ba1\u7b97\u53ef\u91ca\u653e\u7a7a\u95f4\u548c\u6bd4\u4f8b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \u53ef\u91ca\u653e\u7a7a\u95f4\nlet release=current_Size-calc_size\necho can_release_disk_size=${release}\n\n# \u6bd4\u4f8b\nlet rate=release*100\/current_Size\necho can_relese_disk_rate=${rate} %<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%AE%8C%E6%95%B4%E4%BB%A3%E7%A0%81\"><\/span>\u5b8c\u6574\u4ee3\u7801<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>dbname=$1\ntbname=$2\ndata_path=${GBASE_BASE}\/userdata\/gbase\/${dbname}\/sys_tablespace\/${tbname}\nif &#91; ! -d ${data_path} ]; then\n  echo \"${dbname}.${tbname} not exists at ${data_path}\"\n  exit 1;\nfi\n# \u6bcf\u4e2a\u5217\u7684\u4e00\u4e2aDC\u5927\u5c0f\u5360\u7528\u7684\u78c1\u76d8\u5bb9\u91cf\u603b\u8ba1\none_dc_size=0\nfor segname in `ls ${data_path}\/ |cut -d\\. -f 1 |uniq`\ndo\n  echo -n Checking $segname' ';\n  # \u591a\u4e2asegment\u9009\u62e9\u6700\u65b0\u7684\u8bc4\u4f30\n  tmpname=`ls ${data_path}\/${segname}.* -t | head -n 1`\n  size=`metadump ${tmpname}|grep total_size|cut -d',' -f 2`;\n  echo -e \"\\t\"${size}\n#  echo ${size};\n  let one_dc_size+=size;\n#  echo sum=${total};\ndone;\n\nif &#91; ${one_dc_size} -le 0 ]; then\n  echo \"no data file found in ${data_path}\";\n  exit 2\nfi\n\necho one_dc_disk_size=${one_dc_size}\n\n\n# \u5f53\u524d\u6570\u636e\u6587\u4ef6\u5927\u5c0f\u5408\u8ba1\ncurrent_Size=`ls  -lt ${data_path} | head -n 1 | cut -d' ' -f 2`\nlet current_Size*=1024\necho current_disk_size=${current_Size}\n\n# \u8868\u603b\u884c\u6570\ncount=`gncli -uroot -e\"select count(*) from ${dbname}.${tbname}\" -N`\necho record_count=${count}\n\n# \u8ba1\u7b97\u7406\u8bba\u78c1\u76d8\u5360\u7528\nlet calc_size=count*one_dc_size\/65536\necho calc_disk_size=${calc_size}\n\n# \u53ef\u91ca\u653e\u7a7a\u95f4\nlet release=current_Size-calc_size\necho can_release_disk_size=${release}\n\n# \u6bd4\u4f8b\nlet rate=release*100\/current_Size\necho can_relese_disk_rate=${rate} %\n<\/code><\/pre>\n\n\n\n<p>\u8fd0\u884c\u6548\u679c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@rh6-1 zxq]# sh 1.sh testdb t1_n1\nChecking C00000         131106\none_dc_disk_size=131106\ncurrent_disk_size=11206656\nrecord_count=5500007\ncalc_disk_size=11002867\ncan_release_disk_size=203789\ncan_relese_disk_rate=1 %\n&#91;root@rh6-1 zxq]#\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%884%EF%BC%88%E6%96%B0%E7%89%88%E6%9C%AC%E5%B7%A5%E5%85%B7\"><\/span>\u89e3\u51b3\u65b9\u68484\uff08\u65b0\u7248\u672c\u5de5\u5177)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u65b0\u7248\u672c\u7684metadump\u5de5\u5177\uff0c\u63d0\u4f9b\u4e86\u5185\u7f6e\u7684\u65b9\u68483\u7684\u8bc4\u4f30\u529f\u80fd\uff0c\u4f46\u9884\u8ba1\u6700\u5c11\u662f2022\u5e742\u6708\u4efd\u4ee5\u540e\u7684\u65b0\u7248\u672c\u624d\u4f1a\u7248\u672c\u81ea\u5e26\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%91%BD%E4%BB%A4%E4%BB%8B%E7%BB%8D\"><\/span>\u547d\u4ee4\u4ecb\u7ecd<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>metadump -d dbname -t tbname\n\n\u8f93\u51fa\u4fe1\u606f\u5305\u62ec \u8868\u540d\u5b57\u3001\u53ef\u4ee5\u6e05\u7406\u7684\u7a7a\u95f4\u5927\u5c0f\uff0c\u5f53\u524d\u78c1\u76d8\u6570\u636e\u5927\u5c0f\uff0c\u53ef\u6e05\u7406\u6bd4\u4f8b<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E4%BD%BF%E7%94%A8%E6%A0%B7%E4%BE%8B\"><\/span>\u4f7f\u7528\u6837\u4f8b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;gbase@rh6-1 ~]$ .\/metadump -d testdb -t t1_10m_n1\nThis tool is designed for use at GBase internally,and is unsupported\n externally.\n\nGBase makes no claims and holds no liability regarding the external use of\n this tool.\n\nThis tool is copyrighted and his redistribution is restricted.\n\n+------------------------------------------+--------------+\n| table_name                               | testdb.t1_10m_n1 |\n| The size of data which can be cleaned    | 1966590      |\n| The total size of data                   | 11125744     |\n| The percent of data which can be cleaned | 17.7 %       |\n+------------------------------------------+--------------+<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88\"><\/span>\u89e3\u51b3\u65b9\u6848<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u89e3\u51b3\u7a7a\u6d1e\uff0c\u552f\u4e00\u7684\u65b9\u6848\u5c31\u662f\u628a\u6570\u636e\u91cd\u65b0\u6574\u7406\u4e00\u904d\uff0c\u65e0\u8bba\u54ea\u4e2a\u65b9\u6848\u90fd\u907f\u514d\u4e0d\u4e86\u8be5\u6709\u7684\u6027\u80fd\u6d88\u8017\uff0c\u5dee\u8ddd\u5c31\u662f\u6613\u7528\u6027\u6216\u8005\u53ef\u63a7\u6027\u3002<\/p>\n\n\n\n<p>\u6bd4\u5982V95\u65b0\u7248\u672c\u901a\u8fc7\u91cd\u5206\u5e03\u7684\u65b9\u6cd5\uff0c\u539f\u59cb\u8868\u53ef\u4ee5\u7ee7\u7eed\u8ffd\u52a0\u6570\u636e\u548c\u67e5\u8be2\uff0c\u524d\u5929\u7684\u90fd\u5c5e\u4e8eDML\/DDL\u64cd\u4f5c\uff0c\u8868\u5728\u64cd\u4f5c\u671f\u95f4\u662f\u8981\u6301\u6709\u72ec\u5360\u9501\uff0c\u4e0d\u80fd\u5728\u5bf9\u5916DML\u670d\u52a1\uff0c\u5728V8\u7684\u65e9\u671f\u7248\u672c\uff0c\u8fde\u67e5\u8be2\u670d\u52a1\u90fd\u4f1a\u88ab\u72ec\u5360\u9501\u5361\u4f4f\uff0c\u5728V95\u7248\u672c\u91cc\u4e0d\u4f1a\u963b\u585e\u67e5\u8be2\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E9%80%9A%E8%BF%87%E9%87%8D%E5%BB%BA%E8%A1%A8\"><\/span>\u901a\u8fc7\u91cd\u5efa\u8868<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u8be5\u65b9\u6848\u6700\u7b80\u5355\u4e5f\u6700\u5b89\u5168\uff0c\u5efa1\u4e2a\u65b0\u8868\uff0c\u628a\u8001\u7684\u8868\u7684\u6570\u636e\u5168\u90e8\u642c\u8fc7\u53bb\uff0c\u7136\u540erename\u8868\u540d\u5b57\u3002 <\/p>\n\n\n\n<p>\u8be6\u60c5\u53ef\u4ee5\u53c2\u8003  <a href=\"https:\/\/www.gbase8.cn\/8310\">GBase 8a\u5b89\u5168\u91cd\u5efa\u8868\u7684\u4e00\u4e2a\u65b9\u6848<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E9%80%9A%E8%BF%87shink_space\"><\/span>\u901a\u8fc7shink space<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u53ef\u4ee5\u901a\u8fc7shrink space [full] \u6765\u7531\u6570\u636e\u5e93\u5185\u90e8\u8fdb\u884c\u91cd\u5efa\u3002<\/p>\n\n\n\n<p><span class=\"has-inline-color has-luminous-vivid-orange-color\">\u5176\u4e2d\u5e26FULL\u7684\u529f\u80fd\uff0c\u5728\u65e9\u671f\u7684\u7248\u672c\u91cc\u6709BUG\uff0c\u6709\u53ef\u80fd\u9020\u6210\u6570\u636e\u6587\u4ef6\u635f\u574f\u3002 \u5efa\u8bae\u54a8\u8be2GBase \u6280\u672f\u652f\u6301\u4eba\u5458\u786e\u8ba4\u4f7f\u7528\u7684\u7248\u672c\u662f\u5426\u5df2\u7ecf\u89e3\u51b3\u3002<\/span> \u5efa\u8bae\u5347\u7ea7\u5230V95\u65b0\u7248\u672c\uff0c\u91c7\u7528rebalance\u7684\u539f\u7406\u91cd\u5efa\u3002<\/p>\n\n\n\n<p>\u6709\u5173Shrink space\u7684\u529f\u80fd\uff0c\u8bf7\u53c2\u8003 <a href=\"https:\/\/www.gbase8.cn\/377\"> GBase 8a\u96c6\u7fa4\u5220\u9664\u6570\u636e\u540e\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4shrink space<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5357\u5927\u901a\u7528GBase 8a\u6570\u636e\u5e93\u5728\u6570\u636e\u88ab\u5220\u9664\u65f6\uff0c\u5e76\u6ca1\u6709\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\uff0c\u800c\u662f\u53ea\u6253\u4e86\u4e00\u4e2a\u3010\u5df2\u5220\u9664\u3011\u7684\u6807\u8bb0\u3002\uff0c\u8fd9\u5c31\u4f1a\u5bfc\u81f4\u6709\u6548\u6570\u636e\uff0c\u5728\u78c1\u76d8\u4e0a\u662f\u4e0d\u8fde\u7eed\u7684\uff0c\u5176\u6bd4\u4f8b\u5c31\u662f\u7a7a\u6d1e\u7387\u3002 \u5728\u5927\u6570\u636e\u573a\u666f\uff0c\u5c11\u91cf\u7a7a\u6d1e\u662f\u53ef\u4ee5\u63a5\u53d7\u7684\uff0c\u4f46\u5982\u679c\u5df2\u7ecf\u5bf9\u6027\u80fd\u6709\u4e86\u5b9e\u8d28\u5f71\u54cd\uff0c\u5219\u9700\u8981\u8fdb\u884cshrink space\u91cd\u6574\u3002<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[101,69],"class_list":{"0":"post-1008","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-gbase8a","8":"tag-performance_schema","9":"tag-69"},"_links":{"self":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/1008","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/comments?post=1008"}],"version-history":[{"count":18,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/1008\/revisions"}],"predecessor-version":[{"id":8686,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/1008\/revisions\/8686"}],"wp:attachment":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/media?parent=1008"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/categories?post=1008"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/tags?post=1008"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}