Yang, Tong 3f5759eed2 MRS comp-lts 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>
2023-01-19 17:08:45 +00:00

47 lines
12 KiB
HTML

<a name="mrs_01_2093"></a><a name="mrs_01_2093"></a>
<h1 class="topictitle1">Using ZooKeeper from Scratch</h1>
<div id="body32001227"><p id="mrs_01_2093__en-us_topic_0000001173470978_p117571659182510">ZooKeeper is an open-source, highly reliable, and distributed consistency coordination service. ZooKeeper is designed to solve the problem that data consistency cannot be ensured for complex and error-prone distributed systems. There is no need to develop dedicated collaborative applications, which is suitable for high availability services to ensure data consistency.</p>
<div class="section" id="mrs_01_2093__en-us_topic_0000001173470978_section316983143915"><h4 class="sectiontitle">Background Information</h4><p id="mrs_01_2093__en-us_topic_0000001173470978_p847384102817">Before using the client, you need to download and update the client configuration file on all clients except the client of the active management node.</p>
</div>
<div class="section" id="mrs_01_2093__en-us_topic_0000001173470978_section20756233173519"><h4 class="sectiontitle">Procedure</h4><ol id="mrs_01_2093__en-us_topic_0000001173470978_ol20988959103613"><li id="mrs_01_2093__en-us_topic_0000001173470978_li18987145910368"><span>Download the client configuration file.</span><p><ol type="a" id="mrs_01_2093__en-us_topic_0000001173470978_ol169871359123614"><li id="mrs_01_2093__en-us_topic_0000001173470978_li3986195917363">Log in to FusionInsight Manager. For details, see. <a href="mrs_01_2124.html">Accessing FusionInsight Manager</a></li><li id="mrs_01_2093__en-us_topic_0000001173470978_li11986125923613">Choose <strong id="mrs_01_2093__en-us_topic_0000001173470978_b140544061641113">Cluster</strong> &gt; <em id="mrs_01_2093__en-us_topic_0000001173470978_i170798405941113">Name of the desired cluster</em> &gt; <strong id="mrs_01_2093__en-us_topic_0000001173470978_b163951319041113">Dashboard</strong> &gt; <strong id="mrs_01_2093__en-us_topic_0000001173470978_b32289279341113">More</strong> &gt; <strong id="mrs_01_2093__en-us_topic_0000001173470978_b177954557241113">Download Client</strong>.</li><li id="mrs_01_2093__en-us_topic_0000001173470978_li3987145913362">Download the cluster client.<p id="mrs_01_2093__en-us_topic_0000001173470978_p20987105913361"><a name="mrs_01_2093__en-us_topic_0000001173470978_li3987145913362"></a><a name="en-us_topic_0000001173470978_li3987145913362"></a>Set <span class="parmname" id="mrs_01_2093__en-us_topic_0000001173470978_parmname89861359103617"><b>Select Client Type</b></span> to <span class="parmvalue" id="mrs_01_2093__en-us_topic_0000001173470978_parmvalue1198711591367"><b>Configuration Files Only</b></span>, select a platform type, and click <span class="uicontrol" id="mrs_01_2093__en-us_topic_0000001173470978_uicontrol1198745973617"><b>OK</b></span> to generate the client configuration file which is then saved in the <strong id="mrs_01_2093__en-us_topic_0000001173470978_b198087608841113">/tmp/FusionInsight-Client/</strong> directory on the active management node by default.</p>
</li></ol>
</p></li><li id="mrs_01_2093__en-us_topic_0000001173470978_li898785916363"><span>Log in to the active management node of Manager.</span><p><ol type="a" id="mrs_01_2093__en-us_topic_0000001173470978_ol8987145983618"><li id="mrs_01_2093__en-us_topic_0000001173470978_li149871159103614">Log in to any node where Manager is deployed as user <strong id="mrs_01_2093__en-us_topic_0000001173470978_b098755910363">root</strong>.</li><li id="mrs_01_2093__en-us_topic_0000001173470978_li12987185973617">Run the following command to identify the active and standby nodes:<p id="mrs_01_2093__en-us_topic_0000001173470978_p17987205912364"><a name="mrs_01_2093__en-us_topic_0000001173470978_li12987185973617"></a><a name="en-us_topic_0000001173470978_li12987185973617"></a><strong id="mrs_01_2093__en-us_topic_0000001173470978_b159872059163610">sh ${BIGDATA_HOME}/om-server/om/sbin/status-oms.sh</strong></p>
<p id="mrs_01_2093__en-us_topic_0000001173470978_p17987125916360">In the command output, the value of <strong id="mrs_01_2093__en-us_topic_0000001173470978_b60371641141113">HAActive</strong> for the active management node is <strong id="mrs_01_2093__en-us_topic_0000001173470978_b63064278141113">active</strong>, and that for the standby management node is <strong id="mrs_01_2093__en-us_topic_0000001173470978_b143445450741113">standby</strong>. In the following example, <strong id="mrs_01_2093__en-us_topic_0000001173470978_b26489978841113">node-master1</strong> is the active management node, and <strong id="mrs_01_2093__en-us_topic_0000001173470978_b193069777341113">node-master2</strong> is the standby management node.</p>
<pre class="screen" id="mrs_01_2093__en-us_topic_0000001173470978_screen39871559163619">HAMode
double
NodeName HostName HAVersion StartTime HAActive HAAllResOK HARunPhase
192-168-0-30 node-master1 V100R001C01 2020-05-01 23:43:02 active normal Actived
192-168-0-24 node-master2 V100R001C01 2020-05-01 07:14:02 standby normal Deactived </pre>
</li><li id="mrs_01_2093__en-us_topic_0000001173470978_li14987145993619">Log in to the primary management node as user <strong id="mrs_01_2093__en-us_topic_0000001173470978_b1374918482417">root</strong> and run the following command to switch to user <strong id="mrs_01_2093__en-us_topic_0000001173470978_b207492462415">omm</strong>:<p id="mrs_01_2093__en-us_topic_0000001173470978_p1872722617385"><i><b><span class="cmdname" style="font-family:Arial" id="mrs_01_2093__en-us_topic_0000001173470978_cmdname18728102610385">sudo su - omm</span></b></i></p>
</li></ol>
</p></li><li id="mrs_01_2093__en-us_topic_0000001173470978_li098710593365"><span>Run the following command to go to the client installation directory, for example, <span class="filepath" id="mrs_01_2093__en-us_topic_0000001173470978_filepath1412640171315"><b>/opt/client</b></span>.</span><p><p id="mrs_01_2093__en-us_topic_0000001173470978_p298717599361"><b><span class="cmdname" id="mrs_01_2093__en-us_topic_0000001173470978_cmdname159871859183619">cd /opt/client</span></b></p>
</p></li><li id="mrs_01_2093__en-us_topic_0000001173470978_li6988959153617"><span>Run the following command to update the client configuration for the active management node.</span><p><p id="mrs_01_2093__en-us_topic_0000001173470978_p59881159143616"><strong id="mrs_01_2093__en-us_topic_0000001173470978_b71234568378">sh refreshConfig.sh /opt/client</strong> <em id="mrs_01_2093__en-us_topic_0000001173470978_i1012412567376">Full path of the client configuration file package</em></p>
<p id="mrs_01_2093__en-us_topic_0000001173470978_p169881359143611">For example, run the following command:</p>
<p id="mrs_01_2093__en-us_topic_0000001173470978_p3757204518335"><strong id="mrs_01_2093__en-us_topic_0000001173470978_b14757184563314">sh refreshConfig.sh /opt/client /tmp/FusionInsight-C</strong><strong id="mrs_01_2093__en-us_topic_0000001173470978_b10757204510335">lient/</strong><strong id="mrs_01_2093__en-us_topic_0000001173470978_b1757545123316">FusionInsight_Cluster_1_Services_Client.tar</strong></p>
<p id="mrs_01_2093__en-us_topic_0000001173470978_p17988759143612">If the following information is displayed, the configurations have been updated successfully:</p>
<pre class="screen" id="mrs_01_2093__en-us_topic_0000001173470978_screen1698825915368">ReFresh components client config is complete.
Succeed to refresh components client config.</pre>
</p></li></ol><ol start="5" id="mrs_01_2093__en-us_topic_0000001173470978_ol16986175916366"><li id="mrs_01_2093__en-us_topic_0000001173470978_li498695912361"><span>Use the client on a Master node.</span><p><ol type="a" id="mrs_01_2093__en-us_topic_0000001173470978_ol1986105923618"><li id="mrs_01_2093__en-us_topic_0000001173470978_li1798511598362">On the active management node where the client is updated, for example, node <span class="parmvalue" id="mrs_01_2093__en-us_topic_0000001173470978_parmvalue198215943616"><b>192-168-0-30</b></span>, run the following command to go to the client directory:<p id="mrs_01_2093__en-us_topic_0000001173470978_p139851359133616"><b><span class="cmdname" id="mrs_01_2093__en-us_topic_0000001173470978_cmdname055054915177">cd /opt/client</span></b></p>
</li><li id="mrs_01_2093__en-us_topic_0000001173470978_li19985959203615">Run the following command to configure environment variables:<p id="mrs_01_2093__en-us_topic_0000001173470978_p49858599364"><a name="mrs_01_2093__en-us_topic_0000001173470978_li19985959203615"></a><a name="en-us_topic_0000001173470978_li19985959203615"></a><i><b><span class="cmdname" style="font-family:Arial" id="mrs_01_2093__en-us_topic_0000001173470978_cmdname16987135412361">source bigdata_env</span></b></i></p>
</li><li id="mrs_01_2093__en-us_topic_0000001173470978_li139861599367">If Kerberos authentication has been enabled for the current cluster, run the following command to authenticate the current user. If Kerberos authentication is disabled for the current cluster, skip this step:<p id="mrs_01_2093__en-us_topic_0000001173470978_p898655943617"><a name="mrs_01_2093__en-us_topic_0000001173470978_li139861599367"></a><a name="en-us_topic_0000001173470978_li139861599367"></a><strong id="mrs_01_2093__en-us_topic_0000001173470978_b1914312143541">kinit</strong> <em id="mrs_01_2093__en-us_topic_0000001173470978_i014481445416">MRS cluster user</em></p>
<p id="mrs_01_2093__en-us_topic_0000001173470978_p139866594368">Example: <strong id="mrs_01_2093__en-us_topic_0000001173470978_b0838108153510">kinit zookeeperuser</strong>.</p>
</li><li id="mrs_01_2093__en-us_topic_0000001173470978_li1986659173614">Run the following Zookeeper client command:<p id="mrs_01_2093__en-us_topic_0000001173470978_p870610218386"><a name="mrs_01_2093__en-us_topic_0000001173470978_li1986659173614"></a><a name="en-us_topic_0000001173470978_li1986659173614"></a><em id="mrs_01_2093__en-us_topic_0000001173470978_i916251863615">zkCli.sh -server &lt;zookeeper installation node IP&gt;:&lt;port&gt;</em></p>
<p id="mrs_01_2093__en-us_topic_0000001173470978_p137062273816">Example: <strong id="mrs_01_2093__en-us_topic_0000001173470978_b154131916203417">zkCli.sh -server node-master1DGhZ:2181</strong></p>
</li></ol>
</p></li><li id="mrs_01_2093__en-us_topic_0000001173470978_li111718560398"><span>Run the ZooKeeper client command.</span><p><ol type="a" id="mrs_01_2093__en-us_topic_0000001173470978_ol617556153916"><li id="mrs_01_2093__en-us_topic_0000001173470978_li917356123917">Create a ZNode.<pre class="screen" id="mrs_01_2093__en-us_topic_0000001173470978_screen018856203916">create /test</pre>
</li><li id="mrs_01_2093__en-us_topic_0000001173470978_li1918105618391">View ZNode information.<pre class="screen" id="mrs_01_2093__en-us_topic_0000001173470978_screen9181956173911">ls /</pre>
</li><li id="mrs_01_2093__en-us_topic_0000001173470978_li1118155610398">Write data to the ZNode.<pre class="screen" id="mrs_01_2093__en-us_topic_0000001173470978_screen41813562393">set /test "zookeeper test"</pre>
</li><li id="mrs_01_2093__en-us_topic_0000001173470978_li1218556123919">View the data written to the ZNode.<pre class="screen" id="mrs_01_2093__en-us_topic_0000001173470978_screen181814561394">get /test</pre>
</li><li id="mrs_01_2093__en-us_topic_0000001173470978_li41825610393">Delete the created ZNode.<pre class="screen" id="mrs_01_2093__en-us_topic_0000001173470978_screen41885612391">delete /test</pre>
</li></ol>
</p></li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_2092.html">Using ZooKeeper</a></div>
</div>
</div>