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

58 lines
9.0 KiB
HTML

<a name="mrs_01_2101"></a><a name="mrs_01_2101"></a>
<h1 class="topictitle1">Configuring the Port Range Bound to the Client</h1>
<div id="body8662426"><div class="section" id="mrs_01_2101__en-us_topic_0000001219351077_sc7d6d6e2a11a468abfec21efde0e9df6"><h4 class="sectiontitle">Scenarios</h4><p id="mrs_01_2101__en-us_topic_0000001219351077_a68b5e8d14379462d8b6ff44b82e965d0">When the ZooKeeper client is started, it is bound to a random port. In most cases, you want to bind the ZooKeeper client to a specific port. For example, for the client connection whitelist based on the IP address and port number, users can configure the port range bound to the client so that the same port range can be configured in the connection whitelist.</p>
</div>
<div class="section" id="mrs_01_2101__en-us_topic_0000001219351077_s59cab73f79674dfe9c6545e4b2417a63"><h4 class="sectiontitle">Configuration Description</h4><p id="mrs_01_2101__en-us_topic_0000001219351077_a028cc447f62c40e59a926e058ca1ce04">Set <strong id="mrs_01_2101__en-us_topic_0000001219351077_b62063634641816">zookeeper.client.bind.port.range</strong> to <em id="mrs_01_2101__en-us_topic_0000001219351077_i101716231141816">&lt;startPort:endPort&gt;</em> to ensure that the client is always bound to a port in the specified port range. For example, if <span class="parmname" id="mrs_01_2101__en-us_topic_0000001219351077_p1666a7a5e81c46a396ef41c1900b0c87"><b>zookeeper.client.bind.port.range</b></span> is set to <span class="parmvalue" id="mrs_01_2101__en-us_topic_0000001219351077_p91100f3e731a4596ad6ecae77f4e95e0"><b>65510:65512</b></span>, the client can be bound only to port <strong id="mrs_01_2101__en-us_topic_0000001219351077_b22243316141816">65510</strong>, <strong id="mrs_01_2101__en-us_topic_0000001219351077_b172724116541816">65511</strong>, or <strong id="mrs_01_2101__en-us_topic_0000001219351077_b74316567941816">65512</strong>.</p>
<p id="mrs_01_2101__en-us_topic_0000001219351077_a85dab1aeecdf4b99b7ef3f7b268747df">To set <span class="parmname" id="mrs_01_2101__en-us_topic_0000001219351077_pae38c3d48d124724a284f699533839a9"><b>zookeeper.client.bind.port.range</b></span> to <em id="mrs_01_2101__en-us_topic_0000001219351077_i33587153341816">&lt;startPort:endPort&gt;</em>, set <strong id="mrs_01_2101__en-us_topic_0000001219351077_b184493787541816">Dzookeeper.client.bind.port.range</strong> to <em id="mrs_01_2101__en-us_topic_0000001219351077_i48496114441816">&lt;startPort:endPort&gt;</em> when starting the ZooKeeper client.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="mrs_01_2101__en-us_topic_0000001219351077_t3afefc5af25448308d4c840f7bf0b0ae" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameter description</caption><thead align="left"><tr id="mrs_01_2101__en-us_topic_0000001219351077_rc317f844ce7c444e81fb2cd2d6658f45"><th align="left" class="cellrowborder" valign="top" width="15.229999999999999%" id="mcps1.3.2.4.2.5.1.1"><p id="mrs_01_2101__en-us_topic_0000001219351077_a333f9466350e4987bb059a552fc70001"><strong id="mrs_01_2101__en-us_topic_0000001219351077_a39934e247964413f9ab560ae419f9914">Parameter</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="15.920000000000002%" id="mcps1.3.2.4.2.5.1.2"><p id="mrs_01_2101__en-us_topic_0000001219351077_ae2d6b1a806a4448f9c18272a52f36b7c">System Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="52.31%" id="mcps1.3.2.4.2.5.1.3"><p id="mrs_01_2101__en-us_topic_0000001219351077_a222404a627c949e6bccd2542e5eaa517"><strong id="mrs_01_2101__en-us_topic_0000001219351077_ad8d8eacd198c49f690757d89369e48e8">Description</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="16.54%" id="mcps1.3.2.4.2.5.1.4"><p id="mrs_01_2101__en-us_topic_0000001219351077_a23b3fe1c88134c009ac531df6d1ca734"><strong id="mrs_01_2101__en-us_topic_0000001219351077_aa6cbb4270f354128ba000942a6d230b9">Default Value</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="mrs_01_2101__en-us_topic_0000001219351077_re10cbcb076984bc587fc0c2083944624"><td class="cellrowborder" valign="top" width="15.229999999999999%" headers="mcps1.3.2.4.2.5.1.1 "><p id="mrs_01_2101__en-us_topic_0000001219351077_a43917a2b7daf492496b55b4057db1e0a">zookeeper.client.bind.port.range</p>
</td>
<td class="cellrowborder" valign="top" width="15.920000000000002%" headers="mcps1.3.2.4.2.5.1.2 "><p id="mrs_01_2101__en-us_topic_0000001219351077_a332033a43f434dfa884a538058e72637">zookeeper.client.bind.port.range</p>
</td>
<td class="cellrowborder" valign="top" width="52.31%" headers="mcps1.3.2.4.2.5.1.3 "><p id="mrs_01_2101__en-us_topic_0000001219351077_a9a05f719802e487bbbf96f1671f184bf">This parameter is optional. Range of ports that can be used by the client during binding. The format is startPort:endPort (including startPort and endPort). The values of startPort and endPort range from 1024 to 65535, and the value of endPort must be greater than that of startPort. For example, 50000:50050 and 50100:50200.</p>
<p id="mrs_01_2101__en-us_topic_0000001219351077_ae5292e48d89543e4974cb221ed65c8c1">The client can be successfully connected only when at least two ports are available. If no port is available in the configured port range, the client fails to connect to the server. If the configured value is invalid, the value is ignored, the error is recorded, and the client will be bound to a random port.</p>
</td>
<td class="cellrowborder" valign="top" width="16.54%" headers="mcps1.3.2.4.2.5.1.4 "><p id="mrs_01_2101__en-us_topic_0000001219351077_a4a904b7afb634d9ea985013410da09db">-</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="mrs_01_2101__en-us_topic_0000001219351077_section1778581943"><h4 class="sectiontitle">Procedure</h4><ol id="mrs_01_2101__en-us_topic_0000001219351077_ol1038438171017"><li id="mrs_01_2101__en-us_topic_0000001219351077_li1038398131010"><span>Log in to the node where the client is installed as the client installation user.</span></li><li id="mrs_01_2101__en-us_topic_0000001219351077_li83844831012"><span>Run the following command to switch to the client installation directory:</span><p><p id="mrs_01_2101__en-us_topic_0000001219351077_p73841189103"><strong id="mrs_01_2101__en-us_topic_0000001219351077_b738313831019">cd</strong> <strong id="mrs_01_2101__en-us_topic_0000001219351077_b1838412818101">/opt/client</strong></p>
</p></li><li id="mrs_01_2101__en-us_topic_0000001219351077_li15384128101010"><span>Run the following command to edit the <strong id="mrs_01_2101__en-us_topic_0000001219351077_b81347512586">component_env</strong> file:</span><p><p id="mrs_01_2101__en-us_topic_0000001219351077_p738458201016"><strong id="mrs_01_2101__en-us_topic_0000001219351077_b138417811106">vi ZooKeeper/component_env</strong></p>
<p id="mrs_01_2101__en-us_topic_0000001219351077_p1238498181017">Add the <span class="parmname" id="mrs_01_2101__en-us_topic_0000001219351077_parmname1638478141018"><b>zookeeper.client.bind.port.range</b></span> parameter and its value.</p>
<p id="mrs_01_2101__en-us_topic_0000001219351077_p6384128141018">Normal mode:</p>
<pre class="screen" id="mrs_01_2101__en-us_topic_0000001219351077_screen33841188102">export ZOOKEEPER_HOME="/opt/client/ZooKeeper/zookeeper"
PATH_NEW=`echo $PATH | sed "s|:$ZOOKEEPER_HOME/bin||g" | sed "s|$ZOOKEEPER_HOME/bin:||g"`
export PATH="$ZOOKEEPER_HOME/bin:$PATH_NEW"
# default heap for zookeeper client
export ZK_CLIENT_HEAP="256"
export CLIENT_JVMFLAGS="-Xmx${ZK_CLIENT_HEAP}m"
export CLIENT_JVMFLAGS="$CLIENT_JVMFLAGS -Dzookeeper.root.logger=WARN,CONSOLE -Dzookeeper.request.timeout=120000 -Dzookeeper.client.bind.port.range=&lt;<em id="mrs_01_2101__en-us_topic_0000001219351077_i938416814103">startPort</em>:<em id="mrs_01_2101__en-us_topic_0000001219351077_i4384689105">endPort</em>&gt;" # Add a parameter.</pre>
<p id="mrs_01_2101__en-us_topic_0000001219351077_p1338412841010">Security mode:</p>
<pre class="screen" id="mrs_01_2101__en-us_topic_0000001219351077_screen1038438201015">if [ "$HADOOP_SECURITY_AUTHENTICATION" = "kerberos" ]; then
default_realm=`cat $KRB5_CONFIG |grep default_realm|awk -F"=" '{gsub(" ","");print $2}'|tr 'A-Z' 'a-z'`
export ZOO_SERVER_PRINCIPAL="zookeeper/hadoop.${default_realm}"
export CLIENT_JVMFLAGS=" ${CLIENT_JVMFLAGS} -Djava.security.krb5.conf=$KRB5_CONFIG -Dzookeeper.client.bind.port.range=&lt;<em id="mrs_01_2101__en-us_topic_0000001219351077_i238416851016">startPort</em>:<em id="mrs_01_2101__en-us_topic_0000001219351077_i338411819100">endPort</em>&gt;" # Add a parameter.</pre>
</p></li></ol><ol start="4" id="mrs_01_2101__en-us_topic_0000001219351077_ol3383286107"><li id="mrs_01_2101__en-us_topic_0000001219351077_li13834831016"><span>Run the <strong id="mrs_01_2101__en-us_topic_0000001219351077_b298311104597">:wq</strong> command to save execution.</span></li><li id="mrs_01_2101__en-us_topic_0000001219351077_li143831181106"><span>Restart the client for the settings to take effect.</span></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>