{"id":8953,"date":"2025-03-27T11:09:19","date_gmt":"2025-03-27T03:09:19","guid":{"rendered":"https:\/\/nj.transwarp.cn:8180\/?p=8953"},"modified":"2025-03-27T11:09:19","modified_gmt":"2025-03-27T03:09:19","slug":"%e5%ae%89%e5%85%a8%e6%a8%a1%e5%bc%8f%e4%b8%8b%ef%bc%8cslipstream-%e6%b5%81%e8%be%93%e5%87%ba%e5%88%b0%e6%b5%81%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=8953","title":{"rendered":"\u5b89\u5168\u6a21\u5f0f\u4e0b\uff0cslipstream \u6d41\u8f93\u51fa\u5230\u6d41\u64cd\u4f5c"},"content":{"rendered":"<h3>\u6982\u8981\u63cf\u8ff0<\/h3>\n<hr \/>\n<p>\u672c\u6587\u4e3b\u8981\u5305\u542b\u5f00\u542f\u5b89\u5168\u60c5\u51b5\u4e0b\uff0cSlipstream\u63a5\u6536kafka\u6d88\u606f\uff0c\u5e76\u5c06\u7ed3\u679c\u8f93\u51fa\u5230\u53e6\u4e00\u4e2a\u6d41\u7684\u6b65\u9aa4\u3002<br \/>\n\u5173\u4e8eSlipstream\u63a5\u6536kafka\u6d88\u606f\u7684\u8be6\u7ec6\u914d\u7f6e\u53ef\u4ee5\u53c2\u8003KB\uff1a<br \/>\n<a href=\"https:\/\/kb.transwarp.cn\/posts\/720\" title=\"kafka\u5f00\u542fGuardian\u5b89\u5168\u540eSlipstream\u63a5\u6536Kafka\u6d88\u606f\u64cd\u4f5c\u6b65\u9aa4\">kafka\u5f00\u542fGuardian\u5b89\u5168\u540eSlipstream\u63a5\u6536Kafka\u6d88\u606f\u64cd\u4f5c\u6b65\u9aa4<\/a><\/p>\n<h3>\u8be6\u7ec6\u8bf4\u660e<\/h3>\n<hr \/>\n<h4>Kafka\u7aef<\/h4>\n<ol>\n<li>\n<p>\u9996\u5148\u8bbe\u7f6e\u7cfb\u7edf\u5c5e\u6027\uff1a<\/p>\n<pre><code class=\"language-shell\">export KAFKA_OPTS=\"-Djava.security.auth.login.config=\/etc\/kafka1\/conf\/jaas.conf -Djava.security.krb5.conf=\/etc\/kafka1\/conf\/krb5.conf\"<\/code><\/pre>\n<\/li>\n<li>\n<p>\u521b\u5efatopic\uff1a<br \/>\n\u5176\u4e2dbootstrap-server\u6307\u5b9a\u7684broker\u5730\u5740\u5fc5\u987b\u662fKafka\u96c6\u7fa4\u7684controller\u6240\u5bf9\u5e94\u7684broker\u5730\u5740\uff0c\u5177\u4f53\u53c2\u8003\u67e5\u770b[Kafka\u96c6\u7fa4\u5f53\u524dController][755]\u3002<br \/>\n\u6ce8\u610f\u5728\u547d\u4ee4\u4e2d\u8bbe\u7f6e\u4e86\u5b89\u5168\u76f8\u5173\u7684consumer-property\u3002<br \/>\n\u8fdb\u5165\/root\/TDH-Client\/kafka\/bin\u76ee\u5f55\u4e0b\uff0c\u6267\u884c\uff1a<br \/>\n\u521b\u5efa\u8f93\u5165\u6d41\u7684topic\uff1atopic_eventtime<\/p>\n<pre><code class=\"language-shell\">.\/kafka-broker-topics.sh  --bootstrap-server 172.22.32.12:9092 \\\n--create --topic topic_eventtime_out \\\n--replication-factor 3 --partitions 3 \\\n--consumer-property security.protocol=SASL_PLAINTEXT \\\n--consumer-property sasl.kerberos.service.name=kafka<\/code><\/pre>\n<p>\u521b\u5efa\u8f93\u51fa\u6d41\u7684topic\uff1atopic_eventtime_out<\/p>\n<pre><code class=\"language-shell\">.\/kafka-broker-topics.sh  --bootstrap-server 172.22.32.12:9092 \\\n--create --topic topic_eventtime_out \\\n--replication-factor 3 --partitions 3 \\\n--consumer-property security.protocol=SASL_PLAINTEXT \\\n--consumer-property sasl.kerberos.service.name=kafka<\/code><\/pre>\n<\/li>\n<li>\n<p>\u4e3akafka\u63a7\u5236\u53f0\u751f\u4ea7\u8005\u548c\u6d88\u8d39\u8005\u914d\u7f6e\u5b89\u5168\u5c5e\u6027\uff1a<br \/>\n\u5728kafka\u914d\u7f6e\u6587\u4ef6producer.properties\u548cconsumer.properties (\/root\/TDH-Client\/kafka\/config) \u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u5982\u4e0b\u5185\u5bb9:<\/p>\n<pre><code class=\"language-shell\">security.protocol=SASL_PLAINTEXT\nsasl.mechanism=GSSAPI\nsasl.kerberos.service.name=kafka<\/code><\/pre>\n<\/li>\n<li>\n<p>\u542f\u52a8\u751f\u4ea7\u8005\uff1a<\/p>\n<pre><code class=\"language-shell\">.\/kafka-console-producer.sh  --broker-list 172.22.32.11:9092, 172.22.32.12:9092, 172.22.32.13:9092 \\\n--topic topic_eventtime \\\n--producer.config \/root\/TDH-Client\/kafka\/config\/producer.properties<\/code><\/pre>\n<\/li>\n<li>\n<p>\u542f\u52a8\u6d88\u8d39\u8005:<br \/>\n\u53e6\u5f00\u4e00\u4e2asession\uff0c\u8bbe\u7f6e\u7cfb\u7edf\u5c5e\u6027\uff0c\u5982\u4e0a\u3002<\/p>\n<pre><code class=\"language-shell\">.\/kafka-console-consumer.sh  --bootstrap-server 172.22.32.11:9092, 172.22.32.12:9092, 172.22.32.13:9092 \\\n--topic topic_eventtime \\\n--consumer.config \/root\/TDH-Client\/kafka\/config\/consumer.properties<\/code><\/pre>\n<\/li>\n<li>\n<p>\u5229\u7528\u63a7\u5236\u53f0\u6d4b\u8bd5\uff1a<br \/>\n\u5728 kafka \u63a7\u5236\u53f0 producer \u53d1\u9001\u6570\u636e\uff1b\u786e\u8ba4 kafka \u63a7\u5236\u53f0\u7684 consumer \u63a5\u6536\u5230\u6570\u636e\u3002<\/p>\n<\/li>\n<\/ol>\n<h4>Slipstream\u7aef<\/h4>\n<ol>\n<li>\u521b\u5efa\u8f93\u5165\u6d41:<\/li>\n<\/ol>\n<pre><code class=\"language-sql\">drop stream stream_wf_eventtime;\ncreate STREAM stream_wf_eventtime(\n    ftime string,\n    url string,\n    uv int, \n    pv int) \nrow format delimited fields terminated by ',' \ntblproperties(\n\"timefield\"=\"ftime\",\n\"timeformat\"=\"yyyy-MM-dd HH:mm:ss\",\n\"topic\"=\"topic_eventtime\",\n\"kafka.zookeeper\"=\"172.22.32.11:2181, 172.22.32.12:2181, 172.22.32.13:2181\",\n\"kafka.broker.list\"=\"172.22.32.11:9092, 172.22.32.12:9092, 172.22.32.13:9092\",\n\"transwarp.consumer.security.protocol\"=\"SASL_PLAINTEXT\",\n\"transwarp.consumer.sasl.kerberos.service.name\"=\"kafka\",\n\"transwarp.consumer.sasl.jaas.config\"=\"com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true   keyTab=\\\"\/etc\/slipstream1\/conf\/xxll.keytab\\\" principal=\\\"xxll@TDH\\\"\"\n);<\/code><\/pre>\n<ol start=\"2\">\n<li>\u521b\u5efa\u8f93\u51fa\u6d41:<\/li>\n<\/ol>\n<pre><code class=\"language-sql\">drop stream stream_wf_eventtime_out;\ncreate STREAM stream_wf_eventtime_out(\n    ftime_out string,\n    url_out string,\n    uv_out int, \n    pv_out int) \nrow format delimited fields terminated by ',' \ntblproperties(\n\"topic\"=\"topic_eventtime_out\",\n\"kafka.zookeeper\"=\"172.22.32.11:2181, 172.22.32.12:2181, 172.22.32.13:2181\",\n\"kafka.broker.list\"=\"172.22.32.11:9092, 172.22.32.12:9092, 172.22.32.13:9092\",\n\"transwarp.producer.security.protocol\"=\"SASL_PLAINTEXT\",\n\"transwarp.producer.sasl.kerberos.service.name\"=\"kafka\",\n\"transwarp.producer.sasl.jaas.config\"=\"com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true   keyTab=\\\"\/etc\/slipstream1\/conf\/xxll.keytab\\\" principal=\\\"xxll@TDH\\\"\",\n\"transwarp.consumer.security.protocol\"=\"SASL_PLAINTEXT\",\n\"transwarp.consumer.sasl.kerberos.service.name\"=\"kafka\",\n\"transwarp.consumer.sasl.jaas.config\"=\"com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true   keyTab=\\\"\/etc\/slipstream1\/conf\/xxll.keytab\\\" principal=\\\"xxll@TDH\\\"\");<\/code><\/pre>\n<p>\u6ce8\u610f\uff1a<br \/>\n1\uff09\u8f93\u5165\u6d41\u548c\u8f93\u51fa\u6d41\u7684topic\u4e0d\u80fd\u662f\u540c\u4e00\u4e2a\uff1b<br \/>\n2\uff09\u76ee\u6807\u7684stream\u6d41\u8868\u4f5c\u4e3a\u4ec0\u4e48\u89d2\u8272\uff0c\u5373\u9700\u8981\u5728tblproperties\u4e2d\u6307\u5b9a\u89d2\u8272\u7684\u5b89\u5168\u914d\u7f6e\uff0c\u6bd4\u5982\u8f93\u5165\u6d41\u5230\u8f93\u51fa\u6d41\uff0c\u8f93\u51fa\u6d41\u4f5c\u4e3a\u65b0\u7684\u751f\u4ea7\u8005\uff0c\u5c31\u9700\u8981\u914d\u7f6eproducer\u76f8\u5173\u7684\u5b89\u5168\u914d\u7f6e\uff1a<\/p>\n<pre><code class=\"language-shell\">\"transwarp.producer.security.protocol\"=\"SASL_PLAINTEXT\",\n\"transwarp.producer.sasl.kerberos.service.name\"=\"kafka\",\n\"transwarp.producer.sasl.jaas.config\"=\"com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true   keyTab=\\\"\/etc\/slipstream1\/conf\/xxll.keytab\\\" principal=\\\"xxll@TDH\\\"\"<\/code><\/pre>\n<p><strong>\u6b64\u5904\u8f93\u51fa\u6d41\u63a5\u6536\u5230\u8f93\u5165\u6d41\u7684\u6570\u636e\u540e\uff0c\u8fd8\u8981\u843d\u8868\uff0c\u6240\u4ee5consumer\u7684\u5b89\u5168\u914d\u7f6e\u4e5f\u8981\u4e00\u8d77\u52a0\u4e0a<\/strong>\u3002<\/p>\n<p>3\uff09\u7528\u6237\u7684 ketyab \u6587\u4ef6\uff0c\u9700\u8981\u653e\u7f6e\u5728\u6bcf\u4e2a slipsteam executor \u6240\u5728\u8282\u70b9\u7684\/ etc\/slipstream1\/conf\/ \u76ee\u5f55\u4e0b\uff0c\u4e14\u7528\u6237\u9700\u8981\u6709\u5bf9\u5e94topic\u548c\u6d88\u8d39\u7ec4\u6743\u9650\u3002<\/p>\n<ol start=\"3\">\n<li>\u521b\u5efa\u76ee\u6807\u8868:<\/li>\n<\/ol>\n<pre><code class=\"language-sql\">drop table table_eventtime_out;\ncreate table  if not exists  table_eventtime_out (\n    ftime timestamp,\n    url string,\n    uv int, \n    pv int\n) STORED AS HYPERDRIVE;<\/code><\/pre>\n<ol start=\"4\">\n<li>\u521b\u5efa\u6d41\u4efb\u52a1:<\/li>\n<\/ol>\n<pre><code class=\"language-sql\">--\u8f93\u5165\u6d41\u5230\u8f93\u51fa\u6d41\nINSERT  INTO  stream_wf_eventtime_out SELECT  * FROM  stream_wf_eventtime;\n\n--\u8f93\u51fa\u6d41\u5230\u8868\nINSERT INTO table_eventtime_out SELECT * FROM stream_wf_eventtime;<\/code><\/pre>\n<p>\u5f00\u542f\u540e\u53ef\u5728Slipstream\u670d\u52a1\u7684server\u8282\u70b94044\u9875\u9762\u67e5\u770bs1\u72b6\u6001\u662f\u5426\u4e3aactive\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2022\/11\/image-1667963374118.png\" alt=\"file\" \/><\/p>\n<ol start=\"5\">\n<li>\u6d4b\u8bd5:<\/li>\n<\/ol>\n<p>\u5229\u7528kafka\u63a7\u5236\u53f0producer\u53d1\u9001\u6570\u636e\uff0c\u6d4b\u8bd5\u6570\u636e\uff1a<\/p>\n<pre><code class=\"language-shell\">2022-11-07 10:05:05,test01,10,10\n2022-11-07 10:05:10,test01,20,20\n2022-11-07 10:05:15,test01,30,30\n2022-11-07 10:05:20,test02,40,40\n2022-11-07 10:05:25,test02,50,50\n2022-11-07 10:05:30,test02,60,60\n2022-11-07 10:05:35,test03,70,70\n2022-11-07 10:05:40,test03,80,80\n2022-11-07 10:05:45,test03,90,90\n2022-11-07 10:05:50,test04,100,100\n2022-11-07 10:05:55,test04,110,110\n2022-11-07 10:06:00,test04,120,120\n2022-11-07 10:06:05,test04,130,130<\/code><\/pre>\n<p>\u68c0\u67e5\u8868\u662f\u5426\u63a5\u6536\u5230\u6570\u636e\uff1a<\/p>\n<pre><code class=\"language-sql\">SELECT * FROM table_eventtime_out\uff1b<\/code><\/pre>\n<hr \/>\n<h4>\u95ee\u9898\u6392\u67e5\u601d\u8def<\/h4>\n<p>\u5982\u679c\u8868\u6ca1\u6709\u63a5\u6536\u5230\u6570\u636e\uff0c\u67e5\u770b4044\u9875\u9762\u662f\u5426\u6709\u5931\u8d25\u4fe1\u606f\u3002\u6536\u4e0d\u5230\u6570\u636e\u7684\u5e38\u89c1\u539f\u56e0\u662f\uff1a<br \/>\n\uff081\uff09 test.keytab\u6587\u4ef6\u4e0d\u5728\/etc\/slipstream1\/conf\/\u8def\u5f84\u4e0b<br \/>\n\uff082\uff09 \u6d41\u4efb\u52a1\u6ca1\u6709\u6267\u884cstart\uff0c\u53ef\u57284044\u9875\u9762\u67e5\u770bjob\u662f\u5426\u5df2\u63d0\u4ea4<br \/>\n\uff083\uff09 \u751f\u4ea7\u8005\u53d1\u9001\u6570\u636e\u4e0e\u5efa\u6d41\u8868\u6d88\u8d39\u6570\u636e\u7684topic\u4e0d\u4e00\u81f4<br \/>\n\uff084\uff09 kafka\u96c6\u7fa4\u6545\u969c\uff0c\u83b7\u53d6\u4e0d\u5230topic\u5143\u6570\u636e<\/p>\n<p>\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u601d\u8def\u6392\u67e5\uff1a<br \/>\n\uff081\uff09\u5206\u522b\u68c0\u67e5\u8f93\u5165\u6d41\u548c\u8f93\u51fa\u6d41\u751f\u4ea7\u8005\u7684\u6d88\u606f\u80fd\u5426\u6b63\u5e38\u88ab\u624b\u52a8\u6d88\u8d39\uff0c\u5982\u679c\u4e0d\u53ef\u4ee5\uff0c\u68c0\u67e5kafka\u5b89\u5168\u914d\u7f6e\u3002<br \/>\n\uff082\uff09\u901a\u8fc7kafka\u547d\u4ee4\u884c\u67e5\u770b\u6d88\u8d39\u60c5\u51b5\uff0c\u770b\u6570\u636e\u79ef\u538b\u5728\u54ea\u91cc\uff1a<br \/>\n\u5206\u522b\u67e5\u770b\u8f93\u5165\u6d41\u548c\u8f93\u51fa\u6d41\u7684\u6d88\u8d39\u60c5\u51b5\u3002<br \/>\n\u5982\u679c\u79ef\u538b\u5728\u8f93\u5165\u6d41\uff0c\u68c0\u67e5\u8f93\u51fa\u6d41\u7684producer\u5b89\u5168\u914d\u7f6e\uff1b<br \/>\n\u5982\u679c\u79ef\u538b\u5728\u8f93\u51fa\u6d41\uff0c\u68c0\u67e5\u8f93\u51fa\u6d41\u7684consumer\u5b89\u5168\u914d\u7f6e\u3002<\/p>\n<pre><code class=\"language-shell\">.\/kafka-consumer-groups.sh --describe --group default-default.stream_wf_eventtime_out --bootstrap-server 172.22.32.13:9092 --command-config \/root\/TDH-Client\/kafka\/config\/consumer.properties<\/code><\/pre>\n<pre><code class=\"language-shell\">.\/kafka-consumer-groups.sh --describe --group default-default.stream_wf_eventtime --bootstrap-server 172.22.32.13:9092 --command-config \/root\/TDH-Client\/kafka\/config\/consumer.properties <\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 \u672c\u6587\u4e3b\u8981\u5305\u542b\u5f00\u542f\u5b89\u5168\u60c5\u51b5\u4e0b\uff0cSlipstream\u63a5\u6536kafka\u6d88\u606f\uff0c\u5e76\u5c06\u7ed3\u679c\u8f93\u51fa\u5230\u53e6\u4e00\u4e2a\u6d41\u7684\u6b65\u9aa4\u3002  ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=8953\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":105,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38],"tags":[],"class_list":["post-8953","post","type-post","status-publish","format-standard","hentry","category-configuration"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/8953","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/users\/105"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8953"}],"version-history":[{"count":1,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/8953\/revisions"}],"predecessor-version":[{"id":16262,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/8953\/revisions\/16262"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8953"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8953"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8953"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}