{"id":1427,"date":"2022-06-14T11:56:53","date_gmt":"2022-06-14T03:56:53","guid":{"rendered":"http:\/\/www.eait.co\/?p=1427"},"modified":"2022-06-14T11:56:53","modified_gmt":"2022-06-14T03:56:53","slug":"hbase%e6%93%8d%e4%bd%9c%e6%8c%87%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/notes.coremix.net\/?p=1427","title":{"rendered":"hbase\u64cd\u4f5c\u6307\u4ee4"},"content":{"rendered":"<p>\u542f\u52a8\u6210\u529f\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u201chost:port\u201d\u7684\u65b9\u5f0f\u6765\u8bbf\u95eeHBase\u7ba1\u7406\u9875\u9762\uff0c\u4f8b\u5982\uff1a<\/p>\n<p>&nbsp;<\/p>\n<p>http:\/\/bigdata111:16010<\/p>\n<h2>2.2 \u57fa\u672c\u64cd\u4f5c<\/h2>\n<ul>\n<li><strong>\u8fdb\u5165<\/strong><strong>HBase<\/strong><strong>\u5ba2\u6237\u7aef\u547d\u4ee4\u884c<\/strong><\/li>\n<\/ul>\n<p>bin\/hbase shell<\/p>\n<p><strong>2) <\/strong><strong>\u67e5\u770b\u5e2e\u52a9\u547d\u4ee4<\/strong><\/p>\n<p>hbase(main)&gt; help<\/p>\n<p><strong>3) <\/strong><strong>\u67e5\u770b\u5f53\u524d\u6570\u636e\u5e93\u4e2d\u6709\u54ea\u4e9b\u8868<\/strong><\/p>\n<p>hbase(main)&gt; list<\/p>\n<p><strong>4) <\/strong><strong>\u67e5\u770b\u5f53\u524d\u6570\u636e\u5e93\u4e2d\u6709\u54ea\u4e9b\u547d\u540d\u7a7a\u95f4<\/strong><\/p>\n<p>hbase(main)&gt; list_namespace<\/p>\n<h3>2.2.1 \u8868\u7684\u64cd\u4f5c<\/h3>\n<ul>\n<li><strong>\u521b\u5efa\u8868<\/strong><\/li>\n<\/ul>\n<p>hbase(main)&gt; create &#8216;student&#8217;,&#8217;cf1&#8242;<\/p>\n<p>hbase(main)&gt; create &#8216;iparkmerchant_order&#8217;,&#8217;smzf&#8217;<\/p>\n<p>hbase(main)&gt; create &#8216;staff&#8217;,&#8217;info&#8217;<\/p>\n<p><strong>2) <\/strong><strong>\u63d2\u5165\u6570\u636e\u5230\u8868<\/strong><\/p>\n<p>hbase(main) &gt; put &#8216;student&#8217;,&#8217;1001&#8242;,&#8217;cf1:name&#8217;,&#8217;Thomas&#8217;<\/p>\n<p>hbase(main) &gt; put &#8216;student&#8217;,&#8217;1001&#8242;,&#8217;cf1:sex&#8217;,&#8217;male&#8217;<\/p>\n<p>hbase(main) &gt; put &#8216;student&#8217;,&#8217;1001&#8242;,&#8217;cf1:age&#8217;,&#8217;18&#8217;<\/p>\n<p>hbase(main) &gt; put &#8216;student&#8217;,&#8217;1002&#8242;,&#8217;cf1:name&#8217;,&#8217;Janna&#8217;<\/p>\n<p>hbase(main) &gt; put &#8216;student&#8217;,&#8217;1002&#8242;,&#8217;cf1:sex&#8217;,&#8217;female&#8217;<\/p>\n<p>hbase(main) &gt; put &#8216;student&#8217;,&#8217;1002&#8242;,&#8217;cf1:age&#8217;,&#8217;20&#8217;<\/p>\n<p>\u6570\u636e\u63d2\u5165\u540e\u7684\u6570\u636e\u6a21\u578b<\/p>\n<p><strong>3) <\/strong><strong>\u626b\u63cf\u67e5\u770b\u8868\u6570\u636e<\/strong><\/p>\n<p>hbase(main) &gt; scan &#8216;student&#8217;<\/p>\n<p>hbase(main) &gt; scan &#8216;student&#8217;,{STARTROW =&gt; &#8216;1001&#8217;, STOPROW\u00a0 =&gt; &#8216;1001&#8217;}<\/p>\n<p>hbase(main) &gt; scan &#8216;student&#8217;,{STARTROW =&gt; &#8216;1001&#8217;}<\/p>\n<p>\u6ce8\uff1a\u8fd9\u4e2a\u662f\u4ece\u54ea\u4e00\u4e2arowkey\u5f00\u59cb\u626b\u63cf<\/p>\n<p><strong>4) <\/strong><strong>\u67e5\u770b\u8868\u7ed3\u6784<\/strong><\/p>\n<p>hbase(main):012:0&gt; desc &#8216;student&#8217;<\/p>\n<p><strong>5) <\/strong><strong>\u66f4\u65b0\u6307\u5b9a\u5b57\u6bb5\u7684\u6570\u636e<\/strong><\/p>\n<p>hbase(main) &gt; put &#8216;student&#8217;,&#8217;1001&#8242;,&#8217;cf1:name&#8217;,&#8217;Nick&#8217;<\/p>\n<p>hbase(main) &gt; put &#8216;student&#8217;,&#8217;1001&#8242;,&#8217;cf1:age&#8217;,&#8217;100&#8242;<\/p>\n<p>hbase(main) &gt; put &#8216;student&#8217;,&#8217;1001&#8242;,&#8217;cf1:isNull&#8217;,&#8221;\uff08\u4ec5\u6d4b\u8bd5\u7a7a\u503c\u95ee\u9898\uff09<\/p>\n<p><strong>6) <\/strong><strong>\u67e5\u770b\u201c\u6307\u5b9a\u884c\u201d\u6216\u201c\u6307\u5b9a\u5217\u65cf<\/strong><strong>:<\/strong><strong>\u5217\u201d\u7684\u6570\u636e<\/strong><\/p>\n<p>hbase(main) &gt; get &#8216;student&#8217;,&#8217;1001&#8242;<\/p>\n<p>hbase(main) &gt; get &#8216;student&#8217;,&#8217;1001&#8242;,&#8217;cf1:name&#8217;<\/p>\n<p><strong>7) <\/strong><strong>\u5220\u9664\u6570\u636e<\/strong><\/p>\n<p><strong>\u5220\u9664\u67d0<\/strong><strong>rowkey<\/strong><strong>\u7684\u5168\u90e8\u6570\u636e\uff1a<\/strong><\/p>\n<p>hbase(main) &gt; deleteall &#8216;student&#8217;,&#8217;1001&#8242;<\/p>\n<p><strong>8) <\/strong><strong>\u6e05\u7a7a\u8868\u6570\u636e<\/strong><\/p>\n<p>hbase(main) &gt; truncate &#8216;student&#8217;<\/p>\n<p>\u5c16\u53eb\u63d0\u793a\uff1a\u6e05\u7a7a\u8868\u7684\u64cd\u4f5c\u987a\u5e8f\u4e3a\u5148disable\uff0c\u7136\u540e\u518dtruncate\u3002<\/p>\n<p><strong>9) <\/strong><strong>\u5220\u9664\u8868<\/strong><\/p>\n<p><strong>\u9996\u5148\u9700\u8981\u5148\u8ba9\u8be5\u8868\u4e3a<\/strong><strong>disable<\/strong><strong>\u72b6\u6001\uff1a<\/strong><\/p>\n<p>hbase(main) &gt; disable &#8216;student&#8217;<\/p>\n<p><strong>\u68c0\u67e5\u8fd9\u4e2a\u8868\u662f\u5426\u88ab\u7981\u7528<\/strong><\/p>\n<p>hbase(main) &gt; is_enabled &#8216;hbase_book&#8217;<\/p>\n<p>hbase(main) &gt; is_disabled &#8216;hbase_book&#8217;<\/p>\n<p><strong>\u6062\u590d\u88ab\u7981\u7528\u5f97\u8868<\/strong><\/p>\n<p>enable &#8216;student&#8217;<\/p>\n<p><strong>\u7136\u540e\u624d\u80fd<\/strong><strong>drop<\/strong><strong>\u8fd9\u4e2a\u8868\uff1a<\/strong><\/p>\n<p>hbase(main) &gt; drop &#8216;student&#8217;<\/p>\n<p>\u5c16\u53eb\u63d0\u793a\uff1a\u5982\u679c\u76f4\u63a5drop\u8868\uff0c\u4f1a\u62a5\u9519\uff1aDrop the named table. Table must first be disabled<\/p>\n<p>ERROR: Table student is enabled. Disable it first.<\/p>\n<p><strong>10) <\/strong><strong>\u7edf\u8ba1\u8868\u6570\u636e\u884c\u6570<\/strong><\/p>\n<p>hbase(main) &gt; count &#8216;student&#8217;<\/p>\n<p><strong>11) <\/strong><strong>\u53d8\u66f4\u8868\u4fe1\u606f<\/strong><\/p>\n<p>\u5c06info\u5217\u65cf\u4e2d\u7684\u6570\u636e\u5b58\u653e3\u4e2a\u7248\u672c\uff1a<\/p>\n<p>hbase(main) &gt; alter &#8216;student&#8217;,{NAME=&gt;&#8217;info&#8217;,VERSIONS=&gt;3}<\/p>\n<p>\u67e5\u770bstudent\u7684\u6700\u65b0\u7684\u7248\u672c\u7684\u6570\u636e<\/p>\n<p>hbase(main) &gt; get &#8216;student&#8217;,&#8217;1001&#8242;<\/p>\n<p>\u67e5\u770bHBase\u4e2d\u7684\u591a\u7248\u672c<\/p>\n<p>hbase(main) &gt; get &#8216;student&#8217;,&#8217;1001&#8242;,{COLUMN=&gt;&#8217;info:name&#8217;,VERSIONS=&gt;10}<\/p>\n<p><strong>1) satus <\/strong>\u4f8b\u5982\uff1a\u663e\u793a\u670d\u52a1\u5668\u72b6\u6001<\/p>\n<p>hbase&gt; status &#8216;bigdata166&#8217;<\/p>\n<p><strong>2) exist<\/strong><strong>s<\/strong> \u68c0\u67e5\u8868\u662f\u5426\u5b58\u5728\uff0c\u9002\u7528\u4e8e\u8868\u91cf\u7279\u522b\u591a\u7684\u60c5\u51b5<\/p>\n<p>hbase&gt; exists &#8216;hbase_book&#8217;<\/p>\n<p><strong>3) is_enabled\/is_disabled <\/strong>\u68c0\u67e5\u8868\u662f\u5426\u542f\u7528\u6216\u7981\u7528<\/p>\n<p>hbase&gt; is_enabled &#8216;hbase_book&#8217;<\/p>\n<p>hbase&gt; is_disabled &#8216;hbase_book&#8217;<\/p>\n<p><strong>8) alter <\/strong>\u8be5\u547d\u4ee4\u53ef\u4ee5\u6539\u53d8\u8868\u548c\u5217\u65cf\u7684\u6a21\u5f0f\uff0c\u4f8b\u5982\uff1a<\/p>\n<p><strong>\u4e3a\u5f53\u524d\u8868\u589e\u52a0\u5217\u65cf\uff1a<\/strong><\/p>\n<p>hbase&gt; alter &#8216;hbase_book&#8217;, NAME =&gt; &#8216;CF2&#8217;, VERSIONS =&gt; 2<\/p>\n<p><strong>\u4e3a\u5f53\u524d\u8868\u5220\u9664\u5217\u65cf\uff1a<\/strong><\/p>\n<p>hbase&gt; alter &#8216;hbase_book&#8217;, &#8216;delete&#8217; =&gt; &#8216;CF2&#8217;<\/p>\n<p><strong>9) disable<\/strong>\u7981\u7528\u4e00\u5f20\u8868<\/p>\n<p>hbase&gt; disable &#8216;hbase_book&#8217;<\/p>\n<p>hbase&gt; drop &#8216;hbase_book&#8217;<\/p>\n<p><strong>10) delete<\/strong><\/p>\n<p>\u5220\u9664\u4e00\u884c\u4e2d\u4e00\u4e2a\u5355\u5143\u683c\u7684\u503c\uff0c\u4f8b\u5982\uff1a<\/p>\n<p>hbase&gt; delete &#8216;hbase_book&#8217;, &#8216;rowKey&#8217;, &#8216;CF:C&#8217;<\/p>\n<p><strong>11) truncate<\/strong>\u6e05\u7a7a\u8868\u6570\u636e\uff0c\u5373\u7981\u7528\u8868-\u5220\u9664\u8868-\u521b\u5efa\u8868<\/p>\n<p>hbase&gt; truncate &#8216;hbase_book&#8217;<\/p>\n<p><strong>12) create<\/strong><\/p>\n<p>\u521b\u5efa\u591a\u4e2a\u5217\u65cf\uff1a<\/p>\n<p>hbase&gt; create &#8216;t1&#8217;, {NAME =&gt; &#8216;f1&#8217;}, {NAME =&gt; &#8216;f2&#8217;}, {NAME =&gt; &#8216;f3&#8217;}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u542f\u52a8\u6210\u529f\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u201chost:port\u201d\u7684\u65b9\u5f0f\u6765\u8bbf\u95eeHBase\u7ba1\u7406\u9875\u9762\uff0c\u4f8b\u5982\uff1a &nbsp; http:\/\/ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30,1],"tags":[],"class_list":["post-1427","post","type-post","status-publish","format-standard","hentry","category-bigdata","category-uncategorized"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/1427","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1427"}],"version-history":[{"count":2,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/1427\/revisions"}],"predecessor-version":[{"id":1429,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/1427\/revisions\/1429"}],"wp:attachment":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1427"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1427"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}