forked from docs/doc-exports
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>
86 lines
20 KiB
HTML
86 lines
20 KiB
HTML
<a name="mrs_01_2093"></a><a name="mrs_01_2093"></a>
|
|
|
|
<h1 class="topictitle1">Using ZooKeeper from Scratch</h1>
|
|
<div id="body1595986424477"><p id="mrs_01_2093__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__section316983143915"><h4 class="sectiontitle">Background Information</h4><p id="mrs_01_2093__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__section20756233173519"><h4 class="sectiontitle">Procedure</h4><p id="mrs_01_2093__p1210511719287">For MRS 2.<em id="mrs_01_2093__i9352191213372">x</em> or earlier, perform the following operations:</p>
|
|
<ol id="mrs_01_2093__ol11471534103911"><li id="mrs_01_2093__l6b58a848ef0f4fe6a361d4ef0ac39fb8"><a name="mrs_01_2093__l6b58a848ef0f4fe6a361d4ef0ac39fb8"></a><a name="l6b58a848ef0f4fe6a361d4ef0ac39fb8"></a><span>Download the client configuration file.</span><p><ol type="a" id="mrs_01_2093__o10934933c3364550a0be5195fbfc2f32"><li id="mrs_01_2093__lafc53572e58847f385df4f89a1385677">Log in to the MRS console. In the left navigation pane, choose <span class="menucascade" id="mrs_01_2093__m99686aaa19d547d3ba5ead543b52d741"><b><span class="uicontrol" id="mrs_01_2093__udbb80ef904d54c7584d81fa0f2689a3c">Clusters</span></b> > <b><span class="uicontrol" id="mrs_01_2093__u7bd8237cec524ff89935c2545e0ec7de">Active Clusters</span></b></span>, and click the cluster to be operated.</li><li id="mrs_01_2093__li0460185474017">Click the <strong id="mrs_01_2093__b180178536741113">Components</strong> tab.</li><li id="mrs_01_2093__l1bb2266a16d84c7685176eecccfd2abf">Click <span class="uicontrol" id="mrs_01_2093__uicontrol163303774441113"><b>Services</b></span> and then <span class="uicontrol" id="mrs_01_2093__uicontrol155016846941113"><b>Download Client</b></span>.<p id="mrs_01_2093__en-us_topic_0037446806_p491630294745">Set <span class="parmname" id="mrs_01_2093__parmname162869182641113"><b>Client Type</b></span> to <span class="uicontrol" id="mrs_01_2093__uicontrol27638951441113"><b>Only configuration files</b></span>, and click <span class="uicontrol" id="mrs_01_2093__uicontrol171202982541113"><b>OK</b></span> to generate the client configuration file. The generated file is saved in the <strong id="mrs_01_2093__b114051874441113">/tmp/MRS-client</strong> directory on the active management node by default. You can customize the file path.</p>
|
|
</li></ol>
|
|
</p></li><li id="mrs_01_2093__li595112919519"><span>Log in to the active management node of MRS Manager.</span><p><ol type="a" id="mrs_01_2093__oad0dd0b610c34488815d2b07e4656c11"><li id="mrs_01_2093__l52f4be0ff6434297a1b84c6a772a9828">On the MRS console, choose <span class="wintitle" id="mrs_01_2093__wintitle10698591341113"><b>Clusters > Active Clusters</b></span> and click a cluster name. On the <span class="wintitle" id="mrs_01_2093__w4d3386170a29436eb866c94fb041d9fc"><b>Nodes</b></span> tab, view the node names. The node whose name contains <span class="parmvalue" id="mrs_01_2093__p466c031a935b42168c660ebd02e735cf"><b>master1</b></span> is the Master1 node, and the node whose name contains <span class="parmvalue" id="mrs_01_2093__p58b7be931498419d93edb37b5e0606ae"><b>master2</b></span> is the Master2 node.<p id="mrs_01_2093__a2f41d2e8a2434da2a56a6f48035e2d15">The active and standby management nodes of MRS Manager are installed on Master nodes by default. Because Master1 and Master2 are switched over in active and standby mode, Master1 is not always the active management node of MRS Manager. Run a command in Master1 to check whether Master1 is active management node of MRS Manager. For details about the command, see <a href="#mrs_01_2093__le8e7045cece741e8b6209b929a50ff22">2.d</a>.</p>
|
|
</li><li id="mrs_01_2093__lad0d75a7717442b68338881c7c895c81">Log in to the Master1 node using the password as user <strong id="mrs_01_2093__b78501912202015">root</strong>. </li><li id="mrs_01_2093__l96479867566a4bd59da83a86f87373ef">Run the following commands to switch to user <strong id="mrs_01_2093__ac7be28bfafd640048e695d4e9ab7bc0e">omm</strong>:<p id="mrs_01_2093__adbc6f7bd4142423a89ea39d9d7347674"><i><b><span class="cmdname" style="font-family:Arial" id="mrs_01_2093__cmdname519417363351">sudo su - root</span></b></i></p>
|
|
<p id="mrs_01_2093__a09516e4f38e44d8085ab1e7b041fddc0"><i><b><span class="cmdname" style="font-family:Arial" id="mrs_01_2093__cmdname41941536183517">su - omm</span></b></i></p>
|
|
</li><li id="mrs_01_2093__le8e7045cece741e8b6209b929a50ff22"><a name="mrs_01_2093__le8e7045cece741e8b6209b929a50ff22"></a><a name="le8e7045cece741e8b6209b929a50ff22"></a>Run the following command to check the active management node of MRS Manager:<p id="mrs_01_2093__ae3cb33a0b8a7477c92f6b05767f136c3"><a name="mrs_01_2093__le8e7045cece741e8b6209b929a50ff22"></a><a name="le8e7045cece741e8b6209b929a50ff22"></a><b><span class="cmdname" id="mrs_01_2093__c73101799356c44f6a213b083c96e3df0">sh ${BIGDATA_HOME}/om-0.0.1/sbin/status-oms.sh</span></b></p>
|
|
<p id="mrs_01_2093__a2e14fbc736604468bd7585d96245cd58">In the command output, the node whose <span class="parmname" id="mrs_01_2093__parmname146543745441113"><b>HAActive</b></span> is <span class="parmvalue" id="mrs_01_2093__parmvalue122002450841113"><b>active</b></span> is the active management node, and the node whose <span class="parmname" id="mrs_01_2093__parmname128929824241113"><b>HAActive</b></span> is <span class="parmvalue" id="mrs_01_2093__parmvalue99882871441113"><b>standby</b></span> is the standby management node. In the following example, <strong id="mrs_01_2093__b70735472841113">mgtomsdat-sh-3-01-1</strong> is the active management node, and <strong id="mrs_01_2093__b57651620141113">mgtomsdat-sh-3-01-2</strong> is the standby management node.</p>
|
|
<pre class="screen" id="mrs_01_2093__sd906fdd3601748af837ddf8172bd0e75">Ha mode
|
|
double
|
|
NodeName HostName HAVersion StartTime HAActive HAAllResOK HARunPhase
|
|
192-168-0-30 mgtomsdat-sh-3-01-1 V100R001C01 2014-11-18 23:43:02 <strong id="mrs_01_2093__a62984b3e97d740d3bc709bb1da033a2f">active</strong> normal Actived
|
|
192-168-0-24 mgtomsdat-sh-3-01-2 V100R001C01 2014-11-21 07:14:02 <strong id="mrs_01_2093__a31f4111b8e77424caf416a08ed194aa4">standby</strong> normal Deactived</pre>
|
|
</li><li id="mrs_01_2093__lde3b2ea113c34b4687592dfdc8b454c2">Log in to the active management node, for example, <span class="parmvalue" id="mrs_01_2093__p4fa8933886834ca8854b5d0617f23f10"><b>192-168-0-30</b></span> of MRS Manager as user <strong id="mrs_01_2093__b9302185810236">root</strong>, and run the following command to switch to user <strong id="mrs_01_2093__b13021858112316">omm</strong>:<p id="mrs_01_2093__p5130224183718"><i><b><span class="cmdname" style="font-family:Arial" id="mrs_01_2093__cmdname14130924193713">sudo su - omm</span></b></i></p>
|
|
</li></ol>
|
|
</p></li><li id="mrs_01_2093__li1325114150135"><span>Run the following command to go to the client installation directory, for example, <span class="filepath" id="mrs_01_2093__filepath0485132411138"><b>/opt/client</b></span>.</span><p><p id="mrs_01_2093__p1025617151132"><strong id="mrs_01_2093__b1229113093018">cd /opt/client</strong></p>
|
|
</p></li><li id="mrs_01_2093__li15639738131312"><a name="mrs_01_2093__li15639738131312"></a><a name="li15639738131312"></a><span>Run the following command to update the client configuration for the active management node.</span><p><p id="mrs_01_2093__p101581539121410"><strong id="mrs_01_2093__b642115320371">sh refreshConfig.sh /opt/client</strong> <em id="mrs_01_2093__i3424539378">Full path of the client configuration file package</em></p>
|
|
<p id="mrs_01_2093__p86531138181318">For example, run the following command:</p>
|
|
<p id="mrs_01_2093__p3654193818136"><strong id="mrs_01_2093__b14655103818135">sh refreshConfig.sh /opt/client/tmp/MRS-</strong><strong id="mrs_01_2093__b11658173813133">c</strong><strong id="mrs_01_2093__b1365953861310">lient/MRS_Services_Client.tar</strong></p>
|
|
<p id="mrs_01_2093__p9659123820139">If the following information is displayed, the configurations have been updated successfully:</p>
|
|
<pre class="screen" id="mrs_01_2093__screen1866023831317"> ReFresh components client config is complete.
|
|
Succeed to refresh components client config.</pre>
|
|
<div class="note" id="mrs_01_2093__note1971123710424"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="mrs_01_2093__p613218111518">You can perform <a href="#mrs_01_2093__l6b58a848ef0f4fe6a361d4ef0ac39fb8">1</a> to <a href="#mrs_01_2093__li15639738131312">4</a> by referring to Method 2 in <a href="mrs_01_2130.html">Updating a Client (Versions Earlier Than 3.x)</a> .</p>
|
|
</div></div>
|
|
</p></li><li id="mrs_01_2093__l6556791324fa484e91dc201b480e3115"><span>Use the client on a Master node.</span><p><ol type="a" id="mrs_01_2093__od49292eae1f845e8a383e761ce0ce2f7"><li id="mrs_01_2093__led80939ae6024a9ba8841d649d5132b4">On the active management node where the client is updated, for example, node <span class="parmvalue" id="mrs_01_2093__pb923e7c26e0f4bffb26f1521910a2c79"><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_0037446806_p11191414462"><strong id="mrs_01_2093__b11451513191611">cd /opt/client</strong></p>
|
|
</li><li id="mrs_01_2093__ldf91db8293354ac4beabdf4679eb0034">Run the following command to configure environment variables:<p id="mrs_01_2093__en-us_topic_0037446806_p711917124619"><a name="mrs_01_2093__ldf91db8293354ac4beabdf4679eb0034"></a><a name="ldf91db8293354ac4beabdf4679eb0034"></a><i><b><span class="cmdname" style="font-family:Arial" id="mrs_01_2093__cmdname1619443619357">source bigdata_env</span></b></i></p>
|
|
</li><li id="mrs_01_2093__le6f90e19da384d2689c1b5ca5896f874">If Kerberos authentication is 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__aeaf76195462f4119af05c698566aba09"><a name="mrs_01_2093__le6f90e19da384d2689c1b5ca5896f874"></a><a name="le6f90e19da384d2689c1b5ca5896f874"></a><strong id="mrs_01_2093__b43142848941113">kinit</strong> <em id="mrs_01_2093__i55759122241113">MRS cluster user</em></p>
|
|
<p id="mrs_01_2093__en-us_topic_0037446806_p809043511651">Example: <strong id="mrs_01_2093__b522916117208">kinit zookeeperuser</strong>.</p>
|
|
</li><li id="mrs_01_2093__en-us_topic_0037446806_li8119414469">Run the following Zookeeper client command:<p id="mrs_01_2093__ae866cfe594424869bd57657b6921e1a8"><a name="mrs_01_2093__en-us_topic_0037446806_li8119414469"></a><a name="en-us_topic_0037446806_li8119414469"></a><strong id="mrs_01_2093__b142018311920">zkCli.sh -server </strong><em id="mrs_01_2093__i86833165198"><zookeeper installation node IP></em><strong id="mrs_01_2093__b1484209141914">:<port></strong></p>
|
|
<p id="mrs_01_2093__p191351528122319">Example: <em id="mrs_01_2093__i1987511236"><strong id="mrs_01_2093__b5822114882313">zkCli.sh -server node-master1DGhZ:2181</strong></em></p>
|
|
</li></ol>
|
|
</p></li><li id="mrs_01_2093__li2015821418148"><span>Run the ZooKeeper client command.</span><p><ol type="a" id="mrs_01_2093__ol897653825911"><li id="mrs_01_2093__li12976638185912">Create a ZNode.<pre class="screen" id="mrs_01_2093__screen117010582249">create /test</pre>
|
|
</li><li id="mrs_01_2093__li10684611801">View ZNode information.<pre class="screen" id="mrs_01_2093__screen196080189013">ls /</pre>
|
|
</li><li id="mrs_01_2093__li12134202514012">Write data to the ZNode.<pre class="screen" id="mrs_01_2093__screen17485193518011">set /test "zookeeper test"</pre>
|
|
</li><li id="mrs_01_2093__li83797414013">View the data written to the ZNode.<pre class="screen" id="mrs_01_2093__screen843832714278">get /test</pre>
|
|
</li><li id="mrs_01_2093__li9744151415271">Delete the created ZNode.<pre class="screen" id="mrs_01_2093__screen154086223286">delete /test</pre>
|
|
</li></ol>
|
|
</p></li></ol>
|
|
<p id="mrs_01_2093__p3543825154418">For MRS 3.x or later, perform the following operations:</p>
|
|
<ol id="mrs_01_2093__ol20988959103613"><li id="mrs_01_2093__li18987145910368"><span>Download the client configuration file.</span><p><ol type="a" id="mrs_01_2093__ol169871359123614"><li id="mrs_01_2093__li3986195917363">Log in to FusionInsight Manager. For details, see <a href="mrs_01_2124.html">Accessing FusionInsight Manager (MRS 3.x or Later)</a>.</li><li id="mrs_01_2093__li11986125923613">Choose <strong id="mrs_01_2093__b140544061641113">Cluster</strong> > <em id="mrs_01_2093__i170798405941113">Name of the desired cluster</em> > <strong id="mrs_01_2093__b163951319041113">Dashboard</strong> > <strong id="mrs_01_2093__b32289279341113">More</strong> > <strong id="mrs_01_2093__b177954557241113">Download Client</strong>.</li><li id="mrs_01_2093__li3987145913362">Download the cluster client.<p id="mrs_01_2093__p20987105913361"><a name="mrs_01_2093__li3987145913362"></a><a name="li3987145913362"></a>Set <span class="parmname" id="mrs_01_2093__parmname89861359103617"><b>Select Client Type</b></span> to <span class="parmvalue" id="mrs_01_2093__parmvalue1198711591367"><b>Configuration Files Only</b></span>, select a platform type, and click <span class="uicontrol" id="mrs_01_2093__uicontrol1198745973617"><b>OK</b></span> to generate the client configuration file which is then saved in the <strong id="mrs_01_2093__b198087608841113">/tmp/FusionInsight-Client/</strong> directory on the active management node by default.</p>
|
|
</li></ol>
|
|
</p></li><li id="mrs_01_2093__li898785916363"><span>Log in to the active management node of Manager.</span><p><ol type="a" id="mrs_01_2093__ol8987145983618"><li id="mrs_01_2093__li149871159103614">Log in to any node where Manager is deployed as user <strong id="mrs_01_2093__b098755910363">root</strong>.</li><li id="mrs_01_2093__li12987185973617">Run the following command to identify the active and standby nodes:<p id="mrs_01_2093__p17987205912364"><a name="mrs_01_2093__li12987185973617"></a><a name="li12987185973617"></a><strong id="mrs_01_2093__b159872059163610">sh ${BIGDATA_HOME}/om-server/om/sbin/status-oms.sh</strong></p>
|
|
<p id="mrs_01_2093__p17987125916360">In the command output, the value of <strong id="mrs_01_2093__b60371641141113">HAActive</strong> for the active management node is <strong id="mrs_01_2093__b63064278141113">active</strong>, and that for the standby management node is <strong id="mrs_01_2093__b143445450741113">standby</strong>. In the following example, <strong id="mrs_01_2093__b26489978841113">node-master1</strong> is the active management node, and <strong id="mrs_01_2093__b193069777341113">node-master2</strong> is the standby management node.</p>
|
|
<pre class="screen" id="mrs_01_2093__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__li14987145993619">Log in to the primary management node as user <strong id="mrs_01_2093__b1374918482417">root</strong> and run the following command to switch to user <strong id="mrs_01_2093__b207492462415">omm</strong>:<p id="mrs_01_2093__p1872722617385"><i><b><span class="cmdname" style="font-family:Arial" id="mrs_01_2093__cmdname18728102610385">sudo su - omm</span></b></i></p>
|
|
</li></ol>
|
|
</p></li><li id="mrs_01_2093__li098710593365"><span>Run the following command to go to the client installation directory, for example, <span class="filepath" id="mrs_01_2093__filepath1412640171315"><b>/opt/client</b></span>.</span><p><p id="mrs_01_2093__p298717599361"><b><span class="cmdname" id="mrs_01_2093__cmdname159871859183619">cd /opt/client</span></b></p>
|
|
</p></li><li id="mrs_01_2093__li6988959153617"><span>Run the following command to update the client configuration for the active management node.</span><p><p id="mrs_01_2093__p59881159143616"><strong id="mrs_01_2093__b71234568378">sh refreshConfig.sh /opt/client</strong> <em id="mrs_01_2093__i1012412567376">Full path of the client configuration file package</em></p>
|
|
<p id="mrs_01_2093__p169881359143611">For example, run the following command:</p>
|
|
<p id="mrs_01_2093__p3757204518335"><strong id="mrs_01_2093__b14757184563314">sh refreshConfig.sh /opt/client /tmp/FusionInsight-C</strong><strong id="mrs_01_2093__b10757204510335">lient/</strong><strong id="mrs_01_2093__b1757545123316">FusionInsight_Cluster_1_Services_Client.tar</strong></p>
|
|
<p id="mrs_01_2093__p17988759143612">If the following information is displayed, the configurations have been updated successfully:</p>
|
|
<pre class="screen" id="mrs_01_2093__screen1698825915368">ReFresh components client config is complete.
|
|
Succeed to refresh components client config.</pre>
|
|
</p></li></ol><ol start="5" id="mrs_01_2093__ol16986175916366"><li id="mrs_01_2093__li498695912361"><span>Use the client on a Master node.</span><p><ol type="a" id="mrs_01_2093__ol1986105923618"><li id="mrs_01_2093__li1798511598362">On the active management node where the client is updated, for example, node <span class="parmvalue" id="mrs_01_2093__parmvalue198215943616"><b>192-168-0-30</b></span>, run the following command to go to the client directory:<p id="mrs_01_2093__p139851359133616"><b><span class="cmdname" id="mrs_01_2093__cmdname055054915177">cd /opt/client</span></b></p>
|
|
</li><li id="mrs_01_2093__li19985959203615">Run the following command to configure environment variables:<p id="mrs_01_2093__p49858599364"><a name="mrs_01_2093__li19985959203615"></a><a name="li19985959203615"></a><i><b><span class="cmdname" style="font-family:Arial" id="mrs_01_2093__cmdname16987135412361">source bigdata_env</span></b></i></p>
|
|
</li><li id="mrs_01_2093__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__p898655943617"><a name="mrs_01_2093__li139861599367"></a><a name="li139861599367"></a><strong id="mrs_01_2093__b176504015552">kinit</strong> <em id="mrs_01_2093__i667640105517">MRS cluster user</em></p>
|
|
<p id="mrs_01_2093__p139866594368">Example: <strong id="mrs_01_2093__b0838108153510">kinit zookeeperuser</strong>.</p>
|
|
</li><li id="mrs_01_2093__li1986659173614">Run the following Zookeeper client command:<p id="mrs_01_2093__p870610218386"><a name="mrs_01_2093__li1986659173614"></a><a name="li1986659173614"></a><em id="mrs_01_2093__i916251863615">zkCli.sh -server <zookeeper installation node IP>:<port></em></p>
|
|
<p id="mrs_01_2093__p137062273816">Example: <strong id="mrs_01_2093__b154131916203417">zkCli.sh -server node-master1DGhZ:2181</strong></p>
|
|
</li></ol>
|
|
</p></li><li id="mrs_01_2093__li111718560398"><span>Run the ZooKeeper client command.</span><p><ol type="a" id="mrs_01_2093__ol617556153916"><li id="mrs_01_2093__li917356123917">Create a ZNode.<pre class="screen" id="mrs_01_2093__screen018856203916">create /test</pre>
|
|
</li><li id="mrs_01_2093__li1918105618391">View ZNode information.<pre class="screen" id="mrs_01_2093__screen9181956173911">ls /</pre>
|
|
</li><li id="mrs_01_2093__li1118155610398">Write data to the ZNode.<pre class="screen" id="mrs_01_2093__screen41813562393">set /test "zookeeper test"</pre>
|
|
</li><li id="mrs_01_2093__li1218556123919">View the data written to the ZNode.<pre class="screen" id="mrs_01_2093__screen181814561394">get /test</pre>
|
|
</li><li id="mrs_01_2093__li41825610393">Delete the created ZNode.<pre class="screen" id="mrs_01_2093__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>
|
|
|