Yang, Tong 6182f91ba8 MRS component operation guide_normal 2.0.38.SP20 version
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-authored-by: Yang, Tong <yangtong2@huawei.com>
Co-committed-by: Yang, Tong <yangtong2@huawei.com>
2022-12-09 14:55:21 +00:00

76 lines
10 KiB
HTML

<a name="mrs_01_24119"></a><a name="mrs_01_24119"></a>
<h1 class="topictitle1">GeoMesa Command Line</h1>
<div id="body0000001108144836"><div class="note" id="mrs_01_24119__note743381417182"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="mrs_01_24119__p1043317141187">This section applies only to MRS 3.1.0 or later.</p>
</div></div>
<p id="mrs_01_24119__p8060118">This section describes common GeoMesa commands. For more GeoMesa commands, visit <a href="https://www.geomesa.org/documentation/user/accumulo/commandline.html" target="_blank" rel="noopener noreferrer">https://www.geomesa.org/documentation/user/accumulo/commandline.html</a>.</p>
<p id="mrs_01_24119__p180543719182">After installing the HBase client and loading environment variables, you can use the geomesa-hbase command line.</p>
<ul id="mrs_01_24119__ul4991861483"><li id="mrs_01_24119__li129913617482">Viewing <strong id="mrs_01_24119__b842352706164734">classpath</strong><p id="mrs_01_24119__p115301919183917">After you run the <strong id="mrs_01_24119__b842352706164748">classpath</strong> command, all <strong id="mrs_01_24119__b12208122122414">classpath</strong> information of the current command line tool will be returned.</p>
<p id="mrs_01_24119__p55302019193915"><strong id="mrs_01_24119__b1179383434018">bin/geomesa-hbase classpath</strong></p>
</li><li id="mrs_01_24119__li14991766486">Creating a table<p id="mrs_01_24119__p11523191933916"><a name="mrs_01_24119__li14991766486"></a><a name="li14991766486"></a>Run the <strong id="mrs_01_24119__b842352706164833">create-schema</strong> command to create a table. When creating a table, you need to specify the directory name, table name, and table specifications at least.</p>
<p id="mrs_01_24119__p19436191414016"><strong id="mrs_01_24119__b9564123124011">bin/geomesa-hbase create-schema -c geomesa -f test -s Who:String,What:java.lang.Long,When:Date,*Where:Point:srid=4326,Why:String</strong></p>
</li></ul>
<ul id="mrs_01_24119__ul193931545194719"><li id="mrs_01_24119__li1039384514719">Describing a table<p id="mrs_01_24119__p1652351993917"><a name="mrs_01_24119__li1039384514719"></a><a name="li1039384514719"></a>Run the <strong id="mrs_01_24119__b842352706165041">describe-schema</strong> command to obtain table descriptions. When describing a table, you need to specify the directory name and table name.</p>
<p id="mrs_01_24119__p65231519133915"><strong id="mrs_01_24119__b1523719183917">bin/geomesa-hbase describe-schema -c geomesa -f test</strong></p>
</li><li id="mrs_01_24119__li43931045134718">Importing data in batches<p id="mrs_01_24119__p1852371910393"><a name="mrs_01_24119__li43931045134718"></a><a name="li43931045134718"></a>Run the <strong id="mrs_01_24119__b842352706165232">ingest</strong> command to import data in batches. When importing data, you need to specify the directory name, table name, table specifications, and the related data converter.</p>
<p id="mrs_01_24119__p17523819193915">The data in the <strong id="mrs_01_24119__b9929491883">data.csv</strong> file contains license plate number, vehicle color, longitude, latitude, and time. Save the data table to the folder.</p>
<pre class="screen" id="mrs_01_24119__screen13523319183919">AAA,red,113.918417,22.505892,2017-04-09 18:03:46
BBB,white,113.960719,22.556511,2017-04-24 07:38:47
CCC,blue,114.088333,22.637222,2017-04-23 15:07:54
DDD,yellow,114.195456,22.596103,2017-04-21 21:27:06
EEE,black,113.897614,22.551331,2017-04-09 09:34:48</pre>
<p id="mrs_01_24119__p5523181917394">Table structure definition: <strong id="mrs_01_24119__b84235270614151">myschema.sft</strong>. Save <strong id="mrs_01_24119__b842352706141523">myschema.sft</strong> to the <strong id="mrs_01_24119__b842352706141532">conf</strong> folder of the GeoMesa command line tool.</p>
<pre class="screen" id="mrs_01_24119__screen4524141923910">geomesa.sfts.cars = {
attributes = [
{ name = "carid", type = "String", index = true }
{ name = "color", type = "String", index = false }
{ name = "time", type = "Date", index = false }
{ name = "geom", type = "Point", index = true,srid = 4326,default = true }
]
}</pre>
<p id="mrs_01_24119__p1952431915392">Converter definition: <strong id="mrs_01_24119__b842352706141556">myconvertor.convert</strong> Save <strong id="mrs_01_24119__b842352706141610">myconvertor.convert</strong> to the <strong id="mrs_01_24119__b842352706141616">conf</strong> folder of the GeoMesa command line tool.</p>
<pre class="screen" id="mrs_01_24119__screen20525161933911">geomesa.converters.cars= {
type = "delimited-text",
format = "CSV",
id-field = "$fid",
fields = [
{ name = "fid", transform = "concat($1,$5)" }
{ name = "carid", transform = "$1::string" }
{ name = "color", transform = "$2::string" }
{ name = "lon", transform = "$3::double" }
{ name = "lat", transform = "$4::double" }
{ name = "geom", transform = "point($lon,$lat)" }
{ name = "time", transform = "date('YYYY-MM-dd HH:mm:ss',$5)" }
]
}</pre>
<p id="mrs_01_24119__p18525131983913">Run the following command to import data:</p>
<p id="mrs_01_24119__p4525919153916"><strong id="mrs_01_24119__b15525719173910">bin/geomesa-hbase ingest -c geomesa -C conf/myconvertor.convert -s conf/myschema.sft data/data.csv</strong></p>
<p id="mrs_01_24119__p15608182054117">For details about other parameters for importing data, visit <a href="https://www.geomesa.org/documentation/user/accumulo/examples.html#ingesting-data" target="_blank" rel="noopener noreferrer">https://www.geomesa.org/documentation/user/accumulo/examples.html#ingesting-data</a>.</p>
</li><li id="mrs_01_24119__li10394545164719">Querying explanations<p id="mrs_01_24119__p20529181920393"><a name="mrs_01_24119__li10394545164719"></a><a name="li10394545164719"></a>Run the <strong id="mrs_01_24119__b84235270616588">explain</strong> command to obtain execution plan explanations of the specified query statement. You need to specify the directory name, table name, and query statement.</p>
<p id="mrs_01_24119__p325383694210"><strong id="mrs_01_24119__b13970439184210">bin/geomesa-hbase explain -c geomesa -f cars -q "carid = 'BBB'"</strong></p>
</li><li id="mrs_01_24119__li13394144514712">Analyzing statistics<p id="mrs_01_24119__p1552991933912"><a name="mrs_01_24119__li13394144514712"></a><a name="li13394144514712"></a>Run the <strong id="mrs_01_24119__b84235270617543">stats-analyze</strong> command to conduct statistical analysis on the data table. In addition, you can run the <strong id="mrs_01_24119__b84235270617627">stats-bounds</strong>, <strong id="mrs_01_24119__b84235270617632">stats-count</strong>, <strong id="mrs_01_24119__b84235270617638">stats-histogram</strong>, and <strong id="mrs_01_24119__b84235270617644">stats-top-k</strong> commands to collect more detailed statistics on the data table.</p>
<p id="mrs_01_24119__p031911224417"><strong id="mrs_01_24119__b8992238134419">bin/geomesa-hbase stats-analyze -c geomesa -f cars</strong></p>
<p id="mrs_01_24119__p1291811134418"><strong id="mrs_01_24119__b79999386447">bin/geomesa-hbase stats-bounds -c geomesa -f cars</strong></p>
<p id="mrs_01_24119__p23966183442"><strong id="mrs_01_24119__b711399444">bin/geomesa-hbase stats-count -c geomesa -f cars</strong></p>
<p id="mrs_01_24119__p928714266449"><strong id="mrs_01_24119__b173939184410">bin/geomesa-hbase stats-histogram -c geomesa -f cars</strong></p>
<p id="mrs_01_24119__p108243328449"><strong id="mrs_01_24119__b13513934410">bin/geomesa-hbase stats-top-k -c geomesa -f cars</strong></p>
</li><li id="mrs_01_24119__li4394545114715">Exporting a feature<p id="mrs_01_24119__p2529181953917"><a name="mrs_01_24119__li4394545114715"></a><a name="li4394545114715"></a>Run the <strong id="mrs_01_24119__b84235270617810">export</strong> command to export a feature. When exporting the feature, you must specify the directory name and table name. In addition, you can specify a query statement to export the feature.</p>
<p id="mrs_01_24119__p1199734184510"><strong id="mrs_01_24119__b12961191453">bin/geomesa-hbase export -c geomesa -f cars -q "carid = 'BBB'"</strong></p>
</li><li id="mrs_01_24119__li183942455473">Deleting a feature<p id="mrs_01_24119__p25291919193914"><a name="mrs_01_24119__li183942455473"></a><a name="li183942455473"></a>Run the <strong id="mrs_01_24119__b200895014">delete-features</strong> command to delete a feature. When deleting the feature, you must specify the directory name and table name. In addition, you can specify a query statement to delete the feature.</p>
<p id="mrs_01_24119__p10711181134611"><strong id="mrs_01_24119__b1642641564619">bin/geomesa-hbase delete-features -c geomesa -f cars -q "carid = 'BBB'"</strong></p>
</li><li id="mrs_01_24119__li739417455473">Obtain the names of all tables in the directory.<p id="mrs_01_24119__p1352941943917"><a name="mrs_01_24119__li739417455473"></a><a name="li739417455473"></a>Run the <strong id="mrs_01_24119__b842352706171034">get-type-names</strong> command to obtain the names of tables in the specified directory.</p>
<p id="mrs_01_24119__p514444618468"><strong id="mrs_01_24119__b104311849114610">bin/geomesa-hbase get-type-names -c geomesa</strong></p>
</li><li id="mrs_01_24119__li19394164515474">Deleting a table<p id="mrs_01_24119__p1053012199392"><a name="mrs_01_24119__li19394164515474"></a><a name="li19394164515474"></a>Run the <strong id="mrs_01_24119__b842352706171115">remove-schema</strong> command to delete a table. You need to specify the directory name and table name at least.</p>
<p id="mrs_01_24119__p17339537478"><strong id="mrs_01_24119__b1739114134710">bin/geomesa-hbase remove-schema -c geomesa -f test</strong></p>
<p id="mrs_01_24119__p1269516924720"><strong id="mrs_01_24119__b154331414720">bin/geomesa-hbase remove-schema -c geomesa -f cars</strong></p>
</li><li id="mrs_01_24119__li53943455472">Deleting a catalog<p id="mrs_01_24119__p125308191393"><a name="mrs_01_24119__li53943455472"></a><a name="li53943455472"></a>Run the <strong id="mrs_01_24119__b842352706171238">delete-catalog</strong> command to delete the specified catalog.</p>
<p id="mrs_01_24119__p13752193620477"><strong id="mrs_01_24119__b18314144044720">bin/geomesa-hbase delete-catalog -c geomesa</strong></p>
</li></ul>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_0500.html">Using HBase</a></div>
</div>
</div>