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

26 lines
6.6 KiB
HTML

<a name="mrs_01_1031"></a><a name="mrs_01_1031"></a>
<h1 class="topictitle1">Using Kafka from Scratch</h1>
<div id="body8662426"><div class="section" id="mrs_01_1031__en-us_topic_0000001219149187_section43461647164218"><h4 class="sectiontitle">Scenario</h4><p id="mrs_01_1031__en-us_topic_0000001219149187_p8060118">You can create, query, and delete topics on a cluster client.</p>
</div>
<div class="section" id="mrs_01_1031__en-us_topic_0000001219149187_section1022821213273"><h4 class="sectiontitle">Prerequisites</h4><p id="mrs_01_1031__en-us_topic_0000001219149187_p614503812278">The client has been installed. For example, the client is installed in the <strong id="mrs_01_1031__en-us_topic_0000001219149187_b53165215138">/opt/hadoopclient</strong> directory. The client directory in the following operations is only an example. Change it to the actual installation directory.</p>
</div>
<div class="section" id="mrs_01_1031__en-us_topic_0000001219149187_section2695144004617"><h4 class="sectiontitle">Using the Kafka Client</h4><ol id="mrs_01_1031__en-us_topic_0000001219149187_ol1980725416469"><li id="mrs_01_1031__en-us_topic_0000001219149187_li1280725416467"><span>Access the ZooKeeper instance page.</span><p><p id="mrs_01_1031__en-us_topic_0000001219149187_p041836175710">Log in to FusionInsight Manager. For details, see <a href="mrs_01_2124.html">Accessing FusionInsight Manager</a>. Choose <strong id="mrs_01_1031__en-us_topic_0000001219149187_b1212106633111149">Cluster</strong> &gt; <em id="mrs_01_1031__en-us_topic_0000001219149187_i846383776111149">Name of the desired cluster</em> &gt; <strong id="mrs_01_1031__en-us_topic_0000001219149187_b959103026111149">Services</strong> &gt; <strong id="mrs_01_1031__en-us_topic_0000001219149187_b781653376111149">ZooKeeper</strong> &gt; <strong id="mrs_01_1031__en-us_topic_0000001219149187_b472259796111149">Instance</strong>.</p>
</p></li><li id="mrs_01_1031__en-us_topic_0000001219149187_li118082541465"><span>View the IP addresses of the ZooKeeper role instance.</span><p><p id="mrs_01_1031__en-us_topic_0000001219149187_p98081854134614">Record any IP address of the ZooKeeper instance.</p>
</p></li><li id="mrs_01_1031__en-us_topic_0000001219149187_li14808105414460"><span>Log in to the node where the client is installed.</span></li><li id="mrs_01_1031__en-us_topic_0000001219149187_li16808115412465"><span>Run the following command to switch to the client directory, for example, <strong id="mrs_01_1031__en-us_topic_0000001219149187_b189513124168">/opt/hadoopclient/Kafka/kafka/bin</strong>.</span><p><p id="mrs_01_1031__en-us_topic_0000001219149187_p7808165412465"><strong id="mrs_01_1031__en-us_topic_0000001219149187_b8808165415468">cd /opt/hadoopclient/Kafka/kafka/bin</strong></p>
</p></li><li id="mrs_01_1031__en-us_topic_0000001219149187_li17808195411460"><span>Run the following command to configure environment variables:</span><p><p id="mrs_01_1031__en-us_topic_0000001219149187_p188084545468"><strong id="mrs_01_1031__en-us_topic_0000001219149187_b380818549466">source /opt/hadoopclient/bigdata_env</strong></p>
</p></li><li id="mrs_01_1031__en-us_topic_0000001219149187_li78081254164617"><span>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.</span><p><p id="mrs_01_1031__en-us_topic_0000001219149187_p38081054104612"><strong id="mrs_01_1031__en-us_topic_0000001219149187_b537484882">kinit</strong> <em id="mrs_01_1031__en-us_topic_0000001219149187_i1161917706">Kafka user</em></p>
</p></li><li id="mrs_01_1031__en-us_topic_0000001219149187_li4808125415465"><a name="mrs_01_1031__en-us_topic_0000001219149187_li4808125415465"></a><a name="en-us_topic_0000001219149187_li4808125415465"></a><span>Create a topic.</span><p><p id="mrs_01_1031__en-us_topic_0000001219149187_p280865464613"><strong id="mrs_01_1031__en-us_topic_0000001219149187_b1179401103">sh kafka-topics.sh --create --topic </strong><em id="mrs_01_1031__en-us_topic_0000001219149187_i1950582853">Topic name</em><strong id="mrs_01_1031__en-us_topic_0000001219149187_b99190212"> --partitions</strong> <em id="mrs_01_1031__en-us_topic_0000001219149187_i102569010">Number of partitions occupied by the topic</em> <strong id="mrs_01_1031__en-us_topic_0000001219149187_b1785644850">--replication-factor</strong> <em id="mrs_01_1031__en-us_topic_0000001219149187_i1384319177">Number of replicas of the topic</em> <strong id="mrs_01_1031__en-us_topic_0000001219149187_b16399165">--zookeeper</strong> <em id="mrs_01_1031__en-us_topic_0000001219149187_i1709072914">IP address of the node where the ZooKeeper instance resides<strong id="mrs_01_1031__en-us_topic_0000001219149187_b1397485199">:</strong>clientPort</em><strong id="mrs_01_1031__en-us_topic_0000001219149187_b1904870149">/kafka</strong></p>
</p></li><li id="mrs_01_1031__en-us_topic_0000001219149187_li08091154164619"><span>Run the following command to view the topic information in the cluster:</span><p><p id="mrs_01_1031__en-us_topic_0000001219149187_p5809154164618"><strong id="mrs_01_1031__en-us_topic_0000001219149187_b998096281">sh kafka-topics.sh --list --zookeeper </strong><em id="mrs_01_1031__en-us_topic_0000001219149187_i1558358553">IP address of the node where the ZooKeeper instance resides<strong id="mrs_01_1031__en-us_topic_0000001219149187_b705738505">:</strong>clientPort</em><strong id="mrs_01_1031__en-us_topic_0000001219149187_b1017556509">/kafka</strong></p>
</p></li><li id="mrs_01_1031__en-us_topic_0000001219149187_li19809195411460"><span>Delete the topic created in <a href="#mrs_01_1031__en-us_topic_0000001219149187_li4808125415465">7</a>.</span><p><p id="mrs_01_1031__en-us_topic_0000001219149187_p4809135464615"><strong id="mrs_01_1031__en-us_topic_0000001219149187_b1925020179">sh kafka-topics.sh --delete --topic</strong> <em id="mrs_01_1031__en-us_topic_0000001219149187_i2001065566">Topic name</em> <strong id="mrs_01_1031__en-us_topic_0000001219149187_b315257742">--zookeeper</strong> <em id="mrs_01_1031__en-us_topic_0000001219149187_i1295273277">IP address of the node where the ZooKeeper instance resides</em>:<em id="mrs_01_1031__en-us_topic_0000001219149187_i322520286">clientPort</em><strong id="mrs_01_1031__en-us_topic_0000001219149187_b1756637959">/kafka</strong></p>
<p id="mrs_01_1031__en-us_topic_0000001219149187_p1580912543468">Type <strong id="mrs_01_1031__en-us_topic_0000001219149187_b1592280413">y</strong> and press <strong id="mrs_01_1031__en-us_topic_0000001219149187_b1208232590">Enter</strong>.</p>
</p></li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_0375.html">Using Kafka</a></div>
</div>
</div>