forked from docs/doc-exports
Reviewed-by: Kacur, Michal <michal.kacur@t-systems.com> Co-authored-by: Yang, Tong <yangtong2@huawei.com> Co-committed-by: Yang, Tong <yangtong2@huawei.com>
51 lines
10 KiB
HTML
51 lines
10 KiB
HTML
<a name="mrs_01_24511"></a><a name="mrs_01_24511"></a>
|
|
|
|
<h1 class="topictitle1">Exporting IoTDB Data</h1>
|
|
<div id="body0000001532471628"><div class="section" id="mrs_01_24511__section67911831152811"><h4 class="sectiontitle">Scenario</h4><p id="mrs_01_24511__p61719714309">This section describes how to use <strong id="mrs_01_24511__b799053310536">export-csv.sh</strong> to export data from IoTDB to a CSV file.</p>
|
|
<div class="notice" id="mrs_01_24511__note237218011310"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><p id="mrs_01_24511__p1437230732">Exporting data to CSV files may cause injection risks. Exercise caution when performing this operation.</p>
|
|
</div></div>
|
|
</div>
|
|
<div class="section" id="mrs_01_24511__section1563705863318"><h4 class="sectiontitle">Prerequisites</h4><ul id="mrs_01_24511__ul11736334115416"><li id="mrs_01_24511__li1473613445415">The client has been installed. For details, see . For example, the installation directory is <strong id="mrs_01_24511__b1791806201818"><span id="mrs_01_24511__ph18918186131814">/opt/client</span></strong>. The client directory in the following operations is only an example. Change it based on the actual installation directory onsite.</li><li id="mrs_01_24511__li9736183418540">Service component users have been created by the MRS cluster administrator by referring to . In security mode, machine-machine users need to download the keytab file. For details, see . A human-machine user must change the password upon the first login.</li><li id="mrs_01_24511__li65021101298">By default, SSL is enabled on the server. You have generated the <strong id="mrs_01_24511__b155793241718">truststore.jks</strong> certificate by following the instructions provided in <a href="mrs_01_24158.html">Using the IoTDB Client</a> and copied it to the <strong id="mrs_01_24511__b2580142415717"><em id="mrs_01_24511__i125793241979">Client installation directory</em></strong><strong id="mrs_01_24511__b85801241174">/IoTDB/iotdb/conf</strong> directory.</li></ul>
|
|
</div>
|
|
<div class="section" id="mrs_01_24511__section680724533513"><h4 class="sectiontitle">Procedure</h4><ol id="mrs_01_24511__ol1974714117372"><li id="mrs_01_24511__li1726381018114">Log in to the node where the client is installed as the client installation user.</li><li id="mrs_01_24511__li1926341081117">Run the following command to switch to the client installation directory:<p id="mrs_01_24511__p182632101119"><a name="mrs_01_24511__li1926341081117"></a><a name="li1926341081117"></a><strong id="mrs_01_24511__b8263110121119">cd <span id="mrs_01_24511__ph114221759134613">/opt/client</span></strong></p>
|
|
</li><li id="mrs_01_24511__li1126312102112">Run the following command to configure environment variables:<p id="mrs_01_24511__p18263210141112"><a name="mrs_01_24511__li1126312102112"></a><a name="li1126312102112"></a><strong id="mrs_01_24511__b1126361081111">source bigdata_env</strong></p>
|
|
</li><li id="mrs_01_24511__li16611562035">(Optional) Perform this step to authenticate the current user if Kerberos authentication is enabled for the cluster. If Kerberos authentication is not enabled, skip this step.<p id="mrs_01_24511__p1913534557"><a name="mrs_01_24511__li16611562035"></a><a name="li16611562035"></a><strong id="mrs_01_24511__b153118511259">kinit</strong> <em id="mrs_01_24511__i13311951953">Component service user</em></p>
|
|
</li><li id="mrs_01_24511__li1451612116172">Run the following command to switch to the directory where the <strong id="mrs_01_24511__b1473513448515">export-csv.sh</strong> script is stored:<p id="mrs_01_24511__p10531444151716"><strong id="mrs_01_24511__b1053114410177">cd <span id="mrs_01_24511__ph193179718475">/opt/client</span>/IoTDB/iotdb/tools</strong></p>
|
|
</li><li id="mrs_01_24511__li740416134014">Before executing the export script, input some queries or specify some SQL files. If a SQL file contains multiple SQL statements, the SQL statements must be separated by newline characters. For example:<pre class="screen" id="mrs_01_24511__screen155793339386">select * from root.fit.d1
|
|
select * from root.sg1.d1</pre>
|
|
</li><li id="mrs_01_24511__li87641654151912"><a name="mrs_01_24511__li87641654151912"></a><a name="li87641654151912"></a>Execute <strong id="mrs_01_24511__b12347202162114">export-csv.sh</strong> to export data.<p id="mrs_01_24511__p1624313254313"><strong id="mrs_01_24511__b82431429436">./export-csv.sh -h</strong> <em id="mrs_01_24511__i157642355310">Service IP address of the IoTDBServer instance</em> <strong id="mrs_01_24511__b1524362164313">-p</strong> <em id="mrs_01_24511__i1059516496311">IoTDBServer RPC port</em> <strong id="mrs_01_24511__b6650105117714">-td <directory> [-tf <time-format> -s <sqlfile>]</strong></p>
|
|
<p id="mrs_01_24511__p1724342134319">Example:</p>
|
|
<pre class="screen" id="mrs_01_24511__screen5243122204317">./export-csv.sh -h x.x.x.x -p 22260 -td ./
|
|
# Or
|
|
./export-csv.sh -h x.x.x.x -p 22260 -td ./ -tf yyyy-MM-dd\ HH:mm:ss
|
|
# Or
|
|
./export-csv.sh -h x.x.x.x -p 22260 -td ./ -s sql.txt
|
|
# Or
|
|
./export-csv.sh -h x.x.x.x -p 22260 -td ./ -tf yyyy-MM-dd\ HH:mm:ss -s sql.txt</pre>
|
|
<div class="note" id="mrs_01_24511__note368914431116"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="mrs_01_24511__ul28851212562"><li id="mrs_01_24511__li136201025135219">You can log in to FusionInsight Manager, choose <strong id="mrs_01_24511__b541304918223">Cluster</strong> > <strong id="mrs_01_24511__b64191349182212">Services</strong> > <strong id="mrs_01_24511__b742084912223">IoTDB</strong>, and click the <strong id="mrs_01_24511__b11420549142219">Instance</strong> tab to view the service IP address of the IoTDBServer instance node.</li><li id="mrs_01_24511__li04714595535">The default RPC port number is <strong id="mrs_01_24511__b15736135716227">22260</strong>. To obtain the port number, choose <strong id="mrs_01_24511__b3742185742219">Cluster</strong> > <strong id="mrs_01_24511__b1174285782217">Services</strong> > <strong id="mrs_01_24511__b187429577229">IoTDB</strong>, click the <strong id="mrs_01_24511__b13743115717223">Configurations</strong> tab and then <strong id="mrs_01_24511__b107431257152214">All Configurations</strong>, and search for <strong id="mrs_01_24511__b1574315710222">rpc_port</strong>.</li><li id="mrs_01_24511__li188111218569">If the data exported contains a comma (,), it will be enclosed in double quotation marks (""). For example, <strong id="mrs_01_24511__b189562302117">hello,world</strong> is exported as <strong id="mrs_01_24511__b1891217265217">"hello,world"</strong>.</li><li id="mrs_01_24511__li889181219563">If the data exported contains double quotation marks (""), it will be enclosed in double quotation marks ("") and the original double quotation masks are replaced with <strong id="mrs_01_24511__b5250141910238">\"</strong>. For example, <strong id="mrs_01_24511__b12503192332310">"world"</strong> is exported as <strong id="mrs_01_24511__b13783112610234">"\"world\""</strong></li></ul>
|
|
</div></div>
|
|
</li><li id="mrs_01_24511__li626365420716">When you run the command in <a href="#mrs_01_24511__li87641654151912">7</a>, a message is displayed indicating that CSV injection may occur. Enter <strong id="mrs_01_24511__b1358164319452">yes</strong> to continue the command. If you enter another value, the data export operation will be canceled.<p id="mrs_01_24511__p19284175415718"><span><img id="mrs_01_24511__image62842541978" src="en-us_image_0000001583391913.png"></span></p>
|
|
<p id="mrs_01_24511__p228495414719">For example, after you enter <strong id="mrs_01_24511__b7294135814416">yes</strong>, enter the service username and password as prompted. If information in the following figure is displayed, the data is exported:</p>
|
|
<p id="mrs_01_24511__p3519726136"><span><img id="mrs_01_24511__image387217113312" src="en-us_image_0000001582952137.png"></span></p>
|
|
<div class="note" id="mrs_01_24511__note474900184614"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="mrs_01_24511__ul147491306463"><li id="mrs_01_24511__li814125512359">To prevent security risks, you are advised to export CSV files in interactive mode.</li><li id="mrs_01_24511__li662062117513">You can also export CSV files by running the <strong id="mrs_01_24511__b116207218517">./export-csv.sh -h</strong> <em id="mrs_01_24511__i711513812612">Service IP address of the IoTDBServer instance</em> <strong id="mrs_01_24511__b3620921155113">-p</strong> <em id="mrs_01_24511__i94841119718">IoTDBServer RPC port</em> <strong id="mrs_01_24511__b18620521205116">-u</strong> <em id="mrs_01_24511__i1467413161471">Service username</em> <strong id="mrs_01_24511__b46203210511">-pw</strong> <em id="mrs_01_24511__i1454815251376">Service user password</em><strong id="mrs_01_24511__b13681163615711"> -td <directory> [-tf <time-format> -s <sqlfile>]</strong> command.<div class="p" id="mrs_01_24511__p16859153711477">Example:<pre class="screen" id="mrs_01_24511__screen8333636145115">./export-csv.sh -h x.x.x.x -p 22260 -u <em id="mrs_01_24511__i142891414413">test</em> -pw <em id="mrs_01_24511__i6926205985219">Password</em> -td ./
|
|
# Or
|
|
./export-csv.sh -h x.x.x.x -p 22260 -u <em id="mrs_01_24511__i05291845201317">test</em> -pw <em id="mrs_01_24511__i052974517137">Password</em> -td ./
|
|
# Or
|
|
./export-csv.sh -h x.x.x.x -p 22260 -u <em id="mrs_01_24511__i19791105418413">test</em> -pw <em id="mrs_01_24511__i175548785311">Password</em> -td ./ -s sql.txt
|
|
# Or
|
|
./export-csv.sh -h x.x.x.x -p 22260 -u <em id="mrs_01_24511__i12549226478">test</em> -pw <em id="mrs_01_24511__i95492274720">Password</em> -td ./ -tf yyyy-MM-dd\ HH:mm:ss -s sql.txt</pre>
|
|
</div>
|
|
<p id="mrs_01_24511__p76235584511">If information in the following figure is displayed, the CSV file is exported:</p>
|
|
<p id="mrs_01_24511__p5396936356"><span><img id="mrs_01_24511__image1157788519" src="en-us_image_0000001532472784.png"></span></p>
|
|
</li></ul>
|
|
</div></div>
|
|
</li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_24509.html">IoTDB Data Import and Export</a></div>
|
|
</div>
|
|
</div>
|
|
|