{"id":12964,"date":"2025-01-21T10:51:14","date_gmt":"2025-01-21T02:51:14","guid":{"rendered":"https:\/\/www.gbase8.cn\/?p=12964"},"modified":"2025-01-21T10:55:59","modified_gmt":"2025-01-21T02:55:59","slug":"gbase-8a%e9%9b%86%e7%be%a4%e9%80%9a%e8%bf%87sql%e8%8e%b7%e5%be%97%e9%9b%86%e7%be%a4%e9%94%81show-lock%e5%92%8c%e5%ae%b9%e9%94%99show-failover%e4%bf%a1%e6%81%af","status":"publish","type":"post","link":"https:\/\/www.gbase8.cn\/en\/12964","title":{"rendered":"GBase 8a\u96c6\u7fa4\u901a\u8fc7SQL\u83b7\u5f97\u96c6\u7fa4\u9501showlock\u548c\u5bb9\u9519showfailover\u4fe1\u606f"},"content":{"rendered":"<p>\u867d\u7136GBase 8a\u96c6\u7fa4\u5f53\u524d\u7248\u672c\u83b7\u5f97\u96c6\u7fa4\u9501\u4fe1\u606f\u548c\u5bb9\u9519\u4fe1\u606f\uff0c\u5fc5\u987b\u901a\u8fc7gcadmin\u7684\u547d\u4ee4\u884c\u6267\u884c\u624d\u80fd\u83b7\u5f97\uff0c\u4f46\u7531\u4e8e\u652f\u6301python udf\uff0c\u6240\u4ee5\u53ef\u4ee5\u901a\u8fc7\u8fd9\u4e2a\u7279\u6027\u6765\u7528SQL\u83b7\u5f97\u8fd9\u4e9b\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\">Directory Navigation<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2b3ced0f6ef\" 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-6a2b3ced0f6ef\"  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\/12964\/#%E5%8F%82%E8%80%83\" >\u53c2\u8003<\/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\/12964\/#%E9%9B%86%E7%BE%A4%E9%94%81showlock%E7%9A%84python_UDF\" >\u96c6\u7fa4\u9501showlock\u7684python UDF<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.gbase8.cn\/en\/12964\/#%E5%AE%B9%E9%94%99%E4%BF%A1%E6%81%AFshowfailover%E7%9A%84python_udf%E6%A0%B7%E4%BE%8B\" >\u5bb9\u9519\u4fe1\u606fshowfailover\u7684python udf\u6837\u4f8b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.gbase8.cn\/en\/12964\/#%E6%80%BB%E7%BB%93\" >Summary<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%8F%82%E8%80%83\"><\/span>\u53c2\u8003<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><a class=\"\" href=\"https:\/\/www.gbase8.cn\/en\/24\/?hilite=show+lock\">\u5357\u5927\u901a\u7528GBase8a MPP Cluster\u67e5\u770b\u96c6\u7fa4\u9501\u00a0<mark>showlock<\/mark><\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.gbase8.cn\/en\/8757\/?hilite=show+failover\">\u5357\u5927\u901a\u7528GBase 8a\u67e5\u770b\u548c\u6e05\u7406\u6545\u969c\u6062\u590d\u72b6\u6001<mark>Failover<\/mark>\u7684\u65b9\u6cd5<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.gbase8.cn\/en\/2103\/\">\u5357\u5927\u901a\u7528GBase 8a\u901a\u8fc7python UDF\u4ece\u5ba2\u6237\u7aef\u6267\u884cSQL\u8bed\u53e5<\/a>\u00a0<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E9%9B%86%E7%BE%A4%E9%94%81showlock%E7%9A%84python_UDF\"><\/span>\u96c6\u7fa4\u9501showlock\u7684python UDF<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>drop function if exists showlock;\r\ncreate function showlock()\r\nreturns varchar\r\n$$\r\ntry:\r\n    import commands\r\n    output = commands.getoutput(\"gcadmin showlock\")\r\nexcept:\r\n    return None\r\nreturn str(output)\r\n\r\n$$ language plpythonu;<\/code><\/pre>\n\n\n\n<p>\u6267\u884c\u6548\u679c<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase> select showlock();\r\n+-------------------+\r\n| showlock()        |\r\n+-------------------+\r\n|  +=================================================================+\r\n |                          GCLUSTER LOCK                          |\r\n +=================================================================+\r\n +-------------+----------+-------------+--------------+------+----+\r\n |  Lock name  |  owner   |   content   | create time  |locked|type|\r\n +-------------+----------+-------------+--------------+------+----+\r\n |gc-event-lock|10.0.2.201|global master|20250113120320| TRUE | E  |\r\n +-------------+----------+-------------+--------------+------+----+\r\n Total : 1 |\r\n+--------------------+\r\n1 row in set (Elapsed: 00:00:00.63)\r\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%AE%B9%E9%94%99%E4%BF%A1%E6%81%AFshowfailover%E7%9A%84python_udf%E6%A0%B7%E4%BE%8B\"><\/span>\u5bb9\u9519\u4fe1\u606fshowfailover\u7684python udf\u6837\u4f8b<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>drop function if exists showfailover;\r\ncreate function showfailover()\r\nreturns varchar\r\n$$\r\ntry:\r\n    import commands\r\n    output = commands.getoutput(\"gcadmin showfailover\")\r\nexcept:\r\n    return None\r\nreturn str(output)\r\n\r\n$$ language plpythonu;<\/code><\/pre>\n\n\n\n<p>\u6267\u884c\u6548\u679c<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase> drop function if exists showfailover;\r\nQuery OK, 0 rows affected, 1 warning (Elapsed: 00:00:00.00)\r\n\r\ngbase> create function showfailover()\r\n    -> returns varchar\r\n    -> $$\r\n    -> try:\r\n    ->     import commands\r\n    ->     output = commands.getoutput(\"gcadmin showfailover\")\r\n    -> except:\r\n    ->     return None\r\n    -> return str(output)\r\n    ->\r\n    -> $$ language plpythonu;\r\nQuery OK, 0 rows affected (Elapsed: 00:00:00.00)\r\n\r\ngbase> select showfailover();\r\n+--------------------------------------------------------------+\r\n| showfailover()                                               |\r\n+--------------------------------------------------------------+\r\n|\r\ngcadmin showfailover: no gcluster failover information now\r\n |\r\n+--------------------------------------------------------------+\r\n1 row in set (Elapsed: 00:00:00.63)\r\n\r\ngbase>\r\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%80%BB%E7%BB%93\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u901a\u8fc7python udf\uff0c\u5728\u4e0d\u65b9\u4fbf\u547d\u4ee4\u884c\u8bbf\u95ee\u7684\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u63d0\u9ad8\u6570\u636e\u5e93\u7684\u6613\u7528\u6027\u548c\u5b89\u5168\u6027\u3002<\/p>\n\n\n\n<p>\u8f93\u51fa\u5185\u5bb9\u53ef\u4ee5\u589e\u52a0 f\u53c2\u6570\u5b9e\u73b0xml\u683c\u5f0f\uff0c\u8be6\u60c5\u770bgcadmin --help\u7684\u4ecb\u7ecd\u3002<\/p>","protected":false},"excerpt":{"rendered":"<p>\u867d\u7136GBase 8a\u96c6\u7fa4\u5f53\u524d\u7248\u672c\u83b7\u5f97\u96c6\u7fa4\u9501\u4fe1\u606f\u548c\u5bb9\u9519\u4fe1\u606f\uff0c\u5fc5\u987b\u901a\u8fc7gcadmin\u7684\u547d\u4ee4\u884c\u6267\u884c\u624d\u80fd\u83b7\u5f97\uff0c\u4f46\u7531\u4e8e\u652f\u6301python udf\uff0c\u6240\u4ee5\u53ef\u4ee5\u901a\u8fc7\u8fd9\u4e2a\u7279\u6027\u6765\u7528SQL\u83b7\u5f97\u8fd9\u4e9b\u3002<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[98,36,91],"class_list":["post-12964","post","type-post","status-publish","format-standard","hentry","category-gbase8a","tag-python","tag-36","tag-udf"],"_links":{"self":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/12964","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=12964"}],"version-history":[{"count":10,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/12964\/revisions"}],"predecessor-version":[{"id":12975,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/12964\/revisions\/12975"}],"wp:attachment":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/media?parent=12964"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/categories?post=12964"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/tags?post=12964"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}